Additional heap verification for the Gc
There are now two verification booleans which can be enabled. When these get enabled, it verifies that each live object only references other live objects.
Changed SetClass to use SetFieldPtr to avoid having an extra card mark. This is safe since all classes are held live by the class linker.
Change-Id: I005bb59e5cc8153a79d3ccb3d7b5cabd29fb4051
diff --git a/src/heap_bitmap.h b/src/heap_bitmap.h
index 98b42b3..d202ae3 100644
--- a/src/heap_bitmap.h
+++ b/src/heap_bitmap.h
@@ -54,9 +54,9 @@
SpaceBitmap* GetSpaceBitmap(const Object* obj) {
// TODO: C++0x auto
- for (Bitmaps::iterator cur = bitmaps_.begin(); cur != bitmaps_.end(); ++cur) {
- if ((*cur)->HasAddress(obj)) {
- return *cur;
+ for (Bitmaps::iterator it = bitmaps_.begin(); it != bitmaps_.end(); ++it) {
+ if ((*it)->HasAddress(obj)) {
+ return *it;
}
}
return NULL;
@@ -65,8 +65,19 @@
void Walk(SpaceBitmap::Callback* callback, void* arg)
SHARED_LOCKS_REQUIRED(GlobalSynchronization::heap_bitmap_lock_) {
// TODO: C++0x auto
- for (Bitmaps::iterator cur = bitmaps_.begin(); cur != bitmaps_.end(); ++cur) {
- (*cur)->Walk(callback, arg);
+ for (Bitmaps::iterator it = bitmaps_.begin(); it!= bitmaps_.end(); ++it) {
+ (*it)->Walk(callback, arg);
+ }
+ }
+
+ template <typename Visitor>
+ void Visit(const Visitor& visitor)
+ EXCLUSIVE_LOCKS_REQUIRED(GlobalSynchronization::heap_bitmap_lock_) {
+ // TODO: C++0x auto
+ for (Bitmaps::iterator it = bitmaps_.begin(); it != bitmaps_.end(); ++it) {
+ SpaceBitmap* bitmap = *it;
+ bitmap->VisitMarkedRange(bitmap->HeapBegin(), bitmap->HeapLimit(), visitor,
+ IdentityFunctor());
}
}