From 0c3919d5e247ef22e5d8da9da40ab052af0fc9b9 Mon Sep 17 00:00:00 2001 From: Nikolaos Papaspyrou Date: Thu, 6 Oct 2022 15:47:37 +0200 Subject: [PATCH] [heap] Fix inner pointer resolution unit test This CL fixes two bugs in the unit test for inner pointer resolution, implemented using the marking bitmap. First, the tests would not compile after crrev.com/c/3925548, which moved the marking state from the collector to the heap. Second, some tests would fail in builds without pointer compression, because the size of words in heap is different. Bug: v8:13257 Change-Id: I8e6c9c70daa9ed9a8f0ebd5a06f7c017445400e6 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3937964 Commit-Queue: Nikolaos Papaspyrou Reviewed-by: Omer Katz Cr-Commit-Position: refs/heads/main@{#83563} --- src/heap/mark-compact.h | 2 +- src/heap/memory-allocator.h | 3 +- src/heap/spaces.h | 2 +- test/unittests/BUILD.gn | 5 +- ...rking-inner-pointer-resolution-unittest.cc | 283 +++++++++--------- 5 files changed, 147 insertions(+), 148 deletions(-) diff --git a/src/heap/mark-compact.h b/src/heap/mark-compact.h index 6ed8a6870e..e53f40141c 100644 --- a/src/heap/mark-compact.h +++ b/src/heap/mark-compact.h @@ -452,7 +452,7 @@ class MarkCompactCollector final : public CollectorBase { // `kNullAddress` if the parameter does not point to (the interior of) a valid // heap object, or if it points to (the interior of) some object that is // already marked as live (black or grey). - Address FindBasePtrForMarking(Address maybe_inner_ptr); + V8_EXPORT_PRIVATE Address FindBasePtrForMarking(Address maybe_inner_ptr); #endif // V8_ENABLE_INNER_POINTER_RESOLUTION_MB private: diff --git a/src/heap/memory-allocator.h b/src/heap/memory-allocator.h index 0485a7fe8c..ed6e4c82fa 100644 --- a/src/heap/memory-allocator.h +++ b/src/heap/memory-allocator.h @@ -265,7 +265,8 @@ class MemoryAllocator { // Return the normal or large page that contains this address, if it is owned // by this heap, otherwise a nullptr. - const MemoryChunk* LookupChunkContainingAddress(Address addr) const; + V8_EXPORT_PRIVATE const MemoryChunk* LookupChunkContainingAddress( + Address addr) const; // Insert and remove normal and large pages that are owned by this heap. void RecordNormalPageCreated(const Page& page); diff --git a/src/heap/spaces.h b/src/heap/spaces.h index d269348e99..48b8c9fc41 100644 --- a/src/heap/spaces.h +++ b/src/heap/spaces.h @@ -303,7 +303,7 @@ class Page : public MemoryChunk { return categories_[type]; } - size_t ShrinkToHighWaterMark(); + V8_EXPORT_PRIVATE size_t ShrinkToHighWaterMark(); V8_EXPORT_PRIVATE void CreateBlackArea(Address start, Address end); V8_EXPORT_PRIVATE void CreateBlackAreaBackground(Address start, Address end); diff --git a/test/unittests/BUILD.gn b/test/unittests/BUILD.gn index 1e0c556ee4..ae98a65b69 100644 --- a/test/unittests/BUILD.gn +++ b/test/unittests/BUILD.gn @@ -412,7 +412,6 @@ v8_source_set("unittests_sources") { "heap/local-factory-unittest.cc", "heap/local-handles-unittest.cc", "heap/local-heap-unittest.cc", - "heap/marking-inner-pointer-resolution-unittest.cc", "heap/marking-unittest.cc", "heap/marking-worklist-unittest.cc", "heap/memory-reducer-unittest.cc", @@ -585,6 +584,10 @@ v8_source_set("unittests_sources") { sources += [ "heap/object-start-bitmap-unittest.cc" ] } + if (v8_enable_inner_pointer_resolution_mb) { + sources += [ "heap/marking-inner-pointer-resolution-unittest.cc" ] + } + if (v8_enable_i18n_support) { defines = [ "V8_INTL_SUPPORT" ] public_deps = [ "//third_party/icu" ] diff --git a/test/unittests/heap/marking-inner-pointer-resolution-unittest.cc b/test/unittests/heap/marking-inner-pointer-resolution-unittest.cc index 7c5512d63a..1dd205574f 100644 --- a/test/unittests/heap/marking-inner-pointer-resolution-unittest.cc +++ b/test/unittests/heap/marking-inner-pointer-resolution-unittest.cc @@ -10,9 +10,11 @@ namespace v8 { namespace internal { -#ifdef V8_ENABLE_INNER_POINTER_RESOLUTION_MB namespace { +constexpr int Tagged = kTaggedSize; +constexpr int FullCell = Bitmap::kBitsPerCell * Tagged; + class InnerPointerResolutionTest : public TestWithIsolate { public: struct ObjectRequest { @@ -101,7 +103,7 @@ class InnerPointerResolutionTest : public TestWithIsolate { Address ptr = page->area_start(); for (auto object : objects) { DCHECK_NE(ObjectRequest::LARGE, object.type); - DCHECK_EQ(0, object.size % kTaggedSize); + DCHECK_EQ(0, object.size % Tagged); // Check if padding is needed. int index_in_cell = Bitmap::IndexInCell(page->AddressToMarkbitIndex(ptr)); @@ -113,7 +115,7 @@ class InnerPointerResolutionTest : public TestWithIsolate { const int needed_padding_size = ((Bitmap::kBitsPerCell + object.index_in_cell - index_in_cell) % Bitmap::kBitsPerCell) * - Bitmap::kBytesPerCell; + Tagged; if (needed_padding_size > 0) { ObjectRequest pad{needed_padding_size, ObjectRequest::FREE, @@ -183,13 +185,13 @@ class InnerPointerResolutionTest : public TestWithIsolate { switch (object.type) { case ObjectRequest::REGULAR: case ObjectRequest::LARGE: { - DCHECK_LE(2 * kTaggedSize, object.size); + DCHECK_LE(2 * Tagged, object.size); ReadOnlyRoots roots(heap()); HeapObject heap_object(HeapObject::FromAddress(object.address)); heap_object.set_map_after_allocation(roots.unchecked_fixed_array_map(), SKIP_WRITE_BARRIER); FixedArray arr(FixedArray::cast(heap_object)); - arr.set_length((object.size - FixedArray::SizeFor(0)) / kTaggedSize); + arr.set_length((object.size - FixedArray::SizeFor(0)) / Tagged); DCHECK_EQ(object.size, arr.AllocatedSize()); break; } @@ -203,17 +205,17 @@ class InnerPointerResolutionTest : public TestWithIsolate { case ObjectRequest::WHITE: break; case ObjectRequest::GREY: - collector()->marking_state()->WhiteToGrey( + heap()->marking_state()->WhiteToGrey( HeapObject::FromAddress(object.address)); break; case ObjectRequest::BLACK: - DCHECK_LE(2 * kTaggedSize, object.size); - collector()->marking_state()->WhiteToBlack( + DCHECK_LE(2 * Tagged, object.size); + heap()->marking_state()->WhiteToBlack( HeapObject::FromAddress(object.address)); break; case ObjectRequest::BLACK_AREA: { MemoryChunk* page = LookupPage(object.page_id); - collector()->marking_state()->bitmap(page)->SetRange( + heap()->marking_state()->bitmap(page)->SetRange( page->AddressToMarkbitIndex(object.address), page->AddressToMarkbitIndex(object.address + object.size)); break; @@ -231,8 +233,8 @@ class InnerPointerResolutionTest : public TestWithIsolate { !IsPageAlive(object.page_id) || (object.type == ObjectRequest::FREE) || (object.type == ObjectRequest::REGULAR && (object.marked == ObjectRequest::BLACK_AREA || - (object.marked == ObjectRequest::BLACK && offset < 2 * kTaggedSize) || - (object.marked == ObjectRequest::GREY && offset < kTaggedSize))); + (object.marked == ObjectRequest::BLACK && offset < 2 * Tagged) || + (object.marked == ObjectRequest::GREY && offset < Tagged))); if (should_return_null) EXPECT_EQ(kNullAddress, base_ptr); else @@ -281,15 +283,15 @@ TEST_F(InnerPointerResolutionTest, EmptyPage) { TEST_F(InnerPointerResolutionTest, NothingMarked) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {64}, - {48}, - {52}, - {512}, - {4, ObjectRequest::FREE}, - {60}, - {8, ObjectRequest::FREE}, - {8}, - {42176}, + {16 * Tagged}, + {12 * Tagged}, + {13 * Tagged}, + {128 * Tagged}, + {1 * Tagged, ObjectRequest::FREE}, + {15 * Tagged}, + {2 * Tagged, ObjectRequest::FREE}, + {2 * Tagged}, + {10544 * Tagged}, }); TestAll(); } @@ -297,15 +299,15 @@ TEST_F(InnerPointerResolutionTest, NothingMarked) { TEST_F(InnerPointerResolutionTest, AllMarked) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {64, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {48, ObjectRequest::REGULAR, ObjectRequest::GREY}, - {52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {512, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {4, ObjectRequest::FREE, ObjectRequest::GREY}, - {60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {8, ObjectRequest::FREE, ObjectRequest::GREY}, - {8, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {42176, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::GREY}, + {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {1 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY}, + {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {2 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY}, + {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {10544 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, }); TestAll(); } @@ -313,15 +315,15 @@ TEST_F(InnerPointerResolutionTest, AllMarked) { TEST_F(InnerPointerResolutionTest, SomeMarked) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {48, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {512, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {4, ObjectRequest::FREE, ObjectRequest::GREY}, - {60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {8, ObjectRequest::FREE, ObjectRequest::GREY}, - {8, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {42176, ObjectRequest::REGULAR, ObjectRequest::GREY}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {1 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY}, + {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {2 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY}, + {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {10544 * Tagged, ObjectRequest::REGULAR, ObjectRequest::GREY}, }); TestAll(); } @@ -329,15 +331,15 @@ TEST_F(InnerPointerResolutionTest, SomeMarked) { TEST_F(InnerPointerResolutionTest, BlackAreas) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {48, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, - {52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {512, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, - {4, ObjectRequest::FREE, ObjectRequest::GREY}, - {60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {8, ObjectRequest::FREE, ObjectRequest::GREY}, - {8, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {42176, ObjectRequest::REGULAR, ObjectRequest::GREY}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, + {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, + {1 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY}, + {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {2 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY}, + {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {10544 * Tagged, ObjectRequest::REGULAR, ObjectRequest::GREY}, }); TestAll(); } @@ -349,16 +351,16 @@ TEST_F(InnerPointerResolutionTest, ThreeMarkedObjectsInSameCell) { CreateObjectsInPage({ // Some initial large unmarked object, followed by a small marked object // towards the end of the cell. - {512}, - {20, ObjectRequest::REGULAR, ObjectRequest::BLACK, 20, + {128 * Tagged}, + {5 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK, 20, ObjectRequest::PAD_WHITE}, // Then three marked objects in the same cell. - {32, ObjectRequest::REGULAR, ObjectRequest::BLACK, 3, + {8 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK, 3, ObjectRequest::PAD_WHITE}, - {48, ObjectRequest::REGULAR, ObjectRequest::BLACK, 11}, - {20, ObjectRequest::REGULAR, ObjectRequest::BLACK, 23}, + {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK, 11}, + {5 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK, 23}, // This marked object is in the next cell. - {64, ObjectRequest::REGULAR, ObjectRequest::BLACK, 17, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK, 17, ObjectRequest::PAD_WHITE}, }); TestAll(); @@ -369,16 +371,16 @@ TEST_F(InnerPointerResolutionTest, ThreeBlackAreasInSameCell) { CreateObjectsInPage({ // Some initial large unmarked object, followed by a small black area // towards the end of the cell. - {512}, - {20, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 20, + {128 * Tagged}, + {5 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 20, ObjectRequest::PAD_WHITE}, // Then three black areas in the same cell. - {32, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 3, + {8 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 3, ObjectRequest::PAD_WHITE}, - {48, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 11}, - {20, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 23}, + {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 11}, + {5 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 23}, // This black area is in the next cell. - {64, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 17, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 17, ObjectRequest::PAD_WHITE}, }); TestAll(); @@ -387,7 +389,7 @@ TEST_F(InnerPointerResolutionTest, ThreeBlackAreasInSameCell) { TEST_F(InnerPointerResolutionTest, SmallBlackAreaAtPageStart) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 30, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 30, ObjectRequest::PAD_BLACK}, }); TestAll(); @@ -396,8 +398,8 @@ TEST_F(InnerPointerResolutionTest, SmallBlackAreaAtPageStart) { TEST_F(InnerPointerResolutionTest, SmallBlackAreaAtPageStartUntilCellBoundary) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {8, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, + {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, ObjectRequest::PAD_BLACK}, }); TestAll(); @@ -406,9 +408,8 @@ TEST_F(InnerPointerResolutionTest, SmallBlackAreaAtPageStartUntilCellBoundary) { TEST_F(InnerPointerResolutionTest, LargeBlackAreaAtPageStart) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {42 * Bitmap::kBitsPerCell * Bitmap::kBytesPerCell, - ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 30, + {42 * FullCell, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 30, ObjectRequest::PAD_BLACK}, }); TestAll(); @@ -417,9 +418,8 @@ TEST_F(InnerPointerResolutionTest, LargeBlackAreaAtPageStart) { TEST_F(InnerPointerResolutionTest, LargeBlackAreaAtPageStartUntilCellBoundary) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {42 * Bitmap::kBitsPerCell * Bitmap::kBytesPerCell, - ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, + {42 * FullCell, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, ObjectRequest::PAD_BLACK}, }); TestAll(); @@ -428,8 +428,8 @@ TEST_F(InnerPointerResolutionTest, LargeBlackAreaAtPageStartUntilCellBoundary) { TEST_F(InnerPointerResolutionTest, SmallBlackAreaStartingAtCellBoundary) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {512}, - {20, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, + {128 * Tagged}, + {5 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, ObjectRequest::PAD_WHITE}, }); TestAll(); @@ -438,10 +438,9 @@ TEST_F(InnerPointerResolutionTest, SmallBlackAreaStartingAtCellBoundary) { TEST_F(InnerPointerResolutionTest, LargeBlackAreaStartingAtCellBoundary) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {512}, - {42 * Bitmap::kBitsPerCell * Bitmap::kBytesPerCell + 64, - ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, - ObjectRequest::PAD_WHITE}, + {128 * Tagged}, + {42 * FullCell + 16 * Tagged, ObjectRequest::REGULAR, + ObjectRequest::BLACK_AREA, 0, ObjectRequest::PAD_WHITE}, }); TestAll(); } @@ -449,10 +448,10 @@ TEST_F(InnerPointerResolutionTest, LargeBlackAreaStartingAtCellBoundary) { TEST_F(InnerPointerResolutionTest, SmallBlackAreaEndingAtCellBoundary) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {512}, - {8, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 13, + {128 * Tagged}, + {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 13, ObjectRequest::PAD_WHITE}, - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, ObjectRequest::PAD_BLACK}, }); TestAll(); @@ -461,11 +460,10 @@ TEST_F(InnerPointerResolutionTest, SmallBlackAreaEndingAtCellBoundary) { TEST_F(InnerPointerResolutionTest, LargeBlackAreaEndingAtCellBoundary) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {512}, - {42 * Bitmap::kBitsPerCell * Bitmap::kBytesPerCell + 64, - ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, - ObjectRequest::PAD_WHITE}, - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, + {128 * Tagged}, + {42 * FullCell + 16 * Tagged, ObjectRequest::REGULAR, + ObjectRequest::BLACK_AREA, 0, ObjectRequest::PAD_WHITE}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, ObjectRequest::PAD_BLACK}, }); TestAll(); @@ -474,12 +472,12 @@ TEST_F(InnerPointerResolutionTest, LargeBlackAreaEndingAtCellBoundary) { TEST_F(InnerPointerResolutionTest, TwoSmallBlackAreasAtCellBoundaries) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {512}, - {24, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, + {128 * Tagged}, + {6 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, ObjectRequest::PAD_WHITE}, - {8, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 25, + {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 25, ObjectRequest::PAD_WHITE}, - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, ObjectRequest::PAD_BLACK}, }); TestAll(); @@ -488,9 +486,9 @@ TEST_F(InnerPointerResolutionTest, TwoSmallBlackAreasAtCellBoundaries) { TEST_F(InnerPointerResolutionTest, BlackAreaOfOneCell) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {512}, - {Bitmap::kBitsPerCell * Bitmap::kBytesPerCell, ObjectRequest::REGULAR, - ObjectRequest::BLACK_AREA, 0, ObjectRequest::PAD_WHITE}, + {128 * Tagged}, + {1 * FullCell, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, + ObjectRequest::PAD_WHITE}, }); TestAll(); } @@ -498,9 +496,8 @@ TEST_F(InnerPointerResolutionTest, BlackAreaOfOneCell) { TEST_F(InnerPointerResolutionTest, BlackAreaOfManyCells) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {512}, - {17 * Bitmap::kBitsPerCell * Bitmap::kBytesPerCell, - ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, + {128 * Tagged}, + {17 * FullCell, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, ObjectRequest::PAD_WHITE}, }); TestAll(); @@ -511,21 +508,21 @@ TEST_F(InnerPointerResolutionTest, BlackAreaOfManyCells) { TEST_F(InnerPointerResolutionTest, TwoPages) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {512, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {42176, ObjectRequest::REGULAR, ObjectRequest::GREY}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {10544 * Tagged, ObjectRequest::REGULAR, ObjectRequest::GREY}, }); CreateObjectsInPage({ - {512, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {48, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, - {52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {4, ObjectRequest::FREE, ObjectRequest::GREY}, - {8, ObjectRequest::FREE, ObjectRequest::GREY}, - {8, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, + {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {1 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY}, + {2 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY}, + {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, }); TestAll(); } @@ -550,21 +547,21 @@ TEST_F(InnerPointerResolutionTest, SeveralLargePages) { TEST_F(InnerPointerResolutionTest, PagesOfBothKind) { if (v8_flags.enable_third_party_heap) return; CreateObjectsInPage({ - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {512, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {42176, ObjectRequest::REGULAR, ObjectRequest::GREY}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {10544 * Tagged, ObjectRequest::REGULAR, ObjectRequest::GREY}, }); CreateObjectsInPage({ - {512, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {48, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, - {52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {4, ObjectRequest::FREE, ObjectRequest::GREY}, - {8, ObjectRequest::FREE, ObjectRequest::GREY}, - {8, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, + {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {1 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY}, + {2 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY}, + {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, }); CreateLargeObjects({ {1 * MB, ObjectRequest::LARGE, ObjectRequest::WHITE}, @@ -576,21 +573,21 @@ TEST_F(InnerPointerResolutionTest, PagesOfBothKind) { TEST_F(InnerPointerResolutionTest, FreePages) { if (v8_flags.enable_third_party_heap) return; int some_normal_page = CreateObjectsInPage({ - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {512, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {42176, ObjectRequest::REGULAR, ObjectRequest::GREY}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {10544 * Tagged, ObjectRequest::REGULAR, ObjectRequest::GREY}, }); CreateObjectsInPage({ - {512, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, - {64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {48, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, - {52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, - {4, ObjectRequest::FREE, ObjectRequest::GREY}, - {8, ObjectRequest::FREE, ObjectRequest::GREY}, - {8, ObjectRequest::REGULAR, ObjectRequest::WHITE}, - {60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, + {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, + {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, + {1 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY}, + {2 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY}, + {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE}, + {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK}, }); auto large_pages = CreateLargeObjects({ {1 * MB, ObjectRequest::LARGE, ObjectRequest::WHITE}, @@ -622,7 +619,7 @@ TEST_F(InnerPointerResolutionHeapTest, UnusedRegularYoungPages) { const int length = (heap()->MaxRegularHeapObjectSize(AllocationType::kYoung) - FixedArray::SizeFor(0)) / - kTaggedSize; + Tagged; auto h1 = factory()->NewFixedArray(length, AllocationType::kYoung); auto h2 = factory()->NewFixedArray(length, AllocationType::kYoung); weak1.Reset(v8_isolate(), Utils::FixedArrayToLocal(h1)); @@ -648,13 +645,13 @@ TEST_F(InnerPointerResolutionHeapTest, UnusedRegularYoungPages) { EXPECT_EQ(obj3.address(), obj2.address() + obj2.Size(cage_base)); // Keep inner pointers to all objects. - inner_ptr1 = obj1.address() + 17 * kTaggedSize; - inner_ptr2 = obj2.address() + 37 * kTaggedSize; - inner_ptr3 = obj3.address() + 7 * kTaggedSize; + inner_ptr1 = obj1.address() + 17 * Tagged; + inner_ptr2 = obj2.address() + 37 * Tagged; + inner_ptr3 = obj3.address() + 7 * Tagged; // Keep pointers to the end of the pages, after the objects. - outside_ptr1 = page1->area_end() - 3 * kTaggedSize; - outside_ptr2 = page2->area_end() - 2 * kTaggedSize; + outside_ptr1 = page1->area_end() - 3 * Tagged; + outside_ptr2 = page2->area_end() - 2 * Tagged; EXPECT_LE(obj1.address() + obj1.Size(cage_base), outside_ptr1); EXPECT_LE(obj2.address() + obj2.Size(cage_base), outside_ptr2); EXPECT_LE(obj3.address() + obj3.Size(cage_base), outside_ptr2); @@ -690,7 +687,7 @@ TEST_F(InnerPointerResolutionHeapTest, UnusedRegularYoungPages) { marking->Start(GarbageCollector::MARK_COMPACTOR, i::GarbageCollectionReason::kTesting); } - MarkingState* marking_state = marking->marking_state(); + MarkingState* marking_state = heap()->marking_state(); marking_state->WhiteToGrey(obj3); marking_state->GreyToBlack(obj3); } @@ -778,7 +775,7 @@ TEST_F(InnerPointerResolutionHeapTest, UnusedLargeYoungPage) { const int length = std::max(1 << kPageSizeBits, 2 * heap()->MaxRegularHeapObjectSize(AllocationType::kYoung)) / - kTaggedSize; + Tagged; auto h = factory()->NewFixedArray(length, AllocationType::kYoung); weak.Reset(v8_isolate(), Utils::FixedArrayToLocal(h)); weak.SetWeak(); @@ -789,7 +786,7 @@ TEST_F(InnerPointerResolutionHeapTest, UnusedLargeYoungPage) { EXPECT_TRUE(v8_flags.minor_mc || page->IsToPage()); // Keep inner pointer. - inner_ptr = obj.address() + 17 * kTaggedSize; + inner_ptr = obj.address() + 17 * Tagged; // Inner pointer resolution should work now, finding the object. EXPECT_EQ( @@ -826,7 +823,7 @@ TEST_F(InnerPointerResolutionHeapTest, RegularPageAfterEnd) { EXPECT_FALSE(Page::IsAlignedToPageSize(page->area_end())); // Inner pointer resolution after the end of the page area should work. - Address inner_ptr = page->area_end() + kTaggedSize; + Address inner_ptr = page->area_end() + Tagged; EXPECT_FALSE(Page::IsAlignedToPageSize(inner_ptr)); EXPECT_EQ(kNullAddress, heap()->mark_compact_collector()->FindBasePtrForMarking(inner_ptr)); @@ -850,7 +847,7 @@ TEST_F(InnerPointerResolutionHeapTest, LargePageAfterEnd) { EXPECT_FALSE(Page::IsAlignedToPageSize(page->area_end())); // Inner pointer resolution after the end of the pare area should work. - Address inner_ptr = page->area_end() + kTaggedSize; + Address inner_ptr = page->area_end() + Tagged; EXPECT_FALSE(Page::IsAlignedToPageSize(inner_ptr)); EXPECT_EQ(kNullAddress, heap()->mark_compact_collector()->FindBasePtrForMarking(inner_ptr)); @@ -860,7 +857,5 @@ TEST_F(InnerPointerResolutionHeapTest, LargePageAfterEnd) { page); } -#endif // V8_ENABLE_INNER_POINTER_RESOLUTION_MB - } // namespace internal } // namespace v8