diff options
author | 2019-03-29 16:12:04 +0000 | |
---|---|---|
committer | 2019-04-01 09:37:59 +0000 | |
commit | bdc93b47e2e7e8f17413669e03bc461d259d16f6 (patch) | |
tree | bd1c632196a437e90d012475afa83adf614be538 | |
parent | f52d92fce224c86491d9b0fd6fca805564119426 (diff) |
ObjPtr<>-ify StackTraceElement and ClassLoader.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 31113334
Change-Id: I457eeda55bbfb905dd2de0abd68451ab42ef9c1f
-rw-r--r-- | compiler/exception_test.cc | 2 | ||||
-rw-r--r-- | compiler/jni/jni_compiler_test.cc | 2 | ||||
-rw-r--r-- | runtime/class_loader_context.cc | 1 | ||||
-rw-r--r-- | runtime/class_loader_context_test.cc | 2 | ||||
-rw-r--r-- | runtime/common_runtime_test.cc | 2 | ||||
-rw-r--r-- | runtime/debug_print.cc | 2 | ||||
-rw-r--r-- | runtime/mirror/class_loader-inl.h | 5 | ||||
-rw-r--r-- | runtime/mirror/class_loader.h | 4 | ||||
-rw-r--r-- | runtime/mirror/stack_trace_element-inl.h | 42 | ||||
-rw-r--r-- | runtime/mirror/stack_trace_element.cc | 12 | ||||
-rw-r--r-- | runtime/mirror/stack_trace_element.h | 22 | ||||
-rw-r--r-- | runtime/mirror/throwable.cc | 9 | ||||
-rw-r--r-- | runtime/module_exclusion_test.cc | 2 |
13 files changed, 74 insertions, 33 deletions
diff --git a/compiler/exception_test.cc b/compiler/exception_test.cc index d5ceafeac9..633e124d07 100644 --- a/compiler/exception_test.cc +++ b/compiler/exception_test.cc @@ -33,7 +33,7 @@ #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" -#include "mirror/stack_trace_element.h" +#include "mirror/stack_trace_element-inl.h" #include "oat_quick_method_header.h" #include "obj_ptr-inl.h" #include "optimizing/stack_map_stream.h" diff --git a/compiler/jni/jni_compiler_test.cc b/compiler/jni/jni_compiler_test.cc index cbd203183d..0d0f8a0c30 100644 --- a/compiler/jni/jni_compiler_test.cc +++ b/compiler/jni/jni_compiler_test.cc @@ -34,7 +34,7 @@ #include "mirror/class_loader.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" -#include "mirror/stack_trace_element.h" +#include "mirror/stack_trace_element-inl.h" #include "nativehelper/ScopedLocalRef.h" #include "nativeloader/native_loader.h" #include "runtime.h" diff --git a/runtime/class_loader_context.cc b/runtime/class_loader_context.cc index 66d134e7ee..428bf30500 100644 --- a/runtime/class_loader_context.cc +++ b/runtime/class_loader_context.cc @@ -31,6 +31,7 @@ #include "dex/dex_file_loader.h" #include "handle_scope-inl.h" #include "jni/jni_internal.h" +#include "mirror/class_loader-inl.h" #include "mirror/object_array-alloc-inl.h" #include "nativehelper/scoped_local_ref.h" #include "oat_file_assistant.h" diff --git a/runtime/class_loader_context_test.cc b/runtime/class_loader_context_test.cc index 84526754be..6d44b71b67 100644 --- a/runtime/class_loader_context_test.cc +++ b/runtime/class_loader_context_test.cc @@ -29,7 +29,7 @@ #include "handle_scope-inl.h" #include "jni/jni_internal.h" #include "mirror/class.h" -#include "mirror/class_loader.h" +#include "mirror/class_loader-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-alloc-inl.h" #include "oat_file_assistant.h" diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc index 87c7ba61b0..f4cc1617a5 100644 --- a/runtime/common_runtime_test.cc +++ b/runtime/common_runtime_test.cc @@ -52,7 +52,7 @@ #include "jni/jni_internal.h" #include "mirror/class-alloc-inl.h" #include "mirror/class-inl.h" -#include "mirror/class_loader.h" +#include "mirror/class_loader-inl.h" #include "mirror/object_array-alloc-inl.h" #include "native/dalvik_system_DexFile.h" #include "noop_compiler_callbacks.h" diff --git a/runtime/debug_print.cc b/runtime/debug_print.cc index 2939b00e1b..cde4d868cb 100644 --- a/runtime/debug_print.cc +++ b/runtime/debug_print.cc @@ -25,7 +25,7 @@ #include "gc/heap.h" #include "gc/space/space-inl.h" #include "mirror/class.h" -#include "mirror/class_loader.h" +#include "mirror/class_loader-inl.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" #include "thread-current-inl.h" diff --git a/runtime/mirror/class_loader-inl.h b/runtime/mirror/class_loader-inl.h index 64b4e74f4c..1c98e0aa68 100644 --- a/runtime/mirror/class_loader-inl.h +++ b/runtime/mirror/class_loader-inl.h @@ -20,10 +20,15 @@ #include "class_loader.h" #include "class_table-inl.h" +#include "object-inl.h" namespace art { namespace mirror { +inline ObjPtr<ClassLoader> ClassLoader::GetParent() { + return GetFieldObject<ClassLoader>(OFFSET_OF_OBJECT_MEMBER(ClassLoader, parent_)); +} + template <bool kVisitClasses, VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption, diff --git a/runtime/mirror/class_loader.h b/runtime/mirror/class_loader.h index 783ba6a1be..c90a3da48d 100644 --- a/runtime/mirror/class_loader.h +++ b/runtime/mirror/class_loader.h @@ -40,9 +40,7 @@ class MANAGED ClassLoader : public Object { return sizeof(ClassLoader); } - ClassLoader* GetParent() REQUIRES_SHARED(Locks::mutator_lock_) { - return GetFieldObject<ClassLoader>(OFFSET_OF_OBJECT_MEMBER(ClassLoader, parent_)); - } + ObjPtr<ClassLoader> GetParent() REQUIRES_SHARED(Locks::mutator_lock_); template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> ClassTable* GetClassTable() REQUIRES_SHARED(Locks::mutator_lock_) { diff --git a/runtime/mirror/stack_trace_element-inl.h b/runtime/mirror/stack_trace_element-inl.h new file mode 100644 index 0000000000..0ce6866012 --- /dev/null +++ b/runtime/mirror/stack_trace_element-inl.h @@ -0,0 +1,42 @@ +/* + * 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. + */ + +#ifndef ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_INL_H_ +#define ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_INL_H_ + +#include "stack_trace_element.h" + +#include "object-inl.h" + +namespace art { +namespace mirror { + +inline ObjPtr<String> StackTraceElement::GetDeclaringClass() { + return GetFieldObject<String>(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, declaring_class_)); +} + +inline ObjPtr<String> StackTraceElement::GetMethodName() { + return GetFieldObject<String>(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, method_name_)); +} + +inline ObjPtr<String> StackTraceElement::GetFileName() { + return GetFieldObject<String>(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, file_name_)); +} + +} // namespace mirror +} // namespace art + +#endif // ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_INL_H_ diff --git a/runtime/mirror/stack_trace_element.cc b/runtime/mirror/stack_trace_element.cc index 01f2d764aa..2a272d3056 100644 --- a/runtime/mirror/stack_trace_element.cc +++ b/runtime/mirror/stack_trace_element.cc @@ -27,11 +27,11 @@ namespace art { namespace mirror { -StackTraceElement* StackTraceElement::Alloc(Thread* self, - Handle<String> declaring_class, - Handle<String> method_name, - Handle<String> file_name, - int32_t line_number) { +ObjPtr<StackTraceElement> StackTraceElement::Alloc(Thread* self, + Handle<String> declaring_class, + Handle<String> method_name, + Handle<String> file_name, + int32_t line_number) { ObjPtr<StackTraceElement> trace = ObjPtr<StackTraceElement>::DownCast(GetClassRoot<StackTraceElement>()->AllocObject(self)); if (LIKELY(trace != nullptr)) { @@ -41,7 +41,7 @@ StackTraceElement* StackTraceElement::Alloc(Thread* self, trace->Init<false>(declaring_class.Get(), method_name.Get(), file_name.Get(), line_number); } } - return trace.Ptr(); + return trace; } template<bool kTransactionActive> diff --git a/runtime/mirror/stack_trace_element.h b/runtime/mirror/stack_trace_element.h index 37ac57587f..67eedbcaa9 100644 --- a/runtime/mirror/stack_trace_element.h +++ b/runtime/mirror/stack_trace_element.h @@ -29,27 +29,21 @@ namespace mirror { // C++ mirror of java.lang.StackTraceElement class MANAGED StackTraceElement final : public Object { public: - String* GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_) { - return GetFieldObject<String>(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, declaring_class_)); - } + ObjPtr<String> GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_); - String* GetMethodName() REQUIRES_SHARED(Locks::mutator_lock_) { - return GetFieldObject<String>(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, method_name_)); - } + ObjPtr<String> GetMethodName() REQUIRES_SHARED(Locks::mutator_lock_); - String* GetFileName() REQUIRES_SHARED(Locks::mutator_lock_) { - return GetFieldObject<String>(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, file_name_)); - } + ObjPtr<String> GetFileName() REQUIRES_SHARED(Locks::mutator_lock_); int32_t GetLineNumber() REQUIRES_SHARED(Locks::mutator_lock_) { return GetField32(OFFSET_OF_OBJECT_MEMBER(StackTraceElement, line_number_)); } - static StackTraceElement* Alloc(Thread* self, - Handle<String> declaring_class, - Handle<String> method_name, - Handle<String> file_name, - int32_t line_number) + static ObjPtr<StackTraceElement> Alloc(Thread* self, + Handle<String> declaring_class, + Handle<String> method_name, + Handle<String> file_name, + int32_t line_number) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); private: diff --git a/runtime/mirror/throwable.cc b/runtime/mirror/throwable.cc index c6afca0163..faa605c2e0 100644 --- a/runtime/mirror/throwable.cc +++ b/runtime/mirror/throwable.cc @@ -29,7 +29,7 @@ #include "object-inl.h" #include "object_array-inl.h" #include "object_array.h" -#include "stack_trace_element.h" +#include "stack_trace_element-inl.h" #include "string.h" #include "well_known_classes.h" @@ -50,7 +50,8 @@ void Throwable::SetDetailMessage(ObjPtr<String> new_detail_message) { void Throwable::SetCause(ObjPtr<Throwable> cause) { CHECK(cause != nullptr); CHECK(cause != this); - Throwable* current_cause = GetFieldObject<Throwable>(OFFSET_OF_OBJECT_MEMBER(Throwable, cause_)); + ObjPtr<Throwable> current_cause = + GetFieldObject<Throwable>(OFFSET_OF_OBJECT_MEMBER(Throwable, cause_)); CHECK(current_cause == nullptr || current_cause == this); if (Runtime::Current()->IsActiveTransaction()) { SetFieldObject<true>(OFFSET_OF_OBJECT_MEMBER(Throwable, cause_), cause); @@ -137,8 +138,8 @@ std::string Throwable::Dump() { for (int32_t i = 0; i < ste_array->GetLength(); ++i) { ObjPtr<StackTraceElement> ste = ste_array->Get(i); DCHECK(ste != nullptr); - auto* method_name = ste->GetMethodName(); - auto* file_name = ste->GetFileName(); + ObjPtr<String> method_name = ste->GetMethodName(); + ObjPtr<String> file_name = ste->GetFileName(); result += StringPrintf( " at %s (%s:%d)\n", method_name != nullptr ? method_name->ToModifiedUtf8().c_str() : "<unknown method>", diff --git a/runtime/module_exclusion_test.cc b/runtime/module_exclusion_test.cc index 14942edea6..67b79d45db 100644 --- a/runtime/module_exclusion_test.cc +++ b/runtime/module_exclusion_test.cc @@ -19,7 +19,7 @@ #include "class_linker-inl.h" #include "handle.h" #include "handle_scope-inl.h" -#include "mirror/class_loader.h" +#include "mirror/class_loader-inl.h" #include "mirror/dex_cache.h" #include "mirror/object-inl.h" #include "runtime.h" |