From 87266089732835025f29223c341032884db7d153 Mon Sep 17 00:00:00 2001 From: "Aleksei.Glushko" Date: Tue, 24 Oct 2023 16:04:44 +0200 Subject: [PATCH] [K/N] Move parallel-mark-concurrent-sweep GC sources --- .../kotlin/backend/konan/KonanConfig.kt | 4 +- kotlin-native/runtime/build.gradle.kts | 20 +++---- .../src/gc/{cms => pmcs}/cpp/Barriers.cpp | 0 .../src/gc/{cms => pmcs}/cpp/Barriers.hpp | 0 .../src/gc/{cms => pmcs}/cpp/GCImpl.cpp | 2 +- .../src/gc/{cms => pmcs}/cpp/GCImpl.hpp | 10 ++-- .../src/gc/{cms => pmcs}/cpp/ObjectData.hpp | 0 .../src/gc/{cms => pmcs}/cpp/ParallelMark.cpp | 0 .../src/gc/{cms => pmcs}/cpp/ParallelMark.hpp | 0 .../cpp/ParallelMarkConcurrentSweep.cpp} | 32 +++++------ .../cpp/ParallelMarkConcurrentSweep.hpp} | 13 +++-- .../cpp/ParallelMarkConcurrentSweepTest.cpp} | 54 +++++++++---------- 12 files changed, 67 insertions(+), 68 deletions(-) rename kotlin-native/runtime/src/gc/{cms => pmcs}/cpp/Barriers.cpp (100%) rename kotlin-native/runtime/src/gc/{cms => pmcs}/cpp/Barriers.hpp (100%) rename kotlin-native/runtime/src/gc/{cms => pmcs}/cpp/GCImpl.cpp (98%) rename kotlin-native/runtime/src/gc/{cms => pmcs}/cpp/GCImpl.hpp (71%) rename kotlin-native/runtime/src/gc/{cms => pmcs}/cpp/ObjectData.hpp (100%) rename kotlin-native/runtime/src/gc/{cms => pmcs}/cpp/ParallelMark.cpp (100%) rename kotlin-native/runtime/src/gc/{cms => pmcs}/cpp/ParallelMark.hpp (100%) rename kotlin-native/runtime/src/gc/{cms/cpp/ConcurrentMarkAndSweep.cpp => pmcs/cpp/ParallelMarkConcurrentSweep.cpp} (86%) rename kotlin-native/runtime/src/gc/{cms/cpp/ConcurrentMarkAndSweep.hpp => pmcs/cpp/ParallelMarkConcurrentSweep.hpp} (86%) rename kotlin-native/runtime/src/gc/{cms/cpp/ConcurrentMarkAndSweepTest.cpp => pmcs/cpp/ParallelMarkConcurrentSweepTest.cpp} (96%) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt index f751c41b6f1..9ed172c25fe 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt @@ -363,13 +363,13 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration when (gc) { GC.STOP_THE_WORLD_MARK_AND_SWEEP -> add("same_thread_ms_gc_custom.bc") GC.NOOP -> add("noop_gc_custom.bc") - GC.PARALLEL_MARK_CONCURRENT_SWEEP -> add("concurrent_ms_gc_custom.bc") + GC.PARALLEL_MARK_CONCURRENT_SWEEP -> add("pmcs_gc_custom.bc") } } else { when (gc) { GC.STOP_THE_WORLD_MARK_AND_SWEEP -> add("same_thread_ms_gc.bc") GC.NOOP -> add("noop_gc.bc") - GC.PARALLEL_MARK_CONCURRENT_SWEEP -> add("concurrent_ms_gc.bc") + GC.PARALLEL_MARK_CONCURRENT_SWEEP -> add("pmcs_gc.bc") } } if (shouldCoverLibraries || shouldCoverSources) add("profileRuntime.bc") diff --git a/kotlin-native/runtime/build.gradle.kts b/kotlin-native/runtime/build.gradle.kts index 778efa482d1..c5684399d17 100644 --- a/kotlin-native/runtime/build.gradle.kts +++ b/kotlin-native/runtime/build.gradle.kts @@ -305,8 +305,8 @@ bitcode { compilerArgs.add("-DCUSTOM_ALLOCATOR") } - module("concurrent_ms_gc") { - srcRoot.set(layout.projectDirectory.dir("src/gc/cms")) + module("pmcs_gc") { + srcRoot.set(layout.projectDirectory.dir("src/gc/pmcs")) headersDirs.from(files("src/alloc/common/cpp", "src/gcScheduler/common/cpp", "src/gc/common/cpp", "src/mm/cpp", "src/main/cpp", "src/alloc/legacy/cpp")) sourceSets { main {} @@ -314,8 +314,8 @@ bitcode { } } - module("concurrent_ms_gc_custom") { - srcRoot.set(layout.projectDirectory.dir("src/gc/cms")) + module("pmcs_gc_custom") { + srcRoot.set(layout.projectDirectory.dir("src/gc/pmcs")) headersDirs.from(files("src/alloc/common/cpp", "src/gcScheduler/common/cpp", "src/gc/common/cpp", "src/mm/cpp", "src/main/cpp", "src/alloc/custom/cpp")) sourceSets { main {} @@ -387,16 +387,16 @@ bitcode { testSupportModules.addAll("main", "common_alloc", "common_gc", "common_gcScheduler", "manual_gcScheduler", "custom_alloc", "objc") } - testsGroup("experimentalMM_cms_mimalloc_runtime_tests") { - testedModules.addAll("main", "mm", "common_alloc", "common_gc", "common_gcScheduler", "manual_gcScheduler", "concurrent_ms_gc", "mimalloc", "mimalloc_alloc", "legacy_alloc", "objc") + testsGroup("experimentalMM_pmcs_mimalloc_runtime_tests") { + testedModules.addAll("main", "mm", "common_alloc", "common_gc", "common_gcScheduler", "manual_gcScheduler", "pmcs_gc", "mimalloc", "mimalloc_alloc", "legacy_alloc", "objc") } - testsGroup("experimentalMM_cms_std_alloc_runtime_tests") { - testedModules.addAll("main", "mm", "common_alloc", "common_gc", "common_gcScheduler", "manual_gcScheduler", "concurrent_ms_gc", "std_alloc", "legacy_alloc", "objc") + testsGroup("experimentalMM_pmcs_std_alloc_runtime_tests") { + testedModules.addAll("main", "mm", "common_alloc", "common_gc", "common_gcScheduler", "manual_gcScheduler", "pmcs_gc", "std_alloc", "legacy_alloc", "objc") } - testsGroup("experimentalMM_cms_custom_alloc_runtime_tests") { - testedModules.addAll("mm", "concurrent_ms_gc_custom") + testsGroup("experimentalMM_pmcs_custom_alloc_runtime_tests") { + testedModules.addAll("mm", "pmcs_gc_custom") testSupportModules.addAll("main", "common_alloc", "common_gc", "common_gcScheduler", "manual_gcScheduler", "custom_alloc", "objc") } diff --git a/kotlin-native/runtime/src/gc/cms/cpp/Barriers.cpp b/kotlin-native/runtime/src/gc/pmcs/cpp/Barriers.cpp similarity index 100% rename from kotlin-native/runtime/src/gc/cms/cpp/Barriers.cpp rename to kotlin-native/runtime/src/gc/pmcs/cpp/Barriers.cpp diff --git a/kotlin-native/runtime/src/gc/cms/cpp/Barriers.hpp b/kotlin-native/runtime/src/gc/pmcs/cpp/Barriers.hpp similarity index 100% rename from kotlin-native/runtime/src/gc/cms/cpp/Barriers.hpp rename to kotlin-native/runtime/src/gc/pmcs/cpp/Barriers.hpp diff --git a/kotlin-native/runtime/src/gc/cms/cpp/GCImpl.cpp b/kotlin-native/runtime/src/gc/pmcs/cpp/GCImpl.cpp similarity index 98% rename from kotlin-native/runtime/src/gc/cms/cpp/GCImpl.cpp rename to kotlin-native/runtime/src/gc/pmcs/cpp/GCImpl.cpp index e5eb0f51d45..744a5f5c289 100644 --- a/kotlin-native/runtime/src/gc/cms/cpp/GCImpl.cpp +++ b/kotlin-native/runtime/src/gc/pmcs/cpp/GCImpl.cpp @@ -7,7 +7,7 @@ #include -#include "ConcurrentMarkAndSweep.hpp" +#include "ParallelMarkConcurrentSweep.hpp" #include "GC.hpp" #include "GCStatistics.hpp" #include "MarkAndSweepUtils.hpp" diff --git a/kotlin-native/runtime/src/gc/cms/cpp/GCImpl.hpp b/kotlin-native/runtime/src/gc/pmcs/cpp/GCImpl.hpp similarity index 71% rename from kotlin-native/runtime/src/gc/cms/cpp/GCImpl.hpp rename to kotlin-native/runtime/src/gc/pmcs/cpp/GCImpl.hpp index 509a9ff7752..392add34a02 100644 --- a/kotlin-native/runtime/src/gc/cms/cpp/GCImpl.hpp +++ b/kotlin-native/runtime/src/gc/pmcs/cpp/GCImpl.hpp @@ -7,7 +7,7 @@ #include "GC.hpp" -#include "ConcurrentMarkAndSweep.hpp" +#include "ParallelMarkConcurrentSweep.hpp" namespace kotlin { namespace gc { @@ -17,20 +17,20 @@ public: Impl(alloc::Allocator& allocator, gcScheduler::GCScheduler& gcScheduler) noexcept : gc_(allocator, gcScheduler, compiler::gcMutatorsCooperate(), compiler::auxGCThreads()) {} - ConcurrentMarkAndSweep& gc() noexcept { return gc_; } + ParallelMarkConcurrentSweep& gc() noexcept { return gc_; } private: - ConcurrentMarkAndSweep gc_; + ParallelMarkConcurrentSweep gc_; }; class GC::ThreadData::Impl : private Pinned { public: Impl(GC& gc, mm::ThreadData& threadData) noexcept : gc_(gc.impl_->gc(), threadData) {} - ConcurrentMarkAndSweep::ThreadData& gc() noexcept { return gc_; } + ParallelMarkConcurrentSweep::ThreadData& gc() noexcept { return gc_; } private: - ConcurrentMarkAndSweep::ThreadData gc_; + ParallelMarkConcurrentSweep::ThreadData gc_; }; } // namespace gc diff --git a/kotlin-native/runtime/src/gc/cms/cpp/ObjectData.hpp b/kotlin-native/runtime/src/gc/pmcs/cpp/ObjectData.hpp similarity index 100% rename from kotlin-native/runtime/src/gc/cms/cpp/ObjectData.hpp rename to kotlin-native/runtime/src/gc/pmcs/cpp/ObjectData.hpp diff --git a/kotlin-native/runtime/src/gc/cms/cpp/ParallelMark.cpp b/kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMark.cpp similarity index 100% rename from kotlin-native/runtime/src/gc/cms/cpp/ParallelMark.cpp rename to kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMark.cpp diff --git a/kotlin-native/runtime/src/gc/cms/cpp/ParallelMark.hpp b/kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMark.hpp similarity index 100% rename from kotlin-native/runtime/src/gc/cms/cpp/ParallelMark.hpp rename to kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMark.hpp diff --git a/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweep.cpp b/kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMarkConcurrentSweep.cpp similarity index 86% rename from kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweep.cpp rename to kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMarkConcurrentSweep.cpp index eb03de096a8..cda9871e130 100644 --- a/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweep.cpp +++ b/kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMarkConcurrentSweep.cpp @@ -3,7 +3,7 @@ * that can be found in the LICENSE file. */ -#include "ConcurrentMarkAndSweep.hpp" +#include "ParallelMarkConcurrentSweep.hpp" #include @@ -54,13 +54,13 @@ ScopedThread createGCThread(const char* name, Body&& body) { } // namespace -void gc::ConcurrentMarkAndSweep::ThreadData::OnSuspendForGC() noexcept { +void gc::ParallelMarkConcurrentSweep::ThreadData::OnSuspendForGC() noexcept { CallsCheckerIgnoreGuard guard; gc_.markDispatcher_.runOnMutator(commonThreadData()); } -bool gc::ConcurrentMarkAndSweep::ThreadData::tryLockRootSet() { +bool gc::ParallelMarkConcurrentSweep::ThreadData::tryLockRootSet() { bool expected = false; bool locked = rootSetLocked_.compare_exchange_strong(expected, true, std::memory_order_acq_rel); if (locked) { @@ -69,25 +69,25 @@ bool gc::ConcurrentMarkAndSweep::ThreadData::tryLockRootSet() { return locked; } -void gc::ConcurrentMarkAndSweep::ThreadData::publish() { +void gc::ParallelMarkConcurrentSweep::ThreadData::publish() { threadData_.Publish(); published_.store(true, std::memory_order_release); } -bool gc::ConcurrentMarkAndSweep::ThreadData::published() const { +bool gc::ParallelMarkConcurrentSweep::ThreadData::published() const { return published_.load(std::memory_order_acquire); } -void gc::ConcurrentMarkAndSweep::ThreadData::clearMarkFlags() { +void gc::ParallelMarkConcurrentSweep::ThreadData::clearMarkFlags() { published_.store(false, std::memory_order_relaxed); rootSetLocked_.store(false, std::memory_order_release); } -mm::ThreadData& gc::ConcurrentMarkAndSweep::ThreadData::commonThreadData() const { +mm::ThreadData& gc::ParallelMarkConcurrentSweep::ThreadData::commonThreadData() const { return threadData_; } -gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep( +gc::ParallelMarkConcurrentSweep::ParallelMarkConcurrentSweep( alloc::Allocator& allocator, gcScheduler::GCScheduler& gcScheduler, bool mutatorsCooperate, std::size_t auxGCThreads) noexcept : allocator_(allocator), gcScheduler_(gcScheduler), @@ -103,26 +103,26 @@ gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep( RuntimeLogInfo({kTagGC}, "Parallel Mark & Concurrent Sweep GC initialized"); } -gc::ConcurrentMarkAndSweep::~ConcurrentMarkAndSweep() { +gc::ParallelMarkConcurrentSweep::~ParallelMarkConcurrentSweep() { state_.shutdown(); } -void gc::ConcurrentMarkAndSweep::StartFinalizerThreadIfNeeded() noexcept { +void gc::ParallelMarkConcurrentSweep::StartFinalizerThreadIfNeeded() noexcept { NativeOrUnregisteredThreadGuard guard(true); finalizerProcessor_.StartFinalizerThreadIfNone(); finalizerProcessor_.WaitFinalizerThreadInitialized(); } -void gc::ConcurrentMarkAndSweep::StopFinalizerThreadIfRunning() noexcept { +void gc::ParallelMarkConcurrentSweep::StopFinalizerThreadIfRunning() noexcept { NativeOrUnregisteredThreadGuard guard(true); finalizerProcessor_.StopFinalizerThread(); } -bool gc::ConcurrentMarkAndSweep::FinalizersThreadIsRunning() noexcept { +bool gc::ParallelMarkConcurrentSweep::FinalizersThreadIsRunning() noexcept { return finalizerProcessor_.IsRunning(); } -void gc::ConcurrentMarkAndSweep::mainGCThreadBody() { +void gc::ParallelMarkConcurrentSweep::mainGCThreadBody() { while (true) { auto epoch = state_.waitScheduled(); if (epoch.has_value()) { @@ -134,14 +134,14 @@ void gc::ConcurrentMarkAndSweep::mainGCThreadBody() { markDispatcher_.requestShutdown(); } -void gc::ConcurrentMarkAndSweep::auxiliaryGCThreadBody() { +void gc::ParallelMarkConcurrentSweep::auxiliaryGCThreadBody() { RuntimeAssert(!compiler::gcMarkSingleThreaded(), "Should not reach here during single threaded mark"); while (!markDispatcher_.shutdownRequested()) { markDispatcher_.runAuxiliary(); } } -void gc::ConcurrentMarkAndSweep::PerformFullGC(int64_t epoch) noexcept { +void gc::ParallelMarkConcurrentSweep::PerformFullGC(int64_t epoch) noexcept { std::unique_lock mainGCLock(gcMutex); auto gcHandle = GCHandle::create(epoch); @@ -219,7 +219,7 @@ void gc::ConcurrentMarkAndSweep::PerformFullGC(int64_t epoch) noexcept { finalizerProcessor_.ScheduleTasks(std::move(finalizerQueue), epoch); } -void gc::ConcurrentMarkAndSweep::reconfigure(std::size_t maxParallelism, bool mutatorsCooperate, std::size_t auxGCThreads) noexcept { +void gc::ParallelMarkConcurrentSweep::reconfigure(std::size_t maxParallelism, bool mutatorsCooperate, std::size_t auxGCThreads) noexcept { if (compiler::gcMarkSingleThreaded()) { RuntimeCheck(auxGCThreads == 0, "Auxiliary GC threads must not be created with gcMarkSingleThread"); return; diff --git a/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweep.hpp b/kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMarkConcurrentSweep.hpp similarity index 86% rename from kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweep.hpp rename to kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMarkConcurrentSweep.hpp index 05cb218e3e6..17ec84413bc 100644 --- a/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweep.hpp +++ b/kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMarkConcurrentSweep.hpp @@ -29,12 +29,11 @@ namespace kotlin { namespace gc { // Stop-the-world parallel mark + concurrent sweep. The GC runs in a separate thread, finalizers run in another thread of their own. -// TODO: Also make marking run concurrently with Kotlin threads. -class ConcurrentMarkAndSweep : private Pinned { +class ParallelMarkConcurrentSweep : private Pinned { public: class ThreadData : private Pinned { public: - explicit ThreadData(ConcurrentMarkAndSweep& gc, mm::ThreadData& threadData) noexcept : gc_(gc), threadData_(threadData) {} + explicit ThreadData(ParallelMarkConcurrentSweep& gc, mm::ThreadData& threadData) noexcept : gc_(gc), threadData_(threadData) {} ~ThreadData() = default; void OnSuspendForGC() noexcept; @@ -53,8 +52,8 @@ public: mm::ThreadData& commonThreadData() const; private: - friend ConcurrentMarkAndSweep; - ConcurrentMarkAndSweep& gc_; + friend ParallelMarkConcurrentSweep; + ParallelMarkConcurrentSweep& gc_; mm::ThreadData& threadData_; BarriersThreadData barriers_; @@ -62,9 +61,9 @@ public: std::atomic published_ = false; }; - ConcurrentMarkAndSweep( + ParallelMarkConcurrentSweep( alloc::Allocator& allocator, gcScheduler::GCScheduler& scheduler, bool mutatorsCooperate, std::size_t auxGCThreads) noexcept; - ~ConcurrentMarkAndSweep(); + ~ParallelMarkConcurrentSweep(); void StartFinalizerThreadIfNeeded() noexcept; void StopFinalizerThreadIfRunning() noexcept; diff --git a/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweepTest.cpp b/kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMarkConcurrentSweepTest.cpp similarity index 96% rename from kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweepTest.cpp rename to kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMarkConcurrentSweepTest.cpp index c0e31d2814e..d17d1ddbd53 100644 --- a/kotlin-native/runtime/src/gc/cms/cpp/ConcurrentMarkAndSweepTest.cpp +++ b/kotlin-native/runtime/src/gc/pmcs/cpp/ParallelMarkConcurrentSweepTest.cpp @@ -3,7 +3,7 @@ * that can be found in the LICENSE file. */ -#include "ConcurrentMarkAndSweep.hpp" +#include "ParallelMarkConcurrentSweep.hpp" #include #include @@ -30,7 +30,7 @@ using namespace kotlin; -// These tests can only work if `GC` is `ConcurrentMarkAndSweep`. +// These tests can only work if `GC` is `ParallelMarkConcurrentSweep`. namespace { @@ -201,10 +201,10 @@ struct ParallelismOptions { std::size_t auxGCThreads; }; -class ConcurrentMarkAndSweepTest : public testing::TestWithParam { +class ParallelMarkConcurrentSweepTest : public testing::TestWithParam { public: - ConcurrentMarkAndSweepTest() { + ParallelMarkConcurrentSweepTest() { if (supportedConfiguration()) { mm::GlobalData::Instance().gc().impl().gc().reconfigure(GetParam().maxParallelism, GetParam().cooperativeMutators, @@ -218,7 +218,7 @@ public: } } - ~ConcurrentMarkAndSweepTest() { + ~ParallelMarkConcurrentSweepTest() { mm::GlobalsRegistry::Instance().ClearForTests(); mm::SpecialRefRegistry::instance().clearForTests(); mm::GlobalData::Instance().gc().ClearForTests(); @@ -237,7 +237,7 @@ private: } // namespace -TEST_P(ConcurrentMarkAndSweepTest, RootSet) { +TEST_P(ParallelMarkConcurrentSweepTest, RootSet) { RunInNewThread([](mm::ThreadData& threadData) { GlobalObjectHolder global1{threadData}; GlobalObjectArrayHolder global2{threadData}; @@ -272,7 +272,7 @@ TEST_P(ConcurrentMarkAndSweepTest, RootSet) { }); } -TEST_P(ConcurrentMarkAndSweepTest, InterconnectedRootSet) { +TEST_P(ParallelMarkConcurrentSweepTest, InterconnectedRootSet) { RunInNewThread([](mm::ThreadData& threadData) { GlobalObjectHolder global1{threadData}; GlobalObjectArrayHolder global2{threadData}; @@ -318,7 +318,7 @@ TEST_P(ConcurrentMarkAndSweepTest, InterconnectedRootSet) { }); } -TEST_P(ConcurrentMarkAndSweepTest, FreeObjects) { +TEST_P(ParallelMarkConcurrentSweepTest, FreeObjects) { RunInNewThread([](mm::ThreadData& threadData) { auto& object1 = AllocateObject(threadData); auto& object2 = AllocateObject(threadData); @@ -333,7 +333,7 @@ TEST_P(ConcurrentMarkAndSweepTest, FreeObjects) { }); } -TEST_P(ConcurrentMarkAndSweepTest, FreeObjectsWithFinalizers) { +TEST_P(ParallelMarkConcurrentSweepTest, FreeObjectsWithFinalizers) { RunInNewThread([this](mm::ThreadData& threadData) { auto& object1 = AllocateObjectWithFinalizer(threadData); auto& object2 = AllocateObjectWithFinalizer(threadData); @@ -350,7 +350,7 @@ TEST_P(ConcurrentMarkAndSweepTest, FreeObjectsWithFinalizers) { }); } -TEST_P(ConcurrentMarkAndSweepTest, FreeObjectWithFreeWeak) { +TEST_P(ParallelMarkConcurrentSweepTest, FreeObjectWithFreeWeak) { RunInNewThread([this](mm::ThreadData& threadData) { auto& object1 = AllocateObject(threadData); auto& weak1 = ([&threadData, &object1]() -> test_support::RegularWeakReferenceImpl& { @@ -370,7 +370,7 @@ TEST_P(ConcurrentMarkAndSweepTest, FreeObjectWithFreeWeak) { }); } -TEST_P(ConcurrentMarkAndSweepTest, FreeObjectWithHoldedWeak) { +TEST_P(ParallelMarkConcurrentSweepTest, FreeObjectWithHoldedWeak) { RunInNewThread([](mm::ThreadData& threadData) { auto& object1 = AllocateObject(threadData); StackObjectHolder stack{threadData}; @@ -389,7 +389,7 @@ TEST_P(ConcurrentMarkAndSweepTest, FreeObjectWithHoldedWeak) { }); } -TEST_P(ConcurrentMarkAndSweepTest, ObjectReferencedFromRootSet) { +TEST_P(ParallelMarkConcurrentSweepTest, ObjectReferencedFromRootSet) { RunInNewThread([](mm::ThreadData& threadData) { GlobalObjectHolder global{threadData}; StackObjectHolder stack{threadData}; @@ -429,7 +429,7 @@ TEST_P(ConcurrentMarkAndSweepTest, ObjectReferencedFromRootSet) { }); } -TEST_P(ConcurrentMarkAndSweepTest, ObjectsWithCycles) { +TEST_P(ParallelMarkConcurrentSweepTest, ObjectsWithCycles) { RunInNewThread([](mm::ThreadData& threadData) { GlobalObjectHolder global{threadData}; StackObjectHolder stack{threadData}; @@ -478,7 +478,7 @@ TEST_P(ConcurrentMarkAndSweepTest, ObjectsWithCycles) { }); } -TEST_P(ConcurrentMarkAndSweepTest, ObjectsWithCyclesAndFinalizers) { +TEST_P(ParallelMarkConcurrentSweepTest, ObjectsWithCyclesAndFinalizers) { RunInNewThread([this](mm::ThreadData& threadData) { GlobalObjectHolder global{threadData}; StackObjectHolder stack{threadData}; @@ -529,7 +529,7 @@ TEST_P(ConcurrentMarkAndSweepTest, ObjectsWithCyclesAndFinalizers) { }); } -TEST_P(ConcurrentMarkAndSweepTest, ObjectsWithCyclesIntoRootSet) { +TEST_P(ParallelMarkConcurrentSweepTest, ObjectsWithCyclesIntoRootSet) { RunInNewThread([](mm::ThreadData& threadData) { GlobalObjectHolder global{threadData}; StackObjectHolder stack{threadData}; @@ -557,7 +557,7 @@ TEST_P(ConcurrentMarkAndSweepTest, ObjectsWithCyclesIntoRootSet) { }); } -TEST_P(ConcurrentMarkAndSweepTest, RunGCTwice) { +TEST_P(ParallelMarkConcurrentSweepTest, RunGCTwice) { RunInNewThread([](mm::ThreadData& threadData) { GlobalObjectHolder global{threadData}; StackObjectHolder stack{threadData}; @@ -607,7 +607,7 @@ TEST_P(ConcurrentMarkAndSweepTest, RunGCTwice) { }); } -TEST_P(ConcurrentMarkAndSweepTest, PermanentObjects) { +TEST_P(ParallelMarkConcurrentSweepTest, PermanentObjects) { RunInNewThread([](mm::ThreadData& threadData) { GlobalPermanentObjectHolder global1{threadData}; GlobalObjectHolder global2{threadData}; @@ -629,7 +629,7 @@ TEST_P(ConcurrentMarkAndSweepTest, PermanentObjects) { }); } -TEST_P(ConcurrentMarkAndSweepTest, SameObjectInRootSet) { +TEST_P(ParallelMarkConcurrentSweepTest, SameObjectInRootSet) { RunInNewThread([](mm::ThreadData& threadData) { GlobalObjectHolder global{threadData}; StackObjectHolder stack(*global); @@ -715,7 +715,7 @@ private: } // namespace -TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsCollect) { +TEST_P(ParallelMarkConcurrentSweepTest, MultipleMutatorsCollect) { std::vector mutators(kDefaultThreadCount); std::vector globals(kDefaultThreadCount); std::vector locals(kDefaultThreadCount); @@ -772,7 +772,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsCollect) { } } -TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAllCollect) { +TEST_P(ParallelMarkConcurrentSweepTest, MultipleMutatorsAllCollect) { std::vector mutators(kDefaultThreadCount); std::vector globals(kDefaultThreadCount); std::vector locals(kDefaultThreadCount); @@ -834,7 +834,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAllCollect) { } } -TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAddToRootSetAfterCollectionRequested) { +TEST_P(ParallelMarkConcurrentSweepTest, MultipleMutatorsAddToRootSetAfterCollectionRequested) { std::vector mutators(kDefaultThreadCount); std::vector globals(kDefaultThreadCount); std::vector locals(kDefaultThreadCount); @@ -905,7 +905,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAddToRootSetAfterCollectionRe } } -TEST_P(ConcurrentMarkAndSweepTest, CrossThreadReference) { +TEST_P(ParallelMarkConcurrentSweepTest, CrossThreadReference) { std::vector mutators(kDefaultThreadCount); std::vector globals(kDefaultThreadCount); std::vector locals(kDefaultThreadCount); @@ -972,7 +972,7 @@ TEST_P(ConcurrentMarkAndSweepTest, CrossThreadReference) { } } -TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsWeaks) { +TEST_P(ParallelMarkConcurrentSweepTest, MultipleMutatorsWeaks) { std::vector mutators(kDefaultThreadCount); ObjHeader* globalRoot = nullptr; test_support::RegularWeakReferenceImpl* weak = nullptr; @@ -1026,7 +1026,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsWeaks) { } } -TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsWeakNewObj) { +TEST_P(ParallelMarkConcurrentSweepTest, MultipleMutatorsWeakNewObj) { std::vector mutators(kDefaultThreadCount); // Make sure all mutators are initialized. @@ -1072,7 +1072,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsWeakNewObj) { } } -TEST_P(ConcurrentMarkAndSweepTest, NewThreadsWhileRequestingCollection) { +TEST_P(ParallelMarkConcurrentSweepTest, NewThreadsWhileRequestingCollection) { std::vector mutators(kDefaultThreadCount); std::vector globals(2 * kDefaultThreadCount); std::vector locals(2 * kDefaultThreadCount); @@ -1172,7 +1172,7 @@ TEST_P(ConcurrentMarkAndSweepTest, NewThreadsWhileRequestingCollection) { EXPECT_THAT(mutators[0].Alive(), testing::UnorderedElementsAreArray(expectedAlive)); } -TEST_P(ConcurrentMarkAndSweepTest, FreeObjectWithFreeWeakReversedOrder) { +TEST_P(ParallelMarkConcurrentSweepTest, FreeObjectWithFreeWeakReversedOrder) { std::vector mutators(2); std::atomic*> object1 = nullptr; std::atomic weak = nullptr; @@ -1215,7 +1215,7 @@ TEST_P(ConcurrentMarkAndSweepTest, FreeObjectWithFreeWeakReversedOrder) { } INSTANTIATE_TEST_SUITE_P(, - ConcurrentMarkAndSweepTest, + ParallelMarkConcurrentSweepTest, testing::Values( ParallelismOptions{kDefaultThreadCount * 3, false, 0}, ParallelismOptions{kDefaultThreadCount * 3, true, 0}