@@ -2762,7 +2762,7 @@ PhiNode *ConnectionGraph::create_split_phi(PhiNode *orig_phi, int alias_idx, Gro
27622762// Return a new version of Memory Phi "orig_phi" with the inputs having the
27632763// specified alias index.
27642764//
2765- PhiNode *ConnectionGraph::split_memory_phi (PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist) {
2765+ PhiNode *ConnectionGraph::split_memory_phi (PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist, uint rec_depth ) {
27662766 assert (alias_idx != Compile::AliasIdxBot, " can't split out bottom memory" );
27672767 Compile *C = _compile;
27682768 PhaseGVN* igvn = _igvn;
@@ -2778,7 +2778,7 @@ PhiNode *ConnectionGraph::split_memory_phi(PhiNode *orig_phi, int alias_idx, Gro
27782778 bool finished = false ;
27792779 while (!finished) {
27802780 while (idx < phi->req ()) {
2781- Node *mem = find_inst_mem (phi->in (idx), alias_idx, orig_phi_worklist);
2781+ Node *mem = find_inst_mem (phi->in (idx), alias_idx, orig_phi_worklist, rec_depth + 1 );
27822782 if (mem != nullptr && mem->is_Phi ()) {
27832783 PhiNode *newphi = create_split_phi (mem->as_Phi (), alias_idx, orig_phi_worklist, new_phi_created);
27842784 if (new_phi_created) {
@@ -2920,7 +2920,12 @@ void ConnectionGraph::move_inst_mem(Node* n, GrowableArray<PhiNode *> &orig_phi
29202920// Search memory chain of "mem" to find a MemNode whose address
29212921// is the specified alias index.
29222922//
2923- Node* ConnectionGraph::find_inst_mem (Node *orig_mem, int alias_idx, GrowableArray<PhiNode *> &orig_phis) {
2923+ #define FIND_INST_MEM_RECURSION_DEPTH_LIMIT 1000
2924+ Node* ConnectionGraph::find_inst_mem (Node *orig_mem, int alias_idx, GrowableArray<PhiNode *> &orig_phis, uint rec_depth) {
2925+ if (rec_depth > FIND_INST_MEM_RECURSION_DEPTH_LIMIT) {
2926+ _compile->record_failure (_invocation > 0 ? C2Compiler::retry_no_iterative_escape_analysis () : C2Compiler::retry_no_escape_analysis ());
2927+ return nullptr ;
2928+ }
29242929 if (orig_mem == nullptr ) {
29252930 return orig_mem;
29262931 }
@@ -2994,7 +2999,7 @@ Node* ConnectionGraph::find_inst_mem(Node *orig_mem, int alias_idx, GrowableArra
29942999 if (result == mmem->base_memory ()) {
29953000 // Didn't find instance memory, search through general slice recursively.
29963001 result = mmem->memory_at (C->get_general_index (alias_idx));
2997- result = find_inst_mem (result, alias_idx, orig_phis);
3002+ result = find_inst_mem (result, alias_idx, orig_phis, rec_depth + 1 );
29983003 if (C->failing ()) {
29993004 return nullptr ;
30003005 }
@@ -3062,7 +3067,7 @@ Node* ConnectionGraph::find_inst_mem(Node *orig_mem, int alias_idx, GrowableArra
30623067 orig_phis.append_if_missing (mphi);
30633068 } else if (C->get_alias_index (t) != alias_idx) {
30643069 // Create a new Phi with the specified alias index type.
3065- result = split_memory_phi (mphi, alias_idx, orig_phis);
3070+ result = split_memory_phi (mphi, alias_idx, orig_phis, rec_depth + 1 );
30663071 }
30673072 }
30683073 // the result is either MemNode, PhiNode, InitializeNode.
0 commit comments