Search in sources :

Example 51 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class NodeUsagesTests method testReplaceAtUsages.

@Test
public void testReplaceAtUsages() {
    OptionValues options = getOptions();
    Graph graph = new Graph(options, getDebug(options));
    Def def0 = graph.add(new Def());
    Def def1 = graph.add(new Def());
    Use use0 = graph.add(new Use(def0, null, null));
    Use use1 = graph.add(new Use(null, def0, null));
    Use use2 = graph.add(new Use(null, null, def0));
    assertEquals(3, def0.getUsageCount());
    assertThat(def0.usages(), contains(use0));
    assertThat(def0.usages(), contains(use1));
    assertThat(def0.usages(), contains(use2));
    assertThat(def0.usages(), isNotEmpty());
    assertThat(def1.usages(), isEmpty());
    def0.replaceAtUsages(def1);
    assertThat(def0.usages(), isEmpty());
    assertEquals(3, def1.getUsageCount());
    assertThat(def1.usages(), contains(use0));
    assertThat(def1.usages(), contains(use1));
    assertThat(def1.usages(), contains(use2));
    assertThat(def1.usages(), isNotEmpty());
}
Also used : Graph(org.graalvm.compiler.graph.Graph) OptionValues(org.graalvm.compiler.options.OptionValues) Test(org.junit.Test)

Example 52 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class NodeUsagesTests method testReplaceAtUsagesWithPredicate02.

@Test
public void testReplaceAtUsagesWithPredicate02() {
    OptionValues options = getOptions();
    Graph graph = new Graph(options, getDebug(options));
    Def def0 = graph.add(new Def());
    Def def1 = graph.add(new Def());
    Use use0 = graph.add(new Use(def0, null, null));
    Use use1 = graph.add(new Use(null, def0, null));
    Use use2 = graph.add(new Use(null, null, def0));
    assertEquals(3, def0.getUsageCount());
    assertThat(def0.usages(), contains(use0));
    assertThat(def0.usages(), contains(use1));
    assertThat(def0.usages(), contains(use2));
    assertThat(def0.usages(), isNotEmpty());
    assertThat(def1.usages(), isEmpty());
    def0.replaceAtMatchingUsages(def1, u -> u != use1);
    assertEquals(1, def0.getUsageCount());
    assertThat(def0.usages(), contains(use1));
    assertThat(def0.usages(), isNotEmpty());
    assertEquals(2, def1.getUsageCount());
    assertThat(def1.usages(), contains(use0));
    assertThat(def1.usages(), contains(use2));
    assertThat(def1.usages(), isNotEmpty());
}
Also used : Graph(org.graalvm.compiler.graph.Graph) OptionValues(org.graalvm.compiler.options.OptionValues) Test(org.junit.Test)

Example 53 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class NodeUsagesTests method testReplaceAtUsagesWithPredicate023.

@Test
public void testReplaceAtUsagesWithPredicate023() {
    OptionValues options = getOptions();
    Graph graph = new Graph(options, getDebug(options));
    Def def0 = graph.add(new Def());
    Def def1 = graph.add(new Def());
    Use use0 = graph.add(new Use(def0, null, null));
    Use use1 = graph.add(new Use(null, def0, null));
    Use use2 = graph.add(new Use(null, null, def0));
    Use use3 = graph.add(new Use(null, null, def0));
    assertEquals(4, def0.getUsageCount());
    assertThat(def0.usages(), contains(use0));
    assertThat(def0.usages(), contains(use1));
    assertThat(def0.usages(), contains(use2));
    assertThat(def0.usages(), contains(use3));
    assertThat(def0.usages(), isNotEmpty());
    assertThat(def1.usages(), isEmpty());
    def0.replaceAtMatchingUsages(def1, u -> u != use1);
    assertEquals(1, def0.getUsageCount());
    assertThat(def0.usages(), contains(use1));
    assertThat(def0.usages(), isNotEmpty());
    assertEquals(3, def1.getUsageCount());
    assertThat(def1.usages(), contains(use0));
    assertThat(def1.usages(), contains(use2));
    assertThat(def1.usages(), contains(use3));
    assertThat(def1.usages(), isNotEmpty());
}
Also used : Graph(org.graalvm.compiler.graph.Graph) OptionValues(org.graalvm.compiler.options.OptionValues) Test(org.junit.Test)

