use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class MarkUnsafeAccessTest method testCompiled.
@Test
public void testCompiled() throws IOException {
ResolvedJavaMethod getMethod = asResolvedJavaMethod(getMethod(ByteBuffer.class, "get", new Class<?>[] {}));
ResolvedJavaType mbbClass = getMetaAccess().lookupJavaType(MappedByteBuffer.class);
ResolvedJavaMethod getMethodImpl = mbbClass.findUniqueConcreteMethod(getMethod).getResult();
Assert.assertNotNull(getMethodImpl);
StructuredGraph graph = parseForCompile(getMethodImpl);
HighTierContext highContext = getDefaultHighTierContext();
new CanonicalizerPhase().apply(graph, highContext);
new InliningPhase(new InlineEverythingPolicy(), new CanonicalizerPhase()).apply(graph, highContext);
InstalledCode compiledCode = getCode(getMethodImpl, graph);
testMappedByteBuffer(mbb -> {
try {
return (byte) compiledCode.executeVarargs(mbb);
} catch (InvalidInstalledCodeException e) {
Assert.fail();
return 0;
}
});
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class MergeCanonicalizerTest method testReturnCount.
private void testReturnCount(String snippet, int returnCount) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
graph.getDebug().dump(DebugContext.BASIC_LEVEL, graph, "Graph");
assertDeepEquals(returnCount, graph.getNodes(ReturnNode.TYPE).count());
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class MonitorGraphTest method parseAndProcess.
private StructuredGraph parseAndProcess(String snippet) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
ParameterNode param = graph.getNodes(ParameterNode.TYPE).first();
if (param != null) {
ConstantNode constant = ConstantNode.forInt(0, graph);
for (Node n : param.usages().snapshot()) {
if (!(n instanceof FrameState)) {
n.replaceFirstInput(param, constant);
}
}
}
Map<Invoke, Double> hints = new HashMap<>();
for (Invoke invoke : graph.getInvokes()) {
hints.put(invoke, 1000d);
}
HighTierContext context = getDefaultHighTierContext();
new InliningPhase(hints, new CanonicalizerPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
return graph;
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class NodePropertiesTest method prepareGraphForLoopFrequencies.
private static void prepareGraphForLoopFrequencies(StructuredGraph g, HighTierContext htc) {
// let canonicalizer work away branch probability nodes
new CanonicalizerPhase().apply(g, htc);
// recompute the loop frequencies
ComputeLoopFrequenciesClosure.compute(g);
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class NodePropertiesTest method testArrayLoad.
@Test
public void testArrayLoad() {
StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("arrayLoadTest"));
HighTierContext htc = getDefaultHighTierContext();
new CanonicalizerPhase().apply(g1, htc);
GraphCostPhase gc1 = new GraphCostPhase();
gc1.apply(g1, htc);
Assert.assertEquals(15, gc1.finalCycles, 25);
}
Aggregations