From 324e43127362989cedf8c469780bc9a3d376bd5c Mon Sep 17 00:00:00 2001 From: Marc Chevalier Date: Fri, 17 Oct 2025 14:33:16 +0200 Subject: [PATCH 1/5] major_progress as bool --- src/hotspot/share/opto/compile.hpp | 10 +++++----- src/hotspot/share/opto/loopnode.cpp | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp index 66a5497a7ad16..955ae0800fc56 100644 --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -322,7 +322,7 @@ class Compile : public Phase { bool _merge_stores_phase; // Phase for merging stores, after post loop opts phase. bool _allow_macro_nodes; // True if we allow creation of macro nodes. - int _major_progress; // Count of something big happening + bool _major_progress; // Count of something big happening bool _inlining_progress; // progress doing incremental inlining? bool _inlining_incrementally;// Are we doing incremental inlining (post parse) bool _do_cleanup; // Cleanup is needed before proceeding with incremental inlining @@ -583,16 +583,16 @@ class Compile : public Phase { // Control of this compilation. int fixed_slots() const { assert(_fixed_slots >= 0, ""); return _fixed_slots; } void set_fixed_slots(int n) { _fixed_slots = n; } - int major_progress() const { return _major_progress; } void set_inlining_progress(bool z) { _inlining_progress = z; } int inlining_progress() const { return _inlining_progress; } void set_inlining_incrementally(bool z) { _inlining_incrementally = z; } int inlining_incrementally() const { return _inlining_incrementally; } void set_do_cleanup(bool z) { _do_cleanup = z; } int do_cleanup() const { return _do_cleanup; } - void set_major_progress() { _major_progress++; } - void restore_major_progress(int progress) { _major_progress += progress; } - void clear_major_progress() { _major_progress = 0; } + bool major_progress() const { return _major_progress; } + void set_major_progress() { _major_progress = true; } + void set_major_progress(bool progress) { _major_progress = progress; } + void clear_major_progress() { _major_progress = false; } int max_inline_size() const { return _max_inline_size; } void set_freq_inline_size(int n) { _freq_inline_size = n; } int freq_inline_size() const { return _freq_inline_size; } diff --git a/src/hotspot/share/opto/loopnode.cpp b/src/hotspot/share/opto/loopnode.cpp index e8058edb4e5e5..2c3cbc64f4c3e 100644 --- a/src/hotspot/share/opto/loopnode.cpp +++ b/src/hotspot/share/opto/loopnode.cpp @@ -4934,7 +4934,7 @@ void PhaseIdealLoop::build_and_optimize() { bool do_max_unroll = (_mode == LoopOptsMaxUnroll); - int old_progress = C->major_progress(); + bool old_progress = C->major_progress(); uint orig_worklist_size = _igvn._worklist.size(); // Reset major-progress flag for the driver's heuristics @@ -5094,7 +5094,7 @@ void PhaseIdealLoop::build_and_optimize() { if (C->failing()) { return; } if (_verify_only) { - C->restore_major_progress(old_progress); + C->set_major_progress(old_progress); assert(C->unique() == unique, "verification _mode made Nodes? ? ?"); assert(_igvn._worklist.size() == orig_worklist_size, "shouldn't push anything"); return; @@ -5139,7 +5139,7 @@ void PhaseIdealLoop::build_and_optimize() { #endif if (skip_loop_opts) { - C->restore_major_progress(old_progress); + C->set_major_progress(old_progress); return; } @@ -5160,7 +5160,7 @@ void PhaseIdealLoop::build_and_optimize() { } } - C->restore_major_progress(old_progress); + C->set_major_progress(old_progress); return; } @@ -5315,7 +5315,7 @@ void PhaseIdealLoop::print_statistics() { // Build a verify-only PhaseIdealLoop, and see that it agrees with "this". void PhaseIdealLoop::verify() const { ResourceMark rm; - int old_progress = C->major_progress(); + bool old_progress = C->major_progress(); bool success = true; PhaseIdealLoop phase_verify(_igvn, this); @@ -5332,7 +5332,7 @@ void PhaseIdealLoop::verify() const { assert(success, "VerifyLoopOptimizations failed"); // Major progress was cleared by creating a verify version of PhaseIdealLoop. - C->restore_major_progress(old_progress); + C->set_major_progress(old_progress); } // Perform a BFS starting at n, through all inputs. From 96a1bc7cd3ab0909227d7cae8a48100a97505699 Mon Sep 17 00:00:00 2001 From: Marc Chevalier Date: Wed, 22 Oct 2025 09:43:19 +0200 Subject: [PATCH 2/5] Adapt the comment --- src/hotspot/share/opto/compile.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp index 955ae0800fc56..b0e43a6a0080a 100644 --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -322,7 +322,7 @@ class Compile : public Phase { bool _merge_stores_phase; // Phase for merging stores, after post loop opts phase. bool _allow_macro_nodes; // True if we allow creation of macro nodes. - bool _major_progress; // Count of something big happening + bool _major_progress; // Whether something big happened bool _inlining_progress; // progress doing incremental inlining? bool _inlining_incrementally;// Are we doing incremental inlining (post parse) bool _do_cleanup; // Cleanup is needed before proceeding with incremental inlining From 9e5612a19b1e117dd08323d3baeb59cb2e30d90e Mon Sep 17 00:00:00 2001 From: Marc Chevalier Date: Fri, 24 Oct 2025 10:37:56 +0200 Subject: [PATCH 3/5] More comment --- src/hotspot/share/opto/compile.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp index b0e43a6a0080a..c2f03444547ca 100644 --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -322,7 +322,16 @@ class Compile : public Phase { bool _merge_stores_phase; // Phase for merging stores, after post loop opts phase. bool _allow_macro_nodes; // True if we allow creation of macro nodes. - bool _major_progress; // Whether something big happened + /* If major progress is set: + * Marks that the loop tree information (get_ctrl, idom, get_loop, etc.) could be invalid, and we need to rebuild the loop tree. + * It also indicates that the graph was changed in a way that is promising to be able to apply more loop optimization + * If major progress is not set: + * Loop tree information is valid. + * If major progress is not set at the end of a loop opts phase, then we can stop loop opts, because we do not expect any further progress if we did more loop ops phases. + * + * This is not 100% accurate, the semantics of major progress has become less clear over time, but this is the general idea. + */ + bool _major_progress; bool _inlining_progress; // progress doing incremental inlining? bool _inlining_incrementally;// Are we doing incremental inlining (post parse) bool _do_cleanup; // Cleanup is needed before proceeding with incremental inlining From c0b0bdec3d4189c148095e91515b26686dc2114b Mon Sep 17 00:00:00 2001 From: Marc Chevalier Date: Sun, 26 Oct 2025 15:04:14 +0100 Subject: [PATCH 4/5] put back the OR in restORe --- src/hotspot/share/opto/compile.hpp | 2 +- src/hotspot/share/opto/loopnode.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp index c2f03444547ca..4a695478019fb 100644 --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -600,7 +600,7 @@ class Compile : public Phase { int do_cleanup() const { return _do_cleanup; } bool major_progress() const { return _major_progress; } void set_major_progress() { _major_progress = true; } - void set_major_progress(bool progress) { _major_progress = progress; } + void restore_major_progress(bool progress) { _major_progress = _major_progress || progress; } void clear_major_progress() { _major_progress = false; } int max_inline_size() const { return _max_inline_size; } void set_freq_inline_size(int n) { _freq_inline_size = n; } diff --git a/src/hotspot/share/opto/loopnode.cpp b/src/hotspot/share/opto/loopnode.cpp index 2c3cbc64f4c3e..3279c41d6927b 100644 --- a/src/hotspot/share/opto/loopnode.cpp +++ b/src/hotspot/share/opto/loopnode.cpp @@ -5094,7 +5094,7 @@ void PhaseIdealLoop::build_and_optimize() { if (C->failing()) { return; } if (_verify_only) { - C->set_major_progress(old_progress); + C->restore_major_progress(old_progress); assert(C->unique() == unique, "verification _mode made Nodes? ? ?"); assert(_igvn._worklist.size() == orig_worklist_size, "shouldn't push anything"); return; @@ -5139,7 +5139,7 @@ void PhaseIdealLoop::build_and_optimize() { #endif if (skip_loop_opts) { - C->set_major_progress(old_progress); + C->restore_major_progress(old_progress); return; } @@ -5160,7 +5160,7 @@ void PhaseIdealLoop::build_and_optimize() { } } - C->set_major_progress(old_progress); + C->restore_major_progress(old_progress); return; } @@ -5332,7 +5332,7 @@ void PhaseIdealLoop::verify() const { assert(success, "VerifyLoopOptimizations failed"); // Major progress was cleared by creating a verify version of PhaseIdealLoop. - C->set_major_progress(old_progress); + C->restore_major_progress(old_progress); } // Perform a BFS starting at n, through all inputs. From a774b904bbaf12bbdf7261ecd07faaecc8ecdf06 Mon Sep 17 00:00:00 2001 From: Marc Chevalier Date: Tue, 28 Oct 2025 08:16:50 +0100 Subject: [PATCH 5/5] typoes in comment --- src/hotspot/share/opto/compile.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp index 4a695478019fb..845dcf0751277 100644 --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -324,10 +324,10 @@ class Compile : public Phase { /* If major progress is set: * Marks that the loop tree information (get_ctrl, idom, get_loop, etc.) could be invalid, and we need to rebuild the loop tree. - * It also indicates that the graph was changed in a way that is promising to be able to apply more loop optimization + * It also indicates that the graph was changed in a way that is promising to be able to apply more loop optimization. * If major progress is not set: * Loop tree information is valid. - * If major progress is not set at the end of a loop opts phase, then we can stop loop opts, because we do not expect any further progress if we did more loop ops phases. + * If major progress is not set at the end of a loop opts phase, then we can stop loop opts, because we do not expect any further progress if we did more loop opts phases. * * This is not 100% accurate, the semantics of major progress has become less clear over time, but this is the general idea. */