use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class VerifyVirtualizableTest method testVirtualizableEffects.
@SuppressWarnings("try")
private static void testVirtualizableEffects(Class<?> c) {
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);
OptionValues options = getInitialOptions();
DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
for (Method m : c.getDeclaredMethods()) {
if (!Modifier.isNative(m.getModifiers()) && !Modifier.isAbstract(m.getModifiers())) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build();
graphBuilderSuite.apply(graph, context);
try (DebugCloseable s = debug.disableIntercept()) {
new VerifyVirtualizableUsage().apply(graph, context);
}
}
}
}
use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class AllocatorTest method testAllocation.
@SuppressWarnings("try")
protected void testAllocation(String snippet, final int expectedRegisters, final int expectedRegRegMoves, final int expectedSpillMoves) {
final StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
DebugContext debug = graph.getDebug();
try (DebugContext.Scope s = debug.scope("AllocatorTest", graph, graph.method(), getCodeCache())) {
final RegisterStats stats = new RegisterStats(getLIRGenerationResult(graph).getLIR());
try (DebugContext.Scope s2 = debug.scope("Assertions", stats.lir)) {
Assert.assertEquals("register count", expectedRegisters, stats.registers.size());
Assert.assertEquals("reg-reg moves", expectedRegRegMoves, stats.regRegMoves);
Assert.assertEquals("spill moves", expectedSpillMoves, stats.spillMoves);
} catch (Throwable e) {
throw debug.handle(e);
}
} catch (Throwable e) {
throw debug.handle(e);
}
}
use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class StraighteningTest method test.
private void test(final String snippet) {
// No debug scope to reduce console noise for @Test(expected = ...) tests
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
DebugContext debug = graph.getDebug();
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.YES);
assertEquals(referenceGraph, graph);
}
use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class TrivialInliningExplosionTest method parseForCompile.
@Override
protected StructuredGraph parseForCompile(ResolvedJavaMethod method, CompilationIdentifier compilationId, OptionValues options) {
final StructuredGraph graph = super.parseForCompile(method, compilationId, options);
this.afterParseSize = graph.getNodeCount();
return graph;
}
use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class TypeSystemTest method test.
private void test(String snippet, String referenceSnippet) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
DebugContext debug = graph.getDebug();
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
/*
* When using FlowSensitiveReductionPhase instead of ConditionalEliminationPhase,
* tail-duplication gets activated thus resulting in a graph with more nodes than the
* reference graph.
*/
new ConditionalEliminationPhase(false).apply(graph, new PhaseContext(getProviders()));
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
// a second canonicalizer is needed to process nested MaterializeNodes
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
new ConditionalEliminationPhase(false).apply(referenceGraph, new PhaseContext(getProviders()));
new CanonicalizerPhase().apply(referenceGraph, new PhaseContext(getProviders()));
new CanonicalizerPhase().apply(referenceGraph, new PhaseContext(getProviders()));
assertEquals(referenceGraph, graph);
}
Aggregations