@@ -3879,7 +3879,7 @@ PhiNode *ConnectionGraph::create_split_phi(PhiNode *orig_phi, int alias_idx, Gro
38793879// Return a new version of Memory Phi "orig_phi" with the inputs having the
38803880// specified alias index.
38813881//
3882- PhiNode *ConnectionGraph::split_memory_phi (PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist) {
3882+ PhiNode *ConnectionGraph::split_memory_phi (PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist, uint rec_depth ) {
38833883 assert (alias_idx != Compile::AliasIdxBot, " can't split out bottom memory" );
38843884 Compile *C = _compile;
38853885 PhaseGVN* igvn = _igvn;
@@ -3895,7 +3895,7 @@ PhiNode *ConnectionGraph::split_memory_phi(PhiNode *orig_phi, int alias_idx, Gro
38953895 bool finished = false ;
38963896 while (!finished) {
38973897 while (idx < phi->req ()) {
3898- Node *mem = find_inst_mem (phi->in (idx), alias_idx, orig_phi_worklist);
3898+ Node *mem = find_inst_mem (phi->in (idx), alias_idx, orig_phi_worklist, rec_depth + 1 );
38993899 if (mem != nullptr && mem->is_Phi ()) {
39003900 PhiNode *newphi = create_split_phi (mem->as_Phi (), alias_idx, orig_phi_worklist, new_phi_created);
39013901 if (new_phi_created) {
@@ -4037,7 +4037,12 @@ void ConnectionGraph::move_inst_mem(Node* n, GrowableArray<PhiNode *> &orig_phi
40374037// Search memory chain of "mem" to find a MemNode whose address
40384038// is the specified alias index.
40394039//
4040- Node* ConnectionGraph::find_inst_mem (Node *orig_mem, int alias_idx, GrowableArray<PhiNode *> &orig_phis) {
4040+ #define FIND_INST_MEM_RECURSION_DEPTH_LIMIT 1000
4041+ Node* ConnectionGraph::find_inst_mem (Node *orig_mem, int alias_idx, GrowableArray<PhiNode *> &orig_phis, uint rec_depth) {
4042+ if (rec_depth > FIND_INST_MEM_RECURSION_DEPTH_LIMIT) {
4043+ _compile->record_failure (_invocation > 0 ? C2Compiler::retry_no_iterative_escape_analysis () : C2Compiler::retry_no_escape_analysis ());
4044+ return nullptr ;
4045+ }
40414046 if (orig_mem == nullptr ) {
40424047 return orig_mem;
40434048 }
@@ -4111,7 +4116,7 @@ Node* ConnectionGraph::find_inst_mem(Node *orig_mem, int alias_idx, GrowableArra
41114116 if (result == mmem->base_memory ()) {
41124117 // Didn't find instance memory, search through general slice recursively.
41134118 result = mmem->memory_at (C->get_general_index (alias_idx));
4114- result = find_inst_mem (result, alias_idx, orig_phis);
4119+ result = find_inst_mem (result, alias_idx, orig_phis, rec_depth + 1 );
41154120 if (C->failing ()) {
41164121 return nullptr ;
41174122 }
@@ -4179,7 +4184,7 @@ Node* ConnectionGraph::find_inst_mem(Node *orig_mem, int alias_idx, GrowableArra
41794184 orig_phis.append_if_missing (mphi);
41804185 } else if (C->get_alias_index (t) != alias_idx) {
41814186 // Create a new Phi with the specified alias index type.
4182- result = split_memory_phi (mphi, alias_idx, orig_phis);
4187+ result = split_memory_phi (mphi, alias_idx, orig_phis, rec_depth + 1 );
41834188 }
41844189 }
41854190 // the result is either MemNode, PhiNode, InitializeNode.
0 commit comments