Fix zygote live/mark bitmap size.
Fixed some errors with the sizes of mark/live bitmaps after zygote space creation.
This was causing us to occasionally have overlapping mark/live bitmaps.
Added a new verify objects mode called VERIFY_OBJECT_FAST which only checks objects and not their classes.
Refactored/optimized some of the scanning code to use xor to clear bits instead of and+not.
Change-Id: Iec87d9157f69e6a558e300950b51d8781679e3f7
diff --git a/src/heap.cc b/src/heap.cc
index a96472b..626adf9 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -393,13 +393,15 @@
#if VERIFY_OBJECT_ENABLED
void Heap::VerifyObject(const Object* obj) {
- if (this == NULL || !verify_objects_ || Runtime::Current()->IsShuttingDown() ||
+ if (obj == NULL || this == NULL || !verify_objects_ || Runtime::Current()->IsShuttingDown() ||
Thread::Current() == NULL ||
Runtime::Current()->GetThreadList()->GetLockOwner() == Thread::Current()->GetTid()) {
return;
}
- ScopedHeapLock heap_lock;
- Heap::VerifyObjectLocked(obj);
+ {
+ ScopedHeapLock heap_lock;
+ Heap::VerifyObjectLocked(obj);
+ }
}
#endif
@@ -412,39 +414,39 @@
void Heap::VerifyObjectLocked(const Object* obj) {
lock_->AssertHeld();
- if (obj != NULL) {
- if (!IsAligned<kObjectAlignment>(obj)) {
- LOG(FATAL) << "Object isn't aligned: " << obj;
- } else if (!GetLiveBitmap()->Test(obj)) {
- Space* space = FindSpaceFromObject(obj);
- if (space == NULL) {
- DumpSpaces();
- LOG(FATAL) << "Object " << obj << " is not contained in any space";
- }
- LOG(FATAL) << "Object is dead: " << obj << " in space " << *space;
+ if (!IsAligned<kObjectAlignment>(obj)) {
+ LOG(FATAL) << "Object isn't aligned: " << obj;
+ } else if (!GetLiveBitmap()->Test(obj)) {
+ Space* space = FindSpaceFromObject(obj);
+ if (space == NULL) {
+ DumpSpaces();
+ LOG(FATAL) << "Object " << obj << " is not contained in any space";
}
- // Ignore early dawn of the universe verifications
- if (num_objects_allocated_ > 10) {
- const byte* raw_addr = reinterpret_cast<const byte*>(obj) +
- Object::ClassOffset().Int32Value();
- const Class* c = *reinterpret_cast<Class* const *>(raw_addr);
- if (c == NULL) {
- LOG(FATAL) << "Null class in object: " << obj;
- } else if (!IsAligned<kObjectAlignment>(c)) {
- LOG(FATAL) << "Class isn't aligned: " << c << " in object: " << obj;
- } else if (!GetLiveBitmap()->Test(c)) {
- LOG(FATAL) << "Class of object is dead: " << c << " in object: " << obj;
- }
- // Check obj.getClass().getClass() == obj.getClass().getClass().getClass()
- // Note: we don't use the accessors here as they have internal sanity checks
- // that we don't want to run
- raw_addr = reinterpret_cast<const byte*>(c) + Object::ClassOffset().Int32Value();
- const Class* c_c = *reinterpret_cast<Class* const *>(raw_addr);
- raw_addr = reinterpret_cast<const byte*>(c_c) + Object::ClassOffset().Int32Value();
- const Class* c_c_c = *reinterpret_cast<Class* const *>(raw_addr);
- CHECK_EQ(c_c, c_c_c);
- }
+ LOG(FATAL) << "Object is dead: " << obj << " in space " << *space;
}
+#if !VERIFY_OBJECT_FAST
+ // Ignore early dawn of the universe verifications
+ if (num_objects_allocated_ > 10) {
+ const byte* raw_addr = reinterpret_cast<const byte*>(obj) +
+ Object::ClassOffset().Int32Value();
+ const Class* c = *reinterpret_cast<Class* const *>(raw_addr);
+ if (c == NULL) {
+ LOG(FATAL) << "Null class in object: " << obj;
+ } else if (!IsAligned<kObjectAlignment>(c)) {
+ LOG(FATAL) << "Class isn't aligned: " << c << " in object: " << obj;
+ } else if (!GetLiveBitmap()->Test(c)) {
+ LOG(FATAL) << "Class of object is dead: " << c << " in object: " << obj;
+ }
+ // Check obj.getClass().getClass() == obj.getClass().getClass().getClass()
+ // Note: we don't use the accessors here as they have internal sanity checks
+ // that we don't want to run
+ raw_addr = reinterpret_cast<const byte*>(c) + Object::ClassOffset().Int32Value();
+ const Class* c_c = *reinterpret_cast<Class* const *>(raw_addr);
+ raw_addr = reinterpret_cast<const byte*>(c_c) + Object::ClassOffset().Int32Value();
+ const Class* c_c_c = *reinterpret_cast<Class* const *>(raw_addr);
+ CHECK_EQ(c_c, c_c_c);
+ }
+#endif
}
void Heap::VerificationCallback(Object* obj, void* arg) {