Search in sources :

Example 21 with StructuredGraph

use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.

the class HotSpotTruffleCompilerImpl method compileTruffleCallBoundaryMethod.

/**
 * Compiles a method denoted as a
 * {@linkplain HotSpotTruffleCompilerRuntime#getTruffleCallBoundaryMethods() Truffle call
 * boundary}. The compiled code has a special entry point generated by an
 * {@link TruffleCallBoundaryInstrumentationFactory}.
 */
private CompilationResult compileTruffleCallBoundaryMethod(ResolvedJavaMethod javaMethod, CompilationIdentifier compilationId, DebugContext debug) {
    Suites newSuites = this.suites.copy();
    removeInliningPhase(newSuites);
    OptionValues options = TruffleCompilerOptions.getOptions();
    StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.NO).method(javaMethod).compilationId(compilationId).build();
    MetaAccessProvider metaAccess = providers.getMetaAccess();
    Plugins plugins = new Plugins(new InvocationPlugins());
    HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) providers.getCodeCache();
    boolean infoPoints = codeCache.shouldDebugNonSafepoints();
    GraphBuilderConfiguration newConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true).withNodeSourcePosition(infoPoints);
    new GraphBuilderPhase.Instance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), newConfig, OptimisticOptimizations.ALL, null).apply(graph);
    PhaseSuite<HighTierContext> graphBuilderSuite = getGraphBuilderSuite(codeCache, backend.getSuites());
    CompilationResultBuilderFactory factory = getTruffleCallBoundaryInstrumentationFactory(backend.getTarget().arch.getName());
    return compileGraph(graph, javaMethod, providers, backend, graphBuilderSuite, OptimisticOptimizations.ALL, graph.getProfilingInfo(), newSuites, lirSuites, new CompilationResult(compilationId), factory);
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) HotSpotCodeCacheProvider(jdk.vm.ci.hotspot.HotSpotCodeCacheProvider) OptionValues(org.graalvm.compiler.options.OptionValues) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) CompilationResult(org.graalvm.compiler.code.CompilationResult) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) CompilationResultBuilderFactory(org.graalvm.compiler.lir.asm.CompilationResultBuilderFactory) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) Suites(org.graalvm.compiler.phases.tiers.Suites) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 22 with StructuredGraph

use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.

the class GraalSupport method decodeGraph.

public static StructuredGraph decodeGraph(DebugContext debug, String name, CompilationIdentifier compilationId, SharedRuntimeMethod method) {
    // XXX
    EncodedGraph encodedGraph = encodedGraph(method, false);
    if (encodedGraph == null) {
        return null;
    }
    StructuredGraph graph = new StructuredGraph.Builder(debug.getOptions(), debug).name(name).method(method).compilationId(compilationId).build();
    GraphDecoder decoder = new GraphDecoder(ConfigurationValues.getTarget().arch, graph);
    decoder.decode(encodedGraph);
    return graph;
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) GraphDecoder(org.graalvm.compiler.nodes.GraphDecoder) EncodedGraph(org.graalvm.compiler.nodes.EncodedGraph)

Example 23 with StructuredGraph

use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.

the class RuntimeStrengthenStampsPhase method beforeCompilation.

