8074676: java.lang.invoke.PermuteArgsTest.java fails with "assert(is_Initialize()) failed: invalid node class"
authorroland
Wed, 15 Apr 2015 11:01:56 +0200
changeset 30226 5f1a3a275862
parent 30225 e9722ea461d4
child 30227 fdb68fee3e41
child 30295 d91d9c285139
child 30296 95baefac8485
8074676: java.lang.invoke.PermuteArgsTest.java fails with "assert(is_Initialize()) failed: invalid node class" Summary: after guards in Arrays.copyOf() intrinsic, control may become top Reviewed-by: kvn, vlivanov
hotspot/src/share/vm/opto/library_call.cpp
hotspot/test/compiler/arraycopy/TestArrayCopyOfStopped.java
--- a/hotspot/src/share/vm/opto/library_call.cpp	Tue Apr 14 11:43:18 2015 +0100
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Wed Apr 15 11:01:56 2015 +0200
@@ -3943,21 +3943,23 @@
         validated = true;
       }
 
-      newcopy = new_array(klass_node, length, 0);  // no arguments to push
-
-      ArrayCopyNode* ac = ArrayCopyNode::make(this, true, original, start, newcopy, intcon(0), moved, true,
-                                              load_object_klass(original), klass_node);
-      if (!is_copyOfRange) {
-        ac->set_copyof(validated);
-      } else {
-        ac->set_copyofrange(validated);
-      }
-      Node* n = _gvn.transform(ac);
-      if (n == ac) {
-        ac->connect_outputs(this);
-      } else {
-        assert(validated, "shouldn't transform if all arguments not validated");
-        set_all_memory(n);
+      if (!stopped()) {
+        newcopy = new_array(klass_node, length, 0);  // no arguments to push
+
+        ArrayCopyNode* ac = ArrayCopyNode::make(this, true, original, start, newcopy, intcon(0), moved, true,
+                                                load_object_klass(original), klass_node);
+        if (!is_copyOfRange) {
+          ac->set_copyof(validated);
+        } else {
+          ac->set_copyofrange(validated);
+        }
+        Node* n = _gvn.transform(ac);
+        if (n == ac) {
+          ac->connect_outputs(this);
+        } else {
+          assert(validated, "shouldn't transform if all arguments not validated");
+          set_all_memory(n);
+        }
       }
     }
   } // original reexecute is set back here
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/arraycopy/TestArrayCopyOfStopped.java	Wed Apr 15 11:01:56 2015 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8074676
+ * @summary after guards in Arrays.copyOf() intrinsic, control may become top
+ * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestArrayCopyOfStopped
+ *
+ */
+
+import java.util.Arrays;
+
+public class TestArrayCopyOfStopped {
+    static class A {
+    }
+
+    static class B {
+    }
+
+    static final B[] array_of_bs = new B[10];
+    static final A[] array_of_as = new A[10];
+
+    static Object[] m1_helper(Object[] array, boolean flag) {
+        if (flag) {
+            return Arrays.copyOf(array, 10, A[].class);
+        }
+        return null;
+    }
+
+    static Object[] m1(boolean flag) {
+        return m1_helper(array_of_bs, flag);
+    }
+
+    public static void main(String[] args) {
+        for (int i = 0; i < 20000; i++) {
+            m1_helper(array_of_as, (i%2) == 0);
+        }
+
+        for (int i = 0; i < 20000; i++) {
+            m1(false);
+        }
+    }
+}