summaryrefslogtreecommitdiffstats
path: root/runtime/gc/collector/semi_space-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/gc/collector/semi_space-inl.h')
-rw-r--r--runtime/gc/collector/semi_space-inl.h59
1 files changed, 59 insertions, 0 deletions
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