Skip to content

Commit

Permalink
8318183: C2: VM may crash after hitting node limit
Browse files Browse the repository at this point in the history
Reviewed-by: kvn, thartmann
  • Loading branch information
tstuefe committed Oct 18, 2023
1 parent 4e77b3c commit 31ef400
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!
}
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/opto/callGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
16 changes: 15 additions & 1 deletion src/hotspot/share/opto/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -2255,6 +2257,8 @@ void Compile::Optimize() {
// Inline valueOf() methods now.
inline_boxing_calls(igvn);

if (failing()) return;

if (AlwaysIncrementalInline) {
inline_incrementally(igvn);
}
Expand All @@ -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");
Expand All @@ -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()) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.)

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/opto/graphKit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/opto/loopnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/loopnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ class PhaseIdealLoop : public PhaseTransform {
if (!C->failing()) {
// Cleanup any modified bits
igvn.optimize();

if (C->failing()) { return; }
v.log_loop_tree();
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/opto/matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/opto/parse1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 31ef400

Please sign in to comment.