Search in sources :

Example 11 with OptionValues

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

the class NestedBooleanOptionKeyTest method runDefaultTrue.

@Test
public void runDefaultTrue() {
    OptionValues options = new OptionValues(null, Master1, true);
    assertTrue(Master1.getValue(options));
    assertTrue(NestedOption1.getValue(options));
    // nested value unset
    options = new OptionValues(null, Master1, false);
    assertFalse(Master1.getValue(options));
    assertFalse(NestedOption1.getValue(options));
    // set false
    options = new OptionValues(null, Master1, false, NestedOption1, false);
    assertFalse(Master1.getValue(options));
    assertFalse(NestedOption1.getValue(options));
    options = new OptionValues(null, Master1, true, NestedOption1, false);
    assertTrue(Master1.getValue(options));
    assertFalse(NestedOption1.getValue(options));
    // set true
    options = new OptionValues(null, Master1, false, NestedOption1, true);
    assertFalse(Master1.getValue(options));
    assertTrue(NestedOption1.getValue(options));
    options = new OptionValues(null, Master1, true, NestedOption1, true);
    assertTrue(Master1.getValue(options));
    assertTrue(NestedOption1.getValue(options));
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) Test(org.junit.Test)

Example 12 with OptionValues

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

the class HotSpotGraphBuilderPlugins method create.

/**
 * Creates a {@link Plugins} object that should be used when running on HotSpot.
 *
 * @param constantReflection
 * @param snippetReflection
 * @param foreignCalls
 * @param stampProvider
 */
public static Plugins create(CompilerConfiguration compilerConfiguration, GraalHotSpotVMConfig config, HotSpotWordTypes wordTypes, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, SnippetReflectionProvider snippetReflection, ForeignCallsProvider foreignCalls, LoweringProvider lowerer, StampProvider stampProvider, ReplacementsImpl replacements) {
    InvocationPlugins invocationPlugins = new HotSpotInvocationPlugins(config, compilerConfiguration);
    Plugins plugins = new Plugins(invocationPlugins);
    NodeIntrinsificationProvider nodeIntrinsificationProvider = new NodeIntrinsificationProvider(metaAccess, snippetReflection, foreignCalls, lowerer, wordTypes);
    HotSpotWordOperationPlugin wordOperationPlugin = new HotSpotWordOperationPlugin(snippetReflection, wordTypes);
    HotSpotNodePlugin nodePlugin = new HotSpotNodePlugin(wordOperationPlugin);
    plugins.appendTypePlugin(nodePlugin);
    plugins.appendNodePlugin(nodePlugin);
    OptionValues options = replacements.getOptions();
    if (!GeneratePIC.getValue(options)) {
        plugins.appendNodePlugin(new MethodHandlePlugin(constantReflection.getMethodHandleAccess(), true));
    }
    plugins.appendInlineInvokePlugin(replacements);
    if (InlineDuringParsing.getValue(options)) {
        plugins.appendInlineInvokePlugin(new InlineDuringParsingPlugin());
    }
    if (GeneratePIC.getValue(options)) {
        plugins.setClassInitializationPlugin(new HotSpotClassInitializationPlugin());
        if (TieredAOT.getValue(options)) {
            plugins.setProfilingPlugin(new HotSpotAOTProfilingPlugin());
        }
    }
    invocationPlugins.defer(new Runnable() {

        @Override
        public void run() {
            BytecodeProvider replacementBytecodeProvider = replacements.getDefaultReplacementBytecodeProvider();
            registerObjectPlugins(invocationPlugins, options, replacementBytecodeProvider);
            registerClassPlugins(plugins, config, replacementBytecodeProvider);
            registerSystemPlugins(invocationPlugins, foreignCalls);
            registerThreadPlugins(invocationPlugins, metaAccess, wordTypes, config, replacementBytecodeProvider);
            if (!GeneratePIC.getValue(options)) {
                registerCallSitePlugins(invocationPlugins);
            }
            registerReflectionPlugins(invocationPlugins, replacementBytecodeProvider);
            registerConstantPoolPlugins(invocationPlugins, wordTypes, config, replacementBytecodeProvider);
            registerAESPlugins(invocationPlugins, config, replacementBytecodeProvider);
            registerCRC32Plugins(invocationPlugins, config, replacementBytecodeProvider);
            registerCRC32CPlugins(invocationPlugins, config, replacementBytecodeProvider);
            registerBigIntegerPlugins(invocationPlugins, config, replacementBytecodeProvider);
            registerSHAPlugins(invocationPlugins, config, replacementBytecodeProvider);
            registerUnsafePlugins(invocationPlugins, replacementBytecodeProvider);
            StandardGraphBuilderPlugins.registerInvocationPlugins(metaAccess, snippetReflection, invocationPlugins, replacementBytecodeProvider, true);
            registerArrayPlugins(invocationPlugins, replacementBytecodeProvider);
            for (NodeIntrinsicPluginFactory factory : GraalServices.load(NodeIntrinsicPluginFactory.class)) {
                factory.registerPlugins(invocationPlugins, nodeIntrinsificationProvider);
            }
        }
    });
    return plugins;
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) OptionValues(org.graalvm.compiler.options.OptionValues) InlineDuringParsingPlugin(org.graalvm.compiler.replacements.InlineDuringParsingPlugin) NodeIntrinsicPluginFactory(org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider) NodeIntrinsificationProvider(org.graalvm.compiler.replacements.NodeIntrinsificationProvider) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins) StandardGraphBuilderPlugins(org.graalvm.compiler.replacements.StandardGraphBuilderPlugins) MethodHandlePlugin(org.graalvm.compiler.replacements.MethodHandlePlugin)

