diff src/share/vm/opto/escape.cpp @ 38:b789bcaf2dd9

6667610: (Escape Analysis) retry compilation without EA if it fails Summary: During split unique types EA could exceed nodes limit and fail the method compilation. Reviewed-by: rasbold
author kvn
date Thu, 06 Mar 2008 10:30:17 -0800
parents a61af66fc99e
children 76256d272075
line wrap: on
line diff
--- a/src/share/vm/opto/escape.cpp	Wed Mar 05 11:33:31 2008 -0800
+++ b/src/share/vm/opto/escape.cpp	Thu Mar 06 10:30:17 2008 -0800
@@ -395,6 +395,15 @@
   if (result != NULL && C->get_alias_index(result->adr_type()) == alias_idx) {
     return result;
   }
+  if ((int)C->unique() + 2*NodeLimitFudgeFactor > MaxNodeLimit) {
+    if (C->do_escape_analysis() == true && !C->failing()) {
+      // Retry compilation without escape analysis.
+      // If this is the first failure, the sentinel string will "stick"
+      // to the Compile object, and the C2Compiler will see it and retry.
+      C->record_failure(C2Compiler::retry_no_escape_analysis());
+    }
+    return NULL;
+  }
 
   orig_phi_worklist.append_if_missing(orig_phi);
   result = PhiNode::make(orig_phi->in(0), NULL, Type::MEMORY, atype);
@@ -443,6 +452,9 @@
           mem = nphi;
         }
       }
+      if (C->failing()) {
+        return NULL;
+      }
       result->set_req(idx++, mem);
     }
 #ifdef ASSERT
@@ -672,6 +684,9 @@
       if (mem->is_Phi()) {
         mem = split_memory_phi(mem->as_Phi(), alias_idx, orig_phis, igvn);
       }
+      if (_compile->failing()) {
+        return;
+      }
       if (mem != n->in(MemNode::Memory))
         set_map(n->_idx, mem);
       if (n->is_Load()) {
@@ -742,7 +757,11 @@
           if((uint)_compile->get_general_index(ni) == i) {
             Node *m = (ni >= nmm->req()) ? nmm->empty_memory() : nmm->in(ni);
             if (nmm->is_empty_memory(m)) {
-              nmm->set_memory_at(ni, split_memory_phi(mem->as_Phi(), ni, orig_phis, igvn));
+              m = split_memory_phi(mem->as_Phi(), ni, orig_phis, igvn);
+              if (_compile->failing()) {
+                return;
+              }
+              nmm->set_memory_at(ni, m);
             }
           }
         }
@@ -881,6 +900,11 @@
   // Now use the escape information to create unique types for
   // unescaped objects
   split_unique_types(alloc_worklist);
+  if (_compile->failing())  return;
+
+  // Clean up after split unique types.
+  ResourceMark rm;
+  PhaseRemoveUseless pru(_compile->initial_gvn(), _compile->for_igvn());
 }
 
 Node * ConnectionGraph::skip_casts(Node *n) {