< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

Print this page
*** 1203,17 ***
  
  class ShenandoahGCStatePropagatorHandshakeClosure : public HandshakeClosure {
  public:
    explicit ShenandoahGCStatePropagatorHandshakeClosure(char gc_state) :
      HandshakeClosure("Shenandoah GC State Change"),
!     _gc_state(gc_state) {}
  
    void do_thread(Thread* thread) override {
!     ShenandoahThreadLocalData::set_gc_state(thread, _gc_state);
    }
  private:
    char _gc_state;
  };
  
  class ShenandoahPrepareForUpdateRefsHandshakeClosure : public HandshakeClosure {
  public:
    explicit ShenandoahPrepareForUpdateRefsHandshakeClosure(char gc_state) :
--- 1203,18 ---
  
  class ShenandoahGCStatePropagatorHandshakeClosure : public HandshakeClosure {
  public:
    explicit ShenandoahGCStatePropagatorHandshakeClosure(char gc_state) :
      HandshakeClosure("Shenandoah GC State Change"),
!     _gc_state(gc_state), _gc_state_fast(ShenandoahThreadLocalData::compute_gc_state_fast(gc_state)) {}
  
    void do_thread(Thread* thread) override {
!     ShenandoahThreadLocalData::set_gc_state(thread, _gc_state, _gc_state_fast);
    }
  private:
    char _gc_state;
+   char _gc_state_fast;
  };
  
  class ShenandoahPrepareForUpdateRefsHandshakeClosure : public HandshakeClosure {
  public:
    explicit ShenandoahPrepareForUpdateRefsHandshakeClosure(char gc_state) :

*** 1230,10 ***
--- 1231,22 ---
    ShenandoahRetireGCLABClosure _retire;
    ShenandoahGCStatePropagatorHandshakeClosure _propagator;
  };
  
  void ShenandoahHeap::evacuate_collection_set(ShenandoahGeneration* generation, bool concurrent) {
+   if (concurrent && ShenandoahWeakRootsEarly) {
+     // Turn weak roots off now, so that weak barriers do not go slow.
+     {
+       MutexLocker lock(Threads_lock);
+       set_gc_state_concurrent(WEAK_ROOTS, false);
+     }
+ 
+     ShenandoahGCStatePropagatorHandshakeClosure propagate_gc_state(_gc_state.raw_value());
+     Threads::non_java_threads_do(&propagate_gc_state);
+     Handshake::execute(&propagate_gc_state);
+   }
+ 
    assert(generation->is_global(), "Only global generation expected here");
    ShenandoahEvacuationTask task(this, _collection_set, concurrent);
    workers()->run_task(&task);
  }
  

*** 1245,12 ***
      // by the following handshake.
      MutexLocker lock(Threads_lock);
  
      // A cancellation at this point means the degenerated cycle must resume from update-refs.
      set_gc_state_concurrent(EVACUATION, false);
-     set_gc_state_concurrent(WEAK_ROOTS, false);
      set_gc_state_concurrent(UPDATE_REFS, true);
    }
  
    // This will propagate the gc state and retire gclabs and plabs for threads that require it.
    ShenandoahPrepareForUpdateRefsHandshakeClosure prepare_for_update_refs(_gc_state.raw_value());
  
--- 1258,14 ---
      // by the following handshake.
      MutexLocker lock(Threads_lock);
  
      // A cancellation at this point means the degenerated cycle must resume from update-refs.
      set_gc_state_concurrent(EVACUATION, false);
      set_gc_state_concurrent(UPDATE_REFS, true);
+     if (!ShenandoahWeakRootsEarly) {
+       set_gc_state_concurrent(WEAK_ROOTS, false);
+     }
    }
  
    // This will propagate the gc state and retire gclabs and plabs for threads that require it.
    ShenandoahPrepareForUpdateRefsHandshakeClosure prepare_for_update_refs(_gc_state.raw_value());
  
< prev index next >