OSDN Git Service

Don't use ModifyDebugDisallowReadBarrier in transaction mode.
authorHiroshi Yamauchi <yamauchi@google.com>
Fri, 3 Feb 2017 23:09:26 +0000 (15:09 -0800)
committerHiroshi Yamauchi <yamauchi@google.com>
Fri, 3 Feb 2017 23:14:17 +0000 (15:14 -0800)
Bug: 34963782
Test: test-art-host
Change-Id: I356eaf9010f1c137bed703326dcb7f641ce7fcfe

runtime/gc/collector/concurrent_copying.cc

index 0819ba0..f12ad80 100644 (file)
@@ -1875,8 +1875,10 @@ class ConcurrentCopying::RefFieldsVisitor {
 
 // Scan ref fields of an object.
 inline void ConcurrentCopying::Scan(mirror::Object* to_ref) {
-  if (kDisallowReadBarrierDuringScan) {
+  if (kDisallowReadBarrierDuringScan && !Runtime::Current()->IsActiveTransaction()) {
     // Avoid all read barriers during visit references to help performance.
+    // Don't do this in transaction mode because we may read the old value of an field which may
+    // trigger read barriers.
     Thread::Current()->ModifyDebugDisallowReadBarrier(1);
   }
   DCHECK(!region_space_->IsInFromSpace(to_ref));
@@ -1885,7 +1887,7 @@ inline void ConcurrentCopying::Scan(mirror::Object* to_ref) {
   // Disable the read barrier for a performance reason.
   to_ref->VisitReferences</*kVisitNativeRoots*/true, kDefaultVerifyFlags, kWithoutReadBarrier>(
       visitor, visitor);
-  if (kDisallowReadBarrierDuringScan) {
+  if (kDisallowReadBarrierDuringScan && !Runtime::Current()->IsActiveTransaction()) {
     Thread::Current()->ModifyDebugDisallowReadBarrier(-1);
   }
 }