< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/ea/EATestBase.java

Print this page




  60             this(0, 0);
  61         }
  62 
  63         public TestClassInt(int x) {
  64             this(x, 0);
  65         }
  66 
  67         public TestClassInt(int x, int y) {
  68             this.x = x;
  69             this.y = y;
  70         }
  71 
  72         @Override
  73         public boolean equals(Object obj) {
  74             TestClassInt other = (TestClassInt) obj;
  75             return x == other.x && y == other.y && z == other.z;
  76         }
  77 
  78         @Override
  79         public String toString() {
  80             return "{" + x + "," + y + "}";
  81         }
  82 
  83         @Override
  84         public int hashCode() {
  85             return x + 13 * y;
  86         }
  87     }
  88 
  89     public static class TestClassObject {
  90         public Object x;
  91         public Object y;
  92 
  93         public TestClassObject() {
  94             this(null, null);
  95         }
  96 
  97         public TestClassObject(Object x) {
  98             this(x, null);
  99         }
 100 


 141         if (expectedConstantResult != null) {
 142             for (ReturnNode returnNode : returnNodes) {
 143                 Assert.assertTrue(returnNode.result().toString(), returnNode.result().isConstant());
 144                 Assert.assertEquals(expectedConstantResult, returnNode.result().asConstant());
 145             }
 146         }
 147         int newInstanceCount = graph.getNodes().filter(NewInstanceNode.class).count() + graph.getNodes().filter(NewArrayNode.class).count() +
 148                         graph.getNodes().filter(CommitAllocationNode.class).count();
 149         Assert.assertEquals(0, newInstanceCount);
 150     }
 151 
 152     @SuppressWarnings("try")
 153     protected void prepareGraph(String snippet, boolean iterativeEscapeAnalysis) {
 154         ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
 155         DebugContext debug = getDebugContext();
 156         try (DebugContext.Scope s = debug.scope(getClass(), method, getCodeCache())) {
 157             graph = parseEager(method, AllowAssumptions.YES, debug);
 158             context = getDefaultHighTierContext();
 159             new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
 160             new DeadCodeEliminationPhase().apply(graph);
 161             new CanonicalizerPhase().apply(graph, context);
 162             new PartialEscapePhase(iterativeEscapeAnalysis, false, new CanonicalizerPhase(), null, graph.getOptions()).apply(graph, context);

 163             returnNodes = graph.getNodes(ReturnNode.TYPE).snapshot();
 164         } catch (Throwable e) {
 165             throw debug.handle(e);
 166         }







 167     }
 168 }


  60             this(0, 0);
  61         }
  62 
  63         public TestClassInt(int x) {
  64             this(x, 0);
  65         }
  66 
  67         public TestClassInt(int x, int y) {
  68             this.x = x;
  69             this.y = y;
  70         }
  71 
  72         @Override
  73         public boolean equals(Object obj) {
  74             TestClassInt other = (TestClassInt) obj;
  75             return x == other.x && y == other.y && z == other.z;
  76         }
  77 
  78         @Override
  79         public String toString() {
  80             return "{" + x + "," + y + "," + z + "}";
  81         }
  82 
  83         @Override
  84         public int hashCode() {
  85             return x + 13 * y;
  86         }
  87     }
  88 
  89     public static class TestClassObject {
  90         public Object x;
  91         public Object y;
  92 
  93         public TestClassObject() {
  94             this(null, null);
  95         }
  96 
  97         public TestClassObject(Object x) {
  98             this(x, null);
  99         }
 100 


 141         if (expectedConstantResult != null) {
 142             for (ReturnNode returnNode : returnNodes) {
 143                 Assert.assertTrue(returnNode.result().toString(), returnNode.result().isConstant());
 144                 Assert.assertEquals(expectedConstantResult, returnNode.result().asConstant());
 145             }
 146         }
 147         int newInstanceCount = graph.getNodes().filter(NewInstanceNode.class).count() + graph.getNodes().filter(NewArrayNode.class).count() +
 148                         graph.getNodes().filter(CommitAllocationNode.class).count();
 149         Assert.assertEquals(0, newInstanceCount);
 150     }
 151 
 152     @SuppressWarnings("try")
 153     protected void prepareGraph(String snippet, boolean iterativeEscapeAnalysis) {
 154         ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
 155         DebugContext debug = getDebugContext();
 156         try (DebugContext.Scope s = debug.scope(getClass(), method, getCodeCache())) {
 157             graph = parseEager(method, AllowAssumptions.YES, debug);
 158             context = getDefaultHighTierContext();
 159             new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
 160             new DeadCodeEliminationPhase().apply(graph);
 161             canonicalizeGraph();
 162             new PartialEscapePhase(iterativeEscapeAnalysis, false, new CanonicalizerPhase(), null, graph.getOptions()).apply(graph, context);
 163             postEACanonicalizeGraph();
 164             returnNodes = graph.getNodes(ReturnNode.TYPE).snapshot();
 165         } catch (Throwable e) {
 166             throw debug.handle(e);
 167         }
 168     }
 169 
 170     protected void postEACanonicalizeGraph() {
 171     }
 172 
 173     protected void canonicalizeGraph() {
 174         new CanonicalizerPhase().apply(graph, context);
 175     }
 176 }
< prev index next >