Search in sources :

Example 51 with StructuredGraph

use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.

the class TypeSystemTest method testHelper.

private <T extends Node> void testHelper(String snippet, Class<T> clazz) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph " + snippet);
    Assert.assertFalse("shouldn't have nodes of type " + clazz, graph.getNodes().filter(clazz).iterator().hasNext());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 52 with StructuredGraph

use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.

the class UnbalancedMonitorsTest method checkForBailout.

private void checkForBailout(String name) throws ClassNotFoundException {
    ResolvedJavaMethod method = getResolvedJavaMethod(LOADER.findClass(INNER_CLASS_NAME), name);
    try {
        OptionValues options = getInitialOptions();
        StructuredGraph graph = new StructuredGraph.Builder(options, getDebugContext(options, null, method)).method(method).build();
        Plugins plugins = new Plugins(new InvocationPlugins());
        GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
        OptimisticOptimizations optimisticOpts = OptimisticOptimizations.NONE;
        GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(getMetaAccess(), getProviders().getStampProvider(), null, null, graphBuilderConfig, optimisticOpts, null);
        graphBuilder.apply(graph);
    } catch (BailoutException e) {
        if (e.getMessage().contains("unbalanced monitors")) {
            return;
        }
        throw e;
    }
    assertTrue("should have bailed out", false);
}
Also used : BailoutException(jdk.vm.ci.code.BailoutException) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) OptionValues(org.graalvm.compiler.options.OptionValues) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) OptimisticOptimizations(org.graalvm.compiler.phases.OptimisticOptimizations) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 53 with StructuredGraph

use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.

the class UncheckedInterfaceProviderTest method test.

@Test
public void test() {
    StructuredGraph graph = parseEager("snippet", StructuredGraph.AllowAssumptions.YES);
    for (BlackholeNode b : graph.getNodes().filter(BlackholeNode.class)) {
        Assert.assertThat(b.getValue(), is(instanceOf(UncheckedInterfaceProvider.class)));
        Stamp uncheckedStamp = ((UncheckedInterfaceProvider) b.getValue()).uncheckedStamp();
        String context = b.getValue().toString(Verbosity.Debugger);
        Assert.assertNotNull(context, uncheckedStamp);
        ResolvedJavaType uncheckedType = StampTool.typeOrNull(uncheckedStamp);
        ResolvedJavaType type = StampTool.typeOrNull(b.getValue());
        Assert.assertEquals(context, arrayDepth(type), arrayDepth(uncheckedType));
        Assert.assertTrue(context + ": " + type, type == null || type.getElementalType().isJavaLangObject());
        Assert.assertNotNull(context, uncheckedType);
        Assert.assertTrue(context, uncheckedType.getElementalType().isInterface());
    }
}
Also used : BlackholeNode(org.graalvm.compiler.nodes.debug.BlackholeNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Stamp(org.graalvm.compiler.core.common.type.Stamp) UncheckedInterfaceProvider(org.graalvm.compiler.nodes.spi.UncheckedInterfaceProvider) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) Test(org.junit.Test)

Example 54 with StructuredGraph

use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.

the class UnsafeReadEliminationTest method test02.

@Test
public void test02() {
    StructuredGraph graph = parseEager("test1Snippet", AllowAssumptions.NO);
    testPartialEscapeReadElimination(graph, 3, 2);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Test(org.junit.Test)

Example 55 with StructuredGraph

use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.

the class UnsafeReadEliminationTest method test01.

@Test
public void test01() {
    StructuredGraph graph = parseEager("test1Snippet", AllowAssumptions.NO);
    testEarlyReadElimination(graph, 3, 2);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Test(org.junit.Test)

Aggregations

StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)360 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)97 Test (org.junit.Test)96 DebugContext (org.graalvm.compiler.debug.DebugContext)88 ValueNode (org.graalvm.compiler.nodes.ValueNode)70 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)62 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)62 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)57 Node (org.graalvm.compiler.graph.Node)39 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)37 OptionValues (org.graalvm.compiler.options.OptionValues)34 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)28 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)26 FixedNode (org.graalvm.compiler.nodes.FixedNode)26 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)25 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)24 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)24 LogicNode (org.graalvm.compiler.nodes.LogicNode)21 CompilationResult (org.graalvm.compiler.code.CompilationResult)19 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)19