diff options
Diffstat (limited to 'runtime/openjdkjvmti')
| -rw-r--r-- | runtime/openjdkjvmti/OpenjdkJvmTi.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/events.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/jvmti_weak_table.h | 25 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_class.cc | 35 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_dump.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_field.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_heap.cc | 1 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_jni.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_method.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_monitor.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_object.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_phase.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_properties.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_redefine.cc | 36 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_search.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_stack.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_thread.cc | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_thread.h | 2 | ||||
| -rw-r--r-- | runtime/openjdkjvmti/ti_threadgroup.cc | 2 |
19 files changed, 92 insertions, 35 deletions
diff --git a/runtime/openjdkjvmti/OpenjdkJvmTi.cc b/runtime/openjdkjvmti/OpenjdkJvmTi.cc index 9be486e269..45773fdfbf 100644 --- a/runtime/openjdkjvmti/OpenjdkJvmTi.cc +++ b/runtime/openjdkjvmti/OpenjdkJvmTi.cc @@ -46,7 +46,7 @@ #include "object_tagging.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" -#include "thread-inl.h" +#include "thread-current-inl.h" #include "thread_list.h" #include "ti_class.h" #include "ti_dump.h" diff --git a/runtime/openjdkjvmti/events.cc b/runtime/openjdkjvmti/events.cc index 0ec92b7c60..320c59c810 100644 --- a/runtime/openjdkjvmti/events.cc +++ b/runtime/openjdkjvmti/events.cc @@ -44,7 +44,7 @@ #include "runtime.h" #include "ScopedLocalRef.h" #include "scoped_thread_state_change-inl.h" -#include "thread-inl.h" +#include "thread-current-inl.h" namespace openjdkjvmti { diff --git a/runtime/openjdkjvmti/jvmti_weak_table.h b/runtime/openjdkjvmti/jvmti_weak_table.h index a6fd247c51..01c24b1917 100644 --- a/runtime/openjdkjvmti/jvmti_weak_table.h +++ b/runtime/openjdkjvmti/jvmti_weak_table.h @@ -41,7 +41,7 @@ #include "globals.h" #include "jvmti.h" #include "mirror/object.h" -#include "thread-inl.h" +#include "thread-current-inl.h" namespace openjdkjvmti { @@ -59,19 +59,19 @@ class JvmtiWeakTable : public art::gc::SystemWeakHolder { // Remove the mapping for the given object, returning whether such a mapping existed (and the old // value). - bool Remove(art::mirror::Object* obj, /* out */ T* tag) + ALWAYS_INLINE bool Remove(art::mirror::Object* obj, /* out */ T* tag) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!allow_disallow_lock_); - bool RemoveLocked(art::mirror::Object* obj, /* out */ T* tag) + ALWAYS_INLINE bool RemoveLocked(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. - virtual bool Set(art::mirror::Object* obj, T tag) + ALWAYS_INLINE virtual bool Set(art::mirror::Object* obj, T tag) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!allow_disallow_lock_); - virtual bool SetLocked(art::mirror::Object* obj, T tag) + ALWAYS_INLINE virtual bool SetLocked(art::mirror::Object* obj, T tag) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_); @@ -97,11 +97,12 @@ class JvmtiWeakTable : public art::gc::SystemWeakHolder { } // Sweep the container. DO NOT CALL MANUALLY. - void Sweep(art::IsMarkedVisitor* visitor) + ALWAYS_INLINE void Sweep(art::IsMarkedVisitor* visitor) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!allow_disallow_lock_); // Return all objects that have a value mapping in tags. + ALWAYS_INLINE jvmtiError GetTaggedObjects(jvmtiEnv* jvmti_env, jint tag_count, const T* tags, @@ -112,11 +113,11 @@ class JvmtiWeakTable : public art::gc::SystemWeakHolder { REQUIRES(!allow_disallow_lock_); // Locking functions, to allow coarse-grained locking and amortization. - void Lock() ACQUIRE(allow_disallow_lock_); - void Unlock() RELEASE(allow_disallow_lock_); - void AssertLocked() ASSERT_CAPABILITY(allow_disallow_lock_); + ALWAYS_INLINE void Lock() ACQUIRE(allow_disallow_lock_); + ALWAYS_INLINE void Unlock() RELEASE(allow_disallow_lock_); + ALWAYS_INLINE void AssertLocked() ASSERT_CAPABILITY(allow_disallow_lock_); - art::mirror::Object* Find(T tag) + ALWAYS_INLINE art::mirror::Object* Find(T tag) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!allow_disallow_lock_); @@ -129,10 +130,12 @@ class JvmtiWeakTable : public art::gc::SystemWeakHolder { virtual void HandleNullSweep(T tag ATTRIBUTE_UNUSED) {} private: + ALWAYS_INLINE bool SetLocked(art::Thread* self, 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) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_); @@ -160,12 +163,14 @@ 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) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_); // Update the table by doing read barriers on each element, ensuring that to-space pointers // are stored. + ALWAYS_INLINE void UpdateTableWithReadBarrier() REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(allow_disallow_lock_); diff --git a/runtime/openjdkjvmti/ti_class.cc b/runtime/openjdkjvmti/ti_class.cc index e0af6e8dee..0aa93dfb57 100644 --- a/runtime/openjdkjvmti/ti_class.cc +++ b/runtime/openjdkjvmti/ti_class.cc @@ -63,7 +63,7 @@ #include "runtime_callbacks.h" #include "ScopedLocalRef.h" #include "scoped_thread_state_change-inl.h" -#include "thread-inl.h" +#include "thread-current-inl.h" #include "thread_list.h" #include "ti_class_loader.h" #include "ti_phase.h" @@ -129,6 +129,25 @@ static std::unique_ptr<const art::DexFile> MakeSingleDexFile(art::Thread* self, return dex_file; } +// A deleter that acts like the jvmtiEnv->Deallocate so that asan does not get tripped up. +// TODO We should everything use the actual jvmtiEnv->Allocate/Deallocate functions once we can +// figure out which env to use. +template <typename T> +class FakeJvmtiDeleter { + public: + FakeJvmtiDeleter() {} + + FakeJvmtiDeleter(FakeJvmtiDeleter&) = default; + FakeJvmtiDeleter(FakeJvmtiDeleter&&) = default; + FakeJvmtiDeleter& operator=(const FakeJvmtiDeleter&) = default; + + template <typename U> void operator()(const U* ptr) const { + if (ptr != nullptr) { + free(const_cast<U*>(ptr)); + } + } +}; + struct ClassCallback : public art::ClassLoadCallback { void ClassPreDefine(const char* descriptor, art::Handle<art::mirror::Class> klass, @@ -173,7 +192,8 @@ struct ClassCallback : public art::ClassLoadCallback { // Call all Non-retransformable agents. jint post_no_redefine_len = 0; unsigned char* post_no_redefine_dex_data = nullptr; - std::unique_ptr<const unsigned char> post_no_redefine_unique_ptr(nullptr); + std::unique_ptr<const unsigned char, FakeJvmtiDeleter<const unsigned char>> + post_no_redefine_unique_ptr(nullptr, FakeJvmtiDeleter<const unsigned char>()); event_handler->DispatchEvent<ArtJvmtiEvent::kClassFileLoadHookNonRetransformable>( self, static_cast<JNIEnv*>(env), @@ -190,13 +210,16 @@ struct ClassCallback : public art::ClassLoadCallback { post_no_redefine_dex_data = const_cast<unsigned char*>(dex_file_copy->Begin()); post_no_redefine_len = dex_file_copy->Size(); } else { - post_no_redefine_unique_ptr = std::unique_ptr<const unsigned char>(post_no_redefine_dex_data); + post_no_redefine_unique_ptr = + std::unique_ptr<const unsigned char, FakeJvmtiDeleter<const unsigned char>>( + post_no_redefine_dex_data, FakeJvmtiDeleter<const unsigned char>()); DCHECK_GT(post_no_redefine_len, 0); } // Call all retransformable agents. jint final_len = 0; unsigned char* final_dex_data = nullptr; - std::unique_ptr<const unsigned char> final_dex_unique_ptr(nullptr); + std::unique_ptr<const unsigned char, FakeJvmtiDeleter<const unsigned char>> + final_dex_unique_ptr(nullptr, FakeJvmtiDeleter<const unsigned char>()); event_handler->DispatchEvent<ArtJvmtiEvent::kClassFileLoadHookRetransformable>( self, static_cast<JNIEnv*>(env), @@ -213,7 +236,9 @@ struct ClassCallback : public art::ClassLoadCallback { final_dex_data = post_no_redefine_dex_data; final_len = post_no_redefine_len; } else { - final_dex_unique_ptr = std::unique_ptr<const unsigned char>(final_dex_data); + final_dex_unique_ptr = + std::unique_ptr<const unsigned char, FakeJvmtiDeleter<const unsigned char>>( + final_dex_data, FakeJvmtiDeleter<const unsigned char>()); DCHECK_GT(final_len, 0); } diff --git a/runtime/openjdkjvmti/ti_dump.cc b/runtime/openjdkjvmti/ti_dump.cc index d9e3ef1bcf..7a1e53f6e5 100644 --- a/runtime/openjdkjvmti/ti_dump.cc +++ b/runtime/openjdkjvmti/ti_dump.cc @@ -39,7 +39,7 @@ #include "events-inl.h" #include "runtime_callbacks.h" #include "scoped_thread_state_change-inl.h" -#include "thread-inl.h" +#include "thread-current-inl.h" #include "thread_list.h" namespace openjdkjvmti { diff --git a/runtime/openjdkjvmti/ti_field.cc b/runtime/openjdkjvmti/ti_field.cc index 1e5fbda35b..342d8be2b0 100644 --- a/runtime/openjdkjvmti/ti_field.cc +++ b/runtime/openjdkjvmti/ti_field.cc @@ -39,7 +39,7 @@ #include "mirror/object_array-inl.h" #include "modifiers.h" #include "scoped_thread_state_change-inl.h" -#include "thread-inl.h" +#include "thread-current-inl.h" namespace openjdkjvmti { diff --git a/runtime/openjdkjvmti/ti_heap.cc b/runtime/openjdkjvmti/ti_heap.cc index 99774c67b5..319b1c2a9c 100644 --- a/runtime/openjdkjvmti/ti_heap.cc +++ b/runtime/openjdkjvmti/ti_heap.cc @@ -35,6 +35,7 @@ #include "primitive.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" +#include "stack.h" #include "thread-inl.h" #include "thread_list.h" diff --git a/runtime/openjdkjvmti/ti_jni.cc b/runtime/openjdkjvmti/ti_jni.cc index 88f0395ba5..dd2dda118a 100644 --- a/runtime/openjdkjvmti/ti_jni.cc +++ b/runtime/openjdkjvmti/ti_jni.cc @@ -38,7 +38,7 @@ #include "java_vm_ext.h" #include "jni_env_ext.h" #include "runtime.h" -#include "thread-inl.h" +#include "thread-current-inl.h" namespace openjdkjvmti { diff --git a/runtime/openjdkjvmti/ti_method.cc b/runtime/openjdkjvmti/ti_method.cc index f7e53474aa..beb639e208 100644 --- a/runtime/openjdkjvmti/ti_method.cc +++ b/runtime/openjdkjvmti/ti_method.cc @@ -42,7 +42,7 @@ #include "runtime_callbacks.h" #include "scoped_thread_state_change-inl.h" #include "ScopedLocalRef.h" -#include "thread-inl.h" +#include "thread-current-inl.h" #include "thread_list.h" #include "ti_phase.h" diff --git a/runtime/openjdkjvmti/ti_monitor.cc b/runtime/openjdkjvmti/ti_monitor.cc index 645faea41b..61bf533eb7 100644 --- a/runtime/openjdkjvmti/ti_monitor.cc +++ b/runtime/openjdkjvmti/ti_monitor.cc @@ -39,7 +39,7 @@ #include "art_jvmti.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" -#include "thread-inl.h" +#include "thread-current-inl.h" namespace openjdkjvmti { diff --git a/runtime/openjdkjvmti/ti_object.cc b/runtime/openjdkjvmti/ti_object.cc index bf84499035..2506acac3a 100644 --- a/runtime/openjdkjvmti/ti_object.cc +++ b/runtime/openjdkjvmti/ti_object.cc @@ -34,7 +34,7 @@ #include "art_jvmti.h" #include "mirror/object-inl.h" #include "scoped_thread_state_change-inl.h" -#include "thread-inl.h" +#include "thread-current-inl.h" namespace openjdkjvmti { diff --git a/runtime/openjdkjvmti/ti_phase.cc b/runtime/openjdkjvmti/ti_phase.cc index 941cf7b73b..3c8bdc61d0 100644 --- a/runtime/openjdkjvmti/ti_phase.cc +++ b/runtime/openjdkjvmti/ti_phase.cc @@ -38,7 +38,7 @@ #include "runtime_callbacks.h" #include "ScopedLocalRef.h" #include "scoped_thread_state_change-inl.h" -#include "thread-inl.h" +#include "thread-current-inl.h" #include "thread_list.h" #include "ti_thread.h" diff --git a/runtime/openjdkjvmti/ti_properties.cc b/runtime/openjdkjvmti/ti_properties.cc index 8ee5366140..e399b484ec 100644 --- a/runtime/openjdkjvmti/ti_properties.cc +++ b/runtime/openjdkjvmti/ti_properties.cc @@ -40,7 +40,7 @@ #include "art_jvmti.h" #include "runtime.h" -#include "thread-inl.h" +#include "thread-current-inl.h" #include "ti_phase.h" #include "well_known_classes.h" diff --git a/runtime/openjdkjvmti/ti_redefine.cc b/runtime/openjdkjvmti/ti_redefine.cc index cca1486975..959de27667 100644 --- a/runtime/openjdkjvmti/ti_redefine.cc +++ b/runtime/openjdkjvmti/ti_redefine.cc @@ -48,6 +48,7 @@ #include "gc/allocation_listener.h" #include "gc/heap.h" #include "instrumentation.h" +#include "intern_table.h" #include "jdwp/jdwp.h" #include "jdwp/jdwp_constants.h" #include "jdwp/jdwp_event.h" @@ -452,7 +453,30 @@ art::mirror::ClassLoader* Redefiner::ClassRedefinition::GetClassLoader() { art::mirror::DexCache* Redefiner::ClassRedefinition::CreateNewDexCache( art::Handle<art::mirror::ClassLoader> loader) { - return driver_->runtime_->GetClassLinker()->RegisterDexFile(*dex_file_, loader.Get()).Ptr(); + art::StackHandleScope<2> hs(driver_->self_); + art::ClassLinker* cl = driver_->runtime_->GetClassLinker(); + art::Handle<art::mirror::DexCache> cache(hs.NewHandle( + art::ObjPtr<art::mirror::DexCache>::DownCast( + cl->GetClassRoot(art::ClassLinker::kJavaLangDexCache)->AllocObject(driver_->self_)))); + if (cache.IsNull()) { + driver_->self_->AssertPendingOOMException(); + return nullptr; + } + art::Handle<art::mirror::String> location(hs.NewHandle( + cl->GetInternTable()->InternStrong(dex_file_->GetLocation().c_str()))); + if (location.IsNull()) { + driver_->self_->AssertPendingOOMException(); + return nullptr; + } + art::WriterMutexLock mu(driver_->self_, *art::Locks::dex_lock_); + art::mirror::DexCache::InitializeDexCache(driver_->self_, + cache.Get(), + location.Get(), + dex_file_.get(), + loader.IsNull() ? driver_->runtime_->GetLinearAlloc() + : loader->GetAllocator(), + art::kRuntimePointerSize); + return cache.Get(); } void Redefiner::RecordFailure(jvmtiError result, @@ -602,8 +626,8 @@ bool Redefiner::ClassRedefinition::CheckSameMethods() { // Since direct methods have different flags than virtual ones (specifically direct methods must // have kAccPrivate or kAccStatic or kAccConstructor flags) we can tell if a method changes from // virtual to direct. - uint32_t new_flags = new_iter.GetMethodAccessFlags(); - if (new_flags != (old_method->GetAccessFlags() & art::kAccValidMethodFlags)) { + uint32_t new_flags = new_iter.GetMethodAccessFlags() & ~art::kAccPreviouslyWarm; + if (new_flags != (old_method->GetAccessFlags() & (art::kAccValidMethodFlags ^ art::kAccPreviouslyWarm))) { RecordFailure(ERR(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED), StringPrintf("method '%s' (sig: %s) had different access flags", new_method_name, @@ -1293,8 +1317,10 @@ jvmtiError Redefiner::Run() { // At this point we can no longer fail without corrupting the runtime state. for (RedefinitionDataIter data = holder.begin(); data != holder.end(); ++data) { + art::ClassLinker* cl = runtime_->GetClassLinker(); + cl->RegisterExistingDexCache(data.GetNewDexCache(), data.GetSourceClassLoader()); if (data.GetSourceClassLoader() == nullptr) { - runtime_->GetClassLinker()->AppendToBootClassPath(self_, data.GetRedefinition().GetDexFile()); + cl->AppendToBootClassPath(self_, data.GetRedefinition().GetDexFile()); } } UnregisterAllBreakpoints(); @@ -1338,7 +1364,7 @@ void Redefiner::ClassRedefinition::UpdateMethods(art::ObjPtr<art::mirror::Class> const art::DexFile::TypeId& declaring_class_id = dex_file_->GetTypeId(class_def.class_idx_); const art::DexFile& old_dex_file = mclass->GetDexFile(); // Update methods. - for (art::ArtMethod& method : mclass->GetMethods(image_pointer_size)) { + for (art::ArtMethod& method : mclass->GetDeclaredMethods(image_pointer_size)) { const art::DexFile::StringId* new_name_id = dex_file_->FindStringId(method.GetName()); art::dex::TypeIndex method_return_idx = dex_file_->GetIndexForTypeId(*dex_file_->FindTypeId(method.GetReturnTypeDescriptor())); diff --git a/runtime/openjdkjvmti/ti_search.cc b/runtime/openjdkjvmti/ti_search.cc index ec139f2004..6e0196edc3 100644 --- a/runtime/openjdkjvmti/ti_search.cc +++ b/runtime/openjdkjvmti/ti_search.cc @@ -49,7 +49,7 @@ #include "scoped_thread_state_change-inl.h" #include "ScopedLocalRef.h" #include "ti_phase.h" -#include "thread-inl.h" +#include "thread-current-inl.h" #include "thread_list.h" #include "well_known_classes.h" diff --git a/runtime/openjdkjvmti/ti_stack.cc b/runtime/openjdkjvmti/ti_stack.cc index 1ddf04feb4..22da2d2f65 100644 --- a/runtime/openjdkjvmti/ti_stack.cc +++ b/runtime/openjdkjvmti/ti_stack.cc @@ -52,7 +52,7 @@ #include "scoped_thread_state_change-inl.h" #include "ScopedLocalRef.h" #include "stack.h" -#include "thread-inl.h" +#include "thread-current-inl.h" #include "thread_list.h" #include "thread_pool.h" #include "well_known_classes.h" diff --git a/runtime/openjdkjvmti/ti_thread.cc b/runtime/openjdkjvmti/ti_thread.cc index 3dfa63313d..2cc2a26c3b 100644 --- a/runtime/openjdkjvmti/ti_thread.cc +++ b/runtime/openjdkjvmti/ti_thread.cc @@ -49,7 +49,7 @@ #include "runtime_callbacks.h" #include "ScopedLocalRef.h" #include "scoped_thread_state_change-inl.h" -#include "thread-inl.h" +#include "thread-current-inl.h" #include "thread_list.h" #include "well_known_classes.h" diff --git a/runtime/openjdkjvmti/ti_thread.h b/runtime/openjdkjvmti/ti_thread.h index c7f75d8aec..939aea7a29 100644 --- a/runtime/openjdkjvmti/ti_thread.h +++ b/runtime/openjdkjvmti/ti_thread.h @@ -37,7 +37,7 @@ namespace art { class ArtField; -} +} // namespace art namespace openjdkjvmti { diff --git a/runtime/openjdkjvmti/ti_threadgroup.cc b/runtime/openjdkjvmti/ti_threadgroup.cc index dd7be113d6..c0597ad0cc 100644 --- a/runtime/openjdkjvmti/ti_threadgroup.cc +++ b/runtime/openjdkjvmti/ti_threadgroup.cc @@ -45,7 +45,7 @@ #include "object_lock.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" -#include "thread-inl.h" +#include "thread-current-inl.h" #include "thread_list.h" #include "well_known_classes.h" |