Add missing debugger root visiting.
Bug: 13634574
Change-Id: I2a76f6c43f1d0ad1922f06deb40a71ff651129fd
diff --git a/runtime/gc/collector/semi_space-inl.h b/runtime/gc/collector/semi_space-inl.h
index 3b8f7c3..d60298b6 100644
--- a/runtime/gc/collector/semi_space-inl.h
+++ b/runtime/gc/collector/semi_space-inl.h
@@ -17,6 +17,11 @@
#ifndef ART_RUNTIME_GC_COLLECTOR_SEMI_SPACE_INL_H_
#define ART_RUNTIME_GC_COLLECTOR_SEMI_SPACE_INL_H_
+#include "semi_space.h"
+
+#include "gc/accounting/heap_bitmap.h"
+#include "mirror/object-inl.h"
+
namespace art {
namespace gc {
namespace collector {
@@ -30,6 +35,60 @@
return reinterpret_cast<mirror::Object*>(lock_word.ForwardingAddress());
}
+// Used to mark and copy objects. Any newly-marked objects who are in the from space get moved to
+// the to-space and have their forward address updated. Objects which have been newly marked are
+// pushed on the mark stack.
+template<bool kPoisonReferences>
+inline void SemiSpace::MarkObject(
+ mirror::ObjectReference<kPoisonReferences, mirror::Object>* obj_ptr) {
+ mirror::Object* obj = obj_ptr->AsMirrorPtr();
+ if (obj == nullptr) {
+ return;
+ }
+ if (kUseBrooksPointer) {
+ // Verify all the objects have the correct forward pointer installed.
+ obj->AssertSelfBrooksPointer();
+ }
+ if (!immune_region_.ContainsObject(obj)) {
+ if (from_space_->HasAddress(obj)) {
+ mirror::Object* forward_address = GetForwardingAddressInFromSpace(obj);
+ // If the object has already been moved, return the new forward address.
+ if (forward_address == nullptr) {
+ forward_address = MarkNonForwardedObject(obj);
+ DCHECK(forward_address != nullptr);
+ // Make sure to only update the forwarding address AFTER you copy the object so that the
+ // monitor word doesn't get stomped over.
+ obj->SetLockWord(LockWord::FromForwardingAddress(
+ reinterpret_cast<size_t>(forward_address)));
+ // Push the object onto the mark stack for later processing.
+ MarkStackPush(forward_address);
+ }
+ obj_ptr->Assign(forward_address);
+ } else {
+ accounting::SpaceBitmap* object_bitmap =
+ heap_->GetMarkBitmap()->GetContinuousSpaceBitmap(obj);
+ if (LIKELY(object_bitmap != nullptr)) {
+ if (generational_) {
+ // If a bump pointer space only collection, we should not
+ // reach here as we don't/won't mark the objects in the
+ // non-moving space (except for the promoted objects.) Note
+ // the non-moving space is added to the immune space.
+ DCHECK(whole_heap_collection_);
+ }
+ if (!object_bitmap->Set(obj)) {
+ // This object was not previously marked.
+ MarkStackPush(obj);
+ }
+ } else {
+ CHECK(!to_space_->HasAddress(obj)) << "Marking " << obj << " in to_space_";
+ if (MarkLargeObject(obj)) {
+ MarkStackPush(obj);
+ }
+ }
+ }
+ }
+}
+
} // namespace collector
} // namespace gc
} // namespace art
diff --git a/runtime/gc/collector/semi_space.cc b/runtime/gc/collector/semi_space.cc
index 5faa3a1..cd9e217 100644
--- a/runtime/gc/collector/semi_space.cc
+++ b/runtime/gc/collector/semi_space.cc
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "semi_space.h"
+#include "semi_space-inl.h"
#include <functional>
#include <numeric>
@@ -50,7 +50,7 @@
#include "mirror/object_array.h"
#include "mirror/object_array-inl.h"
#include "runtime.h"
-#include "semi_space-inl.h"
+#include "stack.h"
#include "thread-inl.h"
#include "thread_list.h"
#include "verifier/method_verifier.h"
@@ -264,6 +264,7 @@
mirror::Object* ref = obj->GetFieldObject<mirror::Object>(offset, false);
if (from_space_->HasAddress(ref)) {
Runtime::Current()->GetHeap()->DumpObject(LOG(INFO), obj);
+ LOG(FATAL) << ref << " found in from space";
}
}
private:
@@ -574,64 +575,12 @@
return forward_address;
}
-// Used to mark and copy objects. Any newly-marked objects who are in the from space get moved to
-// the to-space and have their forward address updated. Objects which have been newly marked are
-// pushed on the mark stack.
-void SemiSpace::MarkObject(mirror::HeapReference<Object>* obj_ptr) {
- Object* obj = obj_ptr->AsMirrorPtr();
- if (obj == nullptr) {
- return;
- }
- if (kUseBrooksPointer) {
- // Verify all the objects have the correct forward pointer installed.
- obj->AssertSelfBrooksPointer();
- }
- if (!immune_region_.ContainsObject(obj)) {
- if (from_space_->HasAddress(obj)) {
- mirror::Object* forward_address = GetForwardingAddressInFromSpace(obj);
- // If the object has already been moved, return the new forward address.
- if (forward_address == nullptr) {
- forward_address = MarkNonForwardedObject(obj);
- DCHECK(forward_address != nullptr);
- // Make sure to only update the forwarding address AFTER you copy the object so that the
- // monitor word doesn't get stomped over.
- obj->SetLockWord(LockWord::FromForwardingAddress(
- reinterpret_cast<size_t>(forward_address)));
- // Push the object onto the mark stack for later processing.
- MarkStackPush(forward_address);
- }
- obj_ptr->Assign(forward_address);
- } else {
- accounting::SpaceBitmap* object_bitmap =
- heap_->GetMarkBitmap()->GetContinuousSpaceBitmap(obj);
- if (LIKELY(object_bitmap != nullptr)) {
- if (generational_) {
- // If a bump pointer space only collection, we should not
- // reach here as we don't/won't mark the objects in the
- // non-moving space (except for the promoted objects.) Note
- // the non-moving space is added to the immune space.
- DCHECK(whole_heap_collection_);
- }
- if (!object_bitmap->Set(obj)) {
- // This object was not previously marked.
- MarkStackPush(obj);
- }
- } else {
- CHECK(!to_space_->HasAddress(obj)) << "Marking object in to_space_";
- if (MarkLargeObject(obj)) {
- MarkStackPush(obj);
- }
- }
- }
- }
-}
-
void SemiSpace::ProcessMarkStackCallback(void* arg) {
reinterpret_cast<SemiSpace*>(arg)->ProcessMarkStack();
}
mirror::Object* SemiSpace::MarkObjectCallback(mirror::Object* root, void* arg) {
- auto ref = mirror::HeapReference<mirror::Object>::FromMirrorPtr(root);
+ auto ref = StackReference<mirror::Object>::FromMirrorPtr(root);
reinterpret_cast<SemiSpace*>(arg)->MarkObject(&ref);
return ref.AsMirrorPtr();
}
@@ -643,7 +592,7 @@
void SemiSpace::MarkRootCallback(Object** root, void* arg, uint32_t /*thread_id*/,
RootType /*root_type*/) {
- auto ref = mirror::HeapReference<mirror::Object>::FromMirrorPtr(*root);
+ auto ref = StackReference<mirror::Object>::FromMirrorPtr(*root);
reinterpret_cast<SemiSpace*>(arg)->MarkObject(&ref);
if (*root != ref.AsMirrorPtr()) {
*root = ref.AsMirrorPtr();
diff --git a/runtime/gc/collector/semi_space.h b/runtime/gc/collector/semi_space.h
index 523c2ab..52b53aa 100644
--- a/runtime/gc/collector/semi_space.h
+++ b/runtime/gc/collector/semi_space.h
@@ -98,7 +98,8 @@
void FindDefaultMarkBitmap();
// Returns the new address of the object.
- void MarkObject(mirror::HeapReference<mirror::Object>* obj_ptr)
+ template<bool kPoisonReferences>
+ void MarkObject(mirror::ObjectReference<kPoisonReferences, mirror::Object>* obj_ptr)
EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);