use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class ArraysSubstitutionsTest method testVirtualNotEqual.
@Test
public void testVirtualNotEqual() {
StructuredGraph graph = parseEager("testVirtualNotEqualSnippet", AllowAssumptions.NO);
HighTierContext context = getDefaultHighTierContext();
new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
new PartialEscapePhase(false, new CanonicalizerPhase(), graph.getOptions()).apply(graph, context);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
Assert.assertTrue(graph.getNodes(ReturnNode.TYPE).first().result().asJavaConstant().asLong() == 0);
}
use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class ArraysSubstitutionsTest method testVirtualEqual.
@Test
public void testVirtualEqual() {
StructuredGraph graph = parseEager("testVirtualEqualSnippet", AllowAssumptions.NO);
HighTierContext context = new HighTierContext(getProviders(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
new PartialEscapePhase(false, new CanonicalizerPhase(), graph.getOptions()).apply(graph, context);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
Assert.assertTrue(graph.getNodes(ReturnNode.TYPE).first().result().asJavaConstant().asLong() == 1);
}
use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class ArraysSubstitutionsTest method testCanonicalLength.
@Test
public void testCanonicalLength() {
StructuredGraph graph = parseEager("testCanonicalLengthSnippet", AllowAssumptions.NO);
HighTierContext context = new HighTierContext(getProviders(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
Assert.assertTrue(graph.getNodes(ReturnNode.TYPE).first().result().asJavaConstant().asLong() == 0);
}
use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class BitOpNodesTest method parseAndInline.
/**
* Parse and optimize {@code name}. If {@code expectedClass} is non-null and a node of that type
* isn't found simply return null. Otherwise return the node returned by the graph.
*
* @param name
* @param expectedClass
* @return the returned value or null if {@code expectedClass} is not found in the graph.
*/
private ValueNode parseAndInline(String name, Class<? extends ValueNode> expectedClass) {
StructuredGraph graph = parseEager(name, AllowAssumptions.YES);
HighTierContext context = getDefaultHighTierContext();
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
canonicalizer.apply(graph, context);
new InliningPhase(canonicalizer).apply(graph, context);
canonicalizer.apply(graph, context);
Assert.assertEquals(1, graph.getNodes(ReturnNode.TYPE).count());
if (expectedClass != null) {
if (graph.getNodes().filter(expectedClass).count() == 0) {
return null;
}
}
return graph.getNodes(ReturnNode.TYPE).first().result();
}
use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class MethodSubstitutionTest method testGraph.
@SuppressWarnings("try")
protected StructuredGraph testGraph(final String snippet, String name) {
DebugContext debug = getDebugContext();
try (DebugContext.Scope s = debug.scope("MethodSubstitutionTest", getResolvedJavaMethod(snippet))) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES, debug);
HighTierContext context = getDefaultHighTierContext();
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
new CanonicalizerPhase().apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
// Try to ensure any macro nodes are lowered to expose any resulting invokes
if (graph.getNodes().filter(MacroNode.class).isNotEmpty()) {
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
}
if (graph.getNodes().filter(MacroNode.class).isNotEmpty()) {
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, context);
}
assertNotInGraph(graph, MacroNode.class);
if (name != null) {
for (Node node : graph.getNodes()) {
if (node instanceof Invoke) {
Invoke invoke = (Invoke) node;
if (invoke.callTarget() instanceof MethodCallTargetNode) {
MethodCallTargetNode call = (MethodCallTargetNode) invoke.callTarget();
assertTrue(!call.targetMethod().getName().equals(name), "Unexpected invoke of intrinsic %s", call.targetMethod());
}
}
}
} else {
assertNotInGraph(graph, Invoke.class);
}
return graph;
} catch (Throwable e) {
throw debug.handle(e);
}
}
Aggregations