[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 <nikolaos@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83563}
This commit is contained in:
Nikolaos Papaspyrou 2022-10-06 15:47:37 +02:00 committed by V8 LUCI CQ
parent 392c1c3612
commit 0c3919d5e2
5 changed files with 147 additions and 148 deletions

View File

@ -452,7 +452,7 @@ class MarkCompactCollector final : public CollectorBase {
// `kNullAddress` if the parameter does not point to (the interior of) a valid // `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 // heap object, or if it points to (the interior of) some object that is
// already marked as live (black or grey). // 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 #endif // V8_ENABLE_INNER_POINTER_RESOLUTION_MB
private: private:

View File

@ -265,7 +265,8 @@ class MemoryAllocator {
// Return the normal or large page that contains this address, if it is owned // Return the normal or large page that contains this address, if it is owned
// by this heap, otherwise a nullptr. // 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. // Insert and remove normal and large pages that are owned by this heap.
void RecordNormalPageCreated(const Page& page); void RecordNormalPageCreated(const Page& page);

View File

@ -303,7 +303,7 @@ class Page : public MemoryChunk {
return categories_[type]; 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 CreateBlackArea(Address start, Address end);
V8_EXPORT_PRIVATE void CreateBlackAreaBackground(Address start, Address end); V8_EXPORT_PRIVATE void CreateBlackAreaBackground(Address start, Address end);

View File

@ -412,7 +412,6 @@ v8_source_set("unittests_sources") {
"heap/local-factory-unittest.cc", "heap/local-factory-unittest.cc",
"heap/local-handles-unittest.cc", "heap/local-handles-unittest.cc",
"heap/local-heap-unittest.cc", "heap/local-heap-unittest.cc",
"heap/marking-inner-pointer-resolution-unittest.cc",
"heap/marking-unittest.cc", "heap/marking-unittest.cc",
"heap/marking-worklist-unittest.cc", "heap/marking-worklist-unittest.cc",
"heap/memory-reducer-unittest.cc", "heap/memory-reducer-unittest.cc",
@ -585,6 +584,10 @@ v8_source_set("unittests_sources") {
sources += [ "heap/object-start-bitmap-unittest.cc" ] 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) { if (v8_enable_i18n_support) {
defines = [ "V8_INTL_SUPPORT" ] defines = [ "V8_INTL_SUPPORT" ]
public_deps = [ "//third_party/icu" ] public_deps = [ "//third_party/icu" ]

View File

@ -10,9 +10,11 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
#ifdef V8_ENABLE_INNER_POINTER_RESOLUTION_MB
namespace { namespace {
constexpr int Tagged = kTaggedSize;
constexpr int FullCell = Bitmap::kBitsPerCell * Tagged;
class InnerPointerResolutionTest : public TestWithIsolate { class InnerPointerResolutionTest : public TestWithIsolate {
public: public:
struct ObjectRequest { struct ObjectRequest {
@ -101,7 +103,7 @@ class InnerPointerResolutionTest : public TestWithIsolate {
Address ptr = page->area_start(); Address ptr = page->area_start();
for (auto object : objects) { for (auto object : objects) {
DCHECK_NE(ObjectRequest::LARGE, object.type); DCHECK_NE(ObjectRequest::LARGE, object.type);
DCHECK_EQ(0, object.size % kTaggedSize); DCHECK_EQ(0, object.size % Tagged);
// Check if padding is needed. // Check if padding is needed.
int index_in_cell = Bitmap::IndexInCell(page->AddressToMarkbitIndex(ptr)); int index_in_cell = Bitmap::IndexInCell(page->AddressToMarkbitIndex(ptr));
@ -113,7 +115,7 @@ class InnerPointerResolutionTest : public TestWithIsolate {
const int needed_padding_size = const int needed_padding_size =
((Bitmap::kBitsPerCell + object.index_in_cell - index_in_cell) % ((Bitmap::kBitsPerCell + object.index_in_cell - index_in_cell) %
Bitmap::kBitsPerCell) * Bitmap::kBitsPerCell) *
Bitmap::kBytesPerCell; Tagged;
if (needed_padding_size > 0) { if (needed_padding_size > 0) {
ObjectRequest pad{needed_padding_size, ObjectRequest pad{needed_padding_size,
ObjectRequest::FREE, ObjectRequest::FREE,
@ -183,13 +185,13 @@ class InnerPointerResolutionTest : public TestWithIsolate {
switch (object.type) { switch (object.type) {
case ObjectRequest::REGULAR: case ObjectRequest::REGULAR:
case ObjectRequest::LARGE: { case ObjectRequest::LARGE: {
DCHECK_LE(2 * kTaggedSize, object.size); DCHECK_LE(2 * Tagged, object.size);
ReadOnlyRoots roots(heap()); ReadOnlyRoots roots(heap());
HeapObject heap_object(HeapObject::FromAddress(object.address)); HeapObject heap_object(HeapObject::FromAddress(object.address));
heap_object.set_map_after_allocation(roots.unchecked_fixed_array_map(), heap_object.set_map_after_allocation(roots.unchecked_fixed_array_map(),
SKIP_WRITE_BARRIER); SKIP_WRITE_BARRIER);
FixedArray arr(FixedArray::cast(heap_object)); 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()); DCHECK_EQ(object.size, arr.AllocatedSize());
break; break;
} }
@ -203,17 +205,17 @@ class InnerPointerResolutionTest : public TestWithIsolate {
case ObjectRequest::WHITE: case ObjectRequest::WHITE:
break; break;
case ObjectRequest::GREY: case ObjectRequest::GREY:
collector()->marking_state()->WhiteToGrey( heap()->marking_state()->WhiteToGrey(
HeapObject::FromAddress(object.address)); HeapObject::FromAddress(object.address));
break; break;
case ObjectRequest::BLACK: case ObjectRequest::BLACK:
DCHECK_LE(2 * kTaggedSize, object.size); DCHECK_LE(2 * Tagged, object.size);
collector()->marking_state()->WhiteToBlack( heap()->marking_state()->WhiteToBlack(
HeapObject::FromAddress(object.address)); HeapObject::FromAddress(object.address));
break; break;
case ObjectRequest::BLACK_AREA: { case ObjectRequest::BLACK_AREA: {
MemoryChunk* page = LookupPage(object.page_id); 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),
page->AddressToMarkbitIndex(object.address + object.size)); page->AddressToMarkbitIndex(object.address + object.size));
break; break;
@ -231,8 +233,8 @@ class InnerPointerResolutionTest : public TestWithIsolate {
!IsPageAlive(object.page_id) || (object.type == ObjectRequest::FREE) || !IsPageAlive(object.page_id) || (object.type == ObjectRequest::FREE) ||
(object.type == ObjectRequest::REGULAR && (object.type == ObjectRequest::REGULAR &&
(object.marked == ObjectRequest::BLACK_AREA || (object.marked == ObjectRequest::BLACK_AREA ||
(object.marked == ObjectRequest::BLACK && offset < 2 * kTaggedSize) || (object.marked == ObjectRequest::BLACK && offset < 2 * Tagged) ||
(object.marked == ObjectRequest::GREY && offset < kTaggedSize))); (object.marked == ObjectRequest::GREY && offset < Tagged)));
if (should_return_null) if (should_return_null)
EXPECT_EQ(kNullAddress, base_ptr); EXPECT_EQ(kNullAddress, base_ptr);
else else
@ -281,15 +283,15 @@ TEST_F(InnerPointerResolutionTest, EmptyPage) {
TEST_F(InnerPointerResolutionTest, NothingMarked) { TEST_F(InnerPointerResolutionTest, NothingMarked) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{64}, {16 * Tagged},
{48}, {12 * Tagged},
{52}, {13 * Tagged},
{512}, {128 * Tagged},
{4, ObjectRequest::FREE}, {1 * Tagged, ObjectRequest::FREE},
{60}, {15 * Tagged},
{8, ObjectRequest::FREE}, {2 * Tagged, ObjectRequest::FREE},
{8}, {2 * Tagged},
{42176}, {10544 * Tagged},
}); });
TestAll(); TestAll();
} }
@ -297,15 +299,15 @@ TEST_F(InnerPointerResolutionTest, NothingMarked) {
TEST_F(InnerPointerResolutionTest, AllMarked) { TEST_F(InnerPointerResolutionTest, AllMarked) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{64, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{48, ObjectRequest::REGULAR, ObjectRequest::GREY}, {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::GREY},
{52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{512, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{4, ObjectRequest::FREE, ObjectRequest::GREY}, {1 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY},
{60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{8, ObjectRequest::FREE, ObjectRequest::GREY}, {2 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY},
{8, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{42176, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {10544 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
}); });
TestAll(); TestAll();
} }
@ -313,15 +315,15 @@ TEST_F(InnerPointerResolutionTest, AllMarked) {
TEST_F(InnerPointerResolutionTest, SomeMarked) { TEST_F(InnerPointerResolutionTest, SomeMarked) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{48, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{512, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{4, ObjectRequest::FREE, ObjectRequest::GREY}, {1 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY},
{60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{8, ObjectRequest::FREE, ObjectRequest::GREY}, {2 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY},
{8, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{42176, ObjectRequest::REGULAR, ObjectRequest::GREY}, {10544 * Tagged, ObjectRequest::REGULAR, ObjectRequest::GREY},
}); });
TestAll(); TestAll();
} }
@ -329,15 +331,15 @@ TEST_F(InnerPointerResolutionTest, SomeMarked) {
TEST_F(InnerPointerResolutionTest, BlackAreas) { TEST_F(InnerPointerResolutionTest, BlackAreas) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{48, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA},
{52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{512, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA},
{4, ObjectRequest::FREE, ObjectRequest::GREY}, {1 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY},
{60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{8, ObjectRequest::FREE, ObjectRequest::GREY}, {2 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY},
{8, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{42176, ObjectRequest::REGULAR, ObjectRequest::GREY}, {10544 * Tagged, ObjectRequest::REGULAR, ObjectRequest::GREY},
}); });
TestAll(); TestAll();
} }
@ -349,16 +351,16 @@ TEST_F(InnerPointerResolutionTest, ThreeMarkedObjectsInSameCell) {
CreateObjectsInPage({ CreateObjectsInPage({
// Some initial large unmarked object, followed by a small marked object // Some initial large unmarked object, followed by a small marked object
// towards the end of the cell. // towards the end of the cell.
{512}, {128 * Tagged},
{20, ObjectRequest::REGULAR, ObjectRequest::BLACK, 20, {5 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK, 20,
ObjectRequest::PAD_WHITE}, ObjectRequest::PAD_WHITE},
// Then three marked objects in the same cell. // Then three marked objects in the same cell.
{32, ObjectRequest::REGULAR, ObjectRequest::BLACK, 3, {8 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK, 3,
ObjectRequest::PAD_WHITE}, ObjectRequest::PAD_WHITE},
{48, ObjectRequest::REGULAR, ObjectRequest::BLACK, 11}, {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK, 11},
{20, ObjectRequest::REGULAR, ObjectRequest::BLACK, 23}, {5 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK, 23},
// This marked object is in the next cell. // This marked object is in the next cell.
{64, ObjectRequest::REGULAR, ObjectRequest::BLACK, 17, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK, 17,
ObjectRequest::PAD_WHITE}, ObjectRequest::PAD_WHITE},
}); });
TestAll(); TestAll();
@ -369,16 +371,16 @@ TEST_F(InnerPointerResolutionTest, ThreeBlackAreasInSameCell) {
CreateObjectsInPage({ CreateObjectsInPage({
// Some initial large unmarked object, followed by a small black area // Some initial large unmarked object, followed by a small black area
// towards the end of the cell. // towards the end of the cell.
{512}, {128 * Tagged},
{20, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 20, {5 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 20,
ObjectRequest::PAD_WHITE}, ObjectRequest::PAD_WHITE},
// Then three black areas in the same cell. // 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}, ObjectRequest::PAD_WHITE},
{48, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 11}, {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 11},
{20, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 23}, {5 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 23},
// This black area is in the next cell. // 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}, ObjectRequest::PAD_WHITE},
}); });
TestAll(); TestAll();
@ -387,7 +389,7 @@ TEST_F(InnerPointerResolutionTest, ThreeBlackAreasInSameCell) {
TEST_F(InnerPointerResolutionTest, SmallBlackAreaAtPageStart) { TEST_F(InnerPointerResolutionTest, SmallBlackAreaAtPageStart) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 30, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 30,
ObjectRequest::PAD_BLACK}, ObjectRequest::PAD_BLACK},
}); });
TestAll(); TestAll();
@ -396,8 +398,8 @@ TEST_F(InnerPointerResolutionTest, SmallBlackAreaAtPageStart) {
TEST_F(InnerPointerResolutionTest, SmallBlackAreaAtPageStartUntilCellBoundary) { TEST_F(InnerPointerResolutionTest, SmallBlackAreaAtPageStartUntilCellBoundary) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{8, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA},
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0,
ObjectRequest::PAD_BLACK}, ObjectRequest::PAD_BLACK},
}); });
TestAll(); TestAll();
@ -406,9 +408,8 @@ TEST_F(InnerPointerResolutionTest, SmallBlackAreaAtPageStartUntilCellBoundary) {
TEST_F(InnerPointerResolutionTest, LargeBlackAreaAtPageStart) { TEST_F(InnerPointerResolutionTest, LargeBlackAreaAtPageStart) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{42 * Bitmap::kBitsPerCell * Bitmap::kBytesPerCell, {42 * FullCell, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA},
ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 30,
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 30,
ObjectRequest::PAD_BLACK}, ObjectRequest::PAD_BLACK},
}); });
TestAll(); TestAll();
@ -417,9 +418,8 @@ TEST_F(InnerPointerResolutionTest, LargeBlackAreaAtPageStart) {
TEST_F(InnerPointerResolutionTest, LargeBlackAreaAtPageStartUntilCellBoundary) { TEST_F(InnerPointerResolutionTest, LargeBlackAreaAtPageStartUntilCellBoundary) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{42 * Bitmap::kBitsPerCell * Bitmap::kBytesPerCell, {42 * FullCell, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA},
ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0,
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0,
ObjectRequest::PAD_BLACK}, ObjectRequest::PAD_BLACK},
}); });
TestAll(); TestAll();
@ -428,8 +428,8 @@ TEST_F(InnerPointerResolutionTest, LargeBlackAreaAtPageStartUntilCellBoundary) {
TEST_F(InnerPointerResolutionTest, SmallBlackAreaStartingAtCellBoundary) { TEST_F(InnerPointerResolutionTest, SmallBlackAreaStartingAtCellBoundary) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{512}, {128 * Tagged},
{20, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, {5 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0,
ObjectRequest::PAD_WHITE}, ObjectRequest::PAD_WHITE},
}); });
TestAll(); TestAll();
@ -438,10 +438,9 @@ TEST_F(InnerPointerResolutionTest, SmallBlackAreaStartingAtCellBoundary) {
TEST_F(InnerPointerResolutionTest, LargeBlackAreaStartingAtCellBoundary) { TEST_F(InnerPointerResolutionTest, LargeBlackAreaStartingAtCellBoundary) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{512}, {128 * Tagged},
{42 * Bitmap::kBitsPerCell * Bitmap::kBytesPerCell + 64, {42 * FullCell + 16 * Tagged, ObjectRequest::REGULAR,
ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, ObjectRequest::BLACK_AREA, 0, ObjectRequest::PAD_WHITE},
ObjectRequest::PAD_WHITE},
}); });
TestAll(); TestAll();
} }
@ -449,10 +448,10 @@ TEST_F(InnerPointerResolutionTest, LargeBlackAreaStartingAtCellBoundary) {
TEST_F(InnerPointerResolutionTest, SmallBlackAreaEndingAtCellBoundary) { TEST_F(InnerPointerResolutionTest, SmallBlackAreaEndingAtCellBoundary) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{512}, {128 * Tagged},
{8, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 13, {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 13,
ObjectRequest::PAD_WHITE}, ObjectRequest::PAD_WHITE},
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0,
ObjectRequest::PAD_BLACK}, ObjectRequest::PAD_BLACK},
}); });
TestAll(); TestAll();
@ -461,11 +460,10 @@ TEST_F(InnerPointerResolutionTest, SmallBlackAreaEndingAtCellBoundary) {
TEST_F(InnerPointerResolutionTest, LargeBlackAreaEndingAtCellBoundary) { TEST_F(InnerPointerResolutionTest, LargeBlackAreaEndingAtCellBoundary) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{512}, {128 * Tagged},
{42 * Bitmap::kBitsPerCell * Bitmap::kBytesPerCell + 64, {42 * FullCell + 16 * Tagged, ObjectRequest::REGULAR,
ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, ObjectRequest::BLACK_AREA, 0, ObjectRequest::PAD_WHITE},
ObjectRequest::PAD_WHITE}, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0,
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0,
ObjectRequest::PAD_BLACK}, ObjectRequest::PAD_BLACK},
}); });
TestAll(); TestAll();
@ -474,12 +472,12 @@ TEST_F(InnerPointerResolutionTest, LargeBlackAreaEndingAtCellBoundary) {
TEST_F(InnerPointerResolutionTest, TwoSmallBlackAreasAtCellBoundaries) { TEST_F(InnerPointerResolutionTest, TwoSmallBlackAreasAtCellBoundaries) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{512}, {128 * Tagged},
{24, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0, {6 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0,
ObjectRequest::PAD_WHITE}, ObjectRequest::PAD_WHITE},
{8, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 25, {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 25,
ObjectRequest::PAD_WHITE}, ObjectRequest::PAD_WHITE},
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE, 0,
ObjectRequest::PAD_BLACK}, ObjectRequest::PAD_BLACK},
}); });
TestAll(); TestAll();
@ -488,9 +486,9 @@ TEST_F(InnerPointerResolutionTest, TwoSmallBlackAreasAtCellBoundaries) {
TEST_F(InnerPointerResolutionTest, BlackAreaOfOneCell) { TEST_F(InnerPointerResolutionTest, BlackAreaOfOneCell) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{512}, {128 * Tagged},
{Bitmap::kBitsPerCell * Bitmap::kBytesPerCell, ObjectRequest::REGULAR, {1 * FullCell, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0,
ObjectRequest::BLACK_AREA, 0, ObjectRequest::PAD_WHITE}, ObjectRequest::PAD_WHITE},
}); });
TestAll(); TestAll();
} }
@ -498,9 +496,8 @@ TEST_F(InnerPointerResolutionTest, BlackAreaOfOneCell) {
TEST_F(InnerPointerResolutionTest, BlackAreaOfManyCells) { TEST_F(InnerPointerResolutionTest, BlackAreaOfManyCells) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{512}, {128 * Tagged},
{17 * Bitmap::kBitsPerCell * Bitmap::kBytesPerCell, {17 * FullCell, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0,
ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA, 0,
ObjectRequest::PAD_WHITE}, ObjectRequest::PAD_WHITE},
}); });
TestAll(); TestAll();
@ -511,21 +508,21 @@ TEST_F(InnerPointerResolutionTest, BlackAreaOfManyCells) {
TEST_F(InnerPointerResolutionTest, TwoPages) { TEST_F(InnerPointerResolutionTest, TwoPages) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{512, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{42176, ObjectRequest::REGULAR, ObjectRequest::GREY}, {10544 * Tagged, ObjectRequest::REGULAR, ObjectRequest::GREY},
}); });
CreateObjectsInPage({ CreateObjectsInPage({
{512, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA},
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{48, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA},
{52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{4, ObjectRequest::FREE, ObjectRequest::GREY}, {1 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY},
{8, ObjectRequest::FREE, ObjectRequest::GREY}, {2 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY},
{8, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
}); });
TestAll(); TestAll();
} }
@ -550,21 +547,21 @@ TEST_F(InnerPointerResolutionTest, SeveralLargePages) {
TEST_F(InnerPointerResolutionTest, PagesOfBothKind) { TEST_F(InnerPointerResolutionTest, PagesOfBothKind) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
CreateObjectsInPage({ CreateObjectsInPage({
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{512, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{42176, ObjectRequest::REGULAR, ObjectRequest::GREY}, {10544 * Tagged, ObjectRequest::REGULAR, ObjectRequest::GREY},
}); });
CreateObjectsInPage({ CreateObjectsInPage({
{512, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA},
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{48, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA},
{52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{4, ObjectRequest::FREE, ObjectRequest::GREY}, {1 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY},
{8, ObjectRequest::FREE, ObjectRequest::GREY}, {2 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY},
{8, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
}); });
CreateLargeObjects({ CreateLargeObjects({
{1 * MB, ObjectRequest::LARGE, ObjectRequest::WHITE}, {1 * MB, ObjectRequest::LARGE, ObjectRequest::WHITE},
@ -576,21 +573,21 @@ TEST_F(InnerPointerResolutionTest, PagesOfBothKind) {
TEST_F(InnerPointerResolutionTest, FreePages) { TEST_F(InnerPointerResolutionTest, FreePages) {
if (v8_flags.enable_third_party_heap) return; if (v8_flags.enable_third_party_heap) return;
int some_normal_page = CreateObjectsInPage({ int some_normal_page = CreateObjectsInPage({
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{512, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{42176, ObjectRequest::REGULAR, ObjectRequest::GREY}, {10544 * Tagged, ObjectRequest::REGULAR, ObjectRequest::GREY},
}); });
CreateObjectsInPage({ CreateObjectsInPage({
{512, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, {128 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA},
{64, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {16 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{48, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA}, {12 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK_AREA},
{52, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {13 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
{4, ObjectRequest::FREE, ObjectRequest::GREY}, {1 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY},
{8, ObjectRequest::FREE, ObjectRequest::GREY}, {2 * Tagged, ObjectRequest::FREE, ObjectRequest::GREY},
{8, ObjectRequest::REGULAR, ObjectRequest::WHITE}, {2 * Tagged, ObjectRequest::REGULAR, ObjectRequest::WHITE},
{60, ObjectRequest::REGULAR, ObjectRequest::BLACK}, {15 * Tagged, ObjectRequest::REGULAR, ObjectRequest::BLACK},
}); });
auto large_pages = CreateLargeObjects({ auto large_pages = CreateLargeObjects({
{1 * MB, ObjectRequest::LARGE, ObjectRequest::WHITE}, {1 * MB, ObjectRequest::LARGE, ObjectRequest::WHITE},
@ -622,7 +619,7 @@ TEST_F(InnerPointerResolutionHeapTest, UnusedRegularYoungPages) {
const int length = const int length =
(heap()->MaxRegularHeapObjectSize(AllocationType::kYoung) - (heap()->MaxRegularHeapObjectSize(AllocationType::kYoung) -
FixedArray::SizeFor(0)) / FixedArray::SizeFor(0)) /
kTaggedSize; Tagged;
auto h1 = factory()->NewFixedArray(length, AllocationType::kYoung); auto h1 = factory()->NewFixedArray(length, AllocationType::kYoung);
auto h2 = factory()->NewFixedArray(length, AllocationType::kYoung); auto h2 = factory()->NewFixedArray(length, AllocationType::kYoung);
weak1.Reset(v8_isolate(), Utils::FixedArrayToLocal(h1)); 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)); EXPECT_EQ(obj3.address(), obj2.address() + obj2.Size(cage_base));
// Keep inner pointers to all objects. // Keep inner pointers to all objects.
inner_ptr1 = obj1.address() + 17 * kTaggedSize; inner_ptr1 = obj1.address() + 17 * Tagged;
inner_ptr2 = obj2.address() + 37 * kTaggedSize; inner_ptr2 = obj2.address() + 37 * Tagged;
inner_ptr3 = obj3.address() + 7 * kTaggedSize; inner_ptr3 = obj3.address() + 7 * Tagged;
// Keep pointers to the end of the pages, after the objects. // Keep pointers to the end of the pages, after the objects.
outside_ptr1 = page1->area_end() - 3 * kTaggedSize; outside_ptr1 = page1->area_end() - 3 * Tagged;
outside_ptr2 = page2->area_end() - 2 * kTaggedSize; outside_ptr2 = page2->area_end() - 2 * Tagged;
EXPECT_LE(obj1.address() + obj1.Size(cage_base), outside_ptr1); EXPECT_LE(obj1.address() + obj1.Size(cage_base), outside_ptr1);
EXPECT_LE(obj2.address() + obj2.Size(cage_base), outside_ptr2); EXPECT_LE(obj2.address() + obj2.Size(cage_base), outside_ptr2);
EXPECT_LE(obj3.address() + obj3.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, marking->Start(GarbageCollector::MARK_COMPACTOR,
i::GarbageCollectionReason::kTesting); i::GarbageCollectionReason::kTesting);
} }
MarkingState* marking_state = marking->marking_state(); MarkingState* marking_state = heap()->marking_state();
marking_state->WhiteToGrey(obj3); marking_state->WhiteToGrey(obj3);
marking_state->GreyToBlack(obj3); marking_state->GreyToBlack(obj3);
} }
@ -778,7 +775,7 @@ TEST_F(InnerPointerResolutionHeapTest, UnusedLargeYoungPage) {
const int length = const int length =
std::max(1 << kPageSizeBits, std::max(1 << kPageSizeBits,
2 * heap()->MaxRegularHeapObjectSize(AllocationType::kYoung)) / 2 * heap()->MaxRegularHeapObjectSize(AllocationType::kYoung)) /
kTaggedSize; Tagged;
auto h = factory()->NewFixedArray(length, AllocationType::kYoung); auto h = factory()->NewFixedArray(length, AllocationType::kYoung);
weak.Reset(v8_isolate(), Utils::FixedArrayToLocal(h)); weak.Reset(v8_isolate(), Utils::FixedArrayToLocal(h));
weak.SetWeak(); weak.SetWeak();
@ -789,7 +786,7 @@ TEST_F(InnerPointerResolutionHeapTest, UnusedLargeYoungPage) {
EXPECT_TRUE(v8_flags.minor_mc || page->IsToPage()); EXPECT_TRUE(v8_flags.minor_mc || page->IsToPage());
// Keep inner pointer. // Keep inner pointer.
inner_ptr = obj.address() + 17 * kTaggedSize; inner_ptr = obj.address() + 17 * Tagged;
// Inner pointer resolution should work now, finding the object. // Inner pointer resolution should work now, finding the object.
EXPECT_EQ( EXPECT_EQ(
@ -826,7 +823,7 @@ TEST_F(InnerPointerResolutionHeapTest, RegularPageAfterEnd) {
EXPECT_FALSE(Page::IsAlignedToPageSize(page->area_end())); EXPECT_FALSE(Page::IsAlignedToPageSize(page->area_end()));
// Inner pointer resolution after the end of the page area should work. // 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_FALSE(Page::IsAlignedToPageSize(inner_ptr));
EXPECT_EQ(kNullAddress, EXPECT_EQ(kNullAddress,
heap()->mark_compact_collector()->FindBasePtrForMarking(inner_ptr)); heap()->mark_compact_collector()->FindBasePtrForMarking(inner_ptr));
@ -850,7 +847,7 @@ TEST_F(InnerPointerResolutionHeapTest, LargePageAfterEnd) {
EXPECT_FALSE(Page::IsAlignedToPageSize(page->area_end())); EXPECT_FALSE(Page::IsAlignedToPageSize(page->area_end()));
// Inner pointer resolution after the end of the pare area should work. // 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_FALSE(Page::IsAlignedToPageSize(inner_ptr));
EXPECT_EQ(kNullAddress, EXPECT_EQ(kNullAddress,
heap()->mark_compact_collector()->FindBasePtrForMarking(inner_ptr)); heap()->mark_compact_collector()->FindBasePtrForMarking(inner_ptr));
@ -860,7 +857,5 @@ TEST_F(InnerPointerResolutionHeapTest, LargePageAfterEnd) {
page); page);
} }
#endif // V8_ENABLE_INNER_POINTER_RESOLUTION_MB
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8