use of org.graalvm.compiler.phases.tiers.HighTierContext 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.tiers.HighTierContext 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.tiers.HighTierContext 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);
}
use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class NodePropertiesTest method testSameLoopMoreIterationsCostlier.
@Test
public void testSameLoopMoreIterationsCostlier() {
HighTierContext htc = getDefaultHighTierContext();
StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("testLoop01"));
StructuredGraph g2 = parseForCompile(getResolvedJavaMethod("testLoop02"));
prepareGraphForLoopFrequencies(g1, htc);
prepareGraphForLoopFrequencies(g2, htc);
assertFrequency(g1, ITERATIONS_LOOP_1);
assertFrequency(g2, ITERATIONS_LOOP_2);
GraphCostPhase gc1 = new GraphCostPhase();
GraphCostPhase gc2 = new GraphCostPhase();
gc1.apply(g1, htc);
gc2.apply(g2, htc);
g1.getDebug().log("Test testSameLoopMoreIterationsCostlier --> 1.Graph cycles:%f size:%f vs. 2.Graph cycles:%f size:%f\n", gc1.finalCycles, gc1.finalSize, gc2.finalCycles, gc2.finalSize);
Assert.assertTrue(gc2.finalCycles > gc1.finalCycles);
Assert.assertTrue(gc2.finalSize == gc1.finalSize);
}
use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class NodePropertiesTest method testGraphCost.
@Test
public void testGraphCost() {
StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("test1Snippet"));
StructuredGraph g2 = parseForCompile(getResolvedJavaMethod("test2Snippet"));
HighTierContext htc = getDefaultHighTierContext();
new CanonicalizerPhase().apply(g1, htc);
new CanonicalizerPhase().apply(g2, htc);
GraphCostPhase gc1 = new GraphCostPhase();
GraphCostPhase gc2 = new GraphCostPhase();
gc1.apply(g1, htc);
gc2.apply(g2, htc);
g1.getDebug().log("Test Graph Cost --> 1.Graph cost:%f vs. 2.Graph cost:%f\n", gc1.finalCycles, gc2.finalCycles);
Assert.assertTrue(gc2.finalCycles > gc1.finalCycles);
Assert.assertTrue(gc2.finalSize == gc1.finalSize);
}
Aggregations