Remove bad read barrier from boot image relocation.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Repeat with `kCheckDebugDisallowReadBarrierCount = true`.
Bug: 194017033
Change-Id: I9ced1eb194605d218a9f1941e15a378e4ec9877b
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index 633ae7f..fc2aa00 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -1231,7 +1231,8 @@
DCHECK_LT(class_roots_index, image_roots->GetLength<kVerifyNone>());
ObjPtr<mirror::ObjectArray<mirror::Class>> class_roots =
ObjPtr<mirror::ObjectArray<mirror::Class>>::DownCast(boot_image.ToDest(
- image_roots->GetWithoutChecks<kVerifyNone>(class_roots_index).Ptr()));
+ image_roots->GetWithoutChecks<kVerifyNone,
+ kWithoutReadBarrier>(class_roots_index).Ptr()));
return GetClassRoot<mirror::Class, kWithoutReadBarrier>(class_roots);
}();
const auto& class_table_section = image_header->GetClassTableSection();
diff --git a/runtime/read_barrier-inl.h b/runtime/read_barrier-inl.h
index 0861375..2ccb8a1 100644
--- a/runtime/read_barrier-inl.h
+++ b/runtime/read_barrier-inl.h
@@ -29,9 +29,6 @@
namespace art {
-// Disabled for performance reasons.
-static constexpr bool kCheckDebugDisallowReadBarrierCount = false;
-
template <typename MirrorType, bool kIsVolatile, ReadBarrierOption kReadBarrierOption,
bool kAlwaysUpdateField>
inline MirrorType* ReadBarrier::Barrier(
diff --git a/runtime/read_barrier_config.h b/runtime/read_barrier_config.h
index dc11d94..d6b9cb3 100644
--- a/runtime/read_barrier_config.h
+++ b/runtime/read_barrier_config.h
@@ -72,6 +72,9 @@
// and replace it with kUseReadBarrier.
static constexpr bool kEmitCompilerReadBarrier = kForceReadBarrier || kUseReadBarrier;
+// Disabled for performance reasons.
+static constexpr bool kCheckDebugDisallowReadBarrierCount = false;
+
} // namespace art
#endif // __cplusplus
diff --git a/runtime/thread.h b/runtime/thread.h
index b64de25..a7ff1a9 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -1302,11 +1302,13 @@
void InitStringEntryPoints();
void ModifyDebugDisallowReadBarrier(int8_t delta) {
- debug_disallow_read_barrier_ += delta;
+ if (kCheckDebugDisallowReadBarrierCount) {
+ debug_disallow_read_barrier_ += delta;
+ }
}
uint8_t GetDebugDisallowReadBarrierCount() const {
- return debug_disallow_read_barrier_;
+ return kCheckDebugDisallowReadBarrierCount ? debug_disallow_read_barrier_ : 0u;
}
// Gets the current TLSData associated with the key or nullptr if there isn't any. Note that users