diff --git a/.github/scripts/ci-test-extended.sh b/.github/scripts/ci-test-extended.sh index fbbed459..4d585d78 100755 --- a/.github/scripts/ci-test-extended.sh +++ b/.github/scripts/ci-test-extended.sh @@ -19,6 +19,7 @@ $cur/ci-build.sh # Test $cur/ci-test-only-normal.sh $cur/ci-test-only-normal-no-compressed-oops.sh +$cur/ci-test-only-weak-ref.sh # Build with extreme assertions MMTK_EXTREME_ASSERTIONS=1 $cur/ci-build.sh diff --git a/.github/scripts/ci-test-only-weak-ref.sh b/.github/scripts/ci-test-only-weak-ref.sh new file mode 100755 index 00000000..15bc2f76 --- /dev/null +++ b/.github/scripts/ci-test-only-weak-ref.sh @@ -0,0 +1,5 @@ +set -xe + +# Just run everything in ci-test-only-normal.sh, but with reference processing enabled. +export MMTK_NO_REFERENCE_TYPES=false +. $(dirname "$0")/ci-test-only-normal.sh diff --git a/.github/workflows/run-dacapo-2006.yml b/.github/workflows/run-dacapo-2006.yml index 5985afe0..c353bf44 100644 --- a/.github/workflows/run-dacapo-2006.yml +++ b/.github/workflows/run-dacapo-2006.yml @@ -45,7 +45,7 @@ jobs: strategy: fail-fast: false matrix: - test-script: ["ci-test-only-normal", "ci-test-only-normal-no-compressed-oops"] + test-script: ["ci-test-only-normal", "ci-test-only-normal-no-compressed-oops", "ci-test-only-weak-ref"] steps: # We need to check out the binding repo to get the running configs and test scripts - name: Checkout MMTk OpenJDK binding diff --git a/DONT_MERGE b/DONT_MERGE new file mode 100644 index 00000000..e69de29b diff --git a/mmtk/Cargo.lock b/mmtk/Cargo.lock index c74bc311..fe214905 100644 --- a/mmtk/Cargo.lock +++ b/mmtk/Cargo.lock @@ -459,7 +459,7 @@ dependencies = [ [[package]] name = "mmtk" version = "0.31.0" -source = "git+https://github.com/mmtk/mmtk-core.git?rev=7d798ad8a71aa6df80f58f5e565e4f9274d06871#7d798ad8a71aa6df80f58f5e565e4f9274d06871" +source = "git+https://github.com/mmtk/mmtk-core.git?rev=d93262b4397df4866a64a1d268689ae20f208713#d93262b4397df4866a64a1d268689ae20f208713" dependencies = [ "atomic", "atomic-traits", @@ -497,7 +497,7 @@ dependencies = [ [[package]] name = "mmtk-macros" version = "0.31.0" -source = "git+https://github.com/mmtk/mmtk-core.git?rev=7d798ad8a71aa6df80f58f5e565e4f9274d06871#7d798ad8a71aa6df80f58f5e565e4f9274d06871" +source = "git+https://github.com/mmtk/mmtk-core.git?rev=d93262b4397df4866a64a1d268689ae20f208713#d93262b4397df4866a64a1d268689ae20f208713" dependencies = [ "proc-macro-error", "proc-macro2", diff --git a/mmtk/Cargo.toml b/mmtk/Cargo.toml index 6a33a938..3140683d 100644 --- a/mmtk/Cargo.toml +++ b/mmtk/Cargo.toml @@ -35,7 +35,7 @@ probe = "0.5" # - change branch # - change repo name # But other changes including adding/removing whitespaces in commented lines may break the CI. -mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "7d798ad8a71aa6df80f58f5e565e4f9274d06871" } +mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "d93262b4397df4866a64a1d268689ae20f208713" } # Uncomment the following to build locally # mmtk = { path = "../repos/mmtk-core" } diff --git a/openjdk/mmtkUpcalls.cpp b/openjdk/mmtkUpcalls.cpp index fd90cf0e..c665a191 100644 --- a/openjdk/mmtkUpcalls.cpp +++ b/openjdk/mmtkUpcalls.cpp @@ -87,6 +87,15 @@ static void mmtk_resume_mutators(void *tls) { MutexLockerEx locker(MMTkHeap::heap()->gc_lock(), Mutex::_no_safepoint_check_flag); MMTkHeap::heap()->gc_lock()->notify_all(); } + + log_debug(gc)("Notifying mutators blocking on Heap_lock for reference pending list..."); + // Note: That's the ReferenceHandler thread. + { + MutexLockerEx x(Heap_lock, Mutex::_no_safepoint_check_flag); + if (Universe::has_reference_pending_list()) { + Heap_lock->notify_all(); + } + } } static const int GC_THREAD_KIND_WORKER = 1; @@ -293,6 +302,8 @@ static void mmtk_enqueue_references(void** objects, size_t len) { return; } + MutexLocker x(Heap_lock); + oop first = (oop) objects[0]; // This points to the first node of the linked list. oop last = first; // This points to the last node of the linked list. @@ -313,6 +324,7 @@ static void mmtk_enqueue_references(void** objects, size_t len) { oop old_first = Universe::swap_reference_pending_list(first); HeapAccess::oop_store_at(last, java_lang_ref_Reference::discovered_offset, old_first); + assert(Universe::has_reference_pending_list(), "Reference pending list is empty after swap"); } OpenJDK_Upcalls mmtk_upcalls = { diff --git a/openjdk/mmtkVMOperation.cpp b/openjdk/mmtkVMOperation.cpp index 7ba6053f..51227ee3 100644 --- a/openjdk/mmtkVMOperation.cpp +++ b/openjdk/mmtkVMOperation.cpp @@ -32,21 +32,8 @@ VM_MMTkSTWOperation::VM_MMTkSTWOperation(MMTkVMCompanionThread *companion_thread _companion_thread(companion_thread) { } -bool VM_MMTkSTWOperation::doit_prologue() { - Heap_lock->lock(); - return true; -} - void VM_MMTkSTWOperation::doit() { log_trace(vmthread)("Entered VM_MMTkSTWOperation::doit()."); _companion_thread->do_mmtk_stw_operation(); log_trace(vmthread)("Leaving VM_MMTkSTWOperation::doit()"); } - -void VM_MMTkSTWOperation::doit_epilogue() { - // Notify the reference processing thread - if (Universe::has_reference_pending_list()) { - Heap_lock->notify_all(); - } - Heap_lock->unlock(); -} diff --git a/openjdk/mmtkVMOperation.hpp b/openjdk/mmtkVMOperation.hpp index 49897ce7..98d37ea4 100644 --- a/openjdk/mmtkVMOperation.hpp +++ b/openjdk/mmtkVMOperation.hpp @@ -39,9 +39,7 @@ class VM_MMTkSTWOperation : public VM_MMTkOperation { public: VM_MMTkSTWOperation(MMTkVMCompanionThread *companion_thread); - virtual bool doit_prologue() override; virtual void doit() override; - virtual void doit_epilogue() override; }; #endif // MMTK_OPENJDK_MMTK_VM_OPERATION_HPP