@Override
@SuppressWarnings("try")
public void beforeCompilation(BeforeCompilationAccess c) {
    CompilationAccessImpl config = (CompilationAccessImpl) c;
    if (Options.PrintRuntimeCompileMethods.getValue()) {
        printCallTree();
    }
    System.out.println(methods.size() + " method(s) included for runtime compilation");
    if (Options.PrintStaticTruffleBoundaries.getValue()) {
        printStaticTruffleBoundaries();
    }
    Integer maxMethods = Options.MaxRuntimeCompileMethods.getValue();
    if (maxMethods != 0 && methods.size() > maxMethods) {
        printDeepestLevelPath();
        throw VMError.shouldNotReachHere("Number of methods for runtime compilation exceeds the allowed limit: " + methods.size() + " > " + maxMethods);
    }
    HostedMetaAccess hMetaAccess = config.getMetaAccess();
    runtimeConfigBuilder.updateLazyState(hMetaAccess);
    /*
         * Start fresh with a new GraphEncoder, since we are going to optimize all graphs now that
         * the static analysis results are available.
         */
    graphEncoder = new GraphEncoder(ConfigurationValues.getTarget().arch);
    StrengthenStampsPhase strengthenStamps = new RuntimeStrengthenStampsPhase(config.getUniverse(), objectReplacer);
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    PhaseContext phaseContext = new PhaseContext(hostedProviders);
    for (CallTreeNode node : methods.values()) {
        StructuredGraph graph = node.graph;
        if (graph != null) {
            DebugContext debug = graph.getDebug();
            try (DebugContext.Scope scope = debug.scope("RuntimeOptimize", graph)) {
                removeUnreachableInvokes(node);
                strengthenStamps.apply(graph);
                canonicalizer.apply(graph, phaseContext);
                GraalConfiguration.instance().runAdditionalCompilerPhases(graph, this);
                canonicalizer.apply(graph, phaseContext);
                graphEncoder.prepare(graph);
            } catch (Throwable ex) {
                debug.handle(ex);
            }
        }
    }
    graphEncoder.finishPrepare();
    for (CallTreeNode node : methods.values()) {
        if (node.graph != null) {
            registerDeoptEntries(node);
            long startOffset = graphEncoder.encode(node.graph);
            objectReplacer.createMethod(node.implementationMethod).setEncodedGraphStartOffset(startOffset);
            /* We do not need the graph anymore, let the GC do it's work. */
            node.graph = null;
        }
    }
    GraalSupport.setGraphEncoding(graphEncoder.getEncoding(), graphEncoder.getObjects(), graphEncoder.getNodeClasses());
    objectReplacer.updateDataDuringAnalysis((AnalysisMetaAccess) hMetaAccess.getWrapped());
}
Also used : CompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl) GraphEncoder(org.graalvm.compiler.nodes.GraphEncoder) DebugContext(org.graalvm.compiler.debug.DebugContext) HostedMetaAccess(com.oracle.svm.hosted.meta.HostedMetaAccess) PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) StrengthenStampsPhase(com.oracle.svm.hosted.phases.StrengthenStampsPhase)

Example 24 with StructuredGraph

use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.

the class AMD64AddressLowering method lower.

@Override
public AddressNode lower(ValueNode base, ValueNode offset) {
    AMD64AddressNode ret = new AMD64AddressNode(base, offset);
    StructuredGraph graph = base.graph();
    boolean changed;
    do {
        changed = improve(graph, base.getDebug(), ret, false, false);
    } while (changed);
    assert checkAddressBitWidth(ret.getBase());
    assert checkAddressBitWidth(ret.getIndex());
    return graph.unique(ret);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph)

Example 25 with StructuredGraph

use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.

the class PEAReadEliminationTest method testUnsafe1.

@Test
public void testUnsafe1() {
    StructuredGraph graph = processMethod("testUnsafe1Snippet");
    assertDeepEquals(1, graph.getNodes().filter(RawLoadNode.class).count());
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Aggregations

StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)360 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)97 Test (org.junit.Test)96 DebugContext (org.graalvm.compiler.debug.DebugContext)88 ValueNode (org.graalvm.compiler.nodes.ValueNode)70 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)62 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)62 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)57 Node (org.graalvm.compiler.graph.Node)39 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)37 OptionValues (org.graalvm.compiler.options.OptionValues)34 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)28 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)26 FixedNode (org.graalvm.compiler.nodes.FixedNode)26 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)25 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)24 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)24 LogicNode (org.graalvm.compiler.nodes.LogicNode)21 CompilationResult (org.graalvm.compiler.code.CompilationResult)19 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)19