changeset 9687:2e70148efaa5

8134288: compiler/runtime/6859338/Test6859338.java crashes in PhaseIdealLoop::try_move_store_after_loop Summary: Store nodes may not have a control if used to update profiling Reviewed-by: kvn
author roland
date Wed, 26 Aug 2015 12:43:15 +0200
parents 22400a67babe
children 9df4555d2d7d
files src/share/vm/opto/loopopts.cpp test/compiler/TestMoveStoresOutOfLoopsStoreNoCtrl.java
diffstat 2 files changed, 51 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/loopopts.cpp	Thu Aug 27 14:40:19 2015 -0700
+++ b/src/share/vm/opto/loopopts.cpp	Wed Aug 26 12:43:15 2015 +0200
@@ -673,8 +673,7 @@
 Node* PhaseIdealLoop::try_move_store_before_loop(Node* n, Node *n_ctrl) {
   // Store has to be first in the loop body
   IdealLoopTree *n_loop = get_loop(n_ctrl);
-  if (n->is_Store() && n_loop != _ltree_root && n_loop->is_loop()) {
-    assert(n->in(0), "store should have control set");
+  if (n->is_Store() && n_loop != _ltree_root && n_loop->is_loop() && n->in(0) != NULL) {
     Node* address = n->in(MemNode::Address);
     Node* value = n->in(MemNode::ValueIn);
     Node* mem = n->in(MemNode::Memory);
@@ -748,8 +747,7 @@
 
 // Try moving a store out of a loop, right after the loop
 void PhaseIdealLoop::try_move_store_after_loop(Node* n) {
-  if (n->is_Store()) {
-    assert(n->in(0), "store should have control set");
+  if (n->is_Store() && n->in(0) != NULL) {
     Node *n_ctrl = get_ctrl(n);
     IdealLoopTree *n_loop = get_loop(n_ctrl);
     // Store must be in a loop
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/TestMoveStoresOutOfLoopsStoreNoCtrl.java	Wed Aug 26 12:43:15 2015 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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 8134288
+ * @summary Store nodes may not have a control if used to update profiling
+ * @run main/othervm -XX:-ProfileInterpreter -XX:-TieredCompilation -XX:-BackgroundCompilation TestMoveStoresOutOfLoopsStoreNoCtrl
+ *
+ */
+
+public class TestMoveStoresOutOfLoopsStoreNoCtrl {
+
+    static void test(boolean flag) {
+        for (int i = 0; i < 20000; i++) {
+            if (flag) {
+                int j = 0;
+                do {
+                    j++;
+                } while(j < 10);
+            }
+        }
+    }
+
+    static public void main(String[] args) {
+        test(false);
+    }
+
+}