Compiling Object.<init>
Gary Benson
gbenson at redhat.com
Fri Feb 27 01:58:26 PST 2009
Thanks Tom, I did it the way you suggested and it works perfectly.
It even fixed a bug I've had for months and was dreading fixing! :)
Cheers,
Gary
Tom Rodriguez wrote:
> 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/
--
http://gbenson.net/
More information about the hotspot-dev
mailing list