From 6834d3414308e3d536bc685dbb3d60fe70186f23 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 25 May 2018 13:12:09 +0100 Subject: Remove mirror::Reference::java_lang_ref_Reference. And some #include cleanup after previous CLs removing static GcRoot<>s. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: I56b34637f9d793ed7680696a1eeedd07d061ad00 --- runtime/gc/reference_processor.cc | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'runtime/gc/reference_processor.cc') diff --git a/runtime/gc/reference_processor.cc b/runtime/gc/reference_processor.cc index 5be7b325d0..fe4124d788 100644 --- a/runtime/gc/reference_processor.cc +++ b/runtime/gc/reference_processor.cc @@ -16,8 +16,10 @@ #include "reference_processor.h" +#include "art_field-inl.h" #include "base/time_utils.h" #include "base/utils.h" +#include "class_root.h" #include "collector/garbage_collector.h" #include "jni/java_vm_ext.h" #include "mirror/class-inl.h" @@ -25,7 +27,6 @@ #include "mirror/reference-inl.h" #include "nativehelper/scoped_local_ref.h" #include "object_callbacks.h" -#include "reference_processor-inl.h" #include "reflection.h" #include "scoped_thread_state_change-inl.h" #include "task_processor.h" @@ -47,15 +48,37 @@ ReferenceProcessor::ReferenceProcessor() cleared_references_(Locks::reference_queue_cleared_references_lock_) { } +static inline MemberOffset GetSlowPathFlagOffset(ObjPtr reference_class) + REQUIRES_SHARED(Locks::mutator_lock_) { + DCHECK(reference_class == GetClassRoot()); + // Second static field + ArtField* field = reference_class->GetStaticField(1); + DCHECK_STREQ(field->GetName(), "slowPathEnabled"); + return field->GetOffset(); +} + +static inline void SetSlowPathFlag(bool enabled) REQUIRES_SHARED(Locks::mutator_lock_) { + ObjPtr reference_class = GetClassRoot(); + MemberOffset slow_path_offset = GetSlowPathFlagOffset(reference_class); + reference_class->SetFieldBoolean( + slow_path_offset, enabled ? 1 : 0); +} + void ReferenceProcessor::EnableSlowPath() { - mirror::Reference::GetJavaLangRefReference()->SetSlowPath(true); + SetSlowPathFlag(/* enabled */ true); } void ReferenceProcessor::DisableSlowPath(Thread* self) { - mirror::Reference::GetJavaLangRefReference()->SetSlowPath(false); + SetSlowPathFlag(/* enabled */ false); condition_.Broadcast(self); } +bool ReferenceProcessor::SlowPathEnabled() { + ObjPtr reference_class = GetClassRoot(); + MemberOffset slow_path_offset = GetSlowPathFlagOffset(reference_class); + return reference_class->GetFieldBoolean(slow_path_offset); +} + void ReferenceProcessor::BroadcastForSlowPath(Thread* self) { MutexLock mu(self, *Locks::reference_processor_lock_); condition_.Broadcast(self); -- cgit v1.2.3-59-g8ed1b