diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-03-25 09:29:43 -0700 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2014-03-25 13:56:58 -0700 |
commit | 3b05e9ba874449dbff65b01b8781001f7d93eea6 (patch) | |
tree | f341766bff83ebea510344c4857af493725d3f58 /runtime/gc | |
parent | 027f7fa539514d2a50b448de1de39ac307087483 (diff) | |
download | art-3b05e9ba874449dbff65b01b8781001f7d93eea6.zip art-3b05e9ba874449dbff65b01b8781001f7d93eea6.tar.gz art-3b05e9ba874449dbff65b01b8781001f7d93eea6.tar.bz2 |
Add missing debugger root visiting.
Bug: 13634574
Change-Id: I2a76f6c43f1d0ad1922f06deb40a71ff651129fd
Diffstat (limited to 'runtime/gc')
-rw-r--r-- | runtime/gc/accounting/remembered_set.cc | 1 | ||||
-rw-r--r-- | runtime/gc/collector/semi_space-inl.h | 59 | ||||
-rw-r--r-- | runtime/gc/collector/semi_space.cc | 61 | ||||
-rw-r--r-- | runtime/gc/collector/semi_space.h | 3 | ||||
-rw-r--r-- | runtime/gc/heap.cc | 7 |
5 files changed, 71 insertions, 60 deletions
diff --git a/runtime/gc/accounting/remembered_set.cc b/runtime/gc/accounting/remembered_set.cc index afa5054..56f7caa 100644 --- a/runtime/gc/accounting/remembered_set.cc +++ b/runtime/gc/accounting/remembered_set.cc @@ -68,6 +68,7 @@ class RememberedSetReferenceVisitor { void operator()(mirror::Object* obj, MemberOffset offset, bool /* is_static */) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + DCHECK(obj != nullptr); mirror::HeapReference<mirror::Object>* ref_ptr = obj->GetFieldObjectReferenceAddr(offset); if (target_space_->HasAddress(ref_ptr->AsMirrorPtr())) { *contains_reference_to_target_space_ = true; diff --git a/runtime/gc/collector/semi_space-inl.h b/runtime/gc/collector/semi_space-inl.h index 3b8f7c3..d60298b 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 @@ inline mirror::Object* SemiSpace::GetForwardingAddressInFromSpace(mirror::Object 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 @@ class SemiSpaceVerifyNoFromSpaceReferencesVisitor { 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 @@ mirror::Object* SemiSpace::MarkNonForwardedObject(mirror::Object* obj) { 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::MarkHeapReferenceCallback(mirror::HeapReference<mirror::Object>* 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 @@ class SemiSpace : public GarbageCollector { 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_); diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 6c3ae5e..a256b67 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -805,7 +805,8 @@ void Heap::ProcessReferences(TimingLogger& timings, bool clear_soft, // marked, put it on the appropriate list in the heap for later processing. void Heap::DelayReferenceReferent(mirror::Class* klass, mirror::Reference* ref, IsMarkedCallback is_marked_callback, void* arg) { - DCHECK_EQ(klass, ref->GetClass()); + // klass can be the class of the old object if the visitor already updated the class of ref. + DCHECK(klass->IsReferenceClass()); mirror::Object* referent = ref->GetReferent(); if (referent != nullptr) { mirror::Object* forward_address = is_marked_callback(referent, arg); @@ -1306,7 +1307,7 @@ class ReferringObjectsFinder { o->VisitReferences<true>(*this); } - // For MarkSweep::VisitObjectReferences. + // For Object::VisitReferences. void operator()(mirror::Object* obj, MemberOffset offset, bool /* is_static */) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { mirror::Object* ref = obj->GetFieldObject<mirror::Object>(offset, false); @@ -1916,7 +1917,7 @@ class VerifyReferenceVisitor { this->operator()(ref, mirror::Reference::ReferentOffset(), false); } - void operator()(mirror::Object* obj, MemberOffset offset, bool /* static */) const + void operator()(mirror::Object* obj, MemberOffset offset, bool /*is_static*/) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { this->operator()(obj, obj->GetFieldObject<mirror::Object>(offset, false), offset); } |