use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class CFGPrinter method schedule.
private void schedule(Node input, Block block) {
if (!inFixedSchedule(input)) {
Block inputBlock = block;
if (latestScheduling.get(input) != null) {
inputBlock = AbstractControlFlowGraph.commonDominatorTyped(inputBlock, latestScheduling.get(input));
}
if (inputBlock != latestScheduling.get(input)) {
latestScheduling.set(input, inputBlock);
scheduleInputs(input, inputBlock);
}
}
}
use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class CFGPrinter method scheduleInputs.
private void scheduleInputs(Node node, Block nodeBlock) {
if (node instanceof ValuePhiNode) {
PhiNode phi = (PhiNode) node;
Block phiBlock = latestScheduling.get(phi.merge());
assert phiBlock != null;
for (Block pred : phiBlock.getPredecessors()) {
schedule(phi.valueAt((AbstractEndNode) pred.getEndNode()), pred);
}
} else {
for (Node input : node.inputs()) {
schedule(input, nodeBlock);
}
}
}
use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class CFGPrinter method printCFG.
/**
* Prints the specified list of blocks.
*
* @param label A label describing the compilation phase that produced the control flow graph.
* @param blocks The list of blocks to be printed.
*/
public void printCFG(String label, AbstractBlockBase<?>[] blocks, boolean printNodes) {
if (lir == null) {
latestScheduling = new NodeMap<>(cfg.getNodeToBlock());
for (AbstractBlockBase<?> abstractBlock : blocks) {
if (abstractBlock == null) {
continue;
}
Block block = (Block) abstractBlock;
Node cur = block.getBeginNode();
while (true) {
assert inFixedSchedule(cur) && latestScheduling.get(cur) == block;
scheduleInputs(cur, block);
if (cur == block.getEndNode()) {
break;
}
assert cur.successors().count() == 1;
cur = cur.successors().first();
}
}
}
begin("cfg");
out.print("name \"").print(label).println('"');
for (AbstractBlockBase<?> block : blocks) {
printBlock(block, printNodes);
}
end("cfg");
// As a workaround we dump the bytecode after every cfg.
if (method != null) {
printBytecodes(new BytecodeDisassembler(false).disassemble(method));
}
latestScheduling = null;
}
use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class CanonicalStringGraphPrinter method writeCanonicalExpressionCFGString.
protected static void writeCanonicalExpressionCFGString(StructuredGraph graph, boolean checkConstants, boolean removeIdentities, PrintWriter writer) {
ControlFlowGraph controlFlowGraph = getControlFlowGraph(graph);
if (controlFlowGraph == null) {
return;
}
try {
for (Block block : controlFlowGraph.getBlocks()) {
writer.print("Block ");
writer.print(block);
writer.print(" ");
if (block == controlFlowGraph.getStartBlock()) {
writer.print("* ");
}
writer.print("-> ");
for (Block successor : block.getSuccessors()) {
writer.print(successor);
writer.print(" ");
}
writer.println();
FixedNode node = block.getBeginNode();
while (node != null) {
writeCanonicalGraphExpressionString(node, checkConstants, removeIdentities, writer);
writer.println();
if (node instanceof FixedWithNextNode) {
node = ((FixedWithNextNode) node).next();
} else {
node = null;
}
}
}
} catch (Throwable e) {
writer.println();
e.printStackTrace(writer);
}
}
use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class ReentrantBlockIterator method recurseIntoLoop.
private static <StateT> void recurseIntoLoop(BlockIteratorClosure<StateT> closure, Deque<Block> blockQueue, EconomicMap<FixedNode, StateT> states, StateT state, Block successor) {
// recurse into the loop
Loop<Block> loop = successor.getLoop();
LoopBeginNode loopBegin = (LoopBeginNode) loop.getHeader().getBeginNode();
assert successor.getBeginNode() == loopBegin;
List<StateT> exitStates = closure.processLoop(loop, state);
int i = 0;
assert loop.getExits().size() == exitStates.size();
for (Block exit : loop.getExits()) {
states.put(exit.getBeginNode(), exitStates.get(i++));
blockQueue.addFirst(exit);
}
}
Aggregations