Skip to content

Commit

Permalink
Extra assertions that gc state synchronization is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
earthling-amzn committed Dec 15, 2023
1 parent 91a5cee commit 93d0f4e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ class ShenandoahHeap : public CollectedHeap, public ShenandoahSpaceInfo {
public:
char gc_state() const;
void set_gc_state_all_threads();
bool has_gc_state_changed() { return _gc_state_changed; }

void set_concurrent_mark_in_progress(bool in_progress);
void set_evacuation_in_progress(bool in_progress);
Expand Down
11 changes: 11 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,23 @@
#include "interpreter/oopMapCache.hpp"
#include "memory/universe.hpp"

bool VM_ShenandoahOperation::doit_prologue() {
assert(!ShenandoahHeap::heap()->has_gc_state_changed(), "GC State can only be changed on a safepoint.");
return true;
}

void VM_ShenandoahOperation::doit_epilogue() {
assert(!ShenandoahHeap::heap()->has_gc_state_changed(), "GC State was not synchronized to java threads.");
}

bool VM_ShenandoahReferenceOperation::doit_prologue() {
VM_ShenandoahOperation::doit_prologue();
Heap_lock->lock();
return true;
}

void VM_ShenandoahReferenceOperation::doit_epilogue() {
VM_ShenandoahOperation::doit_epilogue();
OopMapCache::cleanup_old_entries();
if (Universe::has_reference_pending_list()) {
Heap_lock->notify_all();
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahVMOperations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class VM_ShenandoahOperation : public VM_Operation {
public:
VM_ShenandoahOperation() : _gc_id(GCId::current()) {};
virtual bool skip_thread_oop_barriers() const { return true; }
bool doit_prologue() override;
void doit_epilogue() override;
};

class VM_ShenandoahReferenceOperation : public VM_ShenandoahOperation {
Expand Down

0 comments on commit 93d0f4e

Please sign in to comment.