use of org.graalvm.compiler.phases.schedule.SchedulePhase in project graal by oracle.
the class AArch64HotSpotSuitesProvider method createSuites.
@Override
public Suites createSuites(OptionValues options) {
Suites suites = super.createSuites(options);
ListIterator<BasePhase<? super LowTierContext>> findPhase = suites.getLowTier().findPhase(FixReadsPhase.class);
if (findPhase == null) {
findPhase = suites.getLowTier().findPhase(ExpandLogicPhase.class);
}
findPhase.add(new AddressLoweringByUsePhase(addressLoweringByUse));
// Put AArch64ReadReplacementPhase right before the SchedulePhase
findPhase = suites.getLowTier().findPhase(SchedulePhase.class);
while (PhaseSuite.findNextPhase(findPhase, SchedulePhase.class)) {
// Search for last occurrence of SchedulePhase
}
findPhase.previous();
findPhase.add(new AArch64ReadReplacementPhase());
return suites;
}
use of org.graalvm.compiler.phases.schedule.SchedulePhase in project graal by oracle.
the class ProfileCompiledMethodsPhase method run.
@Override
protected void run(StructuredGraph graph) {
SchedulePhase schedule = new SchedulePhase(graph.getOptions());
schedule.apply(graph, false);
ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
for (Loop<Block> loop : cfg.getLoops()) {
double loopProbability = cfg.blockFor(loop.getHeader().getBeginNode()).probability();
if (loopProbability > (1D / Integer.MAX_VALUE)) {
addSectionCounters(loop.getHeader().getBeginNode(), loop.getBlocks(), loop.getChildren(), graph.getLastSchedule(), cfg);
}
}
// don't put the counter increase directly after the start (problems with OSR)
FixedWithNextNode current = graph.start();
while (current.next() instanceof FixedWithNextNode) {
current = (FixedWithNextNode) current.next();
}
addSectionCounters(current, Arrays.asList(cfg.getBlocks()), cfg.getLoops(), graph.getLastSchedule(), cfg);
if (WITH_INVOKES) {
for (Node node : graph.getNodes()) {
if (node instanceof Invoke) {
Invoke invoke = (Invoke) node;
DynamicCounterNode.addCounterBefore(GROUP_NAME_INVOKES, invoke.callTarget().targetName(), 1, true, invoke.asNode());
}
}
}
}
use of org.graalvm.compiler.phases.schedule.SchedulePhase in project graal by oracle.
the class ReentrantBlockIteratorTest method getVisitedBlocksInOrder.
private List<Block> getVisitedBlocksInOrder(String snippet) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
// after FSA to ensure HIR loop data structure does not contain loop exits
graph.setGuardsStage(GuardsStage.AFTER_FSA);
ArrayList<Block> blocks = new ArrayList<>();
class VoidState {
}
final VoidState voidState = new VoidState();
BlockIteratorClosure<VoidState> closure = new BlockIteratorClosure<VoidState>() {
@Override
protected VoidState getInitialState() {
return voidState;
}
@Override
protected VoidState processBlock(Block block, VoidState currentState) {
// remember the visit order
blocks.add(block);
return currentState;
}
@Override
protected VoidState merge(Block merge, List<VoidState> states) {
return voidState;
}
@Override
protected VoidState cloneState(VoidState oldState) {
return voidState;
}
@Override
protected List<VoidState> processLoop(Loop<Block> loop, VoidState initialState) {
return ReentrantBlockIterator.processLoop(this, loop, initialState).exitStates;
}
};
ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, false);
ReentrantBlockIterator.apply(closure, cfg.getStartBlock());
// schedule for IGV
new SchedulePhase(graph.getOptions()).apply(graph);
return blocks;
}
use of org.graalvm.compiler.phases.schedule.SchedulePhase in project graal by oracle.
the class TypeSystemTest method outputGraph.
public static void outputGraph(StructuredGraph graph, String message) {
TTY.println("========================= " + message);
SchedulePhase schedulePhase = new SchedulePhase(graph.getOptions());
schedulePhase.apply(graph);
ScheduleResult schedule = graph.getLastSchedule();
for (Block block : schedule.getCFG().getBlocks()) {
TTY.print("Block " + block + " ");
if (block == schedule.getCFG().getStartBlock()) {
TTY.print("* ");
}
TTY.print("-> ");
for (Block succ : block.getSuccessors()) {
TTY.print(succ + " ");
}
TTY.println();
for (Node node : schedule.getBlockToNodesMap().get(block)) {
outputNode(node);
}
}
}
use of org.graalvm.compiler.phases.schedule.SchedulePhase in project graal by oracle.
the class LongNodeChainTest method longAddChain.
private void longAddChain(boolean reverse) {
HighTierContext context = getDefaultHighTierContext();
OptionValues options = getInitialOptions();
StructuredGraph graph = new StructuredGraph.Builder(options, DebugContext.create(options, DebugHandlersFactory.LOADER)).build();
ValueNode constant = graph.unique(ConstantNode.forPrimitive(JavaConstant.INT_1));
ValueNode value = null;
if (reverse) {
// Make sure the constant's stamp is not used to infer the add node's stamp.
OpaqueNode opaque = graph.unique(new OpaqueNode(constant));
constant = opaque;
AddNode addNode = graph.unique(new AddNode(constant, constant));
value = addNode;
for (int i = 1; i < N; ++i) {
AddNode newAddNode = graph.addWithoutUnique(new AddNode(constant, constant));
addNode.setY(newAddNode);
addNode = newAddNode;
}
opaque.replaceAndDelete(opaque.getValue());
} else {
value = constant;
for (int i = 0; i < N; ++i) {
value = graph.unique(new AddNode(constant, value));
}
}
ReturnNode returnNode = graph.add(new ReturnNode(value));
graph.start().setNext(returnNode);
for (SchedulingStrategy s : Strategies) {
new SchedulePhase(s).apply(graph);
}
new CanonicalizerPhase().apply(graph, context);
JavaConstant asConstant = (JavaConstant) returnNode.result().asConstant();
Assert.assertEquals(N + 1, asConstant.asInt());
}
Aggregations