Search in sources :

Example 96 with DebugContext

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

the class LoopFullUnrollPhase method run.

@Override
protected void run(StructuredGraph graph, PhaseContext context) {
    DebugContext debug = graph.getDebug();
    if (graph.hasLoops()) {
        boolean peeled;
        do {
            peeled = false;
            final LoopsData dataCounted = new LoopsData(graph);
            dataCounted.detectedCountedLoops();
            for (LoopEx loop : dataCounted.countedLoops()) {
                if (getPolicies().shouldFullUnroll(loop)) {
                    debug.log("FullUnroll %s", loop);
                    LoopTransformations.fullUnroll(loop, context, canonicalizer);
                    FULLY_UNROLLED_LOOPS.increment(debug);
                    debug.dump(DebugContext.DETAILED_LEVEL, graph, "FullUnroll %s", loop);
                    peeled = true;
                    break;
                }
            }
            dataCounted.deleteUnusedNodes();
        } while (peeled);
    }
}
Also used : LoopsData(org.graalvm.compiler.loop.LoopsData) LoopEx(org.graalvm.compiler.loop.LoopEx) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 97 with DebugContext

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

the class FixPointIntervalBuilder method processBlock.

@SuppressWarnings("try")
private void processBlock(AbstractBlockBase<?> block, Deque<AbstractBlockBase<?>> worklist) {
    DebugContext debug = lir.getDebug();
    if (updateOutBlock(block)) {
        try (Indent indent = debug.logAndIndent("handle block %s", block)) {
            ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block);
            // get out set and mark intervals
            BitSet outSet = liveOutMap.get(block);
            markOutInterval(outSet, getBlockEnd(instructions));
            printLiveSet("liveOut", outSet);
            // process instructions
            BlockClosure closure = new BlockClosure((BitSet) outSet.clone());
            for (int i = instructions.size() - 1; i >= 0; i--) {
                LIRInstruction inst = instructions.get(i);
                closure.processInstructionBottomUp(inst);
            }
            // add predecessors to work list
            for (AbstractBlockBase<?> b : block.getPredecessors()) {
                worklist.add(b);
            }
            // set in set and mark intervals
            BitSet inSet = closure.getCurrentSet();
            liveInMap.put(block, inSet);
            markInInterval(inSet, getBlockBegin(instructions));
            printLiveSet("liveIn", inSet);
        }
    }
}
Also used : Indent(org.graalvm.compiler.debug.Indent) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) BitSet(java.util.BitSet) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 98 with DebugContext

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

the class SimpleStackSlotAllocator method allocateStackSlots.

public void allocateStackSlots(FrameMapBuilderTool builder, LIRGenerationResult res) {
    DebugContext debug = res.getLIR().getDebug();
    StackSlot[] mapping = new StackSlot[builder.getNumberOfStackSlots()];
    boolean allocatedFramesizeEnabled = allocatedFramesize.isEnabled(debug);
    long currentFrameSize = allocatedFramesizeEnabled ? builder.getFrameMap().currentFrameSize() : 0;
    for (VirtualStackSlot virtualSlot : builder.getStackSlots()) {
        final StackSlot slot;
        if (virtualSlot instanceof SimpleVirtualStackSlot) {
            slot = mapSimpleVirtualStackSlot(builder, (SimpleVirtualStackSlot) virtualSlot);
            virtualFramesize.add(debug, builder.getFrameMap().spillSlotSize(virtualSlot.getValueKind()));
        } else if (virtualSlot instanceof VirtualStackSlotRange) {
            VirtualStackSlotRange slotRange = (VirtualStackSlotRange) virtualSlot;
            slot = mapVirtualStackSlotRange(builder, slotRange);
            virtualFramesize.add(debug, builder.getFrameMap().spillSlotRangeSize(slotRange.getSlots()));
        } else {
            throw GraalError.shouldNotReachHere("Unknown VirtualStackSlot: " + virtualSlot);
        }
        allocatedSlots.increment(debug);
        mapping[virtualSlot.getId()] = slot;
    }
    updateLIR(res, mapping);
    if (allocatedFramesizeEnabled) {
        allocatedFramesize.add(debug, builder.getFrameMap().currentFrameSize() - currentFrameSize);
    }
}
Also used : VirtualStackSlotRange(org.graalvm.compiler.lir.framemap.VirtualStackSlotRange) LIRValueUtil.asVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot) SimpleVirtualStackSlot(org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot) StackSlot(jdk.vm.ci.code.StackSlot) LIRValueUtil.isVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot) DebugContext(org.graalvm.compiler.debug.DebugContext) SimpleVirtualStackSlot(org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot) LIRValueUtil.asVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot) SimpleVirtualStackSlot(org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot) LIRValueUtil.isVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot)

Example 99 with DebugContext

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

