Skip to content

Commit 6547a12

Browse files
committed
Revert "Acquire and release Heap_lock on VM_MMTkSTWOperation (#316)"
This reverts commit dc3a9b4.
1 parent df3f955 commit 6547a12

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

openjdk/mmtkUpcalls.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ static void mmtk_resume_mutators(void *tls) {
8787
MutexLockerEx locker(MMTkHeap::heap()->gc_lock(), Mutex::_no_safepoint_check_flag);
8888
MMTkHeap::heap()->gc_lock()->notify_all();
8989
}
90+
91+
log_debug(gc)("Notifying mutators blocking on Heap_lock for reference pending list...");
92+
// Note: That's the ReferenceHandler thread.
93+
{
94+
MutexLockerEx x(Heap_lock, Mutex::_no_safepoint_check_flag);
95+
if (Universe::has_reference_pending_list()) {
96+
Heap_lock->notify_all();
97+
}
98+
}
9099
}
91100

92101
static const int GC_THREAD_KIND_WORKER = 1;
@@ -293,6 +302,8 @@ static void mmtk_enqueue_references(void** objects, size_t len) {
293302
return;
294303
}
295304

305+
MutexLocker x(Heap_lock);
306+
296307
oop first = (oop) objects[0]; // This points to the first node of the linked list.
297308
oop last = first; // This points to the last node of the linked list.
298309

@@ -313,6 +324,7 @@ static void mmtk_enqueue_references(void** objects, size_t len) {
313324

314325
oop old_first = Universe::swap_reference_pending_list(first);
315326
HeapAccess<AS_NO_KEEPALIVE>::oop_store_at(last, java_lang_ref_Reference::discovered_offset, old_first);
327+
assert(Universe::has_reference_pending_list(), "Reference pending list is empty after swap");
316328
}
317329

318330
OpenJDK_Upcalls mmtk_upcalls = {

openjdk/mmtkVMOperation.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,8 @@ VM_MMTkSTWOperation::VM_MMTkSTWOperation(MMTkVMCompanionThread *companion_thread
3232
_companion_thread(companion_thread) {
3333
}
3434

35-
bool VM_MMTkSTWOperation::doit_prologue() {
36-
Heap_lock->lock();
37-
return true;
38-
}
39-
4035
void VM_MMTkSTWOperation::doit() {
4136
log_trace(vmthread)("Entered VM_MMTkSTWOperation::doit().");
4237
_companion_thread->do_mmtk_stw_operation();
4338
log_trace(vmthread)("Leaving VM_MMTkSTWOperation::doit()");
4439
}
45-
46-
void VM_MMTkSTWOperation::doit_epilogue() {
47-
// Notify the reference processing thread
48-
if (Universe::has_reference_pending_list()) {
49-
Heap_lock->notify_all();
50-
}
51-
Heap_lock->unlock();
52-
}

openjdk/mmtkVMOperation.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ class VM_MMTkSTWOperation : public VM_MMTkOperation {
3939

4040
public:
4141
VM_MMTkSTWOperation(MMTkVMCompanionThread *companion_thread);
42-
virtual bool doit_prologue() override;
4342
virtual void doit() override;
44-
virtual void doit_epilogue() override;
4543
};
4644

4745
#endif // MMTK_OPENJDK_MMTK_VM_OPERATION_HPP

0 commit comments

Comments
 (0)