Example 54 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class NodeUsagesTests method testReplaceAtUsagesWithPredicate01.

@Test
public void testReplaceAtUsagesWithPredicate01() {
    OptionValues options = getOptions();
    Graph graph = new Graph(options, getDebug(options));
    Def def0 = graph.add(new Def());
    Def def1 = graph.add(new Def());
    Use use0 = graph.add(new Use(def0, null, null));
    Use use1 = graph.add(new Use(null, def0, null));
    Use use2 = graph.add(new Use(null, null, def0));
    assertEquals(3, def0.getUsageCount());
    assertThat(def0.usages(), contains(use0));
    assertThat(def0.usages(), contains(use1));
    assertThat(def0.usages(), contains(use2));
    assertThat(def0.usages(), isNotEmpty());
    assertThat(def1.usages(), isEmpty());
    def0.replaceAtMatchingUsages(def1, u -> u != use2);
    assertEquals(1, def0.getUsageCount());
    assertThat(def0.usages(), contains(use2));
    assertThat(def0.usages(), isNotEmpty());
    assertEquals(2, def1.getUsageCount());
    assertThat(def1.usages(), contains(use0));
    assertThat(def1.usages(), contains(use1));
    assertThat(def1.usages(), isNotEmpty());
}
Also used : Graph(org.graalvm.compiler.graph.Graph) OptionValues(org.graalvm.compiler.options.OptionValues) Test(org.junit.Test)

Example 55 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class NodeUsagesTests method testReplaceAtUsagesWithPredicateNone.

@Test
public void testReplaceAtUsagesWithPredicateNone() {
    OptionValues options = getOptions();
    Graph graph = new Graph(options, getDebug(options));
    Def def0 = graph.add(new Def());
    Def def1 = graph.add(new Def());
    Use use0 = graph.add(new Use(def0, null, null));
    Use use1 = graph.add(new Use(null, def0, null));
    Use use2 = graph.add(new Use(null, null, def0));
    assertEquals(3, def0.getUsageCount());
    assertThat(def0.usages(), contains(use0));
    assertThat(def0.usages(), contains(use1));
    assertThat(def0.usages(), contains(use2));
    assertThat(def0.usages(), isNotEmpty());
    assertThat(def1.usages(), isEmpty());
    def0.replaceAtMatchingUsages(def1, u -> false);
    assertThat(def1.usages(), isEmpty());
    assertEquals(3, def0.getUsageCount());
    assertThat(def0.usages(), contains(use0));
    assertThat(def0.usages(), contains(use1));
    assertThat(def0.usages(), contains(use2));
    assertThat(def0.usages(), isNotEmpty());
}
Also used : Graph(org.graalvm.compiler.graph.Graph) OptionValues(org.graalvm.compiler.options.OptionValues) Test(org.junit.Test)

Aggregations

OptionValues (org.graalvm.compiler.options.OptionValues)158 Test (org.junit.Test)65 DebugContext (org.graalvm.compiler.debug.DebugContext)50 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)36 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)30 Graph (org.graalvm.compiler.graph.Graph)22 OptionKey (org.graalvm.compiler.options.OptionKey)16 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)13 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)11 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)10 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)10 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)10 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)9 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)9 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)9 Providers (org.graalvm.compiler.phases.util.Providers)9 IOException (java.io.IOException)8 Method (java.lang.reflect.Method)8 CompilationResult (org.graalvm.compiler.code.CompilationResult)7 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)7