use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class NodePropertiesTest method testCanonicalizationExample.
@Test
public void testCanonicalizationExample() {
HighTierContext htc = getDefaultHighTierContext();
ImprovementSavingCanonicalizer c1 = new ImprovementSavingCanonicalizer();
StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("test1Snippet"));
new CanonicalizerPhase(c1).apply(g1, htc);
ImprovementSavingCanonicalizer c2 = new ImprovementSavingCanonicalizer();
StructuredGraph g2 = parseForCompile(getResolvedJavaMethod("test2Snippet"));
new CanonicalizerPhase(c2).apply(g2, htc);
Assert.assertEquals(0, c1.savedCycles);
Assert.assertEquals(0, c2.savedCycles);
}
use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class NodePropertiesTest method testExpectUntrusted.
@Test
public void testExpectUntrusted() {
StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("untrused01"));
HighTierContext htc = getDefaultHighTierContext();
new CanonicalizerPhase().apply(g1, htc);
GraphCostPhase gc1 = new GraphCostPhase();
gc1.apply(g1, htc);
}
use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class StaticInterfaceFieldTest method eagerlyParseMethod.
@SuppressWarnings("try")
private void eagerlyParseMethod(Class<C> clazz, String methodName) {
RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
Providers providers = rt.getHostBackend().getProviders();
MetaAccessProvider metaAccess = providers.getMetaAccess();
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
Plugins plugins = new Plugins(new InvocationPlugins());
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
Assume.assumeTrue(VerifyPhase.class.desiredAssertionStatus());
final Method m = getMethod(clazz, methodName);
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
OptionValues options = getInitialOptions();
DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build();
try (DebugCloseable s = debug.disableIntercept();
DebugContext.Scope ds = debug.scope("GraphBuilding", graph, method)) {
graphBuilderSuite.apply(graph, context);
} catch (Throwable e) {
throw debug.handle(e);
}
}
use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class SwitchDyingLoopTest method test.
@Test
public void test() {
CanonicalizerPhase canonicalizerPhase = new CanonicalizerPhase();
HighTierContext highTierContext = getDefaultHighTierContext();
StructuredGraph graph = parseEager("snippet", StructuredGraph.AllowAssumptions.YES);
// there should be 1 loop and 1 switch
assertThat(graph.getNodes(LoopBeginNode.TYPE), hasCount(1));
assertThat(graph.getNodes(IntegerSwitchNode.TYPE), hasCount(1));
canonicalizerPhase.apply(graph, highTierContext);
// after canonicalization, the loop and switch should still be there
assertThat(graph.getNodes(LoopBeginNode.TYPE), hasCount(1));
assertThat(graph.getNodes(IntegerSwitchNode.TYPE), hasCount(1));
// add stamp to `a` so that paths leading to continue can be trimmed
ParameterNode parameter = graph.getParameter(0);
assertNotNull(parameter);
parameter.setStamp(StampFactory.forInteger(JavaKind.Int, 0, 255, 0, 0xf));
canonicalizerPhase.apply(graph, highTierContext);
// the loop should have disappeared and there should still be a switch
assertThat(graph.getNodes(LoopBeginNode.TYPE), isEmpty());
assertThat(graph.getNodes(IntegerSwitchNode.TYPE), hasCount(1));
}
use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class DegeneratedLoopsTest method test.
@SuppressWarnings("try")
private void test(final String snippet) {
DebugContext debug = getDebugContext();
try (DebugContext.Scope s = debug.scope("DegeneratedLoopsTest", new DebugDumpScope(snippet))) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
HighTierContext context = getDefaultHighTierContext();
new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, context);
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.YES);
debug.dump(DebugContext.BASIC_LEVEL, referenceGraph, "ReferenceGraph");
assertEquals(referenceGraph, graph);
} catch (Throwable e) {
throw debug.handle(e);
}
}
Aggregations