Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java @ 13692:c215dec9d3cf
allow multiple ReturnNodes per graph
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 15 Jan 2014 16:11:56 +0100 |
parents | f4f0a8a01ce0 |
children | a0baf4eeb018 |
comparison
equal
deleted
inserted
replaced
13691:056d9d7dc061 | 13692:c215dec9d3cf |
---|---|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.graal.compiler.test.ea; | 23 package com.oracle.graal.compiler.test.ea; |
24 | |
25 import java.util.*; | |
24 | 26 |
25 import org.junit.*; | 27 import org.junit.*; |
26 | 28 |
27 import com.oracle.graal.api.code.*; | 29 import com.oracle.graal.api.code.*; |
28 import com.oracle.graal.api.meta.*; | 30 import com.oracle.graal.api.meta.*; |
117 | 119 |
118 protected static native void notInlineable(); | 120 protected static native void notInlineable(); |
119 | 121 |
120 protected StructuredGraph graph; | 122 protected StructuredGraph graph; |
121 protected HighTierContext context; | 123 protected HighTierContext context; |
122 protected ReturnNode returnNode; | 124 protected List<ReturnNode> returnNodes; |
123 | 125 |
124 /** | 126 /** |
125 * Runs Escape Analysis on the given snippet and makes sure that no allocations remain in the | 127 * Runs Escape Analysis on the given snippet and makes sure that no allocations remain in the |
126 * graph. | 128 * graph. |
127 * | 129 * |
132 * iteration | 134 * iteration |
133 */ | 135 */ |
134 protected void testEscapeAnalysis(String snippet, final Constant expectedConstantResult, final boolean iterativeEscapeAnalysis) { | 136 protected void testEscapeAnalysis(String snippet, final Constant expectedConstantResult, final boolean iterativeEscapeAnalysis) { |
135 prepareGraph(snippet, iterativeEscapeAnalysis); | 137 prepareGraph(snippet, iterativeEscapeAnalysis); |
136 if (expectedConstantResult != null) { | 138 if (expectedConstantResult != null) { |
137 Assert.assertTrue(returnNode.result().toString(), returnNode.result().isConstant()); | 139 for (ReturnNode returnNode : returnNodes) { |
138 Assert.assertEquals(expectedConstantResult, returnNode.result().asConstant()); | 140 Assert.assertTrue(returnNode.result().toString(), returnNode.result().isConstant()); |
141 Assert.assertEquals(expectedConstantResult, returnNode.result().asConstant()); | |
142 } | |
139 } | 143 } |
140 int newInstanceCount = graph.getNodes().filter(NewInstanceNode.class).count() + graph.getNodes().filter(NewArrayNode.class).count() + | 144 int newInstanceCount = graph.getNodes().filter(NewInstanceNode.class).count() + graph.getNodes().filter(NewArrayNode.class).count() + |
141 graph.getNodes().filter(CommitAllocationNode.class).count(); | 145 graph.getNodes().filter(CommitAllocationNode.class).count(); |
142 Assert.assertEquals(0, newInstanceCount); | 146 Assert.assertEquals(0, newInstanceCount); |
143 } | 147 } |
151 context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL); | 155 context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL); |
152 new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); | 156 new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context); |
153 new DeadCodeEliminationPhase().apply(graph); | 157 new DeadCodeEliminationPhase().apply(graph); |
154 new CanonicalizerPhase(true).apply(graph, context); | 158 new CanonicalizerPhase(true).apply(graph, context); |
155 new PartialEscapePhase(iterativeEscapeAnalysis, false, new CanonicalizerPhase(true)).apply(graph, context); | 159 new PartialEscapePhase(iterativeEscapeAnalysis, false, new CanonicalizerPhase(true)).apply(graph, context); |
156 Assert.assertEquals(1, graph.getNodes().filter(ReturnNode.class).count()); | 160 returnNodes = graph.getNodes(ReturnNode.class).snapshot(); |
157 returnNode = graph.getNodes().filter(ReturnNode.class).first(); | |
158 } catch (Throwable e) { | 161 } catch (Throwable e) { |
159 throw Debug.handle(e); | 162 throw Debug.handle(e); |
160 } | 163 } |
161 } | 164 } |
162 } | 165 } |