diff options
Diffstat (limited to 'runtime/gc/system_weak_test.cc')
-rw-r--r-- | runtime/gc/system_weak_test.cc | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/runtime/gc/system_weak_test.cc b/runtime/gc/system_weak_test.cc index ca112972c2..4f552a6203 100644 --- a/runtime/gc/system_weak_test.cc +++ b/runtime/gc/system_weak_test.cc @@ -111,6 +111,7 @@ static bool CollectorDoesAllowOrBroadcast() { CollectorType type = Runtime::Current()->GetHeap()->CurrentCollectorType(); switch (type) { case CollectorType::kCollectorTypeCMS: + case CollectorType::kCollectorTypeCMC: case CollectorType::kCollectorTypeCC: case CollectorType::kCollectorTypeSS: return true; @@ -124,6 +125,7 @@ static bool CollectorDoesDisallow() { CollectorType type = Runtime::Current()->GetHeap()->CurrentCollectorType(); switch (type) { case CollectorType::kCollectorTypeCMS: + case CollectorType::kCollectorTypeCMC: return true; default: @@ -149,7 +151,12 @@ TEST_F(SystemWeakTest, Keep) { // Expect the holder to have been called. EXPECT_EQ(CollectorDoesAllowOrBroadcast() ? 1U : 0U, cswh.allow_count_); EXPECT_EQ(CollectorDoesDisallow() ? 1U : 0U, cswh.disallow_count_); - EXPECT_EQ(1U, cswh.sweep_count_); + // Userfaultfd GC uses SweepSystemWeaks also for concurrent updation. + // TODO: Explore this can be reverted back to unconditionally compare with 1 + // once concurrent updation of native roots is full implemented in userfaultfd + // GC. + size_t expected_sweep_count = gUseUserfaultfd ? 2U : 1U; + EXPECT_EQ(expected_sweep_count, cswh.sweep_count_); // Expect the weak to not be cleared. EXPECT_FALSE(cswh.Get().IsNull()); @@ -170,7 +177,12 @@ TEST_F(SystemWeakTest, Discard) { // Expect the holder to have been called. EXPECT_EQ(CollectorDoesAllowOrBroadcast() ? 1U : 0U, cswh.allow_count_); EXPECT_EQ(CollectorDoesDisallow() ? 1U : 0U, cswh.disallow_count_); - EXPECT_EQ(1U, cswh.sweep_count_); + // Userfaultfd GC uses SweepSystemWeaks also for concurrent updation. + // TODO: Explore this can be reverted back to unconditionally compare with 1 + // once concurrent updation of native roots is full implemented in userfaultfd + // GC. + size_t expected_sweep_count = gUseUserfaultfd ? 2U : 1U; + EXPECT_EQ(expected_sweep_count, cswh.sweep_count_); // Expect the weak to be cleared. EXPECT_TRUE(cswh.Get().IsNull()); @@ -194,7 +206,12 @@ TEST_F(SystemWeakTest, Remove) { // Expect the holder to have been called. ASSERT_EQ(CollectorDoesAllowOrBroadcast() ? 1U : 0U, cswh.allow_count_); ASSERT_EQ(CollectorDoesDisallow() ? 1U : 0U, cswh.disallow_count_); - ASSERT_EQ(1U, cswh.sweep_count_); + // Userfaultfd GC uses SweepSystemWeaks also for concurrent updation. + // TODO: Explore this can be reverted back to unconditionally compare with 1 + // once concurrent updation of native roots is full implemented in userfaultfd + // GC. + size_t expected_sweep_count = gUseUserfaultfd ? 2U : 1U; + EXPECT_EQ(expected_sweep_count, cswh.sweep_count_); // Expect the weak to not be cleared. ASSERT_FALSE(cswh.Get().IsNull()); @@ -209,7 +226,7 @@ TEST_F(SystemWeakTest, Remove) { // Expectation: no change in the numbers. EXPECT_EQ(CollectorDoesAllowOrBroadcast() ? 1U : 0U, cswh.allow_count_); EXPECT_EQ(CollectorDoesDisallow() ? 1U : 0U, cswh.disallow_count_); - EXPECT_EQ(1U, cswh.sweep_count_); + EXPECT_EQ(expected_sweep_count, cswh.sweep_count_); } } // namespace gc |