[gclist] Question from a newbie

Boehm, Hans hans_boehm@hp.com
Wed, 7 May 2003 12:23:35 -0700


> -----Original Message-----
> From: Bakul Shah [mailto:bakul@bitblocks.com]
> 
> Your intuition is different from mine!  The usual language
> rules dictate that the extent (i.e. lifetime) of an object
> such as obj1 is until the end of m1 (where it goes out of
> scope and its value has not escaped to m1's callee).  So my
> "intuition" says that if for instance I want to examine
> obj1's value in m1 after returning from m2 I should be able
> to do that!  Worse, if there are any side-effects associated
> with freeing of obj1 they will occur in an incorrect order if
> obj1 is freed early.  In general the "as if" rule _limits_
> (or ought to limit) what optimizations are allowed but
> perhaps agressive optimizations have already lowered people's
> expectations....
> 
Some of this was recently debated on the Java memory model mailing list.  Java fairly explicitly allows obj1 to be finalized early, arguably so early that finalization becomes useless.

Also note that your intuition is incompatible with a language like Scheme, which requires that recursive tail calls not consume stack space, so that you can express loops in terms of recursion.  There is no place to save dead locals during a tail call.  Even for other languages, it may have a significant optimization impact.

Hans