[heap] Gate heap verification behind runtime flag

Most verification calls are gated behined both a build flag and a
runtime flag. Some calls were missing the runtime flag.

Bug: v8:12612
Change-Id: I482bf7cd3900e860f9db1932f9490d1af9b19df1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4085007
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84932}
This commit is contained in:
Omer Katz 2022-12-07 13:15:19 +01:00 committed by V8 LUCI CQ
parent 833731b20b
commit 0a7e7383ec
5 changed files with 16 additions and 15 deletions

View File

@ -2256,6 +2256,7 @@ void TranslatedState::UpdateFromPreviouslyMaterializedObjects() {
void TranslatedState::VerifyMaterializedObjects() {
#if VERIFY_HEAP
if (!v8_flags.verify_heap) return;
int length = static_cast<int>(object_positions_.size());
for (int i = 0; i < length; i++) {
TranslatedValue* slot = GetValueByObjectIndex(i);

View File

@ -962,17 +962,13 @@ void MarkCompactCollector::VerifyMarking() {
if (v8_flags.verify_heap) {
FullMarkingVerifier verifier(heap());
verifier.Run();
}
#endif
#ifdef VERIFY_HEAP
if (v8_flags.verify_heap) {
heap()->old_space()->VerifyLiveBytes();
heap()->code_space()->VerifyLiveBytes();
if (heap()->shared_space()) heap()->shared_space()->VerifyLiveBytes();
if (v8_flags.minor_mc && heap()->paged_new_space())
heap()->paged_new_space()->paged_space()->VerifyLiveBytes();
}
#endif
#endif // VERIFY_HEAP
}
namespace {
@ -3614,7 +3610,7 @@ void MarkCompactCollector::ClearWeakCollections() {
non_atomic_marking_state()->IsBlackOrGrey(heap_object));
}
}
#endif
#endif // VERIFY_HEAP
if (!ShouldMarkObject(key)) continue;
if (!non_atomic_marking_state()->IsBlackOrGrey(key)) {
table.RemoveEntry(i);
@ -4817,7 +4813,7 @@ void MarkCompactCollector::Evacuate() {
FullEvacuationVerifier verifier(heap());
verifier.Run();
}
#endif
#endif // VERIFY_HEAP
}
class UpdatingItem : public ParallelWorkItem {
@ -6021,9 +6017,11 @@ void MinorMarkCompactCollector::StartMarking() {
heap()->isolate(), marking_state(), local_marking_worklists());
#ifdef VERIFY_HEAP
if (v8_flags.verify_heap) {
for (Page* page : *heap()->new_space()) {
CHECK(page->marking_bitmap<AccessMode::NON_ATOMIC>()->IsClean());
}
}
#endif // VERIFY_HEAP
}

View File

@ -534,7 +534,7 @@ void Context::VerifyExtensionSlot(HeapObject extension) {
void Context::set_extension(HeapObject object, WriteBarrierMode mode) {
DCHECK(scope_info().HasContextExtensionSlot());
#ifdef VERIFY_HEAP
VerifyExtensionSlot(object);
if (v8_flags.verify_heap) VerifyExtensionSlot(object);
#endif
set(EXTENSION_INDEX, object, mode);
}

View File

@ -38,7 +38,7 @@ bool ExperimentalRegExp::IsCompiled(Handle<JSRegExp> re, Isolate* isolate) {
DCHECK(v8_flags.enable_experimental_regexp_engine);
DCHECK_EQ(re->type_tag(), JSRegExp::EXPERIMENTAL);
#ifdef VERIFY_HEAP
re->JSRegExpVerify(isolate);
if (v8_flags.verify_heap) re->JSRegExpVerify(isolate);
#endif
static constexpr bool kIsLatin1 = true;
@ -102,7 +102,7 @@ bool ExperimentalRegExp::Compile(Isolate* isolate, Handle<JSRegExp> re) {
DCHECK(v8_flags.enable_experimental_regexp_engine);
DCHECK_EQ(re->type_tag(), JSRegExp::EXPERIMENTAL);
#ifdef VERIFY_HEAP
re->JSRegExpVerify(isolate);
if (v8_flags.verify_heap) re->JSRegExpVerify(isolate);
#endif
Handle<String> source(re->source(), isolate);
@ -210,7 +210,7 @@ MaybeHandle<Object> ExperimentalRegExp::Exec(
DCHECK(v8_flags.enable_experimental_regexp_engine);
DCHECK_EQ(regexp->type_tag(), JSRegExp::EXPERIMENTAL);
#ifdef VERIFY_HEAP
regexp->JSRegExpVerify(isolate);
if (v8_flags.verify_heap) regexp->JSRegExpVerify(isolate);
#endif
if (!IsCompiled(regexp, isolate) && !Compile(isolate, regexp)) {

View File

@ -219,8 +219,10 @@ bool DeleteObjectPropertyFast(Isolate* isolate, Handle<JSReceiver> receiver,
// Finally, perform the map rollback.
receiver->set_map(*parent_map, kReleaseStore);
#if VERIFY_HEAP
if (v8_flags.verify_heap) {
receiver->HeapObjectVerify(isolate);
receiver->property_array().PropertyArrayVerify(isolate);
}
#endif
// If the {descriptor} was "const" so far, we need to update the