[K/N] Fixing ConcurrentMarkAndSweepTest ^KT-56233
This commit is contained in:
committed by
Space Team
parent
4e74f7e57c
commit
e6c0f32477
@@ -246,7 +246,7 @@ TEST_P(ConcurrentMarkAndSweepTest, RootSet) {
|
||||
ASSERT_THAT(IsMarked(stack2.header()), false);
|
||||
ASSERT_THAT(IsMarked(stack3.header()), false);
|
||||
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
|
||||
EXPECT_THAT(
|
||||
Alive(threadData),
|
||||
@@ -292,7 +292,7 @@ TEST_P(ConcurrentMarkAndSweepTest, InterconnectedRootSet) {
|
||||
ASSERT_THAT(IsMarked(stack2.header()), false);
|
||||
ASSERT_THAT(IsMarked(stack3.header()), false);
|
||||
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
|
||||
EXPECT_THAT(
|
||||
Alive(threadData),
|
||||
@@ -316,7 +316,7 @@ TEST_P(ConcurrentMarkAndSweepTest, FreeObjects) {
|
||||
ASSERT_THAT(IsMarked(object1.header()), false);
|
||||
ASSERT_THAT(IsMarked(object2.header()), false);
|
||||
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
|
||||
EXPECT_THAT(Alive(threadData), testing::UnorderedElementsAre());
|
||||
});
|
||||
@@ -370,7 +370,7 @@ TEST_P(ConcurrentMarkAndSweepTest, FreeObjectWithHoldedWeak) {
|
||||
ASSERT_THAT(IsMarked(weak1.header()), false);
|
||||
ASSERT_THAT(weak1.get(), object1.header());
|
||||
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
|
||||
EXPECT_THAT(Alive(threadData), testing::UnorderedElementsAre(weak1.header(), stack.header()));
|
||||
EXPECT_THAT(IsMarked(weak1.header()), false);
|
||||
@@ -403,7 +403,7 @@ TEST_P(ConcurrentMarkAndSweepTest, ObjectReferencedFromRootSet) {
|
||||
ASSERT_THAT(IsMarked(object3.header()), false);
|
||||
ASSERT_THAT(IsMarked(object4.header()), false);
|
||||
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
|
||||
EXPECT_THAT(
|
||||
Alive(threadData),
|
||||
@@ -452,7 +452,7 @@ TEST_P(ConcurrentMarkAndSweepTest, ObjectsWithCycles) {
|
||||
ASSERT_THAT(IsMarked(object5.header()), false);
|
||||
ASSERT_THAT(IsMarked(object6.header()), false);
|
||||
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
|
||||
EXPECT_THAT(
|
||||
Alive(threadData),
|
||||
@@ -536,7 +536,7 @@ TEST_P(ConcurrentMarkAndSweepTest, ObjectsWithCyclesIntoRootSet) {
|
||||
ASSERT_THAT(IsMarked(object1.header()), false);
|
||||
ASSERT_THAT(IsMarked(object2.header()), false);
|
||||
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
|
||||
EXPECT_THAT(Alive(threadData), testing::UnorderedElementsAre(global.header(), stack.header(), object1.header(), object2.header()));
|
||||
EXPECT_THAT(IsMarked(global.header()), false);
|
||||
@@ -580,8 +580,8 @@ TEST_P(ConcurrentMarkAndSweepTest, RunGCTwice) {
|
||||
ASSERT_THAT(IsMarked(object5.header()), false);
|
||||
ASSERT_THAT(IsMarked(object6.header()), false);
|
||||
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
|
||||
EXPECT_THAT(
|
||||
Alive(threadData),
|
||||
@@ -611,7 +611,7 @@ TEST_P(ConcurrentMarkAndSweepTest, PermanentObjects) {
|
||||
ASSERT_THAT(Alive(threadData), testing::UnorderedElementsAre(global2.header()));
|
||||
EXPECT_THAT(IsMarked(global2.header()), false);
|
||||
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
|
||||
EXPECT_THAT(Alive(threadData), testing::UnorderedElementsAre(global2.header()));
|
||||
EXPECT_THAT(IsMarked(global2.header()), false);
|
||||
@@ -631,7 +631,7 @@ TEST_P(ConcurrentMarkAndSweepTest, SameObjectInRootSet) {
|
||||
EXPECT_THAT(IsMarked(global.header()), false);
|
||||
EXPECT_THAT(IsMarked(object.header()), false);
|
||||
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
|
||||
EXPECT_THAT(Alive(threadData), testing::UnorderedElementsAre(global.header(), object.header()));
|
||||
EXPECT_THAT(IsMarked(global.header()), false);
|
||||
@@ -729,7 +729,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsCollect) {
|
||||
|
||||
std_support::vector<std::future<void>> gcFutures(kDefaultThreadCount);
|
||||
|
||||
gcFutures[0] = mutators[0].Execute([](mm::ThreadData& threadData, Mutator& mutator) { threadData.gc().ScheduleAndWaitFullGC(); });
|
||||
gcFutures[0] = mutators[0].Execute([](mm::ThreadData& threadData, Mutator& mutator) { threadData.gc().ScheduleAndWaitFullGCWithFinalizers(); });
|
||||
|
||||
// Spin until thread suspension is requested.
|
||||
while (!mm::IsThreadSuspensionRequested()) {
|
||||
@@ -787,7 +787,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAllCollect) {
|
||||
|
||||
for (int i = 0; i < kDefaultThreadCount; ++i) {
|
||||
gcFutures[i] = mutators[i].Execute([](mm::ThreadData& threadData, Mutator& mutator) {
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
// If GC starts before all thread executed line above, two gc will be run
|
||||
// So we are temporary switch threads to native state and then return them back after all GC runs are done
|
||||
SwitchThreadState(mm::GetMemoryState(), kotlin::ThreadState::kNative);
|
||||
@@ -861,7 +861,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsAddToRootSetAfterCollectionRe
|
||||
}
|
||||
|
||||
std_support::vector<std::future<void>> gcFutures(kDefaultThreadCount);
|
||||
gcFutures[0] = mutators[0].Execute([](mm::ThreadData& threadData, Mutator& mutator) { threadData.gc().ScheduleAndWaitFullGC(); });
|
||||
gcFutures[0] = mutators[0].Execute([](mm::ThreadData& threadData, Mutator& mutator) { threadData.gc().ScheduleAndWaitFullGCWithFinalizers(); });
|
||||
|
||||
// Spin until thread suspension is requested.
|
||||
while (!mm::IsThreadSuspensionRequested()) {
|
||||
@@ -926,7 +926,7 @@ TEST_P(ConcurrentMarkAndSweepTest, CrossThreadReference) {
|
||||
|
||||
std_support::vector<std::future<void>> gcFutures(kDefaultThreadCount);
|
||||
|
||||
gcFutures[0] = mutators[0].Execute([](mm::ThreadData& threadData, Mutator& mutator) { threadData.gc().ScheduleAndWaitFullGC(); });
|
||||
gcFutures[0] = mutators[0].Execute([](mm::ThreadData& threadData, Mutator& mutator) { threadData.gc().ScheduleAndWaitFullGCWithFinalizers(); });
|
||||
|
||||
// Spin until thread suspension is requested.
|
||||
while (!mm::IsThreadSuspensionRequested()) {
|
||||
@@ -988,7 +988,7 @@ TEST_P(ConcurrentMarkAndSweepTest, MultipleMutatorsWeaks) {
|
||||
std_support::vector<std::future<void>> gcFutures(kDefaultThreadCount);
|
||||
|
||||
gcFutures[0] = mutators[0].Execute([weak](mm::ThreadData& threadData, Mutator& mutator) {
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
EXPECT_THAT(weak->get(), nullptr);
|
||||
});
|
||||
|
||||
@@ -1039,7 +1039,7 @@ TEST_P(ConcurrentMarkAndSweepTest, NewThreadsWhileRequestingCollection) {
|
||||
|
||||
std_support::vector<std::future<void>> gcFutures(kDefaultThreadCount);
|
||||
|
||||
gcFutures[0] = mutators[0].Execute([](mm::ThreadData& threadData, Mutator& mutator) { threadData.gc().ScheduleAndWaitFullGC(); });
|
||||
gcFutures[0] = mutators[0].Execute([](mm::ThreadData& threadData, Mutator& mutator) { threadData.gc().ScheduleAndWaitFullGCWithFinalizers(); });
|
||||
|
||||
// Spin until thread suspension is requested.
|
||||
while (!mm::IsThreadSuspensionRequested()) {
|
||||
@@ -1106,7 +1106,7 @@ TEST_P(ConcurrentMarkAndSweepTest, FreeObjectWithFreeWeakReversedOrder) {
|
||||
global1->field1 = object1_local.header();
|
||||
while (weak.load() == nullptr)
|
||||
;
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
|
||||
ASSERT_THAT(Alive(threadData), testing::UnorderedElementsAre(object1_local.header(), weak.load()->header(), global1.header()));
|
||||
ASSERT_THAT(IsMarked(global1.header()), false);
|
||||
@@ -1117,7 +1117,7 @@ TEST_P(ConcurrentMarkAndSweepTest, FreeObjectWithFreeWeakReversedOrder) {
|
||||
global1->field1 = nullptr;
|
||||
|
||||
EXPECT_CALL(finalizerHook(), Call(weak.load()->header()));
|
||||
threadData.gc().ScheduleAndWaitFullGC();
|
||||
threadData.gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
|
||||
EXPECT_THAT(Alive(threadData), testing::UnorderedElementsAre(global1.header()));
|
||||
done = true;
|
||||
|
||||
Reference in New Issue
Block a user