Search in sources :

Example 11 with OptionKey

use of org.graalvm.compiler.options.OptionKey in project graal by oracle.

the class CompileTheWorldTest method testJDK.

@Test
public void testJDK() throws Throwable {
    ExceptionAction originalBailoutAction = CompilationBailoutAction.getValue(getInitialOptions());
    ExceptionAction originalFailureAction = CompilationFailureAction.getValue(getInitialOptions());
    // Compile a couple classes in rt.jar
    HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
    System.setProperty("CompileTheWorld.LimitModules", "java.base");
    OptionValues initialOptions = getInitialOptions();
    EconomicMap<OptionKey<?>, Object> compilationOptions = CompileTheWorld.parseOptions("Inline=false");
    new CompileTheWorld(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), CompileTheWorld.SUN_BOOT_CLASS_PATH, 1, 5, null, null, false, initialOptions, compilationOptions).compile();
    assert CompilationBailoutAction.getValue(initialOptions) == originalBailoutAction;
    assert CompilationFailureAction.getValue(initialOptions) == originalFailureAction;
}
Also used : HotSpotGraalCompiler(org.graalvm.compiler.hotspot.HotSpotGraalCompiler) ExceptionAction(org.graalvm.compiler.core.CompilationWrapper.ExceptionAction) OptionValues(org.graalvm.compiler.options.OptionValues) OptionKey(org.graalvm.compiler.options.OptionKey) HotSpotJVMCIRuntimeProvider(jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 12 with OptionKey

use of org.graalvm.compiler.options.OptionKey in project graal by oracle.

the class GraalOSRLockTest method testLockOSROuterCompileRestOfMethod.

@Test
@SuppressWarnings("try")
public void testLockOSROuterCompileRestOfMethod() {
    run(() -> {
        EconomicMap<OptionKey<?>, Object> overrides = osrLockNoDeopt();
        overrides.put(HighTier.Options.Inline, false);
        OptionValues options = new OptionValues(getInitialOptions(), overrides);
        testOSR(options, "testOuterLockCompileRestOfMethod");
    });
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) OptionKey(org.graalvm.compiler.options.OptionKey) Test(org.junit.Test)

Example 13 with OptionKey

use of org.graalvm.compiler.options.OptionKey in project graal by oracle.

the class GraalOSRLockTest method testLockOSROuterInnerLockDepthCompileRestOfMethod.

@Test
@SuppressWarnings("try")
public void testLockOSROuterInnerLockDepthCompileRestOfMethod() {
    run(() -> {
        EconomicMap<OptionKey<?>, Object> overrides = osrLockNoDeopt();
        overrides.put(HighTier.Options.Inline, false);
        OptionValues options = new OptionValues(getInitialOptions(), overrides);
        testOSR(options, "testOuterInnerLockDepth1CompileRestOfMethod");
    });
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) OptionKey(org.graalvm.compiler.options.OptionKey) Test(org.junit.Test)

Example 14 with OptionKey

use of org.graalvm.compiler.options.OptionKey in project graal by oracle.

the class GraalOSRLockTest method testLockOSROuterInnerLockDepthDeopt.

@Test
@SuppressWarnings("try")
public void testLockOSROuterInnerLockDepthDeopt() {
    run(() -> {
        EconomicMap<OptionKey<?>, Object> overrides = osrLockNoDeopt();
        overrides.put(HighTier.Options.Inline, false);
        OptionValues options = new OptionValues(getInitialOptions(), overrides);
        testOSR(options, "testOuterInnerLockDepth1DeoptAfter");
    });
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) OptionKey(org.graalvm.compiler.options.OptionKey) Test(org.junit.Test)

Example 15 with OptionKey

use of org.graalvm.compiler.options.OptionKey in project graal by oracle.

the class HotSpotGraalOptionValues method initializeOptions.

/**
 * Global options. The values for these options are initialized by parsing the file denoted by
 * the {@code VM.getSavedProperty(String) saved} system property named
 * {@value #GRAAL_OPTIONS_FILE_PROPERTY_NAME} if the file exists followed by parsing the options
 * encoded in saved system properties whose names start with
 * {@value #GRAAL_OPTION_PROPERTY_PREFIX}. Key/value pairs are parsed from the aforementioned
 * file with {@link Properties#load(java.io.Reader)}.
 */
@SuppressWarnings("try")
private static OptionValues initializeOptions() {
    EconomicMap<OptionKey<?>, Object> values = OptionValues.newOptionMap();
    try (InitTimer t = timer("InitializeOptions")) {
        Iterable<OptionDescriptors> loader = OptionsParser.getOptionsLoader();
        Map<String, String> savedProps = jdk.vm.ci.services.Services.getSavedProperties();
        String optionsFile = savedProps.get(GRAAL_OPTIONS_FILE_PROPERTY_NAME);
        if (optionsFile != null) {
            File graalOptions = new File(optionsFile);
            if (graalOptions.exists()) {
                try (FileReader fr = new FileReader(graalOptions)) {
                    Properties props = new Properties();
                    props.load(fr);
                    EconomicMap<String, String> optionSettings = EconomicMap.create();
                    for (Map.Entry<Object, Object> e : props.entrySet()) {
                        optionSettings.put((String) e.getKey(), (String) e.getValue());
                    }
                    try {
                        OptionsParser.parseOptions(optionSettings, values, loader);
                    } catch (Throwable e) {
                        throw new InternalError("Error parsing an option from " + graalOptions, e);
                    }
                } catch (IOException e) {
                    throw new InternalError("Error reading " + graalOptions, e);
                }
            }
        }
        EconomicMap<String, String> optionSettings = EconomicMap.create();
        for (Map.Entry<String, String> e : savedProps.entrySet()) {
            String name = e.getKey();
            if (name.startsWith(GRAAL_OPTION_PROPERTY_PREFIX)) {
                if (name.equals("graal.PrintFlags") || name.equals("graal.ShowFlags")) {
                    System.err.println("The " + name + " option has been removed and will be ignored. Use -XX:+JVMCIPrintProperties instead.");
                } else if (name.equals(GRAAL_OPTIONS_FILE_PROPERTY_NAME) || name.equals(GRAAL_VERSION_PROPERTY_NAME)) {
                // Ignore well known properties that do not denote an option
                } else {
                    String value = e.getValue();
                    optionSettings.put(name.substring(GRAAL_OPTION_PROPERTY_PREFIX.length()), value);
                }
            }
        }
        OptionsParser.parseOptions(optionSettings, values, loader);
        return new OptionValues(values);
    }
}
Also used : InitTimer(jdk.vm.ci.common.InitTimer) OptionValues(org.graalvm.compiler.options.OptionValues) OptionDescriptors(org.graalvm.compiler.options.OptionDescriptors) IOException(java.io.IOException) Properties(java.util.Properties) OptionKey(org.graalvm.compiler.options.OptionKey) FileReader(java.io.FileReader) File(java.io.File) EconomicMap(org.graalvm.collections.EconomicMap) Map(java.util.Map)

Aggregations

OptionKey (org.graalvm.compiler.options.OptionKey)17 OptionValues (org.graalvm.compiler.options.OptionValues)15 Test (org.junit.Test)13 DebugContext (org.graalvm.compiler.debug.DebugContext)8 IOException (java.io.IOException)4 Scope (org.graalvm.compiler.debug.DebugContext.Scope)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintStream (java.io.PrintStream)3 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)2 OptionDescriptors (org.graalvm.compiler.options.OptionDescriptors)2 HostedOptionKey (com.oracle.svm.core.option.HostedOptionKey)1 File (java.io.File)1 FileReader (java.io.FileReader)1 Field (java.lang.reflect.Field)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 Path (java.nio.file.Path)1 Map (java.util.Map)1 Properties (java.util.Properties)1