Refactor WriteBarrier logic into its own file
Refactor write barrier logic to have the null check logic in the
barrier if possible.
Moved the logic into its own file.
Test: test-art-host
Change-Id: I8292cd7f01dbdddea7aeab6e01da4d309ab452fe
diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h
index e64a325..faec6e6 100644
--- a/runtime/mirror/dex_cache-inl.h
+++ b/runtime/mirror/dex_cache-inl.h
@@ -34,6 +34,7 @@
#include "mirror/method_type.h"
#include "obj_ptr.h"
#include "runtime.h"
+#include "write_barrier-inl.h"
#include <atomic>
@@ -76,7 +77,7 @@
runtime->RecordResolveString(this, string_idx);
}
// TODO: Fine-grained marking, so that we don't need to go through all arrays in full.
- runtime->GetHeap()->WriteBarrierEveryFieldOf(this);
+ WriteBarrier::ForEveryFieldWrite(this);
}
inline void DexCache::ClearString(dex::StringIndex string_idx) {
@@ -113,7 +114,7 @@
GetResolvedTypes()[TypeSlotIndex(type_idx)].store(
TypeDexCachePair(resolved, type_idx.index_), std::memory_order_release);
// TODO: Fine-grained marking, so that we don't need to go through all arrays in full.
- Runtime::Current()->GetHeap()->WriteBarrierEveryFieldOf(this);
+ WriteBarrier::ForEveryFieldWrite(this);
}
inline void DexCache::ClearResolvedType(dex::TypeIndex type_idx) {
@@ -145,7 +146,7 @@
GetResolvedMethodTypes()[MethodTypeSlotIndex(proto_idx)].store(
MethodTypeDexCachePair(resolved, proto_idx.index_), std::memory_order_relaxed);
// TODO: Fine-grained marking, so that we don't need to go through all arrays in full.
- Runtime::Current()->GetHeap()->WriteBarrierEveryFieldOf(this);
+ WriteBarrier::ForEveryFieldWrite(this);
}
inline CallSite* DexCache::GetResolvedCallSite(uint32_t call_site_idx) {
@@ -171,7 +172,7 @@
reinterpret_cast<Atomic<GcRoot<mirror::CallSite>>&>(target);
if (ref.CompareAndSetStrongSequentiallyConsistent(null_call_site, candidate)) {
// TODO: Fine-grained marking, so that we don't need to go through all arrays in full.
- Runtime::Current()->GetHeap()->WriteBarrierEveryFieldOf(this);
+ WriteBarrier::ForEveryFieldWrite(this);
return call_site;
} else {
return target.Read();