changeset 56262:4cf4325ad271 lworld

8230433: [lworld] C2 compilation fails with assert(_del_tick == node->_del_tick) failed: no unexpected deletions allowed
author thartmann
date Fri, 06 Sep 2019 10:19:05 +0200
parents 521de4f32286
children 35008408519d
files src/hotspot/share/opto/valuetypenode.cpp test/hotspot/jtreg/compiler/valhalla/valuetypes/TestBasicFunctionality.java
diffstat 2 files changed, 39 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/opto/valuetypenode.cpp	Thu Sep 05 09:48:13 2019 -0400
+++ b/src/hotspot/share/opto/valuetypenode.cpp	Fri Sep 06 10:19:05 2019 +0200
@@ -836,10 +836,13 @@
   // Search for allocations of this value type
   for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
     AllocateNode* alloc = fast_out(i)->isa_Allocate();
-    if (alloc != NULL && alloc->result_cast() != NULL && alloc->in(AllocateNode::ValueNode) == this) {
+    if (alloc != NULL && alloc->in(AllocateNode::ValueNode) == this) {
       assert(!is_default(*igvn), "default value type allocation");
       Node* res = alloc->result_cast();
-      Node* res_dom = NULL;
+      if (res == NULL || !res->is_CheckCastPP()) {
+        break; // No unique CheckCastPP
+      }
+      Node* res_dom = res;
       if (is_allocated(igvn)) {
         // The value type is already allocated but still connected to an AllocateNode.
         // This can happen with late inlining when we first allocate a value type argument
@@ -848,18 +851,17 @@
       } else {
         // Search for a dominating allocation of the same value type
         for (DUIterator_Fast jmax, j = fast_outs(jmax); j < jmax; j++) {
-          AllocateNode* alloc_dom = fast_out(j)->isa_Allocate();
-          if (alloc_dom != NULL && alloc != alloc_dom && alloc_dom->result_cast() != NULL &&
-              alloc_dom->in(AllocateNode::ValueNode) == this) {
-            assert(alloc->in(AllocateNode::KlassNode) == alloc_dom->in(AllocateNode::KlassNode), "klasses should match");
-            if (phase->is_dominator(alloc_dom->result_cast()->in(0), res->in(0))) {
-              res_dom = alloc_dom->result_cast();
-              break;
+          AllocateNode* alloc_other = fast_out(j)->isa_Allocate();
+          if (alloc_other != NULL && alloc_other->in(AllocateNode::ValueNode) == this) {
+            Node* res_other = alloc_other->result_cast();
+            if (res_other != NULL && res_other->is_CheckCastPP() && res_other != res_dom &&
+                phase->is_dominator(res_other->in(0), res_dom->in(0))) {
+              res_dom = res_other;
             }
           }
         }
       }
-      if (res_dom != NULL) {
+      if (res_dom != res) {
         // Move users to dominating allocation
         igvn->replace_node(res, res_dom);
         // The result of the dominated allocation is now unused and will be
--- a/test/hotspot/jtreg/compiler/valhalla/valuetypes/TestBasicFunctionality.java	Thu Sep 05 09:48:13 2019 -0400
+++ b/test/hotspot/jtreg/compiler/valhalla/valuetypes/TestBasicFunctionality.java	Fri Sep 06 10:19:05 2019 +0200
@@ -806,4 +806,31 @@
         Test37Value1 vt = new Test37Value1();
         Asserts.assertEQ(test37(vt), vt);
     }
+
+    // Test elimination of inline type allocations without a unique CheckCastPP
+    inline class Test38Value {
+        public int i;
+        public Test38Value(int i) { this.i = i; }
+    }
+
+    static Test38Value test38Field;
+
+    @Test
+    public void test38() {
+        for (int i = 3; i < 100; ++i) {
+            int j = 1;
+            while (++j < 11) {
+                try {
+                    test38Field = new Test38Value(i);
+                } catch (ArithmeticException ae) { }
+            }
+        }
+    }
+
+    @DontCompile
+    public void test38_verifier(boolean warmup) {
+        test38Field = Test38Value.default;
+        test38();
+        Asserts.assertEQ(test38Field, new Test38Value(99));
+    }
 }