Search in sources :

Example 1 with OptionValues

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

the class AMD64HotSpotBackendFactory method createBackend.

@Override
@SuppressWarnings("try")
public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider graalRuntime, CompilerConfiguration compilerConfiguration, HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotBackend host) {
    assert host == null;
    OptionValues options = graalRuntime.getOptions();
    JVMCIBackend jvmci = jvmciRuntime.getHostJVMCIBackend();
    GraalHotSpotVMConfig config = graalRuntime.getVMConfig();
    HotSpotProviders providers;
    HotSpotRegistersProvider registers;
    HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmci.getCodeCache();
    TargetDescription target = codeCache.getTarget();
    HotSpotHostForeignCallsProvider foreignCalls;
    Value[] nativeABICallerSaveRegisters;
    HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) jvmci.getMetaAccess();
    HotSpotConstantReflectionProvider constantReflection = (HotSpotConstantReflectionProvider) jvmci.getConstantReflection();
    ConstantFieldProvider constantFieldProvider = new HotSpotGraalConstantFieldProvider(config, metaAccess);
    HotSpotLoweringProvider lowerer;
    HotSpotSnippetReflectionProvider snippetReflection;
    HotSpotReplacementsImpl replacements;
    HotSpotSuitesProvider suites;
    HotSpotWordTypes wordTypes;
    Plugins plugins;
    BytecodeProvider bytecodeProvider;
    try (InitTimer t = timer("create providers")) {
        try (InitTimer rt = timer("create HotSpotRegisters provider")) {
            registers = createRegisters();
        }
        try (InitTimer rt = timer("create NativeABICallerSaveRegisters")) {
            nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(config, codeCache.getRegisterConfig());
        }
        try (InitTimer rt = timer("create WordTypes")) {
            wordTypes = new HotSpotWordTypes(metaAccess, target.wordJavaKind);
        }
        try (InitTimer rt = timer("create ForeignCalls provider")) {
            foreignCalls = createForeignCalls(jvmciRuntime, graalRuntime, metaAccess, codeCache, wordTypes, nativeABICallerSaveRegisters);
        }
        try (InitTimer rt = timer("create Lowerer provider")) {
            lowerer = createLowerer(graalRuntime, metaAccess, foreignCalls, registers, constantReflection, target);
        }
        HotSpotStampProvider stampProvider = new HotSpotStampProvider();
        Providers p = new Providers(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, null, stampProvider);
        try (InitTimer rt = timer("create SnippetReflection provider")) {
            snippetReflection = createSnippetReflection(graalRuntime, constantReflection, wordTypes);
        }
        try (InitTimer rt = timer("create Bytecode provider")) {
            bytecodeProvider = new ClassfileBytecodeProvider(metaAccess, snippetReflection);
        }
        try (InitTimer rt = timer("create Replacements provider")) {
            replacements = createReplacements(options, p, snippetReflection, bytecodeProvider);
        }
        try (InitTimer rt = timer("create GraphBuilderPhase plugins")) {
            plugins = createGraphBuilderPlugins(compilerConfiguration, config, options, target, constantReflection, foreignCalls, lowerer, metaAccess, snippetReflection, replacements, wordTypes, stampProvider);
            replacements.setGraphBuilderPlugins(plugins);
        }
        try (InitTimer rt = timer("create Suites provider")) {
            suites = createSuites(config, graalRuntime, compilerConfiguration, plugins, registers, replacements, options);
        }
        providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, replacements, suites, registers, snippetReflection, wordTypes, plugins);
    }
    try (InitTimer rt = timer("instantiate backend")) {
        return createBackend(config, graalRuntime, providers);
    }
}
Also used : InitTimer(jdk.vm.ci.common.InitTimer) OptionValues(org.graalvm.compiler.options.OptionValues) JVMCIBackend(jdk.vm.ci.runtime.JVMCIBackend) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) TargetDescription(jdk.vm.ci.code.TargetDescription) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) Providers(org.graalvm.compiler.phases.util.Providers) HotSpotReplacementsImpl(org.graalvm.compiler.hotspot.HotSpotReplacementsImpl) HotSpotRegistersProvider(org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider) HotSpotSuitesProvider(org.graalvm.compiler.hotspot.meta.HotSpotSuitesProvider) AddressLoweringHotSpotSuitesProvider(org.graalvm.compiler.hotspot.meta.AddressLoweringHotSpotSuitesProvider) GraalHotSpotVMConfig(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig) HotSpotStampProvider(org.graalvm.compiler.hotspot.meta.HotSpotStampProvider) HotSpotGraphBuilderPlugins(org.graalvm.compiler.hotspot.meta.HotSpotGraphBuilderPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins) AMD64GraphBuilderPlugins(org.graalvm.compiler.replacements.amd64.AMD64GraphBuilderPlugins) ClassfileBytecodeProvider(org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider) HotSpotHostForeignCallsProvider(org.graalvm.compiler.hotspot.meta.HotSpotHostForeignCallsProvider) HotSpotCodeCacheProvider(jdk.vm.ci.hotspot.HotSpotCodeCacheProvider) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider) ClassfileBytecodeProvider(org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider) HotSpotMetaAccessProvider(jdk.vm.ci.hotspot.HotSpotMetaAccessProvider) HotSpotSnippetReflectionProvider(org.graalvm.compiler.hotspot.meta.HotSpotSnippetReflectionProvider) HotSpotLoweringProvider(org.graalvm.compiler.hotspot.meta.HotSpotLoweringProvider) HotSpotWordTypes(org.graalvm.compiler.hotspot.word.HotSpotWordTypes) Value(jdk.vm.ci.meta.Value) HotSpotConstantReflectionProvider(jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider) HotSpotGraalConstantFieldProvider(org.graalvm.compiler.hotspot.meta.HotSpotGraalConstantFieldProvider) HotSpotGraalConstantFieldProvider(org.graalvm.compiler.hotspot.meta.HotSpotGraalConstantFieldProvider) ConstantFieldProvider(org.graalvm.compiler.core.common.spi.ConstantFieldProvider)

