OSDN Git Service

Use MarkIfNotInToSpace for SemiSpace::MarkObject
authorMathieu Chartier <mathieuc@google.com>
Fri, 4 Mar 2016 18:30:39 +0000 (10:30 -0800)
committerMathieu Chartier <mathieuc@google.com>
Sat, 5 Mar 2016 01:00:14 +0000 (17:00 -0800)
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

runtime/gc/collector/semi_space-inl.h
runtime/gc/collector/semi_space.cc

index 12cf3db..e87b5ff 100644 (file)
@@ -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.
index 2784693..f37daa5 100644 (file)
@@ -619,7 +619,7 @@ mirror::Object* SemiSpace::MarkNonForwardedObject(mirror::Object* obj) {
 
 mirror::Object* SemiSpace::MarkObject(mirror::Object* root) {
   auto ref = StackReference<mirror::Object>::FromMirrorPtr(root);
-  MarkObject(&ref);
+  MarkObjectIfNotInToSpace(&ref);
   return ref.AsMirrorPtr();
 }