Skip to content
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-47647] Introduce -H:±UnlockExperimentalVMOptions. #7190

Merged
merged 17 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class OptionProcessor extends AbstractProcessor {
private static final String OPTION_CLASS_NAME = "org.graalvm.compiler.options.Option";
private static final String OPTION_KEY_CLASS_NAME = "org.graalvm.compiler.options.OptionKey";
private static final String OPTION_TYPE_CLASS_NAME = "org.graalvm.compiler.options.OptionType";
private static final String OPTION_STABILITY_CLASS_NAME = "org.graalvm.compiler.options.OptionStability";
private static final String OPTION_TYPE_GROUP_NAME = "org.graalvm.compiler.options.OptionGroup";
private static final String OPTION_DESCRIPTOR_CLASS_NAME = "org.graalvm.compiler.options.OptionDescriptor";
private static final String OPTION_DESCRIPTORS_CLASS_NAME = "org.graalvm.compiler.options.OptionDescriptors";
Expand Down Expand Up @@ -228,8 +229,8 @@ private void processElement(Element element, OptionsInfo info) {
}
}

String optionStabilityName = getAnnotationValue(annotation, "stability", VariableElement.class).getSimpleName().toString();
if (optionStabilityName.equals("STABLE")) {
String stability = getAnnotationValue(annotation, "stability", VariableElement.class).getSimpleName().toString();
if (stability.equals("STABLE")) {
if (help.length() == 0) {
processingEnv.getMessager().printMessage(Kind.ERROR, "A stable option must have non-empty help text", element);
return;
Expand All @@ -239,7 +240,7 @@ private void processElement(Element element, OptionsInfo info) {
String optionTypeName = getAnnotationValue(annotation, "type", VariableElement.class).getSimpleName().toString();
boolean deprecated = getAnnotationValue(annotation, "deprecated", Boolean.class);
String deprecationMessage = getAnnotationValue(annotation, "deprecationMessage", String.class);
info.options.add(new OptionInfo(optionName, optionTypeName, help, extraHelp, optionType, declaringClass, field.getSimpleName().toString(), deprecated, deprecationMessage));
info.options.add(new OptionInfo(optionName, optionTypeName, help, extraHelp, optionType, declaringClass, field.getSimpleName().toString(), stability, deprecated, deprecationMessage));
}

private String resolveOptionPrefix(Element optionType) {
Expand Down Expand Up @@ -279,6 +280,7 @@ public static void createOptionsDescriptorsFile(ProcessingEnvironment processing
out.println("import java.util.*;");
out.println("import " + getPackageName(OPTION_DESCRIPTORS_CLASS_NAME) + ".*;");
out.println("import " + OPTION_TYPE_CLASS_NAME + ";");
out.println("import " + OPTION_STABILITY_CLASS_NAME + ";");
out.println("");
String implementsClause = info.registerAsService ? " implements " + getSimpleName(OPTION_DESCRIPTORS_CLASS_NAME) : "";
if (info.registerAsService) {
Expand Down Expand Up @@ -319,6 +321,7 @@ public static void createOptionsDescriptorsFile(ProcessingEnvironment processing
List<String> extraHelp = option.extraHelp;
String declaringClass = option.declaringClass;
String fieldName = option.field;
String stability = option.stability;
boolean deprecated = option.deprecated;
String deprecationMessage = option.deprecationMessage;
out.printf(" return " + desc + ".create(\n");
Expand All @@ -336,6 +339,7 @@ public static void createOptionsDescriptorsFile(ProcessingEnvironment processing
out.printf(" /*declaringClass*/ %s.class,\n", declaringClass);
out.printf(" /*fieldName*/ \"%s\",\n", fieldName);
out.printf(" /*option*/ %s,\n", optionField);
out.printf(" /*stability*/ %s.%s,\n", getSimpleName(OPTION_STABILITY_CLASS_NAME), stability);
out.printf(" /*deprecated*/ %b,\n", deprecated);
out.printf(" /*deprecationMessage*/ \"%s\");\n", deprecationMessage);
out.println(" }");
Expand Down Expand Up @@ -379,17 +383,20 @@ public static class OptionInfo implements Comparable<OptionInfo> {
public final String type;
public final String declaringClass;
public final String field;
public final String stability;
public final boolean deprecated;
public final String deprecationMessage;

public OptionInfo(String name, String optionType, String help, List<String> extraHelp, String type, String declaringClass, String field, boolean deprecated, String deprecationMessage) {
public OptionInfo(String name, String optionType, String help, List<String> extraHelp, String type, String declaringClass, String field, String stability, boolean deprecated,
String deprecationMessage) {
this.name = name;
this.optionType = optionType;
this.help = help;
this.extraHelp = extraHelp;
this.type = type;
this.declaringClass = declaringClass;
this.field = field;
this.stability = stability;
this.deprecated = deprecated;
this.deprecationMessage = deprecationMessage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public static class Options {
/*declaringClass*/ Options.class,
/*fieldName*/ "MyDeprecatedOption",
/*option*/ MyDeprecatedOption,
/*stability*/ OptionStability.EXPERIMENTAL,
/*deprecated*/ true,
/*deprecationMessage*/ "Some deprecation message"));
// @formatter:on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public final class OptionDescriptor {
private final OptionKey<?> optionKey;
private final Class<?> declaringClass;
private final String fieldName;
private final OptionStability stability;
private final boolean deprecated;
private final String deprecationMessage;

Expand All @@ -54,7 +55,7 @@ public static OptionDescriptor create(String name,
Class<?> declaringClass,
String fieldName,
OptionKey<?> option) {
return create(name, optionType, optionValueType, help, NO_EXTRA_HELP, declaringClass, fieldName, option, false, "");
return create(name, optionType, optionValueType, help, NO_EXTRA_HELP, declaringClass, fieldName, option, OptionStability.EXPERIMENTAL, false, "");
}

public static OptionDescriptor create(String name,
Expand All @@ -64,9 +65,10 @@ public static OptionDescriptor create(String name,
Class<?> declaringClass,
String fieldName,
OptionKey<?> option,
OptionStability stability,
boolean deprecated,
String deprecationMessage) {
return create(name, optionType, optionValueType, help, NO_EXTRA_HELP, declaringClass, fieldName, option, deprecated, deprecationMessage);
return create(name, optionType, optionValueType, help, NO_EXTRA_HELP, declaringClass, fieldName, option, stability, deprecated, deprecationMessage);
}

public static OptionDescriptor create(String name,
Expand All @@ -77,13 +79,14 @@ public static OptionDescriptor create(String name,
Class<?> declaringClass,
String fieldName,
OptionKey<?> option,
OptionStability stability,
boolean deprecated,
String deprecationMessage) {
assert option != null : declaringClass + "." + fieldName;
OptionDescriptor result = option.getDescriptor();
if (result == null) {
List<String> extraHelpList = extraHelp == null || extraHelp.length == 0 ? Collections.emptyList() : Collections.unmodifiableList(Arrays.asList(extraHelp));
result = new OptionDescriptor(name, optionType, optionValueType, help, extraHelpList, declaringClass, fieldName, option, deprecated, deprecationMessage);
result = new OptionDescriptor(name, optionType, optionValueType, help, extraHelpList, declaringClass, fieldName, option, stability, deprecated, deprecationMessage);
option.setDescriptor(result);
}
assert result.name.equals(name) && result.optionValueType == optionValueType && result.declaringClass == declaringClass && result.fieldName.equals(fieldName) && result.optionKey == option;
Expand All @@ -98,6 +101,7 @@ private OptionDescriptor(String name,
Class<?> declaringClass,
String fieldName,
OptionKey<?> optionKey,
OptionStability stability,
boolean deprecated,
String deprecationMessage) {
this.name = name;
Expand All @@ -108,6 +112,7 @@ private OptionDescriptor(String name,
this.optionKey = optionKey;
this.declaringClass = declaringClass;
this.fieldName = fieldName;
this.stability = stability;
this.deprecated = deprecated || deprecationMessage != null && !deprecationMessage.isEmpty();
this.deprecationMessage = deprecationMessage;
assert !optionValueType.isPrimitive() : "must use boxed optionValueType instead of " + optionValueType;
Expand Down Expand Up @@ -176,6 +181,13 @@ public String getLocation() {
return getDeclaringClass().getName() + "." + getFieldName();
}

/**
* Returns the stability of this option.
*/
public OptionStability getStability() {
return stability;
}

/**
* Returns {@code true} if the option is deprecated.
*/
Expand Down
6 changes: 6 additions & 0 deletions docs/reference-manual/native-image/BuildOutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ Use the `-R:MaxHeapSize` option when building with Native Image to pre-configure
All [`Features`](https://www.graalvm.org/sdk/javadoc/org/graalvm/nativeimage/hosted/Feature.html) that are either provided or specifically enabled by the user, or implicitly registered for the user, for example, by a framework.
GraalVM Native Image deploys a number of internal features, which are excluded from this list.

#### <a name="glossary-experimental-options"></a>Experimental Options
A list of all active experimental options, including their origin and possible API option alternatives if available.

Using experimental options should be avoided in production and can change in any release.
If you rely on experimental features and would like an option to be considered stable, please file an issue.

#### <a name="glossary-build-resources"></a>Build Resources
The memory limit and number of threads used by the build process.

Expand Down
7 changes: 4 additions & 3 deletions espresso/mx.espresso/mx_espresso.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,13 @@ def _espresso_gate_runner(args, tasks):
language='java',
jar_distributions=['espresso:LIB_JAVAVM'],
build_args=[
'-H:-JNIExportSymbols',
'-R:+EnableSignalHandling',
'-R:+InstallSegfaultHandler',
'-H:+DumpThreadStacksOnSignal',
'--features=com.oracle.truffle.espresso.ref.FinalizationFeature',
],
] + mx_sdk_vm_impl.svm_experimental_options([
'-H:-JNIExportSymbols',
'-H:+DumpThreadStacksOnSignal',
]),
)

if mx_sdk_vm.base_jdk_version() not in (17,):
Expand Down
10 changes: 3 additions & 7 deletions espresso/mx.espresso/native-image-preinit.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
Requires = language:nfi

Args = -H:MaxRuntimeCompileMethods=7000 \
-H:ReflectionConfigurationFiles=${.}/reflectconfig.json \
-H:+TruffleCheckBlockListMethods \
--features=com.oracle.truffle.espresso.ref.FinalizationFeature \
--initialize-at-build-time=com.oracle.truffle.espresso
Args = --initialize-at-build-time=com.oracle.truffle.espresso \
--features=com.oracle.truffle.espresso.ref.FinalizationFeature \
-H:MaxRuntimeCompileMethods=7000

JavaArgs = -Dpolyglot.image-build-time.PreinitializeContexts=java \
-Dpolyglot.image-build-time.PreinitializeContextsWithNative=true


9 changes: 3 additions & 6 deletions espresso/mx.espresso/native-image.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
Requires = language:nfi

Args = -H:MaxRuntimeCompileMethods=7000 \
-H:ReflectionConfigurationFiles=${.}/reflectconfig.json \
-H:+TruffleCheckBlockListMethods \
--features=com.oracle.truffle.espresso.ref.FinalizationFeature \
--initialize-at-build-time=com.oracle.truffle.espresso

Args = --initialize-at-build-time=com.oracle.truffle.espresso \
--features=com.oracle.truffle.espresso.ref.FinalizationFeature \
-H:MaxRuntimeCompileMethods=7000
11 changes: 2 additions & 9 deletions espresso/mx.espresso/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@
"linux": {
"<others>": {
"layout": {
"./": ["file:mx.espresso/reflectconfig.json"],
"./native-image.properties": ["file:mx.espresso/native-image-preinit.properties"],
"LICENSE_JAVAONTRUFFLE": "file:LICENSE",
"lib/": [
Expand All @@ -394,10 +393,7 @@
"linux-musl": {
"<others>": {
"layout": {
"./": [
"file:mx.espresso/reflectconfig.json",
"file:mx.espresso/native-image.properties",
],
"./": ["file:mx.espresso/native-image.properties"],
"LICENSE_JAVAONTRUFFLE": "file:LICENSE",
"lib/": [
"dependency:espresso:com.oracle.truffle.espresso.native/<lib:nespresso>",
Expand All @@ -412,10 +408,7 @@
"<others>": {
"<others>": {
"layout": {
"./": [
"file:mx.espresso/native-image.properties",
"file:mx.espresso/reflectconfig.json",
],
"./": ["file:mx.espresso/native-image.properties"],
"LICENSE_JAVAONTRUFFLE": "file:LICENSE",
"lib/": [
"dependency:espresso:com.oracle.truffle.espresso.eden/<lib:eden>",
Expand Down
37 changes: 19 additions & 18 deletions java-benchmarks/mx.java-benchmarks/mx_java_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from mx_benchmark import ParserEntry
import mx_sdk_benchmark
from mx_sdk_benchmark import NativeImageBenchmarkMixin, NativeImageBundleBasedBenchmarkMixin
import mx_sdk_vm_impl

_suite = mx.suite('java-benchmarks')

Expand Down Expand Up @@ -353,19 +354,11 @@ def extra_image_build_argument(self, benchmark, args):
'-J-Duser.language=en',
'-J-Duser.country=US',
'-J-Dfile.encoding=UTF-8',
'-H:-ParseOnce',
'-J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED',
'-J--add-opens=java.base/java.text=ALL-UNNAMED',
'-H:+JNI',
'-H:+AllowFoldMethods',
'-J-Djava.awt.headless=true',
'-H:FallbackThreshold=0',
'-H:+ReportExceptionStackTraces',
'-H:+AddAllCharsets',
'-H:EnableURLProtocols=http',
'-H:NativeLinkerOption=-no-pie',
'-H:-UseServiceLoaderFeature',
'-H:+AllowDeprecatedBuilderClassesOnImageClasspath', # needs to be removed once GR-41746 is fixed
'--no-fallback',
'--enable-http',
'--add-exports=org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED',
'--add-exports=org.graalvm.nativeimage.base/com.oracle.svm.util=ALL-UNNAMED',
'--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.configure=ALL-UNNAMED',
Expand All @@ -374,7 +367,15 @@ def extra_image_build_argument(self, benchmark, args):
'--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jni=ALL-UNNAMED',
'--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.threadlocal=ALL-UNNAMED',
'--initialize-at-run-time=io.netty.internal.tcnative.SSL,io.netty.handler.codec.compression.ZstdOptions',
'-H:+StackTrace'] + super(BaseQuarkusBenchmarkSuite, self).extra_image_build_argument(benchmark, args)
'-H:NativeLinkerOption=-no-pie',
'-H:+AddAllCharsets',
] + mx_sdk_vm_impl.svm_experimental_options([
'-H:-ParseOnce',
'-H:+AllowFoldMethods',
'-H:+ReportExceptionStackTraces',
'-H:-UseServiceLoaderFeature',
'-H:+AllowDeprecatedBuilderClassesOnImageClasspath', # needs to be removed once GR-41746 is fixed
]) + super(BaseQuarkusBenchmarkSuite, self).extra_image_build_argument(benchmark, args)


class BaseTikaBenchmarkSuite(BaseQuarkusBenchmarkSuite):
Expand Down Expand Up @@ -527,23 +528,23 @@ def extra_image_build_argument(self, benchmark, args):
'-J--add-opens=java.base/java.io=ALL-UNNAMED',
'-J--add-opens=java.base/java.lang.invoke=ALL-UNNAMED',
'-J--add-opens=java.base/java.util=ALL-UNNAMED',
'-H:+AllowFoldMethods',
'-J-Djava.awt.headless=true',
'--no-fallback',
'-H:+ReportExceptionStackTraces',
'-H:-AddAllCharsets',
'--enable-url-protocols=http,https',
'-H:-UseServiceLoaderFeature',
'-H:+StackTrace',
'-J--add-exports=org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED',
'-J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED',
'--exclude-config' ,
'io\.netty\.netty-codec',
'/META-INF/native-image/io\.netty/netty-codec/generated/handlers/reflect-config\.json',
'--exclude-config',
'io\.netty\.netty-handler',
'/META-INF/native-image/io\.netty/netty-handler/generated/handlers/reflect-config\.json'
] + super(BaseQuarkusBenchmarkSuite,self).extra_image_build_argument(benchmark, args)
'/META-INF/native-image/io\.netty/netty-handler/generated/handlers/reflect-config\.json',
'-H:-AddAllCharsets',
] + mx_sdk_vm_impl.svm_experimental_options([
'-H:+AllowFoldMethods',
'-H:+ReportExceptionStackTraces',
'-H:-UseServiceLoaderFeature',
]) + super(BaseQuarkusBenchmarkSuite,self).extra_image_build_argument(benchmark, args)

mx_benchmark.add_bm_suite(BaseQuarkusRegistryBenchmark())

Expand Down
4 changes: 2 additions & 2 deletions regex/mx.regex/native-image.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ ExcludeFromAll=true

Requires = language:icu4j

Args = -H:MaxRuntimeCompileMethods=900 \
--initialize-at-build-time=com.oracle.truffle.regex
Args = --initialize-at-build-time=com.oracle.truffle.regex \
-H:MaxRuntimeCompileMethods=900
Loading