Search in sources :

Example 46 with DebugCloseable

use of org.graalvm.compiler.debug.DebugCloseable in project graal by oracle.

the class GraalCompiler method emitBackEnd.

@SuppressWarnings("try")
public static <T extends CompilationResult> void emitBackEnd(StructuredGraph graph, Object stub, ResolvedJavaMethod installedCodeOwner, Backend backend, T compilationResult, CompilationResultBuilderFactory factory, RegisterConfig registerConfig, LIRSuites lirSuites) {
    DebugContext debug = graph.getDebug();
    try (DebugContext.Scope s = debug.scope("BackEnd", graph.getLastSchedule());
        DebugCloseable a = BackEnd.start(debug)) {
        LIRGenerationResult lirGen = null;
        lirGen = emitLIR(backend, graph, stub, registerConfig, lirSuites);
        try (DebugContext.Scope s2 = debug.scope("CodeGen", lirGen, lirGen.getLIR())) {
            int bytecodeSize = graph.method() == null ? 0 : graph.getBytecodeSize();
            compilationResult.setHasUnsafeAccess(graph.hasUnsafeAccess());
            emitCode(backend, graph.getAssumptions(), graph.method(), graph.getMethods(), graph.getFields(), bytecodeSize, lirGen, compilationResult, installedCodeOwner, factory);
        } catch (Throwable e) {
            throw debug.handle(e);
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    } finally {
        graph.checkCancellation();
    }
}
Also used : LIRGenerationResult(org.graalvm.compiler.lir.gen.LIRGenerationResult) DebugContext(org.graalvm.compiler.debug.DebugContext) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable)

Example 47 with DebugCloseable

use of org.graalvm.compiler.debug.DebugCloseable in project graal by oracle.

the class BasePhase method apply.

@SuppressWarnings("try")
protected final void apply(final StructuredGraph graph, final C context, final boolean dumpGraph) {
    graph.checkCancellation();
    DebugContext debug = graph.getDebug();
    try (DebugCloseable a = timer.start(debug);
        DebugContext.Scope s = debug.scope(getClass(), this);
        DebugCloseable c = memUseTracker.start(debug)) {
        int sizeBefore = 0;
        Mark before = null;
        OptionValues options = graph.getOptions();
        boolean verifySizeContract = PhaseOptions.VerifyGraalPhasesSize.getValue(options) && checkContract();
        if (verifySizeContract) {
            sizeBefore = NodeCostUtil.computeGraphSize(graph);
            before = graph.getMark();
        }
        boolean isTopLevel = getEnclosingPhase(graph.getDebug()) == null;
        boolean dumpedBefore = false;
        if (dumpGraph && debug.areScopesEnabled()) {
            dumpedBefore = dumpBefore(graph, context, isTopLevel);
        }
        inputNodesCount.add(debug, graph.getNodeCount());
        this.run(graph, context);
        executionCount.increment(debug);
        if (verifySizeContract) {
            if (!before.isCurrent()) {
                int sizeAfter = NodeCostUtil.computeGraphSize(graph);
                NodeCostUtil.phaseFulfillsSizeContract(graph, sizeBefore, sizeAfter, this);
            }
        }
        if (dumpGraph && debug.areScopesEnabled()) {
            dumpAfter(graph, isTopLevel, dumpedBefore);
        }
        if (debug.isVerifyEnabled()) {
            debug.verify(graph, "%s", getName());
        }
        assert graph.verify();
    } catch (Throwable t) {
        throw debug.handle(t);
    }
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) Mark(org.graalvm.compiler.graph.Graph.Mark) DebugContext(org.graalvm.compiler.debug.DebugContext) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable)

Example 48 with DebugCloseable

use of org.graalvm.compiler.debug.DebugCloseable in project graal by oracle.

the class TypeGuardInlineInfo method createGuard.

@SuppressWarnings("try")
private void createGuard(StructuredGraph graph, Providers providers) {
    try (DebugCloseable context = invoke.asNode().withNodeSourcePosition()) {
        ValueNode nonNullReceiver = InliningUtil.nonNullReceiver(invoke);
        LoadHubNode receiverHub = graph.unique(new LoadHubNode(providers.getStampProvider(), nonNullReceiver));
        ConstantNode typeHub = ConstantNode.forConstant(receiverHub.stamp(NodeView.DEFAULT), providers.getConstantReflection().asObjectHub(type), providers.getMetaAccess(), graph);
        LogicNode typeCheck = CompareNode.createCompareNode(graph, CanonicalCondition.EQ, receiverHub, typeHub, providers.getConstantReflection(), NodeView.DEFAULT);
        FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile));
        assert invoke.predecessor() != null;
        ValueNode anchoredReceiver = InliningUtil.createAnchoredReceiver(graph, guard, type, nonNullReceiver, true);
        invoke.callTarget().replaceFirstInput(nonNullReceiver, anchoredReceiver);
        graph.addBeforeFixed(invoke.asNode(), guard);
    }
}
Also used : FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) LoadHubNode(org.graalvm.compiler.nodes.extended.LoadHubNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable)

Aggregations

DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)48 DebugContext (org.graalvm.compiler.debug.DebugContext)23 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)18 ValueNode (org.graalvm.compiler.nodes.ValueNode)14 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)9 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)9 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)9 OptionValues (org.graalvm.compiler.options.OptionValues)9 FixedNode (org.graalvm.compiler.nodes.FixedNode)8 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)8 Node (org.graalvm.compiler.graph.Node)7 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)7 MergeNode (org.graalvm.compiler.nodes.MergeNode)7 EndNode (org.graalvm.compiler.nodes.EndNode)6 StartNode (org.graalvm.compiler.nodes.StartNode)6 Method (java.lang.reflect.Method)5 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)5 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)5 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)5 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)5