annotate graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java @ 19403:61d3cb8e1280

Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 16 Feb 2015 17:47:43 +0100
parents a0a760b0fb5f
children b1530a6cce8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
6334
f8ba3bb81f6f Renamed com.oracle.graal.tests project to com.oracle.graal.compiler.test
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5565
diff changeset
23 package com.oracle.graal.compiler.test;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 import org.junit.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26
15192
644dfe49c0f4 Move packages com.oracle.graal.cfg to com.oracle.graal.compiler.common.cfg.
Josef Eisl <josef.eisl@jku.at>
parents: 15157
diff changeset
27 import com.oracle.graal.compiler.common.cfg.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
28 import com.oracle.graal.debug.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
29 import com.oracle.graal.graph.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
30 import com.oracle.graal.nodes.*;
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
31 import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
6529
2e96dc4eb8e2 renamed package: com.oracle.graal.lir.cfg -> com.oracle.graal.nodes.cfg
Doug Simon <doug.simon@oracle.com>
parents: 6409
diff changeset
32 import com.oracle.graal.nodes.cfg.*;
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6539
diff changeset
33 import com.oracle.graal.nodes.java.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34
5565
0083a59ced84 Renaming GraphTest => GraalCompilerTest.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
35 public class NestedLoopTest extends GraalCompilerTest {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 @Test
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38 public void test1() {
4545
5d8eaed30aee Fix unit test cases for new way of creating exception edges for invokes (i.e. only create edge if there was at least 1 exception at that place).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4525
diff changeset
39 test("test1Snippet", 1, 2, 2);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 @Test
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43 public void test2() {
4545
5d8eaed30aee Fix unit test cases for new way of creating exception edges for invokes (i.e. only create edge if there was at least 1 exception at that place).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4525
diff changeset
44 test("test2Snippet", 1, 2, 2);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 @Test
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 public void test3() {
4545
5d8eaed30aee Fix unit test cases for new way of creating exception edges for invokes (i.e. only create edge if there was at least 1 exception at that place).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4525
diff changeset
49 test("test3Snippet", 1, 2, 2);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 @Test
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 public void test4() {
4545
5d8eaed30aee Fix unit test cases for new way of creating exception edges for invokes (i.e. only create edge if there was at least 1 exception at that place).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4525
diff changeset
54 test("test4Snippet", 1, 3, 2);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
57 @SuppressWarnings("all")
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 public static void test1Snippet(int a) {
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
59 while (a()) { // a() exits root, while() exits root
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
60 m1: while (b()) { // b() exits nested & root, while() exits nested
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
61 while (c()) { // c() exits innermost & nested & root, while() exits innermost
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
62 if (d()) { // d() exits innermost & nested & root
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
63 break m1; // break exits innermost & nested
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 }
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
68 }// total : root = 5 exits, nested = 5, innermost = 4
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
70 @SuppressWarnings("all")
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 public static void test2Snippet(int a) {
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
72 while (a()) { // a() exits root, while() exits root
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73 try {
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
74 m1: while (b()) { // b() exits nested, while() exits nested
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
75 while (c()) { // c() exits innermost & nested, while() exits innermost
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
76 if (d()) { // d() exits innermost & nested
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
77 break m1; // break exits innermost & nested
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 } catch (Throwable t) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 }
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
84 }// total : root = 2 exits, nested = 5, innermost = 4
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
86 @SuppressWarnings("all")
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 public static void test3Snippet(int a) {
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
88 while (a == 0) { // while() exits root
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89 try {
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
90 m1: while (b()) { // b() exits nested, while() exits nested
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
91 while (c()) { // c() exits innermost & nested, while() exits innermost
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
92 if (d()) { // d() exits innermost & nested
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
93 a(); // a() exits nothing (already outside innermost & nested)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
94 break m1; // break exits innermost & nested
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
96 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98 } catch (Throwable t) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100 }
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
101 }// total : root = 1 exit, nested = 5, innermost = 4
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103 public static void test4Snippet(int a) {
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
104 while (a != 0) { // while() exits root
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 try {
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
106 m1: while (a != 0) { // while() exits nested
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
107 b(); // b() exits nested
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
108 while (c()) { // c() exits innermost & nested, while() exits innermost
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
109 if (d()) { // d() exits innermost & nested
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
110 break m1; // break exits innermost & nested
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 if (a != 2) {
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
114 a(); // a() exits nothing (already outside innermost & nested)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
115 throw new Exception(); // throw exits nested
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 } catch (Throwable t) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120 }
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
121 } // total : root = 1 exit, nested = 6, innermost = 4
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 private static boolean a() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 private static boolean b() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131 private static boolean c() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 private static boolean d() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
139 private static Invoke getInvoke(String name, StructuredGraph graph) {
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19306
diff changeset
140 for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.TYPE)) {
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6539
diff changeset
141 if (callTarget.targetMethod().getName().equals(name)) {
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6539
diff changeset
142 return callTarget.invoke();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147
4328
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4142
diff changeset
148 private void test(String snippet, int rootExits, int nestedExits, int innerExits) {
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
149 StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4142
diff changeset
150 Debug.dump(graph, "Graph");
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
151 ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
152
15107
1bf700e19e84 Make Loop generic.
Josef Eisl <josef.eisl@jku.at>
parents: 9147
diff changeset
153 Assert.assertTrue(cfg.getLoops().size() == 3);
1bf700e19e84 Make Loop generic.
Josef Eisl <josef.eisl@jku.at>
parents: 9147
diff changeset
154 Loop<Block> rootLoop = cfg.getLoops().get(0);
1bf700e19e84 Make Loop generic.
Josef Eisl <josef.eisl@jku.at>
parents: 9147
diff changeset
155 Loop<Block> nestedLoop = cfg.getLoops().get(1);
1bf700e19e84 Make Loop generic.
Josef Eisl <josef.eisl@jku.at>
parents: 9147
diff changeset
156 Loop<Block> innerMostLoop = cfg.getLoops().get(2);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157 Invoke a = getInvoke("a", graph);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 Invoke b = getInvoke("b", graph);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159 Invoke c = getInvoke("c", graph);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160 Invoke d = getInvoke("d", graph);
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
161 Assert.assertTrue(containsDirect(rootLoop, a, cfg));
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
162 Assert.assertTrue(containsDirect(nestedLoop, b, cfg));
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
163 Assert.assertTrue(containsDirect(innerMostLoop, c, cfg));
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
164 Assert.assertTrue(containsDirect(innerMostLoop, d, cfg));
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
165 Assert.assertTrue(contains(rootLoop, d, cfg));
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
166 Assert.assertTrue(contains(nestedLoop, d, cfg));
15534
4bd6ad45ee0a Encapsulate members of Loop.
Josef Eisl <josef.eisl@jku.at>
parents: 15192
diff changeset
167 Assert.assertEquals(rootExits, rootLoop.getExits().size());
4bd6ad45ee0a Encapsulate members of Loop.
Josef Eisl <josef.eisl@jku.at>
parents: 15192
diff changeset
168 Assert.assertEquals(nestedExits, nestedLoop.getExits().size());
4bd6ad45ee0a Encapsulate members of Loop.
Josef Eisl <josef.eisl@jku.at>
parents: 15192
diff changeset
169 Assert.assertEquals(innerExits, innerMostLoop.getExits().size());
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4142
diff changeset
170 Debug.dump(graph, "Graph");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 }
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
172
15107
1bf700e19e84 Make Loop generic.
Josef Eisl <josef.eisl@jku.at>
parents: 9147
diff changeset
173 private static boolean contains(Loop<Block> loop, Invoke node, ControlFlowGraph cfg) {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
174 Block block = cfg.blockFor((Node) node);
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
175 Assert.assertNotNull(block);
15534
4bd6ad45ee0a Encapsulate members of Loop.
Josef Eisl <josef.eisl@jku.at>
parents: 15192
diff changeset
176 return loop.getBlocks().contains(block);
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
177 }
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
178
15107
1bf700e19e84 Make Loop generic.
Josef Eisl <josef.eisl@jku.at>
parents: 9147
diff changeset
179 private static boolean containsDirect(Loop<Block> loop, Invoke node, ControlFlowGraph cfg) {
15534
4bd6ad45ee0a Encapsulate members of Loop.
Josef Eisl <josef.eisl@jku.at>
parents: 15192
diff changeset
180 for (Loop<Block> child : loop.getChildren()) {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
181 if (contains(child, node, cfg)) {
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
182 return false;
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
183 }
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
184 }
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
185 return contains(loop, node, cfg);
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4370
diff changeset
186 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187 }