From: Mathieu Chartier Date: Fri, 4 Mar 2016 18:30:39 +0000 (-0800) Subject: Use MarkIfNotInToSpace for SemiSpace::MarkObject X-Git-Tag: android-x86-7.1-r1~340^2~24^2~5^2~6^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9a9aee662ebde18bed2a8e263c921df4f529b27b;p=android-x86%2Fart.git Use MarkIfNotInToSpace for SemiSpace::MarkObject SemiSpace::MarkObject is called from ModUnionScanImageRootVisitor which. These roots may be visited multiple times by the GC. One example is the allocation stack traces and a class visiting the same ArtMethod twice. Bug: 27435111 Change-Id: I721b8bcf7fe43f4c351d902c2f3422d3bb585295 --- diff --git a/runtime/gc/collector/semi_space-inl.h b/runtime/gc/collector/semi_space-inl.h index 12cf3dbf9..e87b5ff33 100644 --- a/runtime/gc/collector/semi_space-inl.h +++ b/runtime/gc/collector/semi_space-inl.h @@ -75,6 +75,7 @@ inline void SemiSpace::MarkObject( } obj_ptr->Assign(forward_address); } else if (!collect_from_space_only_ && !immune_spaces_.IsInImmuneRegion(obj)) { + DCHECK(!to_space_->HasAddress(obj)) << "Tried to mark " << obj << " in to-space"; BitmapSetSlowPathVisitor visitor(this); if (!mark_bitmap_->Set(obj, visitor)) { // This object was not previously marked. diff --git a/runtime/gc/collector/semi_space.cc b/runtime/gc/collector/semi_space.cc index 278469329..f37daa54e 100644 --- a/runtime/gc/collector/semi_space.cc +++ b/runtime/gc/collector/semi_space.cc @@ -619,7 +619,7 @@ mirror::Object* SemiSpace::MarkNonForwardedObject(mirror::Object* obj) { mirror::Object* SemiSpace::MarkObject(mirror::Object* root) { auto ref = StackReference::FromMirrorPtr(root); - MarkObject(&ref); + MarkObjectIfNotInToSpace(&ref); return ref.AsMirrorPtr(); }