Example 13 with OptionValues

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

the class HotSpotProfilingPlugin method profileGoto.

@Override
public void profileGoto(GraphBuilderContext builder, ResolvedJavaMethod method, int bci, int targetBci, FrameState frameState) {
    assert shouldProfile(builder, method);
    OptionValues options = builder.getOptions();
    if (Options.ProfileBackedges.getValue(options) && targetBci <= bci) {
        ProfileNode p = builder.append(new ProfileBranchNode(method, backedgeNotifyFreqLog(options), backedgeProfilePobabilityLog(options), bci, targetBci));
        p.setStateBefore(frameState);
    }
}
Also used : ProfileBranchNode(org.graalvm.compiler.hotspot.nodes.profiling.ProfileBranchNode) OptionValues(org.graalvm.compiler.options.OptionValues) ProfileNode(org.graalvm.compiler.hotspot.nodes.profiling.ProfileNode)

Example 14 with OptionValues

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

the class HotSpotGraalCompiler method compileMethod.

@SuppressWarnings("try")
CompilationRequestResult compileMethod(CompilationRequest request, boolean installAsDefault) {
    if (graalRuntime.isShutdown()) {
        return HotSpotCompilationRequestResult.failure(String.format("Shutdown entered"), false);
    }
    ResolvedJavaMethod method = request.getMethod();
    OptionValues options = graalRuntime.getOptions(method);
    if (graalRuntime.isBootstrapping()) {
        if (DebugOptions.BootstrapInitializeOnly.getValue(options)) {
            return HotSpotCompilationRequestResult.failure(String.format("Skip compilation because %s is enabled", DebugOptions.BootstrapInitializeOnly.getName()), true);
        }
        if (bootstrapWatchDog != null) {
            if (bootstrapWatchDog.hitCriticalCompilationRateOrTimeout()) {
                // Drain the compilation queue to expedite completion of the bootstrap
                return HotSpotCompilationRequestResult.failure("hit critical bootstrap compilation rate or timeout", true);
            }
        }
    }
    HotSpotCompilationRequest hsRequest = (HotSpotCompilationRequest) request;
    try (CompilationWatchDog w1 = CompilationWatchDog.watch(method, hsRequest.getId(), options);
        BootstrapWatchDog.Watch w2 = bootstrapWatchDog == null ? null : bootstrapWatchDog.watch(request);
        CompilationAlarm alarm = CompilationAlarm.trackCompilationPeriod(options)) {
        if (compilationCounters != null) {
            compilationCounters.countCompilation(method);
        }
        CompilationTask task = new CompilationTask(jvmciRuntime, this, hsRequest, true, installAsDefault, options);
        CompilationRequestResult r = null;
        try (DebugContext debug = graalRuntime.openDebugContext(options, task.getCompilationIdentifier(), method, getDebugHandlersFactories());
            Activation a = debug.activate()) {
            r = task.runCompilation(debug);
        }
        assert r != null;
        return r;
    }
}
Also used : CompilationRequestResult(jdk.vm.ci.code.CompilationRequestResult) HotSpotCompilationRequestResult(jdk.vm.ci.hotspot.HotSpotCompilationRequestResult) OptionValues(org.graalvm.compiler.options.OptionValues) CompilationAlarm(org.graalvm.compiler.core.common.util.CompilationAlarm) Activation(org.graalvm.compiler.debug.DebugContext.Activation) DebugContext(org.graalvm.compiler.debug.DebugContext) HotSpotCompilationRequest(jdk.vm.ci.hotspot.HotSpotCompilationRequest) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 15 with OptionValues

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

the class HotSpotGraalMBean method currentMap.

private OptionValues currentMap(OptionValues initialValues, ResolvedJavaMethod method) {
    if (changes.isEmpty() && methodDumps.isEmpty()) {
        return initialValues;
    }
    OptionValues current = cachedOptions;
    if (current == null) {
        current = new OptionValues(initialValues, changes);
        cachedOptions = current;
    }
    if (method != null) {
        for (Dump request : methodDumps) {
            final String clazzName = method.getDeclaringClass().getName();
            if (method.getName().equals(request.method) && clazzName.equals(request.clazz)) {
                current = new OptionValues(current, DebugOptions.Dump, request.filter, DebugOptions.PrintGraphHost, request.host, DebugOptions.PrintBinaryGraphPort, request.port);
                break;
            }
        }
    }
    return current;
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues)

Aggregations

OptionValues (org.graalvm.compiler.options.OptionValues)158 Test (org.junit.Test)65 DebugContext (org.graalvm.compiler.debug.DebugContext)50 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)36 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)30 Graph (org.graalvm.compiler.graph.Graph)22 OptionKey (org.graalvm.compiler.options.OptionKey)16 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)13 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)11 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)10 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)10 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)10 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)9 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)9 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)9 Providers (org.graalvm.compiler.phases.util.Providers)9 IOException (java.io.IOException)8 Method (java.lang.reflect.Method)8 CompilationResult (org.graalvm.compiler.code.CompilationResult)7 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)7