Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8257641: Shenandoah: Query is_at_shenandoah_safepoint() from control …
…thread should return false

Reviewed-by: shade
  • Loading branch information
zhengyu123 committed Dec 3, 2020
1 parent 55f5542 commit e29ee5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp
Expand Up @@ -122,6 +122,7 @@ class ShenandoahHeap : public CollectedHeap {
friend class ShenandoahGCSession;
friend class ShenandoahGCStateResetter;
friend class ShenandoahParallelObjectIterator;
friend class ShenandoahSafepoint;
// ---------- Locks that guard important data structures in Heap
//
private:
Expand Down
8 changes: 7 additions & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp
Expand Up @@ -147,9 +147,15 @@ class ShenandoahSafepoint : public AllStatic {
static inline bool is_at_shenandoah_safepoint() {
if (!SafepointSynchronize::is_at_safepoint()) return false;

Thread* const thr = Thread::current();
// Shenandoah GC specific safepoints are scheduled by control thread.
// So if we are enter here from control thread, then we are definitely not
// at Shenandoah safepoint, but at something else.
if (thr == ShenandoahHeap::heap()->control_thread()) return false;

// This is not VM thread, cannot see what VM thread is doing,
// so pretend this is a proper Shenandoah safepoint
if (!Thread::current()->is_VM_thread()) return true;
if (!thr->is_VM_thread()) return true;

// Otherwise check we are at proper operation type
VM_Operation* vm_op = VMThread::vm_operation();
Expand Down

1 comment on commit e29ee5b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.