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
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h
index a30eb23..53dea72 100644
--- a/runtime/entrypoints/entrypoint_utils-inl.h
+++ b/runtime/entrypoints/entrypoint_utils-inl.h
@@ -219,10 +219,10 @@
// 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 @@
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 @@
// 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 2d6a9eb..28ae76c 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 @@
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 a9e5d1a..68c176a 100644
--- a/runtime/mirror/throwable.h
+++ b/runtime/mirror/throwable.h
@@ -33,7 +33,7 @@
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 @@
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 3eb5b15..6a68f14 100644
--- a/runtime/obj_ptr-inl.h
+++ b/runtime/obj_ptr-inl.h
@@ -129,42 +129,42 @@
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);
}