Search in sources :

Example 36 with ScheduleResult

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

the class LIRGenerationPhase method run.

@Override
protected final void run(TargetDescription target, LIRGenerationResult lirGenRes, LIRGenerationPhase.LIRGenerationContext context) {
    NodeLIRBuilderTool nodeLirBuilder = context.nodeLirBuilder;
    StructuredGraph graph = context.graph;
    ScheduleResult schedule = context.schedule;
    for (AbstractBlockBase<?> b : lirGenRes.getLIR().getControlFlowGraph().getBlocks()) {
        emitBlock(nodeLirBuilder, lirGenRes, (Block) b, graph, schedule.getBlockToNodesMap());
    }
    context.lirGen.beforeRegisterAllocation();
    assert SSAUtil.verifySSAForm(lirGenRes.getLIR());
    nodeCount.add(graph.getDebug(), graph.getNodeCount());
}
Also used : ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) NodeLIRBuilderTool(org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool)

Example 37 with ScheduleResult

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

the class CFGPrinterObserver method dumpSandboxed.

public void dumpSandboxed(DebugContext debug, Object object, String message) {
    OptionValues options = debug.getOptions();
    boolean dumpFrontend = PrintCFG.getValue(options);
    if (!dumpFrontend && isFrontendObject(object)) {
        return;
    }
    if (cfgPrinter == null) {
        try {
            Path dumpFile = debug.getDumpPath(".cfg", false);
            cfgFile = dumpFile.toFile();
            OutputStream out = new BufferedOutputStream(new FileOutputStream(cfgFile));
            cfgPrinter = new CFGPrinter(out);
        } catch (IOException e) {
            throw (GraalError) new GraalError("Could not open %s", cfgFile == null ? "[null]" : cfgFile.getAbsolutePath()).initCause(e);
        }
    }
    if (!checkMethodScope(debug)) {
        return;
    }
    try {
        if (curMethod instanceof ResolvedJavaMethod) {
            cfgPrinter.method = (ResolvedJavaMethod) curMethod;
        }
        if (object instanceof LIR) {
            cfgPrinter.lir = (LIR) object;
        } else {
            cfgPrinter.lir = debug.contextLookup(LIR.class);
        }
        cfgPrinter.nodeLirGenerator = debug.contextLookup(NodeLIRBuilder.class);
        cfgPrinter.livenessInfo = debug.contextLookup(GlobalLivenessInfo.class);
        cfgPrinter.res = debug.contextLookup(LIRGenerationResult.class);
        if (cfgPrinter.nodeLirGenerator != null) {
            cfgPrinter.target = cfgPrinter.nodeLirGenerator.getLIRGeneratorTool().target();
        }
        if (cfgPrinter.lir != null && cfgPrinter.lir.getControlFlowGraph() instanceof ControlFlowGraph) {
            cfgPrinter.cfg = (ControlFlowGraph) cfgPrinter.lir.getControlFlowGraph();
        }
        CodeCacheProvider codeCache = debug.contextLookup(CodeCacheProvider.class);
        if (codeCache != null) {
            cfgPrinter.target = codeCache.getTarget();
        }
        if (object instanceof BciBlockMapping) {
            BciBlockMapping blockMap = (BciBlockMapping) object;
            cfgPrinter.printCFG(message, blockMap);
            if (blockMap.code.getCode() != null) {
                cfgPrinter.printBytecodes(new BytecodeDisassembler(false).disassemble(blockMap.code));
            }
        } else if (object instanceof LIR) {
            // Currently no node printing for lir
            cfgPrinter.printCFG(message, cfgPrinter.lir.codeEmittingOrder(), false);
            lastLIR = (LIR) object;
            if (delayedIntervals != null) {
                cfgPrinter.printIntervals(message, delayedIntervals);
                delayedIntervals = null;
            }
        } else if (object instanceof ScheduleResult) {
            cfgPrinter.printSchedule(message, (ScheduleResult) object);
        } else if (object instanceof StructuredGraph) {
            if (cfgPrinter.cfg == null) {
                StructuredGraph graph = (StructuredGraph) object;
                cfgPrinter.cfg = ControlFlowGraph.compute(graph, true, true, true, false);
                cfgPrinter.printCFG(message, cfgPrinter.cfg.getBlocks(), true);
            } else {
                cfgPrinter.printCFG(message, cfgPrinter.cfg.getBlocks(), true);
            }
        } else if (object instanceof CompilationResult) {
            final CompilationResult compResult = (CompilationResult) object;
            cfgPrinter.printMachineCode(disassemble(codeCache, compResult, null), message);
        } else if (object instanceof InstalledCode) {
            CompilationResult compResult = debug.contextLookup(CompilationResult.class);
            if (compResult != null) {
                cfgPrinter.printMachineCode(disassemble(codeCache, compResult, (InstalledCode) object), message);
            }
        } else if (object instanceof IntervalDumper) {
            if (lastLIR == cfgPrinter.lir) {
                cfgPrinter.printIntervals(message, (IntervalDumper) object);
            } else {
                if (delayedIntervals != null) {
                    debug.log("Some delayed intervals were dropped (%s)", delayedIntervals);
                }
                delayedIntervals = (IntervalDumper) object;
            }
        } else if (object instanceof AbstractBlockBase<?>[]) {
            cfgPrinter.printCFG(message, (AbstractBlockBase<?>[]) object, false);
        } else if (object instanceof Trace) {
            cfgPrinter.printCFG(message, ((Trace) object).getBlocks(), false);
        } else if (object instanceof TraceBuilderResult) {
            cfgPrinter.printTraces(message, (TraceBuilderResult) object);
        }
    } finally {
        cfgPrinter.target = null;
        cfgPrinter.lir = null;
        cfgPrinter.res = null;
        cfgPrinter.nodeLirGenerator = null;
        cfgPrinter.livenessInfo = null;
        cfgPrinter.cfg = null;
        cfgPrinter.flush();
    }
}
Also used : BytecodeDisassembler(org.graalvm.compiler.bytecode.BytecodeDisassembler) IntervalDumper(org.graalvm.compiler.lir.debug.IntervalDumper) ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult) OptionValues(org.graalvm.compiler.options.OptionValues) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) CodeCacheProvider(jdk.vm.ci.code.CodeCacheProvider) AbstractBlockBase(org.graalvm.compiler.core.common.cfg.AbstractBlockBase) LIRGenerationResult(org.graalvm.compiler.lir.gen.LIRGenerationResult) GraalError(org.graalvm.compiler.debug.GraalError) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) InstalledCode(jdk.vm.ci.code.InstalledCode) TraceBuilderResult(org.graalvm.compiler.core.common.alloc.TraceBuilderResult) BufferedOutputStream(java.io.BufferedOutputStream) Path(java.nio.file.Path) BciBlockMapping(org.graalvm.compiler.java.BciBlockMapping) GlobalLivenessInfo(org.graalvm.compiler.lir.alloc.trace.GlobalLivenessInfo) IOException(java.io.IOException) Trace(org.graalvm.compiler.core.common.alloc.Trace) LIR(org.graalvm.compiler.lir.LIR) FileOutputStream(java.io.FileOutputStream) ControlFlowGraph(org.graalvm.compiler.nodes.cfg.ControlFlowGraph) NodeLIRBuilder(org.graalvm.compiler.core.gen.NodeLIRBuilder) CompilationResult(org.graalvm.compiler.code.CompilationResult) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 38 with ScheduleResult

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

