diff options
author | 2018-05-25 13:12:09 +0100 | |
---|---|---|
committer | 2018-05-25 14:12:31 +0100 | |
commit | 6834d3414308e3d536bc685dbb3d60fe70186f23 (patch) | |
tree | 7c579de52d3acc5cc4d02babf25c7fcb2b94793b | |
parent | c7aa87e1666ac48ddf9149cfdfd64b026b3969e5 (diff) |
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
-rw-r--r-- | openjdkjvmti/ti_class.cc | 2 | ||||
-rw-r--r-- | runtime/Android.bp | 1 | ||||
-rw-r--r-- | runtime/class_linker.cc | 3 | ||||
-rw-r--r-- | runtime/class_table-inl.h | 1 | ||||
-rw-r--r-- | runtime/gc/reference_processor-inl.h | 34 | ||||
-rw-r--r-- | runtime/gc/reference_processor.cc | 29 | ||||
-rw-r--r-- | runtime/image-inl.h | 1 | ||||
-rw-r--r-- | runtime/mirror/array.h | 1 | ||||
-rw-r--r-- | runtime/mirror/class-inl.h | 30 | ||||
-rw-r--r-- | runtime/mirror/class.h | 9 | ||||
-rw-r--r-- | runtime/mirror/dex_cache.h | 1 | ||||
-rw-r--r-- | runtime/mirror/method_handle_impl.h | 1 | ||||
-rw-r--r-- | runtime/mirror/reference-inl.h | 6 | ||||
-rw-r--r-- | runtime/mirror/reference.cc | 43 | ||||
-rw-r--r-- | runtime/mirror/reference.h | 10 | ||||
-rw-r--r-- | runtime/mirror/string.h | 3 | ||||
-rw-r--r-- | runtime/mirror/var_handle.h | 1 | ||||
-rw-r--r-- | runtime/runtime.cc | 1 |
18 files changed, 32 insertions, 145 deletions
diff --git a/openjdkjvmti/ti_class.cc b/openjdkjvmti/ti_class.cc index c9d71b4857..726e47ed5f 100644 --- a/openjdkjvmti/ti_class.cc +++ b/openjdkjvmti/ti_class.cc @@ -63,7 +63,7 @@ #include "mirror/object-refvisitor-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object_reference.h" -#include "mirror/reference.h" +#include "mirror/reference-inl.h" #include "nativehelper/scoped_local_ref.h" #include "reflection.h" #include "runtime.h" diff --git a/runtime/Android.bp b/runtime/Android.bp index 9043866e73..b276c81d5a 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -130,7 +130,6 @@ libart_cc_defaults { "mirror/method_handles_lookup.cc", "mirror/method_type.cc", "mirror/object.cc", - "mirror/reference.cc", "mirror/stack_trace_element.cc", "mirror/string.cc", "mirror/throwable.cc", diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 5d0932128c..ea6d7ccc05 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -510,7 +510,6 @@ bool ClassLinker::InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> b // Setup java.lang.ref.Reference. Handle<mirror::Class> java_lang_ref_Reference(hs.NewHandle( AllocClass(self, java_lang_Class.Get(), mirror::Reference::ClassSize(image_pointer_size_)))); - mirror::Reference::SetClass(java_lang_ref_Reference.Get()); java_lang_ref_Reference->SetObjectSize(mirror::Reference::InstanceSize()); mirror::Class::SetStatus(java_lang_ref_Reference, ClassStatus::kResolved, self); @@ -1048,7 +1047,6 @@ bool ClassLinker::InitFromBootImage(std::string* error_msg) { mirror::Method::SetClass(GetClassRoot(ClassRoot::kJavaLangReflectMethod, this).Ptr()); mirror::Method::SetArrayClass( GetClassRoot(ClassRoot::kJavaLangReflectMethodArrayClass, this).Ptr()); - mirror::Reference::SetClass(GetClassRoot(ClassRoot::kJavaLangRefReference, this)); mirror::Throwable::SetClass(GetClassRoot(ClassRoot::kJavaLangThrowable, this)); mirror::StackTraceElement::SetClass(GetClassRoot(ClassRoot::kJavaLangStackTraceElement, this)); mirror::EmulatedStackFrame::SetClass( @@ -2135,7 +2133,6 @@ ClassLinker::~ClassLinker() { mirror::Constructor::ResetClass(); mirror::Field::ResetClass(); mirror::Method::ResetClass(); - mirror::Reference::ResetClass(); mirror::StackTraceElement::ResetClass(); mirror::String::ResetClass(); mirror::Throwable::ResetClass(); diff --git a/runtime/class_table-inl.h b/runtime/class_table-inl.h index 5da5470c1a..6b6fe341e0 100644 --- a/runtime/class_table-inl.h +++ b/runtime/class_table-inl.h @@ -20,6 +20,7 @@ #include "class_table.h" #include "gc_root-inl.h" +#include "mirror/class.h" #include "oat_file.h" namespace art { diff --git a/runtime/gc/reference_processor-inl.h b/runtime/gc/reference_processor-inl.h deleted file mode 100644 index 0f47d3dc9f..0000000000 --- a/runtime/gc/reference_processor-inl.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ART_RUNTIME_GC_REFERENCE_PROCESSOR_INL_H_ -#define ART_RUNTIME_GC_REFERENCE_PROCESSOR_INL_H_ - -#include "reference_processor.h" - -#include "mirror/reference-inl.h" - -namespace art { -namespace gc { - -inline bool ReferenceProcessor::SlowPathEnabled() { - return mirror::Reference::GetJavaLangRefReference()->GetSlowPathEnabled(); -} - -} // namespace gc -} // namespace art - -#endif // ART_RUNTIME_GC_REFERENCE_PROCESSOR_INL_H_ 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<mirror::Class> reference_class) + REQUIRES_SHARED(Locks::mutator_lock_) { + DCHECK(reference_class == GetClassRoot<mirror::Reference>()); + // 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<mirror::Class> reference_class = GetClassRoot<mirror::Reference>(); + MemberOffset slow_path_offset = GetSlowPathFlagOffset(reference_class); + reference_class->SetFieldBoolean</* kTransactionActive */ false, /* kCheckTransaction */ false>( + 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<mirror::Class> reference_class = GetClassRoot<mirror::Reference>(); + 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); diff --git a/runtime/image-inl.h b/runtime/image-inl.h index 935a1b6705..3a66a34cb3 100644 --- a/runtime/image-inl.h +++ b/runtime/image-inl.h @@ -22,6 +22,7 @@ #include "art_method.h" #include "imt_conflict_table.h" #include "imtable.h" +#include "mirror/object_array-inl.h" #include "read_barrier-inl.h" namespace art { diff --git a/runtime/mirror/array.h b/runtime/mirror/array.h index c9c99e8621..aeaaf67310 100644 --- a/runtime/mirror/array.h +++ b/runtime/mirror/array.h @@ -19,7 +19,6 @@ #include "base/enums.h" #include "gc/allocator_type.h" -#include "gc_root.h" #include "obj_ptr.h" #include "object.h" diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index 72b31790f0..ab50973e89 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -36,7 +36,6 @@ #include "object-inl.h" #include "object_array.h" #include "read_barrier-inl.h" -#include "reference-inl.h" #include "runtime.h" #include "string.h" @@ -857,11 +856,6 @@ inline uint32_t Class::ComputeClassSize(bool has_embedded_vtable, return size; } -template<ReadBarrierOption kReadBarrierOption> -inline bool Class::IsReferenceClass() const { - return this == Reference::GetJavaLangRefReference<kReadBarrierOption>(); -} - template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption> inline bool Class::IsClassClass() { ObjPtr<Class> java_lang_Class = GetClass<kVerifyFlags, kReadBarrierOption>()-> @@ -916,30 +910,6 @@ inline ObjectArray<ObjectArray<Class>>* Class::GetProxyThrows() { return GetFieldObject<ObjectArray<ObjectArray<Class>>>(field_offset); } -inline MemberOffset Class::GetDisableIntrinsicFlagOffset() { - CHECK(IsReferenceClass()); - // First static field - auto* field = GetStaticField(0); - DCHECK_STREQ(field->GetName(), "disableIntrinsic"); - return field->GetOffset(); -} - -inline MemberOffset Class::GetSlowPathFlagOffset() { - CHECK(IsReferenceClass()); - // Second static field - auto* field = GetStaticField(1); - DCHECK_STREQ(field->GetName(), "slowPathEnabled"); - return field->GetOffset(); -} - -inline bool Class::GetSlowPathEnabled() { - return GetFieldBoolean(GetSlowPathFlagOffset()); -} - -inline void Class::SetSlowPath(bool enabled) { - SetFieldBoolean<false, false>(GetSlowPathFlagOffset(), enabled); -} - inline void Class::InitializeClassVisitor::operator()(ObjPtr<Object> obj, size_t usable_size) const { DCHECK_LE(class_size_, usable_size); diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index 98e25eb320..7d5f539576 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -437,9 +437,6 @@ class MANAGED Class FINAL : public Object { bool IsThrowableClass() REQUIRES_SHARED(Locks::mutator_lock_); - template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> - bool IsReferenceClass() const REQUIRES_SHARED(Locks::mutator_lock_); - static MemberOffset ComponentTypeOffset() { return OFFSET_OF_OBJECT_MEMBER(Class, component_type_); } @@ -1212,12 +1209,6 @@ class MANAGED Class FINAL : public Object { // For proxy class only. ObjectArray<ObjectArray<Class>>* GetProxyThrows() REQUIRES_SHARED(Locks::mutator_lock_); - // For reference class only. - MemberOffset GetDisableIntrinsicFlagOffset() REQUIRES_SHARED(Locks::mutator_lock_); - MemberOffset GetSlowPathFlagOffset() REQUIRES_SHARED(Locks::mutator_lock_); - bool GetSlowPathEnabled() REQUIRES_SHARED(Locks::mutator_lock_); - void SetSlowPath(bool enabled) REQUIRES_SHARED(Locks::mutator_lock_); - // May cause thread suspension due to EqualParameters. ArtMethod* GetDeclaredConstructor(Thread* self, Handle<ObjectArray<Class>> args, diff --git a/runtime/mirror/dex_cache.h b/runtime/mirror/dex_cache.h index 9aff9ec49a..bb86004a90 100644 --- a/runtime/mirror/dex_cache.h +++ b/runtime/mirror/dex_cache.h @@ -21,6 +21,7 @@ #include "base/bit_utils.h" #include "base/mutex.h" #include "dex/dex_file_types.h" +#include "gc_root-inl.h" #include "object.h" #include "object_array.h" diff --git a/runtime/mirror/method_handle_impl.h b/runtime/mirror/method_handle_impl.h index 4813b3c3f7..030a49ed1e 100644 --- a/runtime/mirror/method_handle_impl.h +++ b/runtime/mirror/method_handle_impl.h @@ -20,7 +20,6 @@ #include "art_field.h" #include "art_method.h" #include "class.h" -#include "gc_root.h" #include "method_type.h" #include "object.h" diff --git a/runtime/mirror/reference-inl.h b/runtime/mirror/reference-inl.h index 84e54948dd..c65f740a78 100644 --- a/runtime/mirror/reference-inl.h +++ b/runtime/mirror/reference-inl.h @@ -49,12 +49,6 @@ inline void FinalizerReference::SetZombie(ObjPtr<Object> zombie) { return SetFieldObjectVolatile<kTransactionActive>(ZombieOffset(), zombie); } -template<ReadBarrierOption kReadBarrierOption> -inline Class* Reference::GetJavaLangRefReference() { - DCHECK(!java_lang_ref_Reference_.IsNull()); - return java_lang_ref_Reference_.Read<kReadBarrierOption>(); -} - } // namespace mirror } // namespace art diff --git a/runtime/mirror/reference.cc b/runtime/mirror/reference.cc deleted file mode 100644 index 1d0b4c5b27..0000000000 --- a/runtime/mirror/reference.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "reference-inl.h" - -#include "art_method.h" -#include "gc_root-inl.h" - -namespace art { -namespace mirror { - -GcRoot<Class> Reference::java_lang_ref_Reference_; - -void Reference::SetClass(ObjPtr<Class> java_lang_ref_Reference) { - CHECK(java_lang_ref_Reference_.IsNull()); - CHECK(java_lang_ref_Reference != nullptr); - java_lang_ref_Reference_ = GcRoot<Class>(java_lang_ref_Reference); -} - -void Reference::ResetClass() { - CHECK(!java_lang_ref_Reference_.IsNull()); - java_lang_ref_Reference_ = GcRoot<Class>(nullptr); -} - -void Reference::VisitRoots(RootVisitor* visitor) { - java_lang_ref_Reference_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass)); -} - -} // namespace mirror -} // namespace art diff --git a/runtime/mirror/reference.h b/runtime/mirror/reference.h index b10c29444e..63c5ae5ff8 100644 --- a/runtime/mirror/reference.h +++ b/runtime/mirror/reference.h @@ -20,8 +20,6 @@ #include "base/enums.h" #include "base/macros.h" #include "base/mutex.h" -#include "class.h" -#include "gc_root.h" #include "obj_ptr.h" #include "object.h" #include "read_barrier_option.h" @@ -98,12 +96,6 @@ class MANAGED Reference : public Object { return GetPendingNext<kWithoutReadBarrier>() == nullptr; } - template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> - static ALWAYS_INLINE Class* GetJavaLangRefReference() REQUIRES_SHARED(Locks::mutator_lock_); - static void SetClass(ObjPtr<Class> klass); - static void ResetClass(); - static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_); - private: // Note: This avoids a read barrier, it should only be used by the GC. HeapReference<Object>* GetReferentReferenceAddr() REQUIRES_SHARED(Locks::mutator_lock_) { @@ -116,8 +108,6 @@ class MANAGED Reference : public Object { HeapReference<Reference> queue_next_; HeapReference<Object> referent_; // Note this is Java volatile: - static GcRoot<Class> java_lang_ref_Reference_; - friend struct art::ReferenceOffsets; // for verifying offset information friend class gc::ReferenceProcessor; friend class gc::ReferenceQueue; diff --git a/runtime/mirror/string.h b/runtime/mirror/string.h index 545fe93516..c45dc499e5 100644 --- a/runtime/mirror/string.h +++ b/runtime/mirror/string.h @@ -18,7 +18,8 @@ #define ART_RUNTIME_MIRROR_STRING_H_ #include "gc/allocator_type.h" -#include "gc_root.h" +#include "gc_root-inl.h" +#include "class.h" #include "object.h" namespace art { diff --git a/runtime/mirror/var_handle.h b/runtime/mirror/var_handle.h index 4fd18c14e2..9829456854 100644 --- a/runtime/mirror/var_handle.h +++ b/runtime/mirror/var_handle.h @@ -19,7 +19,6 @@ #include "handle.h" #include "interpreter/shadow_frame.h" -#include "gc_root.h" #include "jvalue.h" #include "object.h" diff --git a/runtime/runtime.cc b/runtime/runtime.cc index d126fe979a..e42bbc20ef 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -1978,7 +1978,6 @@ void Runtime::VisitConstantRoots(RootVisitor* visitor) { // need to be visited once per GC since they never change. mirror::Class::VisitRoots(visitor); mirror::Constructor::VisitRoots(visitor); - mirror::Reference::VisitRoots(visitor); mirror::Method::VisitRoots(visitor); mirror::StackTraceElement::VisitRoots(visitor); mirror::String::VisitRoots(visitor); |