JEP draft: JVMCI based JIT Compiler pre-compiled as shared library
Owner | Vladimir Kozlov |
Type | Feature |
Scope | Implementation |
Status | Draft |
Component | hotspot / compiler |
Discussion | hotspot dash compiler dash dev at openjdk dot java dot net |
Effort | M |
Duration | M |
Created | 2019/05/02 01:36 |
Updated | 2024/06/10 08:35 |
Issue | 8223220 |
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:
- 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.
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:
- 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
Dependencies
These implementation requirse JVMCI changes which are tracked by RFE JDK-8220623