commit 0f5129a223d42d81e6513d59822f652e97a8abdb
Author: Marc Chevalier <marc.chevalier@oracle.com>
Date:   2025-10-22 21:32:36 +0200

    With instrumentation

diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp
index 6babc13e1b3..48aa4b4883f 100644
--- a/src/hotspot/share/opto/compile.cpp
+++ b/src/hotspot/share/opto/compile.cpp
@@ -1061,6 +1061,7 @@ void Compile::Init(bool aliasing) {
   set_has_boxed_value(false);
   _trap_can_recompile = false;  // no traps emitted yet
   _major_progress = true; // start out assuming good things will happen
+  _old_major_progress = true; // start out assuming good things will happen
   set_has_unsafe_access(false);
   set_max_vector_size(0);
   set_clear_upper_avx(false);  //false as default for clear upper bits of ymm registers
@@ -2182,6 +2183,7 @@ void Compile::inline_incrementally(PhaseIterGVN& igvn) {
         if (failing())  return;
         low_live_nodes = live_nodes();
         _major_progress = true;
+        _old_major_progress = true;
       }
 
       if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp
index b0e43a6a008..dc38084d16a 100644
--- a/src/hotspot/share/opto/compile.hpp
+++ b/src/hotspot/share/opto/compile.hpp
@@ -322,6 +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 _old_major_progress;
   bool                  _major_progress;        // Whether something big happened
   bool                  _inlining_progress;     // progress doing incremental inlining?
   bool                  _inlining_incrementally;// Are we doing incremental inlining (post parse)
@@ -589,10 +590,19 @@ class Compile : public Phase {
   int               inlining_incrementally() const { return _inlining_incrementally; }
   void          set_do_cleanup(bool z)          { _do_cleanup = z; }
   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        clear_major_progress()            { _major_progress = false; }
+  bool              major_progress() const {
+#ifdef ASSERT
+    if ((_old_major_progress > 0) != _major_progress) {
+      tty->print_cr("_old_major_progress: %d; _major_progress: %d", _old_major_progress, _major_progress);
+      assert((_old_major_progress > 0) == _major_progress, "should match");
+    }
+#endif
+    return _major_progress;
+  }
+  int old_major_progress() const { return _old_major_progress;  }
+  void          set_major_progress()            { _old_major_progress++; _major_progress = true; }
+  void          set_major_progress(bool progress, int old_progress) { _old_major_progress += old_progress; _major_progress = progress; }
+  void        clear_major_progress()            { _old_major_progress = 0; _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 2c3cbc64f4c..3e987458133 100644
--- a/src/hotspot/share/opto/loopnode.cpp
+++ b/src/hotspot/share/opto/loopnode.cpp
@@ -4935,6 +4935,7 @@ void PhaseIdealLoop::build_and_optimize() {
 
 
   bool old_progress = C->major_progress();
+  int old_old_progress = C->old_major_progress();
   uint orig_worklist_size = _igvn._worklist.size();
 
   // Reset major-progress flag for the driver's heuristics
@@ -5094,7 +5095,7 @@ void PhaseIdealLoop::build_and_optimize() {
   if (C->failing()) { return; }
 
   if (_verify_only) {
-    C->set_major_progress(old_progress);
+    C->set_major_progress(old_progress, old_old_progress);
     assert(C->unique() == unique, "verification _mode made Nodes? ? ?");
     assert(_igvn._worklist.size() == orig_worklist_size, "shouldn't push anything");
     return;
@@ -5139,7 +5140,7 @@ void PhaseIdealLoop::build_and_optimize() {
 #endif
 
   if (skip_loop_opts) {
-    C->set_major_progress(old_progress);
+    C->set_major_progress(old_progress, old_old_progress);
     return;
   }
 
@@ -5160,7 +5161,7 @@ void PhaseIdealLoop::build_and_optimize() {
       }
     }
 
-    C->set_major_progress(old_progress);
+    C->set_major_progress(old_progress, old_old_progress);
     return;
   }
 
@@ -5316,6 +5317,7 @@ void PhaseIdealLoop::print_statistics() {
 void PhaseIdealLoop::verify() const {
   ResourceMark rm;
   bool old_progress = C->major_progress();
+  int old_old_progress = C->old_major_progress();
   bool success = true;
 
   PhaseIdealLoop phase_verify(_igvn, this);
@@ -5332,7 +5334,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->set_major_progress(old_progress, old_old_progress);
 }
 
 // Perform a BFS starting at n, through all inputs.
