From f6fef2411804b38745d3f2838ed2c3b72adb13b9 Mon Sep 17 00:00:00 2001 From: "erik.corry@gmail.com" Date: Tue, 25 Oct 2011 13:27:46 +0000 Subject: [PATCH] Move some heap verification code in under the --verify-heap flag to speed up debug mode tests. Review URL: http://codereview.chromium.org/8381040 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9774 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/heap-inl.h | 4 +++- src/heap.cc | 30 ++++++++++++++++++++++-------- src/incremental-marking.cc | 2 +- src/objects-inl.h | 9 +++++++-- src/objects.cc | 6 ++++-- src/runtime.cc | 8 ++++++-- src/spaces.cc | 11 ----------- src/spaces.h | 5 ----- src/store-buffer.cc | 16 ++++++++-------- 9 files changed, 51 insertions(+), 40 deletions(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index 49bce1c6af..aaf2927f7f 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -590,7 +590,9 @@ void ExternalStringTable::AddOldString(String* string) { void ExternalStringTable::ShrinkNewStrings(int position) { new_space_strings_.Rewind(position); - Verify(); + if (FLAG_verify_heap) { + Verify(); + } } diff --git a/src/heap.cc b/src/heap.cc index 40d7315a50..bbb9d3e26d 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -693,7 +693,9 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector, PROFILE(isolate_, CodeMovingGCEvent()); } - VerifySymbolTable(); + if (FLAG_verify_heap) { + VerifySymbolTable(); + } if (collector == MARK_COMPACTOR && global_gc_prologue_callback_) { ASSERT(!allocation_allowed_); GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); @@ -789,7 +791,9 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector, GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); global_gc_epilogue_callback_(); } - VerifySymbolTable(); + if (FLAG_verify_heap) { + VerifySymbolTable(); + } return next_gc_likely_to_collect_more; } @@ -983,7 +987,7 @@ void StoreBufferRebuilder::Callback(MemoryChunk* page, StoreBufferEvent event) { void Heap::Scavenge() { #ifdef DEBUG - if (FLAG_enable_slow_asserts) VerifyNonPointerSpacePointers(); + if (FLAG_verify_heap) VerifyNonPointerSpacePointers(); #endif gc_state_ = SCAVENGE; @@ -1112,7 +1116,9 @@ String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, void Heap::UpdateNewSpaceReferencesInExternalStringTable( ExternalStringTableUpdaterCallback updater_func) { - external_string_table_.Verify(); + if (FLAG_verify_heap) { + external_string_table_.Verify(); + } if (external_string_table_.new_space_strings_.is_empty()) return; @@ -2910,7 +2916,9 @@ MaybeObject* Heap::AllocateSubString(String* buffer, ASSERT(buffer->IsFlat()); #if DEBUG - buffer->StringVerify(); + if (FLAG_verify_heap) { + buffer->StringVerify(); + } #endif Object* result; @@ -3156,7 +3164,9 @@ MaybeObject* Heap::CreateCode(const CodeDesc& desc, code->CopyFrom(desc); #ifdef DEBUG - code->Verify(); + if (FLAG_verify_heap) { + code->Verify(); + } #endif return code; } @@ -3236,7 +3246,9 @@ MaybeObject* Heap::CopyCode(Code* code, Vector reloc_info) { new_code->Relocate(new_addr - old_addr); #ifdef DEBUG - code->Verify(); + if (FLAG_verify_heap) { + code->Verify(); + } #endif return new_code; } @@ -6345,7 +6357,9 @@ void ExternalStringTable::CleanUp() { old_space_strings_[last++] = old_space_strings_[i]; } old_space_strings_.Rewind(last); - Verify(); + if (FLAG_verify_heap) { + Verify(); + } } diff --git a/src/incremental-marking.cc b/src/incremental-marking.cc index b118000463..68b830a4df 100644 --- a/src/incremental-marking.cc +++ b/src/incremental-marking.cc @@ -473,7 +473,7 @@ void IncrementalMarking::StartMarking(CompactionFlag flag) { #ifdef DEBUG // Marking bits are cleared by the sweeper. - if (FLAG_enable_slow_asserts) { + if (FLAG_verify_heap) { heap_->mark_compact_collector()->VerifyMarkbitsAreClean(); } #endif diff --git a/src/objects-inl.h b/src/objects-inl.h index c46f02630e..dcda314ed0 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -765,7 +765,10 @@ bool Object::IsJSFunctionResultCache() { return false; } #ifdef DEBUG - reinterpret_cast(this)->JSFunctionResultCacheVerify(); + if (FLAG_verify_heap) { + reinterpret_cast(this)-> + JSFunctionResultCacheVerify(); + } #endif return true; } @@ -777,7 +780,9 @@ bool Object::IsNormalizedMapCache() { return false; } #ifdef DEBUG - reinterpret_cast(this)->NormalizedMapCacheVerify(); + if (FLAG_verify_heap) { + reinterpret_cast(this)->NormalizedMapCacheVerify(); + } #endif return true; } diff --git a/src/objects.cc b/src/objects.cc index fe7bca5409..e49a46c200 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -3231,7 +3231,9 @@ MaybeObject* NormalizedMapCache::Get(JSObject* obj, if (result->IsMap() && Map::cast(result)->EquivalentToForNormalization(fast, mode)) { #ifdef DEBUG - Map::cast(result)->SharedMapVerify(); + if (FLAG_verify_heap) { + Map::cast(result)->SharedMapVerify(); + } if (FLAG_enable_slow_asserts) { // The cached map should match newly created normalized map bit-by-bit. Object* fresh; @@ -4727,7 +4729,7 @@ MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode, Map::cast(result)->set_is_shared(sharing == SHARED_NORMALIZED_MAP); #ifdef DEBUG - if (Map::cast(result)->is_shared()) { + if (FLAG_verify_heap && Map::cast(result)->is_shared()) { Map::cast(result)->SharedMapVerify(); } #endif diff --git a/src/runtime.cc b/src/runtime.cc index f1de96c0d8..4d59c2eb25 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -13199,7 +13199,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) { } #ifdef DEBUG - cache_handle->JSFunctionResultCacheVerify(); + if (FLAG_verify_heap) { + cache_handle->JSFunctionResultCacheVerify(); + } #endif // Function invocation may have cleared the cache. Reread all the data. @@ -13228,7 +13230,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) { cache_handle->set_finger_index(index); #ifdef DEBUG - cache_handle->JSFunctionResultCacheVerify(); + if (FLAG_verify_heap) { + cache_handle->JSFunctionResultCacheVerify(); + } #endif return *value; diff --git a/src/spaces.cc b/src/spaces.cc index 2b933694b6..f467f710ce 100644 --- a/src/spaces.cc +++ b/src/spaces.cc @@ -95,10 +95,6 @@ void HeapObjectIterator::Initialize(PagedSpace* space, cur_end_ = end; page_mode_ = mode; size_func_ = size_f; - -#ifdef DEBUG - Verify(); -#endif } @@ -123,13 +119,6 @@ bool HeapObjectIterator::AdvanceToNextPage() { } -#ifdef DEBUG -void HeapObjectIterator::Verify() { - // TODO(gc): We should do something here. -} -#endif - - // ----------------------------------------------------------------------------- // CodeRange diff --git a/src/spaces.h b/src/spaces.h index 8fa4d427e9..25359fbaf0 100644 --- a/src/spaces.h +++ b/src/spaces.h @@ -1132,11 +1132,6 @@ class HeapObjectIterator: public ObjectIterator { Address end, PageMode mode, HeapObjectCallback size_func); - -#ifdef DEBUG - // Verifies whether fields have valid values. - void Verify(); -#endif }; diff --git a/src/store-buffer.cc b/src/store-buffer.cc index c67d147fb4..7c8b5f2077 100644 --- a/src/store-buffer.cc +++ b/src/store-buffer.cc @@ -390,20 +390,20 @@ void StoreBuffer::VerifyPointers(LargeObjectSpace* space) { void StoreBuffer::Verify() { #ifdef DEBUG - if (FLAG_enable_slow_asserts || FLAG_verify_heap) { - VerifyPointers(heap_->old_pointer_space(), - &StoreBuffer::FindPointersToNewSpaceInRegion); - VerifyPointers(heap_->map_space(), - &StoreBuffer::FindPointersToNewSpaceInMapsRegion); - VerifyPointers(heap_->lo_space()); - } + VerifyPointers(heap_->old_pointer_space(), + &StoreBuffer::FindPointersToNewSpaceInRegion); + VerifyPointers(heap_->map_space(), + &StoreBuffer::FindPointersToNewSpaceInMapsRegion); + VerifyPointers(heap_->lo_space()); #endif } void StoreBuffer::GCEpilogue() { during_gc_ = false; - Verify(); + if (FLAG_verify_heap) { + Verify(); + } }