[heap] Fix test failure with disabled map space

Fix failing tests with --no-use-map-space enabled.

Bug: v8:12578
Change-Id: I121b0d22cd69e76b6c5c02d1f83a166af0610b83
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3663343
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80717}
This commit is contained in:
Dominik Inführ 2022-05-24 12:53:14 +02:00 committed by V8 LUCI CQ
parent 377df357b5
commit 3674876cd6
3 changed files with 9 additions and 2 deletions

View File

@ -582,6 +582,7 @@ class OldGenerationMemoryChunkIterator {
PageIterator old_iterator_;
PageIterator code_iterator_;
PageIterator map_iterator_;
const PageIterator map_iterator_end_;
LargePageIterator lo_iterator_;
LargePageIterator code_lo_iterator_;
};

View File

@ -105,6 +105,8 @@ OldGenerationMemoryChunkIterator::OldGenerationMemoryChunkIterator(Heap* heap)
code_iterator_(heap->code_space()->begin()),
map_iterator_(heap->map_space() ? heap->map_space()->begin()
: PageRange::iterator(nullptr)),
map_iterator_end_(heap->map_space() ? heap->map_space()->end()
: PageRange::iterator(nullptr)),
lo_iterator_(heap->lo_space()->begin()),
code_lo_iterator_(heap->code_lo_space()->begin()) {}
@ -116,7 +118,7 @@ MemoryChunk* OldGenerationMemoryChunkIterator::next() {
V8_FALLTHROUGH;
}
case kMapState: {
if (map_iterator_ != heap_->map_space()->end()) return *(map_iterator_++);
if (map_iterator_ != map_iterator_end_) return *(map_iterator_++);
state_ = kCodeState;
V8_FALLTHROUGH;
}

View File

@ -144,7 +144,11 @@ void CrashKeyCallback(v8::CrashKeyId id, const std::string& value) {
} // namespace
TEST_F(IsolateTest, SetAddCrashKeyCallback) {
isolate()->SetAddCrashKeyCallback(CrashKeyCallback);
EXPECT_EQ(crash_keys.size(), 6u);
internal::Isolate* i_isolate =
reinterpret_cast<internal::Isolate*>(isolate());
const bool has_map_space = i_isolate->heap()->map_space() != nullptr;
EXPECT_EQ(crash_keys.size(), has_map_space ? 6u : 5u);
}
} // namespace v8