diff options
author | 2019-03-26 17:08:41 +0000 | |
---|---|---|
committer | 2019-03-27 09:45:20 +0000 | |
commit | 3b45890cf987c0b57965acd78958cd8eca487b8e (patch) | |
tree | 18a3dd853e9829873688a6a61bda39dd681b2a27 | |
parent | 423bebb17f15c3867a52315f0ae421f08f14544f (diff) |
ObjPtr<>-ify mirror::Throwable.
And do some cleanup after previously submitted changes.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 31113334
Change-Id: I4f8e118bb385a9cba464a564b15addc1c7306ac2
-rw-r--r-- | runtime/entrypoints/entrypoint_utils-inl.h | 8 | ||||
-rw-r--r-- | runtime/mirror/throwable.cc | 7 | ||||
-rw-r--r-- | runtime/mirror/throwable.h | 8 | ||||
-rw-r--r-- | runtime/obj_ptr-inl.h | 12 |
4 files changed, 18 insertions, 17 deletions
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h index a30eb23014..53dea7204c 100644 --- a/runtime/entrypoints/entrypoint_utils-inl.h +++ b/runtime/entrypoints/entrypoint_utils-inl.h @@ -219,10 +219,10 @@ inline ObjPtr<mirror::Object> AllocObjectFromCodeResolved(ObjPtr<mirror::Class> // Pass in false since the object cannot be finalizable. // CheckClassInitializedForObjectAlloc can cause thread suspension which means we may now be // instrumented. - return klass->Alloc</*kInstrumented=*/true, false>(self, heap->GetCurrentAllocator()).Ptr(); + return klass->Alloc</*kInstrumented=*/true, false>(self, heap->GetCurrentAllocator()); } // Pass in false since the object cannot be finalizable. - return klass->Alloc<kInstrumented, false>(self, allocator_type).Ptr(); + return klass->Alloc<kInstrumented, false>(self, allocator_type); } // Given the context of a calling Method and an initialized class, create an instance. @@ -233,7 +233,7 @@ inline ObjPtr<mirror::Object> AllocObjectFromCodeInitialized(ObjPtr<mirror::Clas gc::AllocatorType allocator_type) { DCHECK(klass != nullptr); // Pass in false since the object cannot be finalizable. - return klass->Alloc<kInstrumented, false>(self, allocator_type).Ptr(); + return klass->Alloc<kInstrumented, false>(self, allocator_type); } @@ -314,7 +314,7 @@ inline ObjPtr<mirror::Array> AllocArrayFromCodeResolved(ObjPtr<mirror::Class> kl // No need to retry a slow-path allocation as the above code won't cause a GC or thread // suspension. return mirror::Array::Alloc<kInstrumented>(self, klass, component_count, - klass->GetComponentSizeShift(), allocator_type).Ptr(); + klass->GetComponentSizeShift(), allocator_type); } template<FindFieldType type, bool access_check> diff --git a/runtime/mirror/throwable.cc b/runtime/mirror/throwable.cc index 2d6a9ebc8a..28ae76c677 100644 --- a/runtime/mirror/throwable.cc +++ b/runtime/mirror/throwable.cc @@ -25,6 +25,7 @@ #include "class_root.h" #include "dex/dex_file-inl.h" #include "gc/accounting/card_table-inl.h" +#include "obj_ptr-inl.h" #include "object-inl.h" #include "object_array-inl.h" #include "object_array.h" @@ -157,15 +158,15 @@ std::string Throwable::Dump() { return result; } -Object* Throwable::GetStackState() { +ObjPtr<Object> Throwable::GetStackState() { return GetFieldObjectVolatile<Object>(OFFSET_OF_OBJECT_MEMBER(Throwable, backtrace_)); } -Object* Throwable::GetStackTrace() { +ObjPtr<Object> Throwable::GetStackTrace() { return GetFieldObjectVolatile<Object>(OFFSET_OF_OBJECT_MEMBER(Throwable, backtrace_)); } -String* Throwable::GetDetailMessage() { +ObjPtr<String> Throwable::GetDetailMessage() { return GetFieldObject<String>(OFFSET_OF_OBJECT_MEMBER(Throwable, detail_message_)); } diff --git a/runtime/mirror/throwable.h b/runtime/mirror/throwable.h index a9e5d1a30b..68c176a1da 100644 --- a/runtime/mirror/throwable.h +++ b/runtime/mirror/throwable.h @@ -33,7 +33,7 @@ class MANAGED Throwable : public Object { public: void SetDetailMessage(ObjPtr<String> new_detail_message) REQUIRES_SHARED(Locks::mutator_lock_); - String* GetDetailMessage() REQUIRES_SHARED(Locks::mutator_lock_); + ObjPtr<String> GetDetailMessage() REQUIRES_SHARED(Locks::mutator_lock_); std::string Dump() REQUIRES_SHARED(Locks::mutator_lock_); @@ -48,11 +48,11 @@ class MANAGED Throwable : public Object { int32_t GetStackDepth() REQUIRES_SHARED(Locks::mutator_lock_); private: - Object* GetStackState() REQUIRES_SHARED(Locks::mutator_lock_); - Object* GetStackTrace() REQUIRES_SHARED(Locks::mutator_lock_); + ObjPtr<Object> GetStackState() REQUIRES_SHARED(Locks::mutator_lock_); + ObjPtr<Object> GetStackTrace() REQUIRES_SHARED(Locks::mutator_lock_); // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". - HeapReference<Object> backtrace_; // Note this is Java volatile: + HeapReference<Object> backtrace_; HeapReference<Throwable> cause_; HeapReference<String> detail_message_; HeapReference<Object> stack_trace_; diff --git a/runtime/obj_ptr-inl.h b/runtime/obj_ptr-inl.h index 3eb5b15e2e..6a68f147de 100644 --- a/runtime/obj_ptr-inl.h +++ b/runtime/obj_ptr-inl.h @@ -129,42 +129,42 @@ size_t HashObjPtr::operator()(const ObjPtr<MirrorType>& ptr) const { template<class MirrorType1, class MirrorType2> inline std::enable_if_t<std::is_base_of_v<MirrorType1, MirrorType2> || std::is_base_of_v<MirrorType2, MirrorType1>, bool> -operator==(ObjPtr<MirrorType1> lhs, ObjPtr<MirrorType2> rhs) REQUIRES_SHARED(Locks::mutator_lock_) { +operator==(ObjPtr<MirrorType1> lhs, ObjPtr<MirrorType2> rhs) { return lhs.Ptr() == rhs.Ptr(); } template<class MirrorType1, class MirrorType2> inline std::enable_if_t<std::is_base_of_v<MirrorType1, MirrorType2> || std::is_base_of_v<MirrorType2, MirrorType1>, bool> -operator==(const MirrorType1* lhs, ObjPtr<MirrorType2> rhs) REQUIRES_SHARED(Locks::mutator_lock_) { +operator==(const MirrorType1* lhs, ObjPtr<MirrorType2> rhs) { return lhs == rhs.Ptr(); } template<class MirrorType1, class MirrorType2> inline std::enable_if_t<std::is_base_of_v<MirrorType1, MirrorType2> || std::is_base_of_v<MirrorType2, MirrorType1>, bool> -operator==(ObjPtr<MirrorType1> lhs, const MirrorType2* rhs) REQUIRES_SHARED(Locks::mutator_lock_) { +operator==(ObjPtr<MirrorType1> lhs, const MirrorType2* rhs) { return lhs.Ptr() == rhs; } template<class MirrorType1, class MirrorType2> inline std::enable_if_t<std::is_base_of_v<MirrorType1, MirrorType2> || std::is_base_of_v<MirrorType2, MirrorType1>, bool> -operator!=(ObjPtr<MirrorType1> lhs, ObjPtr<MirrorType2> rhs) REQUIRES_SHARED(Locks::mutator_lock_) { +operator!=(ObjPtr<MirrorType1> lhs, ObjPtr<MirrorType2> rhs) { return !(lhs == rhs); } template<class MirrorType1, class MirrorType2> inline std::enable_if_t<std::is_base_of_v<MirrorType1, MirrorType2> || std::is_base_of_v<MirrorType2, MirrorType1>, bool> -operator!=(const MirrorType1* lhs, ObjPtr<MirrorType2> rhs) REQUIRES_SHARED(Locks::mutator_lock_) { +operator!=(const MirrorType1* lhs, ObjPtr<MirrorType2> rhs) { return !(lhs == rhs); } template<class MirrorType1, class MirrorType2> inline std::enable_if_t<std::is_base_of_v<MirrorType1, MirrorType2> || std::is_base_of_v<MirrorType2, MirrorType1>, bool> -operator!=(ObjPtr<MirrorType1> lhs, const MirrorType2* rhs) REQUIRES_SHARED(Locks::mutator_lock_) { +operator!=(ObjPtr<MirrorType1> lhs, const MirrorType2* rhs) { return !(lhs == rhs); } |