Commit 070b5f30 authored by Anton Bikineev's avatar Anton Bikineev Committed by V8 LUCI CQ

cppgc: young-gen: Return range size for AgeTable to 4KB

Allocation granularity (8 bytes on 64bit platforms) is already subsumed
by whatever range size we choose.

Bug: chromium:1029379
Change-Id: Iab95e6f36955c9ffbbe9ea0c98cb9d1f8dd0337b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3629869Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Auto-Submit: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80415}
parent 8f1a5c8e
......@@ -26,7 +26,7 @@ class HeapBase;
#if defined(CPPGC_YOUNG_GENERATION)
// AgeTable is the bytemap needed for the fast generation check in the write
// barrier. AgeTable contains entries that correspond to 512 bytes memory
// barrier. AgeTable contains entries that correspond to 4096 bytes memory
// regions (cards). Each entry in the table represents generation of the objects
// that reside on the corresponding card (young, old or mixed).
class V8_EXPORT AgeTable final {
......@@ -42,8 +42,7 @@ class V8_EXPORT AgeTable final {
enum class AdjacentCardsPolicy : uint8_t { kConsider, kIgnore };
static constexpr size_t kCardSizeInBytes =
(api_constants::kCagedHeapReservationSize / kAllocationGranularity) /
kRequiredSize;
api_constants::kCagedHeapReservationSize / kRequiredSize;
void SetAge(uintptr_t cage_offset, Age age) {
table_[card(cage_offset)] = age;
......@@ -67,7 +66,7 @@ class V8_EXPORT AgeTable final {
__builtin_ctz(static_cast<uint32_t>(kCardSizeInBytes));
#else //! V8_HAS_BUILTIN_CTZ
// Hardcode and check with assert.
9;
12;
#endif // !V8_HAS_BUILTIN_CTZ
static_assert((1 << kGranularityBits) == kCardSizeInBytes);
const size_t entry = offset >> kGranularityBits;
......
......@@ -196,5 +196,15 @@ TEST_F(AgeTableTest, SetAgeForMultipleCardsConsiderAdjacentCards) {
EXPECT_EQ(Age::kYoung, GetAge(object_end));
}
TEST_F(AgeTableTest, MarkAllCardsAsYoung) {
void* heap_start = Heap::From(GetHeap())->caged_heap().base();
void* heap_end =
static_cast<uint8_t*>(heap_start) + kCagedHeapReservationSize - 1;
AssertAgeForAddressRange(heap_start, heap_end, Age::kOld);
SetAgeForAddressRange(heap_start, heap_end, Age::kYoung,
AdjacentCardsPolicy::kIgnore);
AssertAgeForAddressRange(heap_start, heap_end, Age::kYoung);
}
} // namespace internal
} // namespace cppgc
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment