(Experimental) Add Brooks pointers.
This feature is disabled by default.
Verified that the Brooks pointers are installed correctly by using the
CMS/SS collectors.
Change-Id: Ia9be9814ab6e29169ac85edc4792ce8c81d552a9
diff --git a/runtime/gc/collector/semi_space.cc b/runtime/gc/collector/semi_space.cc
index fe8c253..d639db5 100644
--- a/runtime/gc/collector/semi_space.cc
+++ b/runtime/gc/collector/semi_space.cc
@@ -517,6 +517,12 @@
// references.
saved_bytes_ +=
CopyAvoidingDirtyingPages(reinterpret_cast<void*>(forward_address), obj, object_size);
+ if (kUseBrooksPointer) {
+ obj->AssertSelfBrooksPointer();
+ DCHECK_EQ(forward_address->GetBrooksPointer(), obj);
+ forward_address->SetBrooksPointer(forward_address);
+ forward_address->AssertSelfBrooksPointer();
+ }
if (to_space_live_bitmap_ != nullptr) {
to_space_live_bitmap_->Set(forward_address);
}
@@ -529,6 +535,12 @@
// the to-space and have their forward address updated. Objects which have been newly marked are
// pushed on the mark stack.
Object* SemiSpace::MarkObject(Object* obj) {
+ if (kUseBrooksPointer) {
+ // Verify all the objects have the correct forward pointer installed.
+ if (obj != nullptr) {
+ obj->AssertSelfBrooksPointer();
+ }
+ }
Object* forward_address = obj;
if (obj != nullptr && !IsImmune(obj)) {
if (from_space_->HasAddress(obj)) {