handler labels

Stephen Weeks MLton@sourcelight.com
Fri, 11 Aug 2000 16:13:36 -0700 (PDT)


> Question 1: from the Chunk.t datatype, I get two lists of labels: 
> gcReturns and entries.  I understand that gcReturns are the set of labels
> that got inserted for limitChecks and prims that enter the runtime.  And
> entries are the function entry points. 

The "entries" list consists of (toplevel) function labels as well as handler and
continuation labels.  See the code around line 200 of backend.fun for details.

> I had thought that those where the
> only ways of "entering" the Chunk. 

They are.  That is, entries and gcReturns are the only way to enter a chunk.  I
conclude this because the C codegen ChunkSwitch switches on the entries and
gcReturns.

> But handlers are handled differently?

No.  They are in the entries list.

> i.e., is it possible to transfer between chunks because of a handle? 

Yes.  But all handlers appear in the entry list.

> I
> think that might explain why I'm getting unresolved symbols.  I wanted to
> be aggressive and simply count all the jumps to each label

Surely you want to count stores of the label to the stack as a reference.  This
is what happens with handlers and conts.

> and then toss
> out anything that has 0 jumps to it.  Obviously, things like gcReturns
> have no explicit jumps, so they are marked as Must (be kept).  I guess
> handlers are the same way -- some of them are never explicitly jumped to,
> yet they must be kept.

You need to keep every label that is referred to, either via jump or reference.

> I suspect this issue arose in the c-backend as well.  (I think) it
> explains why I didn't understand why all the targets of Switches and
> SwitchIPs were forced to be output.

I think that's unrelated, but I can't explain why that is done offhand.

> Question 2: Any reason not to build up a list of handler labels and pass
> them along with the Chunks in order to do this precise analysis?  Or are
> there other cases where it would break?

I don't quite understand what you want, but I believe that the entries list
contains all labels that are referred to by other chunks.