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
This commit is contained in:
yangguo@chromium.org 2014-10-31 09:30:59 +00:00
parent 48584766d9
commit f01e08315f
3 changed files with 27 additions and 0 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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();
}