8318183: C2: VM may crash after hitting node limit

Reviewed-by: kvn, thartmann
This commit is contained in:
Thomas Stuefe 2023-10-18 08:39:00 +00:00
parent 4e77b3c378
commit 31ef400f31
8 changed files with 26 additions and 4 deletions

@ -63,6 +63,7 @@ bool ShenandoahBarrierC2Support::expand(Compile* C, PhaseIterGVN& igvn) {
C->clear_major_progress();
C->process_for_post_loop_opts_igvn(igvn);
if (C->failing()) return false;
}
C->set_post_loop_opts_phase(); // now for real!
}

@ -97,6 +97,8 @@ JVMState* ParseGenerator::generate(JVMState* jvms) {
}
Parse parser(jvms, method(), _expected_uses);
if (C->failing()) return nullptr;
// Grab signature for matching/allocation
GraphKit& exits = parser.exits();

@ -2245,6 +2245,8 @@ void Compile::Optimize() {
process_for_unstable_if_traps(igvn);
if (failing()) return;
inline_incrementally(igvn);
print_method(PHASE_INCREMENTAL_INLINE, 2);
@ -2255,6 +2257,8 @@ void Compile::Optimize() {
// Inline valueOf() methods now.
inline_boxing_calls(igvn);
if (failing()) return;
if (AlwaysIncrementalInline) {
inline_incrementally(igvn);
}
@ -2270,16 +2274,20 @@ void Compile::Optimize() {
// CastPP nodes.
remove_speculative_types(igvn);
if (failing()) return;
// No more new expensive nodes will be added to the list from here
// so keep only the actual candidates for optimizations.
cleanup_expensive_nodes(igvn);
if (failing()) return;
assert(EnableVectorSupport || !has_vbox_nodes(), "sanity");
if (EnableVectorSupport && has_vbox_nodes()) {
TracePhase tp("", &timers[_t_vector]);
PhaseVector pv(igvn);
pv.optimize_vector_boxes();
if (failing()) return;
print_method(PHASE_ITER_GVN_AFTER_VECTOR, 2);
}
assert(!has_vbox_nodes(), "sanity");
@ -2299,6 +2307,8 @@ void Compile::Optimize() {
// safepoints
remove_root_to_sfpts_edges(igvn);
if (failing()) return;
// Perform escape analysis
if (do_escape_analysis() && ConnectionGraph::has_candidates(this)) {
if (has_loops()) {
@ -2411,6 +2421,8 @@ void Compile::Optimize() {
process_for_post_loop_opts_igvn(igvn);
if (failing()) return;
#ifdef ASSERT
bs->verify_gc_barriers(this, BarrierSetC2::BeforeMacroExpand);
#endif
@ -2449,6 +2461,7 @@ void Compile::Optimize() {
// More opportunities to optimize virtual and MH calls.
// Though it's maybe too late to perform inlining, strength-reducing them to direct calls is still an option.
process_late_inline_calls_no_inline(igvn);
if (failing()) return;
}
} // (End scope of igvn; run destructor if necessary for asserts.)
@ -4925,6 +4938,7 @@ void Compile::remove_speculative_types(PhaseIterGVN &igvn) {
igvn.remove_speculative_types();
if (modified > 0) {
igvn.optimize();
if (failing()) return;
}
#ifdef ASSERT
// Verify that after the IGVN is over no speculative type has resurfaced

@ -82,7 +82,8 @@ class GraphKit : public Phase {
#ifdef ASSERT
~GraphKit() {
assert(!has_exceptions(), "user must call transfer_exceptions_into_jvms");
assert(failing() || !has_exceptions(),
"unless compilation failed, user must call transfer_exceptions_into_jvms");
}
#endif

@ -4692,6 +4692,7 @@ void PhaseIdealLoop::verify() const {
bool success = true;
PhaseIdealLoop phase_verify(_igvn, this);
if (C->failing()) return;
// Verify ctrl and idom of every node.
success &= verify_idom_and_nodes(C->root(), &phase_verify);

@ -1194,7 +1194,7 @@ public:
if (!C->failing()) {
// Cleanup any modified bits
igvn.optimize();
if (C->failing()) { return; }
v.log_loop_tree();
}
}

@ -356,7 +356,9 @@ void Matcher::match( ) {
// Recursively match trees from old space into new space.
// Correct leaves of new-space Nodes; they point to old-space.
_visited.clear();
C->set_cached_top_node(xform( C->top(), live_nodes ));
Node* const n = xform(C->top(), live_nodes);
if (C->failing()) return;
C->set_cached_top_node(n);
if (!C->failing()) {
Node* xroot = xform( C->root(), 1 );
if (xroot == nullptr) {

@ -1575,6 +1575,7 @@ void Parse::do_one_block() {
#endif //ASSERT
do_one_bytecode();
if (failing()) return;
assert(!have_se || stopped() || failing() || (sp() - pre_bc_sp) == depth,
"incorrect depth prediction: sp=%d, pre_bc_sp=%d, depth=%d", sp(), pre_bc_sp, depth);