use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class HotSpotInvokeDynamicPluginTest method test.
private void test(String name, int expectedResolves, int expectedStubCalls) {
StructuredGraph graph = parseEager(name, AllowAssumptions.NO, new OptionValues(getInitialOptions(), GraalOptions.GeneratePIC, true));
MidTierContext midTierContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
Assert.assertEquals(expectedResolves, graph.getNodes().filter(ResolveDynamicConstantNode.class).count());
Assert.assertEquals(0, graph.getNodes().filter(ResolveDynamicStubCall.class).count());
PhaseContext context = new PhaseContext(getProviders());
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new GuardLoweringPhase().apply(graph, midTierContext);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, context);
new FrameStateAssignmentPhase().apply(graph);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.LOW_TIER).apply(graph, context);
Assert.assertEquals(0, graph.getNodes().filter(ResolveDynamicConstantNode.class).count());
Assert.assertEquals(expectedStubCalls, graph.getNodes().filter(ResolveDynamicStubCall.class).count());
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class ArraysSubstitutionsTest method testCanonicalEqual.
@Test
public void testCanonicalEqual() {
StructuredGraph graph = parseEager("testCanonicalEqualSnippet", 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() == 1);
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class GraphEncoderTest method testStringMethods.
public void testStringMethods(boolean canonicalize) {
/* Encode and decode all methods of java.lang.String. */
List<StructuredGraph> originalGraphs = new ArrayList<>();
for (Method method : String.class.getDeclaredMethods()) {
ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method);
if (javaMethod.hasBytecodes()) {
StructuredGraph originalGraph = parseEager(javaMethod, AllowAssumptions.YES);
if (canonicalize) {
PhaseContext context = new PhaseContext(getProviders());
new CanonicalizerPhase().apply(originalGraph, context);
}
originalGraphs.add(originalGraph);
}
}
GraphEncoder encoder = new GraphEncoder(getTarget().arch);
for (StructuredGraph originalGraph : originalGraphs) {
encoder.prepare(originalGraph);
}
encoder.finishPrepare();
Map<StructuredGraph, Integer> startOffsets = new HashMap<>();
for (StructuredGraph originalGraph : originalGraphs) {
startOffsets.put(originalGraph, encoder.encode(originalGraph));
}
for (StructuredGraph originalGraph : originalGraphs) {
EncodedGraph encodedGraph = new EncodedGraph(encoder.getEncoding(), startOffsets.get(originalGraph), encoder.getObjects(), encoder.getNodeClasses(), originalGraph);
GraphEncoder.verifyEncoding(originalGraph, encodedGraph, getTarget().arch);
}
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class GuardPrioritiesTest method prepareGraph.
private StructuredGraph prepareGraph(String method) {
StructuredGraph graph = parseEager(method, StructuredGraph.AllowAssumptions.YES);
HighTierContext highTierContext = getDefaultHighTierContext();
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
new ConvertDeoptimizeToGuardPhase().apply(graph, highTierContext);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highTierContext);
new FloatingReadPhase().apply(graph);
return graph;
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class BoxingEliminationTest method compareGraphs.
private void compareGraphs(final String snippet, final String referenceSnippet, final boolean loopPeeling, final boolean excludeVirtual) {
graph = parseEager(snippet, AllowAssumptions.NO);
HighTierContext context = getDefaultHighTierContext();
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
canonicalizer.apply(graph, context);
new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
if (loopPeeling) {
new LoopPeelingPhase(new DefaultLoopPolicies()).apply(graph, context);
}
new DeadCodeEliminationPhase().apply(graph);
canonicalizer.apply(graph, context);
new PartialEscapePhase(false, canonicalizer, graph.getOptions()).apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
canonicalizer.apply(graph, context);
StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.YES);
new InliningPhase(new CanonicalizerPhase()).apply(referenceGraph, context);
new DeadCodeEliminationPhase().apply(referenceGraph);
new CanonicalizerPhase().apply(referenceGraph, context);
assertEquals(referenceGraph, graph, excludeVirtual, true);
}
Aggregations