[13] RFR(L) 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library

Tom Rodriguez tom.rodriguez at oracle.com
Mon Apr 1 17:01:08 UTC 2019

>> Since a safepoint can happen at any time when you are in native, I don't see how using a Handle in native would be safe or correct. I'm guessing you are missing a HandleMark somewhere when you re-enter VM?
> Tom, can you recall why this HandleMark was added? Doe we run any JVMCI code on a JVMTI agent thread?
> -Doug

It's a leftover from the JNI self call logic I added early in libgraal 
development for testing.  To ease testing and bringing up libgraal I'd 
added logic to let HotSpot call itself through JNI.  This let me test 
and debug libgraal JVMCI changes without having a fully working 
libgraal.  It required adding HandleMarks in a few places that had 
nothing to do with JVMCI because we were calling back into ourselves.  I 
forgot to remove all of them when I removed the self call stuff.

Basically the problem I saw was that the HandleMarkCleaner takes over 
the last HandleMark it finds in the current thread and will clean out 
it's contents in its own destructor, which is actually earlier than the 
HandleMark destructor.  If you aren't careful about having a HandleMark 
close to where you call out of the JVM you could end up releasing a 
handle earlier than the HandleMark scoping would suggest.  I convinced 
myself this isn't a problem in the current code but maybe I missed 
something.  I can resurrect my assertion checking if someone thinks 
there might be a real bug lurking here.


More information about the graal-dev mailing list