(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/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc
index cc34689..736dcb1 100644
--- a/runtime/gc/collector/mark_sweep.cc
+++ b/runtime/gc/collector/mark_sweep.cc
@@ -439,6 +439,12 @@
inline void MarkSweep::UnMarkObjectNonNull(const Object* obj) {
DCHECK(!IsImmune(obj));
+
+ if (kUseBrooksPointer) {
+ // Verify all the objects have the correct Brooks pointer installed.
+ obj->AssertSelfBrooksPointer();
+ }
+
// Try to take advantage of locality of references within a space, failing this find the space
// the hard way.
accounting::SpaceBitmap* object_bitmap = current_mark_bitmap_;
@@ -459,6 +465,11 @@
inline void MarkSweep::MarkObjectNonNull(const Object* obj) {
DCHECK(obj != NULL);
+ if (kUseBrooksPointer) {
+ // Verify all the objects have the correct Brooks pointer installed.
+ obj->AssertSelfBrooksPointer();
+ }
+
if (IsImmune(obj)) {
DCHECK(IsMarked(obj));
return;
@@ -521,6 +532,11 @@
inline bool MarkSweep::MarkObjectParallel(const Object* obj) {
DCHECK(obj != NULL);
+ if (kUseBrooksPointer) {
+ // Verify all the objects have the correct Brooks pointer installed.
+ obj->AssertSelfBrooksPointer();
+ }
+
if (IsImmune(obj)) {
DCHECK(IsMarked(obj));
return false;
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)) {