// 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<typename CompressedReferenceType> inlinevoid SemiSpace::MarkObject(CompressedReferenceType* obj_ptr) {
mirror::Object* obj = obj_ptr->AsMirrorPtr(); if (obj == nullptr) { return;
} if (from_space_->HasAddress(obj)) {
mirror::Object* forward_address = GetForwardingAddressInFromSpace(obj); // If the object has already been moved, return the new forward address. if (UNLIKELY(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)), false); // Push the object onto the mark stack for later processing.
MarkStackPush(forward_address);
}
obj_ptr->Assign(forward_address);
} elseif (!immune_spaces_.IsInImmuneRegion(obj)) {
DCHECK(!to_space_->HasAddress(obj)) << "Tried to mark " << obj << " in to-space"; auto slow_path = [this](const mirror::Object* ref) {
CHECK(!to_space_->HasAddress(ref)) << "Marking " << ref << " in to_space_"; // Marking a large object, make sure its aligned as a consistency check.
CHECK_ALIGNED_PARAM(ref, space::LargeObjectSpace::ObjectAlignment());
}; if (!mark_bitmap_->Set(obj, slow_path)) { // This object was not previously marked.
MarkStackPush(obj);
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.