8075921: assert assert(allocx == alloc) fails in library_call.cpp
authorroland
Fri, 27 Mar 2015 08:58:45 +0100
changeset 30208 ed11124f18e1
parent 30207 7bf1f70e147b
child 30209 8ea30dc99369
8075921: assert assert(allocx == alloc) fails in library_call.cpp Summary: control becomes top after arraycopy guards and confuses tighly coupled allocation logic Reviewed-by: kvn, vlivanov
hotspot/src/share/vm/opto/graphKit.cpp
hotspot/src/share/vm/opto/library_call.cpp
hotspot/test/compiler/arraycopy/TestArrayCopyStoppedAfterGuards.java
--- a/hotspot/src/share/vm/opto/graphKit.cpp	Mon Mar 30 08:03:47 2015 +0000
+++ b/hotspot/src/share/vm/opto/graphKit.cpp	Fri Mar 27 08:58:45 2015 +0100
@@ -2530,6 +2530,11 @@
 // prior to coming here.
 Node* Phase::gen_subtype_check(Node* subklass, Node* superklass, Node** ctrl, MergeMemNode* mem, PhaseGVN* gvn) {
   Compile* C = gvn->C;
+
+  if ((*ctrl)->is_top()) {
+    return C->top();
+  }
+
   // Fast check for identical types, perhaps identical constants.
   // The types can even be identical non-constants, in cases
   // involving Array.newInstance, Object.clone, etc.
@@ -2793,6 +2798,10 @@
 Node* GraphKit::maybe_cast_profiled_obj(Node* obj,
                                         ciKlass* type,
                                         bool not_null) {
+  if (stopped()) {
+    return obj;
+  }
+
   // type == NULL if profiling tells us this object is always null
   if (type != NULL) {
     Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check;
--- a/hotspot/src/share/vm/opto/library_call.cpp	Mon Mar 30 08:03:47 2015 +0000
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Fri Mar 27 08:58:45 2015 +0100
@@ -3670,6 +3670,11 @@
 //---------------------generate_array_guard_common------------------------
 Node* LibraryCallKit::generate_array_guard_common(Node* kls, RegionNode* region,
                                                   bool obj_array, bool not_array) {
+
+  if (stopped()) {
+    return NULL;
+  }
+
   // If obj_array/non_array==false/false:
   // Branch around if the given klass is in fact an array (either obj or prim).
   // If obj_array/non_array==false/true:
@@ -4761,7 +4766,7 @@
 // guarantees there's no observer of the allocated array at this point
 // and the control flow is simple enough.
 void LibraryCallKit::arraycopy_move_allocation_here(AllocateArrayNode* alloc, Node* dest, JVMState* saved_jvms, int saved_reexecute_sp) {
-  if (saved_jvms != NULL) {
+  if (saved_jvms != NULL && !stopped()) {
     assert(alloc != NULL, "only with a tightly coupled allocation");
     // restore JVM state to the state at the arraycopy
     saved_jvms->map()->set_control(map()->control());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/arraycopy/TestArrayCopyStoppedAfterGuards.java	Fri Mar 27 08:58:45 2015 +0100
@@ -0,0 +1,51 @@
+/*
+ * 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 8075921
+ * @summary control becomes top after arraycopy guards and confuses tighly coupled allocation logic
+ * @run main/othervm -Xcomp -XX:CompileOnly=TestArrayCopyStoppedAfterGuards.test,System.arraycopy TestArrayCopyStoppedAfterGuards
+ *
+ */
+
+public class TestArrayCopyStoppedAfterGuards {
+
+    static void test() {
+        Object src = new Object();
+        int[] dst = new int[10];
+        System.arraycopy(src, 0, dst, 0, 10);
+    }
+
+    static public void main(String[] args) {
+        // warmup
+        Object o = new Object();
+        int[] src = new int[10];
+        int[] dst = new int[10];
+        System.arraycopy(src, 0, dst, 0, 10);
+
+        try {
+            test();
+        } catch(ArrayStoreException ase) {}
+    }
+}