use of org.graalvm.compiler.graph.Graph in project graal by oracle.
the class TypedNodeIteratorTest method complicatedIterationTest.
@Test
public void complicatedIterationTest() {
OptionValues options = getOptions();
Graph graph = new Graph(options, getDebug(options));
graph.add(new TestNode("a"));
for (TestNode tn : graph.getNodes(TestNode.TYPE)) {
String name = tn.getName();
for (int i = 0; i < name.length(); ++i) {
char c = name.charAt(i);
if (c == 'a') {
tn.safeDelete();
graph.add(new TestNode("b"));
graph.add(new TestNode("c"));
} else if (c == 'b') {
tn.safeDelete();
} else if (c == 'c') {
graph.add(new TestNode("d"));
graph.add(new TestNode("e"));
graph.add(new TestNode("d"));
graph.add(new TestNode("e"));
graph.add(new TestNode("e"));
graph.add(new TestNode("d"));
graph.add(new TestNode("e"));
graph.add(new TestNode("d"));
} else if (c == 'd') {
for (TestNode tn2 : graph.getNodes(TestNode.TYPE)) {
if (tn2.getName().equals("e")) {
tn2.safeDelete();
} else if (tn2.getName().equals("c")) {
tn2.safeDelete();
}
}
} else if (c == 'e') {
fail("All e nodes must have been deleted by visiting the d node");
}
}
}
assertEquals("dddd", toString(graph.getNodes(TestNode.TYPE)));
}
use of org.graalvm.compiler.graph.Graph in project graal by oracle.
the class TypedNodeIteratorTest method iteratorBehaviorTest.
@Test
public void iteratorBehaviorTest() {
OptionValues options = getOptions();
Graph graph = new Graph(options, getDebug(options));
graph.add(new TestNode("a"));
Iterator<TestNode> iterator = graph.getNodes(TestNode.TYPE).iterator();
assertTrue(iterator.hasNext());
assertEquals("a", iterator.next().getName());
assertFalse(iterator.hasNext());
graph.add(new TestNode("b"));
assertTrue(iterator.hasNext());
assertEquals("b", iterator.next().getName());
assertFalse(iterator.hasNext());
TestNode c = new TestNode("c");
graph.add(c);
assertTrue(iterator.hasNext());
c.safeDelete();
assertFalse(iterator.hasNext());
}
use of org.graalvm.compiler.graph.Graph in project graal by oracle.
the class TypedNodeIteratorTest method deletingNodeTest.
@Test
public void deletingNodeTest() {
TestNode testNode = new TestNode("a");
OptionValues options = getOptions();
Graph graph = new Graph(options, getDebug(options));
graph.add(testNode);
testNode.safeDelete();
assertEquals("", toString(graph.getNodes(TestNode.TYPE)));
}
use of org.graalvm.compiler.graph.Graph in project graal by oracle.
the class TypedNodeIteratorTest2 method addingNodeDuringIterationTest.
@Test
public void addingNodeDuringIterationTest() {
Graph graph = new Graph(getOptions(), getDebug());
graph.add(new NodeB("b1"));
NodeD d1 = graph.add(new NodeD("d1"));
StringBuilder sb = new StringBuilder();
for (NodeB tn : graph.getNodes(NodeB.TYPE)) {
if (tn == d1) {
graph.add(new NodeB("b2"));
}
sb.append(tn.getName());
}
assertEquals("b1d1b2", sb.toString());
for (NodeB tn : graph.getNodes(NodeB.TYPE)) {
if (tn == d1) {
graph.add(new NodeB("b3"));
}
assertNotNull(tn);
}
assertEquals(4, graph.getNodes(NodeB.TYPE).count());
assertEquals(1, graph.getNodes(NodeD.TYPE).count());
}
use of org.graalvm.compiler.graph.Graph in project graal by oracle.
the class NodeBitMapTest method before.
@Before
public void before() {
// Need to initialize HotSpotGraalRuntime before any Node class is initialized.
Graal.getRuntime();
OptionValues options = getOptions();
graph = new Graph(options, getDebug(options));
for (int i = 0; i < nodes.length; i++) {
nodes[i] = graph.add(new TestNode());
}
map = graph.createNodeBitMap();
}
Aggregations