< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp

Print this page

 40 class ShenandoahPeriodicTask : public PeriodicTask {
 41 private:
 42   ShenandoahControlThread* _thread;
 43 public:
 44   ShenandoahPeriodicTask(ShenandoahControlThread* thread) :
 45           PeriodicTask(100), _thread(thread) {}
 46   virtual void task();
 47 };
 48 
 49 // Periodic task to notify blocked paced waiters.
 50 class ShenandoahPeriodicPacerNotify : public PeriodicTask {
 51 public:
 52   ShenandoahPeriodicPacerNotify() : PeriodicTask(PeriodicTask::min_interval) {}
 53   virtual void task();
 54 };
 55 
 56 class ShenandoahControlThread: public ConcurrentGCThread {
 57   friend class VMStructs;
 58 
 59 private:
 60   typedef enum {
 61     none,
 62     concurrent_normal,
 63     stw_degenerated,
 64     stw_full
 65   } GCMode;
 66 
 67   // While we could have a single lock for these, it may risk unblocking
 68   // GC waiters when alloc failure GC cycle finishes. We want instead
 69   // to make complete explicit cycle for for demanding customers.
 70   Monitor _alloc_failure_waiters_lock;
 71   Monitor _gc_waiters_lock;


 72   ShenandoahPeriodicTask _periodic_task;
 73   ShenandoahPeriodicPacerNotify _periodic_pacer_notify_task;
 74 
 75 public:








 76   void run_service();
 77   void stop_service();
 78 


 79 private:


 80   ShenandoahSharedFlag _gc_requested;
 81   ShenandoahSharedFlag _alloc_failure_gc;
 82   ShenandoahSharedFlag _graceful_shutdown;
 83   ShenandoahSharedFlag _heap_changed;
 84   ShenandoahSharedFlag _do_counters_update;
 85   ShenandoahSharedFlag _force_counters_update;
 86   GCCause::Cause       _requested_gc_cause;

 87   ShenandoahGC::ShenandoahDegenPoint _degen_point;

 88 
 89   shenandoah_padding(0);
 90   volatile size_t _allocs_seen;
 91   shenandoah_padding(1);
 92   volatile size_t _gc_id;
 93   shenandoah_padding(2);


 94 

 95   bool check_cancellation_or_degen(ShenandoahGC::ShenandoahDegenPoint point);
 96   void service_concurrent_normal_cycle(GCCause::Cause cause);



 97   void service_stw_full_cycle(GCCause::Cause cause);
 98   void service_stw_degenerated_cycle(GCCause::Cause cause, ShenandoahGC::ShenandoahDegenPoint point);



 99   void service_uncommit(double shrink_before, size_t shrink_until);
100 

101   bool try_set_alloc_failure_gc();

102   void notify_alloc_failure_waiters();

103   bool is_alloc_failure_gc();
104 
105   void reset_gc_id();
106   void update_gc_id();
107   size_t get_gc_id();
108 
109   void notify_gc_waiters();
110 
111   // Handle GC request.
112   // Blocks until GC is over.
113   void handle_requested_gc(GCCause::Cause cause);
114 
115   bool is_explicit_gc(GCCause::Cause cause) const;




116 

117   bool check_soft_max_changed() const;
118 


119 public:
120   // Constructor
121   ShenandoahControlThread();
122   ~ShenandoahControlThread();
123 
124   // Handle allocation failure from normal allocation.
125   // Blocks until memory is available.
126   void handle_alloc_failure(ShenandoahAllocRequest& req);
127 
128   // Handle allocation failure from evacuation path.
129   // Optionally blocks while collector is handling the failure.
130   void handle_alloc_failure_evac(size_t words);
131 
132   void request_gc(GCCause::Cause cause);


133 
134   void handle_counters_update();
135   void handle_force_counters_update();
136   void set_forced_counters_update(bool value);
137 
138   void notify_heap_changed();
139 
140   void pacing_notify_alloc(size_t words);
141 
142   void start();
143   void prepare_for_graceful_shutdown();
144   bool in_graceful_shutdown();




















145 };
146 
147 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCONTROLTHREAD_HPP

 40 class ShenandoahPeriodicTask : public PeriodicTask {
 41 private:
 42   ShenandoahControlThread* _thread;
 43 public:
 44   ShenandoahPeriodicTask(ShenandoahControlThread* thread) :
 45           PeriodicTask(100), _thread(thread) {}
 46   virtual void task();
 47 };
 48 
 49 // Periodic task to notify blocked paced waiters.
 50 class ShenandoahPeriodicPacerNotify : public PeriodicTask {
 51 public:
 52   ShenandoahPeriodicPacerNotify() : PeriodicTask(PeriodicTask::min_interval) {}
 53   virtual void task();
 54 };
 55 
 56 class ShenandoahControlThread: public ConcurrentGCThread {
 57   friend class VMStructs;
 58 
 59 private:







 60   // While we could have a single lock for these, it may risk unblocking
 61   // GC waiters when alloc failure GC cycle finishes. We want instead
 62   // to make complete explicit cycle for demanding customers.
 63   Monitor _alloc_failure_waiters_lock;
 64   Monitor _gc_waiters_lock;
 65   Monitor _control_lock;
 66   Monitor _regulator_lock;
 67   ShenandoahPeriodicTask _periodic_task;
 68   ShenandoahPeriodicPacerNotify _periodic_pacer_notify_task;
 69 
 70 public:
 71   typedef enum {
 72     none,
 73     concurrent_normal,
 74     stw_degenerated,
 75     stw_full,
 76     servicing_old
 77   } GCMode;
 78 
 79   void run_service();
 80   void stop_service();
 81 
 82   size_t get_gc_id();
 83 
 84 private:
 85   ShenandoahSharedFlag _allow_old_preemption;
 86   ShenandoahSharedFlag _preemption_requested;
 87   ShenandoahSharedFlag _gc_requested;
 88   ShenandoahSharedFlag _alloc_failure_gc;
 89   ShenandoahSharedFlag _graceful_shutdown;

 90   ShenandoahSharedFlag _do_counters_update;
 91   ShenandoahSharedFlag _force_counters_update;
 92   GCCause::Cause       _requested_gc_cause;
 93   GenerationMode       _requested_generation;
 94   ShenandoahGC::ShenandoahDegenPoint _degen_point;
 95   ShenandoahGeneration* _degen_generation;
 96 
 97   shenandoah_padding(0);
 98   volatile size_t _allocs_seen;
 99   shenandoah_padding(1);
100   volatile size_t _gc_id;
101   shenandoah_padding(2);
102   volatile GCMode _mode;
103   shenandoah_padding(3);
104 
105   // Returns true if the cycle has been cancelled or degenerated.
106   bool check_cancellation_or_degen(ShenandoahGC::ShenandoahDegenPoint point);
107 
108   // Returns true if the old generation marking completed (i.e., final mark executed for old generation).
109   bool resume_concurrent_old_cycle(ShenandoahGeneration* generation, GCCause::Cause cause);
110   void service_concurrent_cycle(ShenandoahGeneration* generation, GCCause::Cause cause, bool reset_old_bitmap_specially);
111   void service_stw_full_cycle(GCCause::Cause cause);
112 
113   // Return true if degenerated cycle finishes normally.  Return false if the degenerated cycle transformed itself
114   // into a full GC.
115   bool service_stw_degenerated_cycle(GCCause::Cause cause, ShenandoahGC::ShenandoahDegenPoint point);
116   void service_uncommit(double shrink_before, size_t shrink_until);
117 
118   // Return true if setting the flag which indicates allocation failure succeeds.
119   bool try_set_alloc_failure_gc();
120   // Notify threads waiting for GC to complete.
121   void notify_alloc_failure_waiters();
122   // True if allocation failure flag has been set.
123   bool is_alloc_failure_gc();
124 
125   void reset_gc_id();
126   void update_gc_id();

127 
128   void notify_gc_waiters();
129 
130   // Handle GC request.
131   // Blocks until GC is over.
132   void handle_requested_gc(GCCause::Cause cause);
133 
134   bool is_explicit_gc(GCCause::Cause cause) const;
135   bool is_implicit_gc(GCCause::Cause cause) const;
136 
137   // Returns true if the old generation marking was interrupted to allow a young cycle.
138   bool preempt_old_marking(GenerationMode generation);
139 
140   // Returns true if the soft maximum heap has been changed using management APIs.
141   bool check_soft_max_changed() const;
142 
143   void process_phase_timings(const ShenandoahHeap* heap);
144 
145 public:
146   // Constructor
147   ShenandoahControlThread();
148   ~ShenandoahControlThread();
149 
150   // Handle allocation failure from normal allocation.
151   // Blocks until memory is available.
152   void handle_alloc_failure(ShenandoahAllocRequest& req);
153 
154   // Handle allocation failure from evacuation path.
155   // Optionally blocks while collector is handling the failure.
156   void handle_alloc_failure_evac(size_t words);
157 
158   void request_gc(GCCause::Cause cause);
159   // Return true if the request to start a concurrent GC for the given generation succeeded.
160   bool request_concurrent_gc(GenerationMode generation);
161 
162   void handle_counters_update();
163   void handle_force_counters_update();
164   void set_forced_counters_update(bool value);
165 
166   void notify_heap_changed();
167 
168   void pacing_notify_alloc(size_t words);
169 
170   void start();
171   void prepare_for_graceful_shutdown();
172   bool in_graceful_shutdown();
173 
174   void service_concurrent_normal_cycle(const ShenandoahHeap* heap,
175                                        const GenerationMode generation,
176                                        GCCause::Cause cause);
177 
178   void service_concurrent_old_cycle(const ShenandoahHeap* heap,
179                                     GCCause::Cause &cause);
180 
181   void set_gc_mode(GCMode new_mode);
182   GCMode gc_mode() {
183     return _mode;
184   }
185 
186  private:
187   static const char* gc_mode_name(GCMode mode);
188   void notify_control_thread();
189 
190   void service_concurrent_cycle(const ShenandoahHeap* heap, ShenandoahGeneration* generation, GCCause::Cause &cause,
191                                 bool do_old_gc_bootstrap);
192 
193 };
194 
195 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCONTROLTHREAD_HPP
< prev index next >