[MLton-devel] handler and link liveness in backend/live.fun
Matthew Fluet
fluet@CS.Cornell.EDU
Wed, 1 Jan 2003 18:15:45 -0500 (EST)
> I am guessing that the foldr is important because earlier in live.fun
> the statements in each block were visited in order, meaning that the
> earlier statements appear later in !defuse. Hence, with the foldr,
> the defs and uses are visited in order for each block.
That corresponds to my reading of the code.
> This means
> that by doing "List.exists (defs, ...", we are considering all of the
> earlier definitions in the block, if any.
Yup.
> What I don't understand is
> that since we are visiting all of the statements in the block
> together, in order, aren't we guaranteed that if there is a prior
> definition then it will be first on the defs list? So, can I replace
> the "List.exists (defs, ..." with
>
> case defs of
> [] => false
> | b' :: _ => LiveInfo.equals (b, b')
>
> The efficiency gain would be nice, but I am more concerned about my
> understanding of the code, since I am modifying it.
That should be true. I tend to use lists as sets, so I'm more likely to
do List.exists than to rely on/reason that a particular element is at a
particular place.
The bigger picture is dealing with blocks that contain both
SetExnStackSlot and SetSlotExnStack, which might occur if the SSA program
contained the (nop):
val _ = handlerPush h
val _ = handlerPop h
In such a case, the exn slot isn't live at the beginning of the block,
because the def occurs in the same block as the use. But, we also need to
watch out for a use before a def in the same block, which can also occur.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel