Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gluon-bot committed Nov 6, 2023
2 parents 83898e3 + 902dba9 commit bc6c516
Show file tree
Hide file tree
Showing 23 changed files with 330 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import jdk.graal.compiler.debug.DebugContext.Activation;
import jdk.graal.compiler.debug.DebugHandlersFactory;
import jdk.graal.compiler.debug.DebugOptions;
import jdk.graal.compiler.hotspot.meta.HotSpotProviders;
import jdk.graal.compiler.hotspot.HotSpotGraalRuntime.HotSpotGC;
import jdk.graal.compiler.hotspot.meta.HotSpotProviders;
import jdk.graal.compiler.hotspot.phases.OnStackReplacementPhase;
import jdk.graal.compiler.java.GraphBuilderPhase;
import jdk.graal.compiler.java.StableMethodNameFormatter;
Expand All @@ -59,7 +59,6 @@
import jdk.graal.compiler.phases.tiers.Suites;
import jdk.graal.compiler.printer.GraalDebugHandlersFactory;
import jdk.graal.compiler.serviceprovider.GraalUnsafeAccess;

import jdk.vm.ci.code.CompilationRequest;
import jdk.vm.ci.code.CompilationRequestResult;
import jdk.vm.ci.hotspot.HotSpotCompilationRequest;
Expand Down Expand Up @@ -285,28 +284,25 @@ protected LIRSuites getLIRSuites(HotSpotProviders providers, OptionValues option
*/
protected PhaseSuite<HighTierContext> configGraphBuilderSuite(PhaseSuite<HighTierContext> suite, boolean shouldDebugNonSafepoints, boolean shouldRetainLocalVariables, boolean eagerResolving,
boolean isOSR) {
if (shouldDebugNonSafepoints || shouldRetainLocalVariables || isOSR || eagerResolving) {
PhaseSuite<HighTierContext> newGbs = suite.copy();
GraphBuilderPhase graphBuilderPhase = (GraphBuilderPhase) newGbs.findPhase(GraphBuilderPhase.class).previous();
GraphBuilderConfiguration graphBuilderConfig = graphBuilderPhase.getGraphBuilderConfig();
if (shouldDebugNonSafepoints) {
graphBuilderConfig = graphBuilderConfig.withNodeSourcePosition(true);
}
if (shouldRetainLocalVariables) {
graphBuilderConfig = graphBuilderConfig.withRetainLocalVariables(true);
}
if (eagerResolving) {
graphBuilderConfig = graphBuilderConfig.withEagerResolving(true);
graphBuilderConfig = graphBuilderConfig.withUnresolvedIsError(true);
}
GraphBuilderPhase newGraphBuilderPhase = new HotSpotGraphBuilderPhase(graphBuilderConfig);
newGbs.findPhase(GraphBuilderPhase.class).set(newGraphBuilderPhase);
if (isOSR) {
newGbs.appendPhase(new OnStackReplacementPhase());
}
return newGbs;
PhaseSuite<HighTierContext> newGbs = suite.copy();
GraphBuilderPhase graphBuilderPhase = (GraphBuilderPhase) newGbs.findPhase(GraphBuilderPhase.class).previous();
GraphBuilderConfiguration graphBuilderConfig = graphBuilderPhase.getGraphBuilderConfig();
if (shouldDebugNonSafepoints) {
graphBuilderConfig = graphBuilderConfig.withNodeSourcePosition(true);
}
if (shouldRetainLocalVariables) {
graphBuilderConfig = graphBuilderConfig.withRetainLocalVariables(true);
}
if (eagerResolving) {
graphBuilderConfig = graphBuilderConfig.withEagerResolving(true);
graphBuilderConfig = graphBuilderConfig.withUnresolvedIsError(true);
}
GraphBuilderPhase newGraphBuilderPhase = new HotSpotGraphBuilderPhase(graphBuilderConfig);
newGbs.findPhase(GraphBuilderPhase.class).set(newGraphBuilderPhase);
if (isOSR) {
newGbs.appendPhase(new OnStackReplacementPhase());
}
return suite;
return newGbs;
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions docs/reference-manual/native-image/MemoryManagement.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The Java heap is created when the native image starts up, and may increase or de
When the heap becomes full, a garbage collection is triggered to reclaim memory of objects that are no longer used.

For managing the Java heap, Native Image provides different garbage collector (GC) implementations:
* The **Serial GC** is the default GC in GraalVM.
* The **Serial GC** is the default GC in GraalVM Native Image.
It is optimized for low memory footprint and small Java heap sizes.
* The **G1 GC** is a multi-threaded GC that is optimized to reduce stop-the-world pauses and therefore improve latency, while achieving high throughput.
To enable it, pass the option `--gc=G1` to the `native-image` builder.
Expand All @@ -42,7 +42,7 @@ The exact values may depend on the system configuration and the used GC.

* The *maximum Java heap size* defines the upper limit for the size of the whole Java heap.
If the Java heap is full and the GC is unable reclaim sufficient memory for a Java object allocation, the allocation will fail with the `OutOfMemoryError`.
Note: The maximum heap size is only the upper limit for the Java heap and not necessarily the upper limit for the total amount of consumed memory, as Native Image places some data such as thread stacks, just-in-time compiled code, and internal data structures in memory that is separate from the Java heap.
Note: The maximum heap size is only the upper limit for the Java heap and not necessarily the upper limit for the total amount of consumed memory, as Native Image places some data such as thread stacks, just-in-time compiled code (for Truffle runtime compilation), and internal data structures in memory that is separate from the Java heap.
* The *minimum Java heap size* defines how much memory the GC may always assume as reserved for the Java heap, no matter how little of that memory is actually used.
* The *young generation size* determines the amount of Java memory that can be allocated without triggering a garbage collection.

Expand Down Expand Up @@ -234,4 +234,4 @@ Which data is printed in detail depends on the used GC.

### Further Reading

* [Memory Configuration for Native Image Build](BuildConfiguration.md#memory-configuration-for-native-image-build)
* [Memory Configuration for Native Image Build](BuildConfiguration.md#memory-configuration-for-native-image-build)
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import com.oracle.svm.core.option.RuntimeOptionKey;
import com.oracle.svm.core.option.SubstrateOptionsParser;
import com.oracle.svm.core.thread.VMOperationControl;
import com.oracle.svm.core.util.InterruptImageBuilding;
import com.oracle.svm.core.util.UserError;
import com.oracle.svm.util.LogUtils;
import com.oracle.svm.util.ModuleSupport;
Expand Down Expand Up @@ -112,7 +113,11 @@ public static boolean parseOnce() {

@APIOption(name = "static")//
@Option(help = "Build statically linked executable (requires static libc and zlib)")//
public static final HostedOptionKey<Boolean> StaticExecutable = new HostedOptionKey<>(false);
public static final HostedOptionKey<Boolean> StaticExecutable = new HostedOptionKey<>(false, key -> {
if (!Platform.includedIn(Platform.LINUX.class)) {
throw new InterruptImageBuilding("Building static executable images is currently only supported on Linux. Remove the '--static' option or build on a Linux machine.");
}
});

@APIOption(name = "libc")//
@Option(help = "Selects the libc implementation to use. Available implementations: glibc, musl, bionic")//
Expand Down Expand Up @@ -335,7 +340,7 @@ public static void setOptimizeValueUpdateHandler(ValueUpdateHandler<Optimization
@Option(help = "Path passed to the linker as the -rpath (list of comma-separated directories)")//
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> LinkerRPath = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());

@Option(help = "Directory of the image file to be generated", type = OptionType.User)//
@Option(help = {"Directory of the image file to be generated", "Use the '-o' option instead."}, type = OptionType.User)//
public static final HostedOptionKey<String> Path = new HostedOptionKey<>(null);

public static final class GCGroup implements APIOptionGroup {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,22 @@ public static final class Options {
@Option(help = "file:doc-files/ReflectionConfigurationFilesHelp.txt", type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> ReflectionConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing program elements to be made available for reflection (see ReflectionConfigurationFiles).", type = OptionType.User)//
@Option(help = {"Resources describing program elements to be made available for reflection (see ReflectionConfigurationFiles).",
"Use a reflect-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> ReflectionConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());

@Option(help = "file:doc-files/ProxyConfigurationFilesHelp.txt", type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> DynamicProxyConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing program elements to be made available for reflection (see ProxyConfigurationFiles).", type = OptionType.User)//
@Option(help = {"Resources describing program elements to be made available for reflection (see ProxyConfigurationFiles).",
"Use a proxy-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> DynamicProxyConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());

@Option(help = "file:doc-files/SerializationConfigurationFilesHelp.txt", type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> SerializationConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing program elements to be made available for serialization (see SerializationConfigurationFiles).", type = OptionType.User)//
@Option(help = {"Resources describing program elements to be made available for serialization (see SerializationConfigurationFiles).",
"Use a serialization-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> SerializationConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());

@Option(help = "file:doc-files/SerializationConfigurationFilesHelp.txt", type = OptionType.User)//
Expand All @@ -82,18 +85,22 @@ public static final class Options {
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> SerializationDenyConfigurationResources = new HostedOptionKey<>(
LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());

@Option(help = "Files describing Java resources to be included in the image according to the schema at " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json", type = OptionType.User)//
@Option(help = {"Files describing Java resources to be included in the image according to the schema at " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json",
"Use a resource-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> ResourceConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing Java resources to be included in the image according to the schema at " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json", type = OptionType.User)//
@Option(help = {"Resources describing Java resources to be included in the image according to the schema at " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json",
"Use a resource-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> ResourceConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());

@Option(help = "Files describing program elements to be made accessible via JNI (for syntax, see ReflectionConfigurationFiles)", type = OptionType.User)//
@Option(help = {"Files describing program elements to be made accessible via JNI (for syntax, see ReflectionConfigurationFiles)",
"Use a jni-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> JNIConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing program elements to be made accessible via JNI (see JNIConfigurationFiles).", type = OptionType.User)//
@Option(help = {"Resources describing program elements to be made accessible via JNI (see JNIConfigurationFiles).",
"Use a jni-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> JNIConfigurationResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());

@Option(help = "Files describing stubs allowing foreign calls.", type = OptionType.User)//
Expand All @@ -102,12 +109,14 @@ public static final class Options {
@Option(help = "Resources describing stubs allowing foreign calls.", type = OptionType.User)//
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> ForeignResources = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());

@Option(help = "Files describing predefined classes that can be loaded at runtime according to the schema at " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json", type = OptionType.User)//
@Option(help = {"Files describing predefined classes that can be loaded at runtime according to the schema at " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json",
"Use a predefined-classes-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
@BundleMember(role = BundleMember.Role.Input)//
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> PredefinedClassesConfigurationFiles = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
@Option(help = "Resources describing predefined classes that can be loaded at runtime according to the schema at " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json", type = OptionType.User)//
@Option(help = {"Resources describing predefined classes that can be loaded at runtime according to the schema at " +
"https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json",
"Use a predefined-classes-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead."}, type = OptionType.User)//
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> PredefinedClassesConfigurationResources = new HostedOptionKey<>(
LocatableMultiOptionValue.Strings.buildWithCommaDelimiter());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
One or several (comma-separated) paths to JSON files that specify lists of interfaces that define Java proxy classes.
Use a proxy-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.

The JSON structure is described in the following schema:

https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/proxy-config-schema-v1.0.0.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
One or several (comma-separated) paths to JSON files that specify which program elements should be made available via reflection.
Use a reflect-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.

The JSON object schema is described at:

https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/reflect-config-schema-v1.0.0.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
One or several (comma-separated) paths to JSON files that specify lists of serialization configurations.
Use a serialization-config.json in your META-INF/native-image/<groupID>/<artifactID> directory instead.

The structure is described in the following schema:

https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/serialization-config-schema-v1.0.0.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
import java.util.function.Predicate;

import org.graalvm.collections.EconomicMap;
import jdk.graal.compiler.options.OptionDescriptor;
import jdk.graal.compiler.options.OptionDescriptors;
import jdk.graal.compiler.options.OptionKey;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

Expand All @@ -47,6 +44,10 @@
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.util.LogUtils;

import jdk.graal.compiler.options.OptionDescriptor;
import jdk.graal.compiler.options.OptionDescriptors;
import jdk.graal.compiler.options.OptionKey;

/**
* This class contains methods for parsing options and matching them against
* {@link OptionDescriptor}s.
Expand Down Expand Up @@ -178,14 +179,18 @@ public static String commandArgument(OptionKey<?> option, String value, String a
/* Ensure descriptor is loaded */
OptionDescriptor optionDescriptor = option.loadDescriptor();
Field field;
APIOption[] apiOptions;
try {
field = optionDescriptor.getDeclaringClass().getDeclaredField(optionDescriptor.getFieldName());
apiOptions = field.getAnnotationsByType(APIOption.class);
} catch (ReflectiveOperationException ex) {
throw VMError.shouldNotReachHere(ex);
/*
* Options whose fields cannot be looked up (e.g., due to stripped sources) cannot be
* API options by definition.
*/
apiOptions = new APIOption[0];
}

APIOption[] apiOptions = field.getAnnotationsByType(APIOption.class);

if (optionDescriptor.getOptionValueType() == Boolean.class) {
VMError.guarantee(value.equals("+") || value.equals("-"), "Boolean option value can be only + or -");
for (APIOption apiOption : apiOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,6 @@ public static RuntimeException unsupportedFeature(String msg) {
throw new HostedError("UNSUPPORTED FEATURE: " + msg);
}

public static boolean hostedError(Throwable t) {
return t instanceof HostedError;
}

/**
* Processes {@code args} to convert selected values to strings.
* <ul>
Expand Down
Loading

0 comments on commit bc6c516

Please sign in to comment.