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);
}
}
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);
}
}
}
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);
}
}
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);
}
}
}
}
}
}
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;
}
Aggregations