Support JVMCI based Just-In-Time Compiler (such as Graal) which is Ahead-Of-Time compiled into a native shared library.
To replace native compilers in HotSpot (i.e., C1 and C2), JVMCI based Compiler should have the following characteristics:
- fast startup
- compile time similar to native compilers
- memory usage disjoint from the application Java heap
- bulk de-allocation of memory used during a single compilation
- do not pollute profiling of JDK code used by the application.
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:
- A technology by which JVMCI and Compiler can be compiled into a shared library that implements the JNI Invocation API
- Enhancements to JVMCI to support both producing and using SVM compiled shared library.
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
These implementation requirse JVMCI changes which are tracked by RFE JDK-8220623