Add missing WriteBarrier on VisitReflectiveTargets
We weren't performing write-barriers during VisitReflectiveTargets.
This could lead to incorrect marking.
Test: ./test.py --host --gcstress
Change-Id: I153f319e257675d83cae6ec25e041cbddecf1a94
diff --git a/runtime/mirror/dex_cache.cc b/runtime/mirror/dex_cache.cc
index 96fc403..dba2860 100644
--- a/runtime/mirror/dex_cache.cc
+++ b/runtime/mirror/dex_cache.cc
@@ -31,6 +31,7 @@
#include "string.h"
#include "thread.h"
#include "utils/dex_cache_arrays_layout-inl.h"
+#include "write_barrier.h"
namespace art {
namespace mirror {
@@ -174,6 +175,7 @@
}
void DexCache::VisitReflectiveTargets(ReflectiveValueVisitor* visitor) {
+ bool wrote = false;
for (size_t i = 0; i < NumResolvedFields(); i++) {
auto pair(GetNativePairPtrSize(GetResolvedFields(), i, kRuntimePointerSize));
if (pair.index == FieldDexCachePair::InvalidIndexForSlot(i)) {
@@ -188,6 +190,7 @@
pair.object = new_val;
}
SetNativePairPtrSize(GetResolvedFields(), i, pair, kRuntimePointerSize);
+ wrote = true;
}
}
for (size_t i = 0; i < NumResolvedMethods(); i++) {
@@ -204,8 +207,12 @@
pair.object = new_val;
}
SetNativePairPtrSize(GetResolvedMethods(), i, pair, kRuntimePointerSize);
+ wrote = true;
}
}
+ if (wrote) {
+ WriteBarrier::ForEveryFieldWrite(this);
+ }
}
bool DexCache::AddPreResolvedStringsArray() {
diff --git a/runtime/mirror/executable-inl.h b/runtime/mirror/executable-inl.h
index f2d684a..77669da 100644
--- a/runtime/mirror/executable-inl.h
+++ b/runtime/mirror/executable-inl.h
@@ -47,6 +47,7 @@
SetArtMethod(new_target);
SetDexMethodIndex(new_target->GetDexMethodIndex());
SetDeclaringClass(new_target->GetDeclaringClass());
+ WriteBarrier::ForEveryFieldWrite(this);
}
}
diff --git a/runtime/mirror/field.cc b/runtime/mirror/field.cc
index aa071a8..9e566b5 100644
--- a/runtime/mirror/field.cc
+++ b/runtime/mirror/field.cc
@@ -20,6 +20,7 @@
#include "dex_cache-inl.h"
#include "object-inl.h"
#include "object_array-inl.h"
+#include "write_barrier.h"
namespace art {
namespace mirror {
@@ -32,6 +33,7 @@
SetDexFieldIndex<false>(new_value->GetDexFieldIndex());
SetOffset<false>(new_value->GetOffset().Int32Value());
SetDeclaringClass<false>(new_value->GetDeclaringClass());
+ WriteBarrier::ForEveryFieldWrite(this);
}
DCHECK_EQ(new_value, GetArtField(/*use_dex_cache*/false));
}