8253778: ShenandoahSafepoint::is_at_shenandoah_safepoint should not access VMThread state from other threads

Reviewed-by: jiefu, rehn, rkennke
This commit is contained in:
Aleksey Shipilev 2020-09-30 08:58:24 +00:00
parent 4c65365116
commit 8331e63fe4

View File

@ -141,10 +141,17 @@ public:
class ShenandoahSafepoint : public AllStatic {
public:
// check if Shenandoah GC safepoint is in progress
// Check if Shenandoah GC safepoint is in progress. This is nominally
// equivalent to calling SafepointSynchronize::is_at_safepoint(), but
// it also checks the Shenandoah specifics, when it can.
static inline bool is_at_shenandoah_safepoint() {
if (!SafepointSynchronize::is_at_safepoint()) 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;
// Otherwise check we are at proper operation type
VM_Operation* vm_op = VMThread::vm_operation();
if (vm_op == NULL) return false;