Example 2 with OptionValues

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

the class AMD64HotSpotLIRGenerator method emitUncompress.

@Override
public Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
    LIRKind inputKind = pointer.getValueKind(LIRKind.class);
    LIRKindTool lirKindTool = getLIRKindTool();
    assert inputKind.getPlatformKind() == lirKindTool.getNarrowOopKind().getPlatformKind();
    if (inputKind.isReference(0)) {
        // oop
        Variable result = newVariable(lirKindTool.getObjectKind());
        append(new AMD64Move.UncompressPointerOp(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull, lirKindTool));
        return result;
    } else {
        // metaspace pointer
        LIRKind uncompressedKind = lirKindTool.getWordKind();
        Variable result = newVariable(uncompressedKind);
        AllocatableValue base = Value.ILLEGAL;
        OptionValues options = getResult().getLIR().getOptions();
        if (encoding.hasBase() || GeneratePIC.getValue(options)) {
            if (GeneratePIC.getValue(options)) {
                Variable baseAddress = newVariable(uncompressedKind);
                AMD64HotSpotMove.BaseMove move = new AMD64HotSpotMove.BaseMove(baseAddress, config);
                append(move);
                base = baseAddress;
            } else {
                base = emitLoadConstant(uncompressedKind, JavaConstant.forLong(encoding.getBase()));
            }
        }
        append(new AMD64Move.UncompressPointerOp(result, asAllocatable(pointer), base, encoding, nonNull, lirKindTool));
        return result;
    }
}
Also used : Variable(org.graalvm.compiler.lir.Variable) OptionValues(org.graalvm.compiler.options.OptionValues) LIRKindTool(org.graalvm.compiler.core.common.spi.LIRKindTool) LIRKind(org.graalvm.compiler.core.common.LIRKind) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) AMD64Move(org.graalvm.compiler.lir.amd64.AMD64Move)

Example 3 with OptionValues

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

the class AMD64HotSpotLIRGenerator method emitCompress.

