From f01e08315fc6b5ca484b3a07bd70705674200501 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Fri, 31 Oct 2014 09:30:59 +0000 Subject: [PATCH] Assert that unoptimized code does not embed context-specific objects. R=verwaest@chromium.org Review URL: https://codereview.chromium.org/690713003 Cr-Commit-Position: refs/heads/master@{#25029} git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25029 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/full-codegen.cc | 5 +++++ src/objects-debug.cc | 18 ++++++++++++++++++ src/objects.h | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/src/full-codegen.cc b/src/full-codegen.cc index bd3846711d..58e5e978ab 100644 --- a/src/full-codegen.cc +++ b/src/full-codegen.cc @@ -346,6 +346,11 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) { info->SetCode(code); void* line_info = masm.positions_recorder()->DetachJITHandlerData(); LOG_CODE_EVENT(isolate, CodeEndLinePosInfoRecordEvent(*code, line_info)); + +#ifdef DEBUG + // Check that no context-specific object has been embedded. + code->VerifyEmbeddedObjectsInFullCode(); +#endif // DEBUG return true; } diff --git a/src/objects-debug.cc b/src/objects-debug.cc index 92bd97a87f..353cfdaa44 100644 --- a/src/objects-debug.cc +++ b/src/objects-debug.cc @@ -1218,6 +1218,24 @@ bool TransitionArray::IsConsistentWithBackPointers(Map* current_map) { } +void Code::VerifyEmbeddedObjectsInFullCode() { + // Check that no context-specific object has been embedded. + Heap* heap = GetIsolate()->heap(); + int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); + for (RelocIterator it(this, mask); !it.done(); it.next()) { + Object* obj = it.rinfo()->target_object(); + if (obj->IsCell()) obj = Cell::cast(obj)->value(); + if (obj->IsPropertyCell()) obj = PropertyCell::cast(obj)->value(); + if (!obj->IsHeapObject()) continue; + Map* map = obj->IsMap() ? Map::cast(obj) : HeapObject::cast(obj)->map(); + int i = 0; + while (map != heap->roots_array_start()[i++]) { + CHECK_LT(i, Heap::kStrongRootListLength); + } + } +} + + #endif // DEBUG } } // namespace v8::internal diff --git a/src/objects.h b/src/objects.h index d513f97922..fb947440fc 100644 --- a/src/objects.h +++ b/src/objects.h @@ -5362,6 +5362,10 @@ class Code: public HeapObject { void VerifyEmbeddedObjectsDependency(); #endif +#ifdef DEBUG + void VerifyEmbeddedObjectsInFullCode(); +#endif // DEBUG + inline bool CanContainWeakObjects() { return is_optimized_code() || is_weak_stub(); }