diff options
author | 2019-02-13 16:33:14 -0800 | |
---|---|---|
committer | 2019-02-14 10:09:19 -0800 | |
commit | d902558e31a0095770778ce9d9ad19ac9a2c4f9f (patch) | |
tree | 0c0ec46ca5e06f9887a6d7a673509d359f015a0b | |
parent | 35a760d5e5879d50cd2d36e3d6286fe6c12888aa (diff) |
ObjPtr-ify the jvmti tagging system.
There's no reason for this to use raw pointers.
Test: ./test/testrunner/testrunner.py --host -j80
Change-Id: I11859ee86dbfd88c0428d6725aae3545a3fcef67
-rw-r--r-- | openjdkjvmti/jvmti_weak_table-inl.h | 20 | ||||
-rw-r--r-- | openjdkjvmti/jvmti_weak_table.h | 22 | ||||
-rw-r--r-- | openjdkjvmti/object_tagging.cc | 4 | ||||
-rw-r--r-- | openjdkjvmti/object_tagging.h | 8 |
4 files changed, 27 insertions, 27 deletions
diff --git a/openjdkjvmti/jvmti_weak_table-inl.h b/openjdkjvmti/jvmti_weak_table-inl.h index d9b8a84e55..5b28e458f8 100644 --- a/openjdkjvmti/jvmti_weak_table-inl.h +++ b/openjdkjvmti/jvmti_weak_table-inl.h @@ -77,7 +77,7 @@ void JvmtiWeakTable<T>::UpdateTableWithReadBarrier() { } template <typename T> -bool JvmtiWeakTable<T>::GetTagSlowPath(art::Thread* self, art::mirror::Object* obj, T* result) { +bool JvmtiWeakTable<T>::GetTagSlowPath(art::Thread* self, art::ObjPtr<art::mirror::Object> obj, T* result) { // Under concurrent GC, there is a window between moving objects and sweeping of system // weaks in which mutators are active. We may receive a to-space object pointer in obj, // but still have from-space pointers in the table. Explicitly update the table once. @@ -87,7 +87,7 @@ bool JvmtiWeakTable<T>::GetTagSlowPath(art::Thread* self, art::mirror::Object* o } template <typename T> -bool JvmtiWeakTable<T>::Remove(art::mirror::Object* obj, /* out */ T* tag) { +bool JvmtiWeakTable<T>::Remove(art::ObjPtr<art::mirror::Object> obj, /* out */ T* tag) { art::Thread* self = art::Thread::Current(); art::MutexLock mu(self, allow_disallow_lock_); Wait(self); @@ -95,7 +95,7 @@ bool JvmtiWeakTable<T>::Remove(art::mirror::Object* obj, /* out */ T* tag) { return RemoveLocked(self, obj, tag); } template <typename T> -bool JvmtiWeakTable<T>::RemoveLocked(art::mirror::Object* obj, T* tag) { +bool JvmtiWeakTable<T>::RemoveLocked(art::ObjPtr<art::mirror::Object> obj, T* tag) { art::Thread* self = art::Thread::Current(); allow_disallow_lock_.AssertHeld(self); Wait(self); @@ -104,7 +104,7 @@ bool JvmtiWeakTable<T>::RemoveLocked(art::mirror::Object* obj, T* tag) { } template <typename T> -bool JvmtiWeakTable<T>::RemoveLocked(art::Thread* self, art::mirror::Object* obj, T* tag) { +bool JvmtiWeakTable<T>::RemoveLocked(art::Thread* self, art::ObjPtr<art::mirror::Object> obj, T* tag) { auto it = tagged_objects_.find(art::GcRoot<art::mirror::Object>(obj)); if (it != tagged_objects_.end()) { if (tag != nullptr) { @@ -132,7 +132,7 @@ bool JvmtiWeakTable<T>::RemoveLocked(art::Thread* self, art::mirror::Object* obj } template <typename T> -bool JvmtiWeakTable<T>::Set(art::mirror::Object* obj, T new_tag) { +bool JvmtiWeakTable<T>::Set(art::ObjPtr<art::mirror::Object> obj, T new_tag) { art::Thread* self = art::Thread::Current(); art::MutexLock mu(self, allow_disallow_lock_); Wait(self); @@ -140,7 +140,7 @@ bool JvmtiWeakTable<T>::Set(art::mirror::Object* obj, T new_tag) { return SetLocked(self, obj, new_tag); } template <typename T> -bool JvmtiWeakTable<T>::SetLocked(art::mirror::Object* obj, T new_tag) { +bool JvmtiWeakTable<T>::SetLocked(art::ObjPtr<art::mirror::Object> obj, T new_tag) { art::Thread* self = art::Thread::Current(); allow_disallow_lock_.AssertHeld(self); Wait(self); @@ -149,7 +149,7 @@ bool JvmtiWeakTable<T>::SetLocked(art::mirror::Object* obj, T new_tag) { } template <typename T> -bool JvmtiWeakTable<T>::SetLocked(art::Thread* self, art::mirror::Object* obj, T new_tag) { +bool JvmtiWeakTable<T>::SetLocked(art::Thread* self, art::ObjPtr<art::mirror::Object> obj, T new_tag) { auto it = tagged_objects_.find(art::GcRoot<art::mirror::Object>(obj)); if (it != tagged_objects_.end()) { it->second = new_tag; @@ -362,7 +362,7 @@ jvmtiError JvmtiWeakTable<T>::GetTaggedObjects(jvmtiEnv* jvmti_env, } if (select) { - art::mirror::Object* obj = pair.first.template Read<art::kWithReadBarrier>(); + art::ObjPtr<art::mirror::Object> obj = pair.first.template Read<art::kWithReadBarrier>(); if (obj != nullptr) { count++; if (object_result_ptr != nullptr) { @@ -386,14 +386,14 @@ jvmtiError JvmtiWeakTable<T>::GetTaggedObjects(jvmtiEnv* jvmti_env, } template <typename T> -art::mirror::Object* JvmtiWeakTable<T>::Find(T tag) { +art::ObjPtr<art::mirror::Object> JvmtiWeakTable<T>::Find(T tag) { art::Thread* self = art::Thread::Current(); art::MutexLock mu(self, allow_disallow_lock_); Wait(self); for (auto& pair : tagged_objects_) { if (tag == pair.second) { - art::mirror::Object* obj = pair.first.template Read<art::kWithReadBarrier>(); + art::ObjPtr<art::mirror::Object> obj = pair.first.template Read<art::kWithReadBarrier>(); if (obj != nullptr) { return obj; } diff --git a/openjdkjvmti/jvmti_weak_table.h b/openjdkjvmti/jvmti_weak_table.h index cba8ef06a7..ea0d023728 100644 --- a/openjdkjvmti/jvmti_weak_table.h +++ b/openjdkjvmti/jvmti_weak_table.h @@ -60,25 +60,25 @@ class JvmtiWeakTable : public art::gc::SystemWeakHolder { // Remove the mapping for the given object, returning whether such a mapping existed (and the old // value). - ALWAYS_INLINE bool Remove(art::mirror::Object* obj, /* out */ T* tag) + ALWAYS_INLINE bool Remove(art::ObjPtr<art::mirror::Object> obj, /* out */ T* tag) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!allow_disallow_lock_); - ALWAYS_INLINE bool RemoveLocked(art::mirror::Object* obj, /* out */ T* tag) + ALWAYS_INLINE bool RemoveLocked(art::ObjPtr<art::mirror::Object> obj, /* out */ T* tag) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_); // Set the mapping for the given object. Returns true if this overwrites an already existing // mapping. - ALWAYS_INLINE virtual bool Set(art::mirror::Object* obj, T tag) + ALWAYS_INLINE virtual bool Set(art::ObjPtr<art::mirror::Object> obj, T tag) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!allow_disallow_lock_); - ALWAYS_INLINE virtual bool SetLocked(art::mirror::Object* obj, T tag) + ALWAYS_INLINE virtual bool SetLocked(art::ObjPtr<art::mirror::Object> obj, T tag) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_); // Return the value associated with the given object. Returns true if the mapping exists, false // otherwise. - bool GetTag(art::mirror::Object* obj, /* out */ T* result) + bool GetTag(art::ObjPtr<art::mirror::Object> obj, /* out */ T* result) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!allow_disallow_lock_) { art::Thread* self = art::Thread::Current(); @@ -87,7 +87,7 @@ class JvmtiWeakTable : public art::gc::SystemWeakHolder { return GetTagLocked(self, obj, result); } - bool GetTagLocked(art::mirror::Object* obj, /* out */ T* result) + bool GetTagLocked(art::ObjPtr<art::mirror::Object> obj, /* out */ T* result) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_) { art::Thread* self = art::Thread::Current(); @@ -118,7 +118,7 @@ class JvmtiWeakTable : public art::gc::SystemWeakHolder { ALWAYS_INLINE void Unlock() RELEASE(allow_disallow_lock_); ALWAYS_INLINE void AssertLocked() ASSERT_CAPABILITY(allow_disallow_lock_); - ALWAYS_INLINE art::mirror::Object* Find(T tag) + ALWAYS_INLINE art::ObjPtr<art::mirror::Object> Find(T tag) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!allow_disallow_lock_); @@ -132,16 +132,16 @@ class JvmtiWeakTable : public art::gc::SystemWeakHolder { private: ALWAYS_INLINE - bool SetLocked(art::Thread* self, art::mirror::Object* obj, T tag) + bool SetLocked(art::Thread* self, art::ObjPtr<art::mirror::Object> obj, T tag) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_); ALWAYS_INLINE - bool RemoveLocked(art::Thread* self, art::mirror::Object* obj, /* out */ T* tag) + bool RemoveLocked(art::Thread* self, art::ObjPtr<art::mirror::Object> obj, /* out */ T* tag) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_); - bool GetTagLocked(art::Thread* self, art::mirror::Object* obj, /* out */ T* result) + bool GetTagLocked(art::Thread* self, art::ObjPtr<art::mirror::Object> obj, /* out */ T* result) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_) { auto it = tagged_objects_.find(art::GcRoot<art::mirror::Object>(obj)); @@ -165,7 +165,7 @@ class JvmtiWeakTable : public art::gc::SystemWeakHolder { // Slow-path for GetTag. We didn't find the object, but we might be storing from-pointers and // are asked to retrieve with a to-pointer. ALWAYS_INLINE - bool GetTagSlowPath(art::Thread* self, art::mirror::Object* obj, /* out */ T* result) + bool GetTagSlowPath(art::Thread* self, art::ObjPtr<art::mirror::Object> obj, /* out */ T* result) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_); diff --git a/openjdkjvmti/object_tagging.cc b/openjdkjvmti/object_tagging.cc index 0a51bf2f6b..d52933a50e 100644 --- a/openjdkjvmti/object_tagging.cc +++ b/openjdkjvmti/object_tagging.cc @@ -71,7 +71,7 @@ void ObjectTagTable::SendSingleFreeEvent(jlong tag) { jvmti_env_, art::Thread::Current(), tag); } -bool ObjectTagTable::Set(art::mirror::Object* obj, jlong new_tag) { +bool ObjectTagTable::Set(art::ObjPtr<art::mirror::Object> obj, jlong new_tag) { if (new_tag == 0) { jlong tmp; return Remove(obj, &tmp); @@ -79,7 +79,7 @@ bool ObjectTagTable::Set(art::mirror::Object* obj, jlong new_tag) { return JvmtiWeakTable<jlong>::Set(obj, new_tag); } -bool ObjectTagTable::SetLocked(art::mirror::Object* obj, jlong new_tag) { +bool ObjectTagTable::SetLocked(art::ObjPtr<art::mirror::Object> obj, jlong new_tag) { if (new_tag == 0) { jlong tmp; return RemoveLocked(obj, &tmp); diff --git a/openjdkjvmti/object_tagging.h b/openjdkjvmti/object_tagging.h index ca05a05541..bd72ce3254 100644 --- a/openjdkjvmti/object_tagging.h +++ b/openjdkjvmti/object_tagging.h @@ -61,21 +61,21 @@ class ObjectTagTable final : public JvmtiWeakTable<jlong> { REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!allow_disallow_lock_); - bool Set(art::mirror::Object* obj, jlong tag) override + bool Set(art::ObjPtr<art::mirror::Object> obj, jlong tag) override REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!allow_disallow_lock_); - bool SetLocked(art::mirror::Object* obj, jlong tag) override + bool SetLocked(art::ObjPtr<art::mirror::Object> obj, jlong tag) override REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_); - jlong GetTagOrZero(art::mirror::Object* obj) + jlong GetTagOrZero(art::ObjPtr<art::mirror::Object> obj) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!allow_disallow_lock_) { jlong tmp = 0; GetTag(obj, &tmp); return tmp; } - jlong GetTagOrZeroLocked(art::mirror::Object* obj) + jlong GetTagOrZeroLocked(art::ObjPtr<art::mirror::Object> obj) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_) { jlong tmp = 0; |