-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GR-60088] Add jdk.graal.nativeimage module. #10380
base: master
Are you sure you want to change the base?
Conversation
a229752
to
aeed0d5
Compare
52e529a
to
2f4508a
Compare
…vm.graal.hotspot.libgraal
2f4508a
to
584d4d0
Compare
584d4d0
to
07a5f5d
Compare
07a5f5d
to
ffd8bc9
Compare
…tiveimage.jar and nativebridge.jar
…ed to FeatureComponent
…ed to FeatureComponent ++
ffd8bc9
to
7542c2f
Compare
@AutomaticallyRegisteredImageSingleton({VMRuntimeSupport.class, RuntimeSupport.class, LibGraalRuntimeSupport.class}) | ||
public final class RuntimeSupport implements VMRuntimeSupport, LibGraalRuntimeSupport { | ||
|
||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should move all these new methods to a separate libgraal-specific image singleton that implements LibGraalRuntimeSupport
(for a normal native image, it does not make sense to use any of these methods).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Where would you suggest to put LibGraalRuntimeSupportImpl
? In substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/libgraal/LibGraalRuntimeSupportImpl.java
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
* RuntimeSystemProperties.register(NATIVE_IMAGE_SETTING_KEY_PREFIX + "gc", "serial"); | ||
* </pre> | ||
*/ | ||
public static final String NATIVE_IMAGE_SETTING_KEY_PREFIX = "org.graalvm.nativeimage.setting."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jdk.graal.compiler
exports everything (*
) to org.graalvm.nativeimage...
which makes of course sense for hosted graal usage.
If I understand correctly, LibGraalFeature
is guest graal only. I.e., org.graalvm.nativeimage...
should not depend on it, or even have access to it, right? Otherwise, we might introduce dependencies from native image to a specific version of LibGraalFeature
without noticing it.
Currently, we only access NATIVE_IMAGE_SETTING_KEY_PREFIX
so not a problem. Still, would it make sense to separate it out LibGraalFeature
to avoid problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable. Where would you suggest moving it to?
synchronized (LibGraalFeature.class) { | ||
GraalError.guarantee(singleton == null, "only a single %s instance should be created", LibGraalFeature.class.getName()); | ||
singleton = this; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we move the singleton initialization into the static initializer of a private static inner class? that way we don't need to do a manual synchronize and the JVM guarantees us that there is only one initialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can a feature be created and registered by some other means (e.g. search for static field or factory method) instead of by calling the default constructor? Based on my reading of com.oracle.svm.hosted.FeatureHandler#registerFeature
I think the answer is no?
8061a46
to
0f47855
Compare
…e latter instead of using a FieldValueTransformer
0f47855
to
46bf4bb
Compare
…ndencies of jdk.graal.compiler
This PR adds the
jdk.graal.nativeimage
module. This provides a stable API for use by libgraal that is an extension to the standard Native Image API (i.e., theorg.graalvm.nativeimage**
packages here). Using this extended API,LibGraalFeature.java
has been moved intocompiler/
, out ofsubstratevm/
. It no longer depends on Native Image internals, allowing any GraalVM binary that supportsjdk.graal.nativeimage
to be used as a tool for building libgraal. This is a step towards Project Galahad.Over time, some or all of
jdk.graal.nativeimage
may be moved intoorg.graalvm.nativeimage
. This is a discussion to be had in follow-up PRs.The API changes can most easily been seen here:
A large part of the code changes comes from the fact that
LibGraalFeature
itself is now loaded in the LibGraalClassLoader which is separate from the Native Image class loader. This means the use of method handles to communicate between the "hosted" parts of libgraal (those loaded by the Native Image class loader) and the "guest" parts of libgraal has been removed. This is a large code reduction and makes the logic much easier to follow. It also means no more need for@NativeImageReinitialize
as the Graal classes loaded for compiling into libgraal are different from those loaded to do the compilation and thus no longer need re-initializing.Other changes of note:
-Djdk.graal.ShowConfiguration=info
has changed (and improved) slightly to also show the SVM GC algorithm used in libgraal.Before:
Using "Graal Enterprise compiler with Truffle extensions" loaded from a PGO optimized Native Image shared library
After:
Using "Graal Enterprise compiler with Truffle extensions" loaded from a Native Image shared library (PGO optimized, gc=Serial GC)
--upgrade-module-path
to accelerate Truffle now needs 2 extra jars:graal-nativeimage.jar
andnativebridge.jar
. This will be made clearer whenpom.xml
for the graal-js Maven demo is subsequently updated by @tzezula .FoldNodePlugin
class will be deleted once [GR-60866] Use plugin class name to filter fold plugin application #10447 is merged. Ignore it.