Commit 4a5bccfc authored by yangguo@chromium.org's avatar yangguo@chromium.org

Tighten object verification.

Often, when we call MaybeObject::Verify, what we want is Object::ObjectVerify.

R=hpayer@chromium.org

Review URL: https://codereview.chromium.org/218993005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20382 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8806f2d8
......@@ -533,7 +533,7 @@ i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) {
LOG_API(isolate, "Persistent::New");
i::Handle<i::Object> result = isolate->global_handles()->Create(*obj);
#ifdef DEBUG
(*obj)->Verify();
(*obj)->ObjectVerify();
#endif // DEBUG
return result.location();
}
......@@ -542,7 +542,7 @@ i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) {
i::Object** V8::CopyPersistent(i::Object** obj) {
i::Handle<i::Object> result = i::GlobalHandles::CopyGlobal(obj);
#ifdef DEBUG
(*obj)->Verify();
(*obj)->ObjectVerify();
#endif // DEBUG
return result.location();
}
......
......@@ -2000,7 +2000,7 @@ bool Genesis::InstallNatives() {
}
#ifdef VERIFY_HEAP
builtins->Verify();
builtins->ObjectVerify();
#endif
return true;
......
......@@ -41,17 +41,22 @@ namespace internal {
void MaybeObject::Verify() {
Object* this_as_object;
if (ToObject(&this_as_object)) {
if (this_as_object->IsSmi()) {
Smi::cast(this_as_object)->SmiVerify();
} else {
HeapObject::cast(this_as_object)->HeapObjectVerify();
}
this_as_object->ObjectVerify();
} else {
Failure::cast(this)->FailureVerify();
}
}
void Object::ObjectVerify() {
if (IsSmi()) {
Smi::cast(this)->SmiVerify();
} else {
HeapObject::cast(this)->HeapObjectVerify();
}
}
void Object::VerifyPointer(Object* p) {
if (p->IsHeapObject()) {
HeapObject::VerifyHeapPointer(p);
......@@ -380,11 +385,7 @@ void AliasedArgumentsEntry::AliasedArgumentsEntryVerify() {
void FixedArray::FixedArrayVerify() {
for (int i = 0; i < length(); i++) {
Object* e = get(i);
if (e->IsHeapObject()) {
VerifyHeapPointer(e);
} else {
e->Verify();
}
VerifyPointer(e);
}
}
......@@ -626,7 +627,7 @@ void PropertyCell::PropertyCellVerify() {
void Code::CodeVerify() {
CHECK(IsAligned(reinterpret_cast<intptr_t>(instruction_start()),
kCodeAlignment));
relocation_info()->Verify();
relocation_info()->ObjectVerify();
Address last_gc_pc = NULL;
for (RelocIterator it(this); !it.done(); it.next()) {
it.rinfo()->Verify();
......@@ -811,7 +812,7 @@ void Foreign::ForeignVerify() {
void Box::BoxVerify() {
CHECK(IsBox());
value()->Verify();
value()->ObjectVerify();
}
......@@ -947,7 +948,7 @@ void Script::ScriptVerify() {
void JSFunctionResultCache::JSFunctionResultCacheVerify() {
JSFunction::cast(get(kFactoryIndex))->Verify();
JSFunction::cast(get(kFactoryIndex))->ObjectVerify();
int size = Smi::cast(get(kCacheSizeIndex))->value();
CHECK(kEntriesIndex <= size);
......@@ -962,18 +963,18 @@ void JSFunctionResultCache::JSFunctionResultCacheVerify() {
if (FLAG_enable_slow_asserts) {
for (int i = kEntriesIndex; i < size; i++) {
CHECK(!get(i)->IsTheHole());
get(i)->Verify();
get(i)->ObjectVerify();
}
for (int i = size; i < length(); i++) {
CHECK(get(i)->IsTheHole());
get(i)->Verify();
get(i)->ObjectVerify();
}
}
}
void NormalizedMapCache::NormalizedMapCacheVerify() {
FixedArray::cast(this)->Verify();
FixedArray::cast(this)->FixedArrayVerify();
if (FLAG_enable_slow_asserts) {
for (int i = 0; i < length(); i++) {
Object* e = get(i);
......
......@@ -1629,6 +1629,7 @@ class Object : public MaybeObject {
// < the length of the string. Used to implement [] on strings.
inline bool IsStringObjectWithCharacterAt(uint32_t index);
DECLARE_VERIFIER(Object)
#ifdef VERIFY_HEAP
// Verify a pointer is a valid object pointer.
static void VerifyPointer(Object* p);
......
......@@ -1195,7 +1195,7 @@ void PagedSpace::Verify(ObjectVisitor* visitor) {
VerifyObject(object);
// The object itself should look OK.
object->Verify();
object->ObjectVerify();
// All the interior pointers should be contained in the heap.
int size = object->Size();
......@@ -1478,7 +1478,7 @@ void NewSpace::Verify() {
CHECK(!object->IsCode());
// The object itself should look OK.
object->Verify();
object->ObjectVerify();
// All the interior pointers should be contained in the heap.
VerifyPointersVisitor visitor;
......@@ -3119,7 +3119,7 @@ void LargeObjectSpace::Verify() {
object->IsFixedDoubleArray() || object->IsByteArray());
// The object itself should look OK.
object->Verify();
object->ObjectVerify();
// Byte arrays and strings don't have interior pointers.
if (object->IsCode()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment