diff src/share/vm/opto/loopnode.cpp @ 23474:7c5babab479b

8144935: C2: safepoint is pruned from a non-counted loop Reviewed-by: roland
author vlivanov
date Thu, 10 Dec 2015 14:51:53 +0300
parents cf93dd06db0f
children 501f014415d8
line wrap: on
line diff
--- a/src/share/vm/opto/loopnode.cpp	Fri Dec 04 14:06:38 2015 +0100
+++ b/src/share/vm/opto/loopnode.cpp	Thu Dec 10 14:51:53 2015 +0300
@@ -1811,10 +1811,9 @@
 }
 
 void IdealLoopTree::remove_safepoints(PhaseIdealLoop* phase, bool keep_one) {
-  // Look for a safepoint on the idom-path.
   Node* keep = NULL;
   if (keep_one) {
-    // Keep one if possible
+    // Look for a safepoint on the idom-path.
     for (Node* i = tail(); i != _head; i = phase->idom(i)) {
       if (i->Opcode() == Op_SafePoint && phase->get_loop(i) == this) {
         keep = i;
@@ -1823,9 +1822,14 @@
     }
   }
 
+  // Don't remove any safepoints if it is requested to keep a single safepoint and
+  // no safepoint was found on idom-path. It is not safe to remove any safepoint
+  // in this case since there's no safepoint dominating all paths in the loop body.
+  bool prune = !keep_one || keep != NULL;
+
   // Delete other safepoints in this loop.
   Node_List* sfpts = _safepts;
-  if (sfpts != NULL) {
+  if (prune && sfpts != NULL) {
     assert(keep == NULL || keep->Opcode() == Op_SafePoint, "not safepoint");
     for (uint i = 0; i < sfpts->size(); i++) {
       Node* n = sfpts->at(i);
@@ -1918,6 +1922,15 @@
     if (cl->is_main_loop()) tty->print(" main");
     if (cl->is_post_loop()) tty->print(" post");
   }
+  if (_has_call) tty->print(" has_call");
+  if (_has_sfpt) tty->print(" has_sfpt");
+  if (_rce_candidate) tty->print(" rce");
+  if (_safepts != NULL && _safepts->size() > 0) {
+    tty->print(" sfpts={"); _safepts->dump_simple(); tty->print(" }");
+  }
+  if (_required_safept != NULL && _required_safept->size() > 0) {
+    tty->print(" req={"); _required_safept->dump_simple(); tty->print(" }");
+  }
   tty->cr();
 }