Compiling Object.<init>

Tom Rodriguez Thomas.Rodriguez at Sun.COM
Wed Feb 25 09:35:22 PST 2009


The new version of the JLS and JVMS changed the point at which  
finalizable objects are registered to be finalized.  They are now  
registered once we reach Object.<init>.  This help deal with various  
tricks that allow a subclass to execute code before the super  
constructor has run which can result in incompletely initialized  
objects being registered for finalization.  To implement this in the  
interpreter a new internal bytecode was added.  In the compilers we  
treat Object.<init> as an intrinsic and insert the registration call  
when we return from it.  For example:

void Parse::return_current(Node* value) {
   if (RegisterFinalizersAtInit &&
       method()->intrinsic_id() == vmIntrinsics::_Object_init) {
     call_register_finalizer();
   }

Conceivably you could modify the ciBytecodeStream to allow  
return_register_finalizer to leak through to the parser but that's  
more tricky.

tom

On Feb 25, 2009, at 4:39 AM, Gary Benson wrote:

> Hi all,
>
> I'm writing a JIT for OpenJDK, and I'm not sure what I should be doing
> when compiling Object.<init>.  I was confused to see it scheduled for
> compilation at all, since it's an empty method, but now I see its one
> bytecode is not _return but _return_register_finalizer so of course
> the empty method detector doesn't recognise it.
>
> When it gets compiled, the bytecode is read via a ciBytecodeStream,
> and it seems to be coming through as a _return as I have no code to
> handle _return_register_finalizer and it would have aborted if it got
> that.
>
> Do I need to detect that I'm compiling Object.<init> and special case
> it?
>
> Cheers,
> Gary
>
> -- 
> http://gbenson.net/




More information about the hotspot-dev mailing list