@Override
public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
    LIRKind inputKind = pointer.getValueKind(LIRKind.class);
    LIRKindTool lirKindTool = getLIRKindTool();
    assert inputKind.getPlatformKind() == lirKindTool.getObjectKind().getPlatformKind();
    if (inputKind.isReference(0)) {
        // oop
        Variable result = newVariable(lirKindTool.getNarrowOopKind());
        append(new AMD64Move.CompressPointerOp(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull, getLIRKindTool()));
        return result;
    } else {
        // metaspace pointer
        Variable result = newVariable(lirKindTool.getNarrowPointerKind());
        AllocatableValue base = Value.ILLEGAL;
        OptionValues options = getResult().getLIR().getOptions();
        if (encoding.hasBase() || GeneratePIC.getValue(options)) {
            if (GeneratePIC.getValue(options)) {
                Variable baseAddress = newVariable(lirKindTool.getWordKind());
                AMD64HotSpotMove.BaseMove move = new AMD64HotSpotMove.BaseMove(baseAddress, config);
                append(move);
                base = baseAddress;
            } else {
                base = emitLoadConstant(lirKindTool.getWordKind(), JavaConstant.forLong(encoding.getBase()));
            }
        }
        append(new AMD64Move.CompressPointerOp(result, asAllocatable(pointer), base, encoding, nonNull, getLIRKindTool()));
        return result;
    }
}
Also used : Variable(org.graalvm.compiler.lir.Variable) OptionValues(org.graalvm.compiler.options.OptionValues) LIRKindTool(org.graalvm.compiler.core.common.spi.LIRKindTool) LIRKind(org.graalvm.compiler.core.common.LIRKind) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) AMD64Move(org.graalvm.compiler.lir.amd64.AMD64Move)

Example 4 with OptionValues

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

the class CompressedNullCheckTest method testImplicit.

@SuppressWarnings("try")
private void testImplicit(Integer i) {
    Assume.assumeTrue(runtime().getVMConfig().useCompressedOops);
    Container c = new Container();
    c.i = i;
    ResolvedJavaMethod method = getResolvedJavaMethod("testSnippet");
    Result expect = executeExpected(method, null, c);
    // make sure we don't get a profile that removes the implicit null check
    method.reprofile();
    OptionValues options = new OptionValues(getInitialOptions(), OptImplicitNullChecks, true);
    Result actual = executeActual(options, method, null, c);
    assertEquals(expect, actual);
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 5 with OptionValues

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

the class TypedNodeIteratorTest method complicatedIterationTest.

@Test
public void complicatedIterationTest() {
    OptionValues options = getOptions();
    Graph graph = new Graph(options, getDebug(options));
    graph.add(new TestNode("a"));
    for (TestNode tn : graph.getNodes(TestNode.TYPE)) {
        String name = tn.getName();
        for (int i = 0; i < name.length(); ++i) {
            char c = name.charAt(i);
            if (c == 'a') {
                tn.safeDelete();
                graph.add(new TestNode("b"));
                graph.add(new TestNode("c"));
            } else if (c == 'b') {
                tn.safeDelete();
            } else if (c == 'c') {
                graph.add(new TestNode("d"));
                graph.add(new TestNode("e"));
                graph.add(new TestNode("d"));
                graph.add(new TestNode("e"));
                graph.add(new TestNode("e"));
                graph.add(new TestNode("d"));
                graph.add(new TestNode("e"));
                graph.add(new TestNode("d"));
            } else if (c == 'd') {
                for (TestNode tn2 : graph.getNodes(TestNode.TYPE)) {
                    if (tn2.getName().equals("e")) {
                        tn2.safeDelete();
                    } else if (tn2.getName().equals("c")) {
                        tn2.safeDelete();
                    }
                }
            } else if (c == 'e') {
                fail("All e nodes must have been deleted by visiting the d node");
            }
        }
    }
    assertEquals("dddd", toString(graph.getNodes(TestNode.TYPE)));
}
Also used : Graph(org.graalvm.compiler.graph.Graph) OptionValues(org.graalvm.compiler.options.OptionValues) Test(org.junit.Test)

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