the class SimpleStackSlotAllocator method updateLIR.

@SuppressWarnings("try")
protected void updateLIR(LIRGenerationResult res, StackSlot[] mapping) {
    DebugContext debug = res.getLIR().getDebug();
    try (DebugContext.Scope scope = debug.scope("StackSlotMappingLIR")) {
        ValueProcedure updateProc = (value, mode, flags) -> {
            if (isVirtualStackSlot(value)) {
                StackSlot stackSlot = mapping[asVirtualStackSlot(value).getId()];
                debug.log("map %s -> %s", value, stackSlot);
                return stackSlot;
            }
            return value;
        };
        for (AbstractBlockBase<?> block : res.getLIR().getControlFlowGraph().getBlocks()) {
            try (Indent indent0 = debug.logAndIndent("block: %s", block)) {
                for (LIRInstruction inst : res.getLIR().getLIRforBlock(block)) {
                    try (Indent indent1 = debug.logAndIndent("Inst: %d: %s", inst.id(), inst)) {
                        inst.forEachAlive(updateProc);
                        inst.forEachInput(updateProc);
                        inst.forEachOutput(updateProc);
                        inst.forEachTemp(updateProc);
                        inst.forEachState(updateProc);
                    }
                }
            }
        }
    }
}
Also used : ValueProcedure(org.graalvm.compiler.lir.ValueProcedure) AbstractBlockBase(org.graalvm.compiler.core.common.cfg.AbstractBlockBase) FrameMapBuilderTool(org.graalvm.compiler.lir.framemap.FrameMapBuilderTool) AllocationPhase(org.graalvm.compiler.lir.phases.AllocationPhase) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) StackSlotAllocatorUtil.allocatedSlots(org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.allocatedSlots) VirtualStackSlotRange(org.graalvm.compiler.lir.framemap.VirtualStackSlotRange) LIRGenerationResult(org.graalvm.compiler.lir.gen.LIRGenerationResult) TargetDescription(jdk.vm.ci.code.TargetDescription) LIRValueUtil.asVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot) SimpleVirtualStackSlot(org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot) DebugContext(org.graalvm.compiler.debug.DebugContext) StackSlotAllocatorUtil.virtualFramesize(org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.virtualFramesize) Indent(org.graalvm.compiler.debug.Indent) GraalError(org.graalvm.compiler.debug.GraalError) StackSlot(jdk.vm.ci.code.StackSlot) LIRValueUtil.isVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot) ValueProcedure(org.graalvm.compiler.lir.ValueProcedure) StackSlotAllocatorUtil.allocatedFramesize(org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.allocatedFramesize) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot) Indent(org.graalvm.compiler.debug.Indent) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) LIRValueUtil.asVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot) SimpleVirtualStackSlot(org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot) StackSlot(jdk.vm.ci.code.StackSlot) LIRValueUtil.isVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 100 with DebugContext

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

the class LoopEx method reassociateInvariants.

public boolean reassociateInvariants() {
    int count = 0;
    StructuredGraph graph = loopBegin().graph();
    InvariantPredicate invariant = new InvariantPredicate();
    for (BinaryArithmeticNode<?> binary : whole().nodes().filter(BinaryArithmeticNode.class)) {
        if (!binary.isAssociative()) {
            continue;
        }
        ValueNode result = BinaryArithmeticNode.reassociate(binary, invariant, binary.getX(), binary.getY(), NodeView.DEFAULT);
        if (result != binary) {
            if (!result.isAlive()) {
                assert !result.isDeleted();
                result = graph.addOrUniqueWithInputs(result);
            }
            DebugContext debug = graph.getDebug();
            if (debug.isLogEnabled()) {
                debug.log("%s : Reassociated %s into %s", graph.method().format("%H::%n"), binary, result);
            }
            binary.replaceAtUsages(result);
            GraphUtil.killWithUnusedFloatingInputs(binary);
            count++;
        }
    }
    return count != 0;
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValueNode(org.graalvm.compiler.nodes.ValueNode) DebugContext(org.graalvm.compiler.debug.DebugContext)

Aggregations

DebugContext (org.graalvm.compiler.debug.DebugContext)234 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)87 OptionValues (org.graalvm.compiler.options.OptionValues)50 Indent (org.graalvm.compiler.debug.Indent)37 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)31 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)29 Test (org.junit.Test)27 Node (org.graalvm.compiler.graph.Node)24 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)24 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)22 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)20 Scope (org.graalvm.compiler.debug.DebugContext.Scope)18 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)18 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)17 ValueNode (org.graalvm.compiler.nodes.ValueNode)16 FixedNode (org.graalvm.compiler.nodes.FixedNode)14 CompilationResult (org.graalvm.compiler.code.CompilationResult)13 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)13 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)12 LIR (org.graalvm.compiler.lir.LIR)11