[jmm-dev] finalization

Hans Boehm boehm at acm.org
Fri Aug 15 01:38:16 UTC 2014

On Thu, Aug 14, 2014 at 5:22 PM, Doug Lea <dl at cs.oswego.edu> wrote:

> On 08/13/2014 07:11 PM, Hans Boehm wrote:
>> You're suggesting that if a method accesses an @Finalized field (including
>> passing it to other methods), then all reference variables in that method
>> are
>>  kept around until the end of their scope?
> I'm suggesting something slightly simpler. A reachabilityFence(x)
> is placed/checked after each access of @Finalized field x.r.
> No other JLS changes.

I don't think that keeping it live until just after the access is good
enough.  I will typically retrieve the @Finalized field (which might be a
long holding a native pointer), and then later pass the value, now in a
local variable or a temporary, to a routine f() that consumes the result
(e.g. by dereferencing the native pointer).  I need to defer finalization
until f() finishes.  I think the only really safe place to do that is at
the end of x's scope and before any subsequent assignment to x.  This gets
a bit messy if the reference is actually to x.y.z.r.  But all of this is
probably still OK.  In the worst case, I do no dead variable elimination in
functions that reference @Finalized fields, which seems quite tolerable in
terms of performance.  It does have compiler impact, but I doubt that's

More information about the jmm-dev mailing list