JEP draft: JVMCI based JIT Compiler pre-compiled as shared library

OwnerVladimir Kozlov
TypeFeature
ScopeImplementation
StatusDraft
Componenthotspot / compiler
Discussionhotspot dash compiler dash dev at openjdk dot java dot net
EffortM
DurationM
Created2019/05/02 01:36
Updated2019/05/08 18:08
Issue8223220

Summary

Support JVMCI based Just-In-Time Compiler (such as Graal) which is Ahead-Of-Time compiled into a native shared library.

Goals

To replace native compilers in HotSpot (i.e., C1 and C2), JVMCI based Compiler should have the following characteristics:

Description

The best way to achieve this is to compile such Compiler with SubstrateVM native-image tool into a shared library that HotSpot VM can interface with via JNI. This requires:

JVMCI C++ code would need to operate on JVMCI Java objects in 2 different heaps - the HotSpot heap and the shared library heap. We'll introduce JVMCIObject, a wrapper that abstracts over whether a Java object is a HotSpot oop or a JNI jobject.

The JVMCIRuntime C++ class would be converted to have non-static methods and be instantiated one instance per HotSpotJVMCIRutime Java object in each heap. It would include methods that allow invoking JVMCI Java methods, abstracting over whether calling into the HotSpot or shared library runtime.

Care must be taken to handle cross-runtime-heap objects references.

Compiler's shared library (libjvmcicompiler.so) will be generated during JDK build according to configure setting.

New HotSpot flags will be added:

-XX:+UseJVMCINativeLibrary to load shared library from default location (in JDK directory)

-XX:JVMCILibPath="path" to specify library location

Dependencies

These implementation requirse JVMCI changes which are tracked by RFE JDK-8220623