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