174
175 Thread* const thr = Thread::current();
176 // Shenandoah GC specific safepoints are scheduled by control thread.
177 // So if we are enter here from control thread, then we are definitely not
178 // at Shenandoah safepoint, but at something else.
179 if (thr == ShenandoahHeap::heap()->control_thread()) return false;
180
181 // This is not VM thread, cannot see what VM thread is doing,
182 // so pretend this is a proper Shenandoah safepoint
183 if (!thr->is_VM_thread()) return true;
184
185 // Otherwise check we are at proper operation type
186 VM_Operation* vm_op = VMThread::vm_operation();
187 if (vm_op == nullptr) return false;
188
189 VM_Operation::VMOp_Type type = vm_op->type();
190 return type == VM_Operation::VMOp_ShenandoahInitMark ||
191 type == VM_Operation::VMOp_ShenandoahFinalMarkStartEvac ||
192 type == VM_Operation::VMOp_ShenandoahInitUpdateRefs ||
193 type == VM_Operation::VMOp_ShenandoahFinalUpdateRefs ||
194 type == VM_Operation::VMOp_ShenandoahFinalVerify ||
195 type == VM_Operation::VMOp_ShenandoahFullGC ||
196 type == VM_Operation::VMOp_ShenandoahDegeneratedGC;
197 }
198 };
199
200 class ShenandoahWorkerSession : public StackObj {
201 protected:
202 ShenandoahWorkerSession(uint worker_id);
203 public:
204 static inline uint worker_id() {
205 return WorkerThread::worker_id();
206 }
207 };
208
209 class ShenandoahConcurrentWorkerSession : public ShenandoahWorkerSession {
210 private:
211 EventGCPhaseConcurrent _event;
212
213 public:
214 ShenandoahConcurrentWorkerSession(uint worker_id) : ShenandoahWorkerSession(worker_id) { }
|
174
175 Thread* const thr = Thread::current();
176 // Shenandoah GC specific safepoints are scheduled by control thread.
177 // So if we are enter here from control thread, then we are definitely not
178 // at Shenandoah safepoint, but at something else.
179 if (thr == ShenandoahHeap::heap()->control_thread()) return false;
180
181 // This is not VM thread, cannot see what VM thread is doing,
182 // so pretend this is a proper Shenandoah safepoint
183 if (!thr->is_VM_thread()) return true;
184
185 // Otherwise check we are at proper operation type
186 VM_Operation* vm_op = VMThread::vm_operation();
187 if (vm_op == nullptr) return false;
188
189 VM_Operation::VMOp_Type type = vm_op->type();
190 return type == VM_Operation::VMOp_ShenandoahInitMark ||
191 type == VM_Operation::VMOp_ShenandoahFinalMarkStartEvac ||
192 type == VM_Operation::VMOp_ShenandoahInitUpdateRefs ||
193 type == VM_Operation::VMOp_ShenandoahFinalUpdateRefs ||
194 type == VM_Operation::VMOp_ShenandoahFinalRoots ||
195 type == VM_Operation::VMOp_ShenandoahFullGC ||
196 type == VM_Operation::VMOp_ShenandoahDegeneratedGC;
197 }
198 };
199
200 class ShenandoahWorkerSession : public StackObj {
201 protected:
202 ShenandoahWorkerSession(uint worker_id);
203 public:
204 static inline uint worker_id() {
205 return WorkerThread::worker_id();
206 }
207 };
208
209 class ShenandoahConcurrentWorkerSession : public ShenandoahWorkerSession {
210 private:
211 EventGCPhaseConcurrent _event;
212
213 public:
214 ShenandoahConcurrentWorkerSession(uint worker_id) : ShenandoahWorkerSession(worker_id) { }
|