On Wed, Dec 1, 2010 at 4:36 AM, Rémi Forax <[email protected]> wrote:
> If you can stack-allocate a closure. Your closure don't escape.
> So your runtime should be able to know if a closure escape or not
> and if it doesn't escape, you can generate the bytecode from
> where you create the closure to where you use it.

No, that's not correct. A simple case: All calls on a given thread
would still use the same stack-allocated closure, but Hotspot only
inlines up to two target methods at a given call site. So...

i = 1234
p = proc {|i| puts i }

objs = ['foo', [:a, :b], {:a => :b}]

for j in 1..1000 do
  objs[j % 3].each &p
end

In this case, there's three different target impls of "each" at the
same call site that will receive the same closure. All will be on the
same thread and could use the same stack-allocated object, but
according to Hotspot's EA, the closure object would not be eligible
for elimination since it won't inline three targets at a given call
site.

Of course this is a trivialized example, but the point is that EA is
still very fragile, and any one path that receives an object but isn't
inlined will prevent it, where stack allocation would work fine.

- Charlie

-- 
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en.

Reply via email to