the class GuardLoweringPhase method run.

@Override
protected void run(StructuredGraph graph, MidTierContext context) {
    if (graph.getGuardsStage().allowsFloatingGuards()) {
        SchedulePhase schedulePhase = new SchedulePhase(SchedulingStrategy.EARLIEST_WITH_GUARD_ORDER);
        schedulePhase.apply(graph);
        ScheduleResult schedule = graph.getLastSchedule();
        for (Block block : schedule.getCFG().getBlocks()) {
            processBlock(block, schedule);
        }
        graph.setGuardsStage(GuardsStage.FIXED_DEOPTS);
    }
    assert assertNoGuardsLeft(graph);
}
Also used : SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult) Block(org.graalvm.compiler.nodes.cfg.Block)

Aggregations

ScheduleResult (org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult)38 Test (org.junit.Test)24 Block (org.graalvm.compiler.nodes.cfg.Block)14 Node (org.graalvm.compiler.graph.Node)10 SchedulePhase (org.graalvm.compiler.phases.schedule.SchedulePhase)9 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)8 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)6 ValueNode (org.graalvm.compiler.nodes.ValueNode)6 List (java.util.List)5 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)5 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)5 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)5 DebugContext (org.graalvm.compiler.debug.DebugContext)4 FixedNode (org.graalvm.compiler.nodes.FixedNode)4 FrameState (org.graalvm.compiler.nodes.FrameState)4 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)4 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)4 InitializeKlassNode (org.graalvm.compiler.hotspot.nodes.aot.InitializeKlassNode)3 LoadConstantIndirectlyFixedNode (org.graalvm.compiler.hotspot.nodes.aot.LoadConstantIndirectlyFixedNode)3 LoadConstantIndirectlyNode (org.graalvm.compiler.hotspot.nodes.aot.LoadConstantIndirectlyNode)3