From a75e5892fba6d0208f33e9ab8e19e732daf94996 Mon Sep 17 00:00:00 2001 From: Alex Light Date: Mon, 11 Mar 2019 15:49:40 +0000 Subject: Revert^2 "Remove Global deopt requirement for several jvmti events" This reverts commit ad344b6a14feba90a06a205760e9bc766c56cab0. Jit-on-first-use would cause the runtime to skip sending FramePop events for exceptions in some circumstances due to longjmp-ing over the frames. This requires forcing jit off from the first instant a thread can get frame popped events, which is unfortunate. Reason for revert: Fixed issue causing 1925 to fail on jit-on-first-use and redefine-stress Test: ./test.py --host Test: ./art/test/testrunner/run_build_test_target.py -j50 art-jit-on-first-use Change-Id: I6ec2a799db1041262a055be10e1af1faece6f2fc --- openjdkjvmti/deopt_manager.cc | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'openjdkjvmti/deopt_manager.cc') diff --git a/openjdkjvmti/deopt_manager.cc b/openjdkjvmti/deopt_manager.cc index d456d83368..ee77b7bb77 100644 --- a/openjdkjvmti/deopt_manager.cc +++ b/openjdkjvmti/deopt_manager.cc @@ -49,6 +49,7 @@ #include "nativehelper/scoped_local_ref.h" #include "runtime_callbacks.h" #include "scoped_thread_state_change-inl.h" +#include "scoped_thread_state_change.h" #include "thread-current-inl.h" #include "thread_list.h" #include "ti_phase.h" @@ -356,6 +357,47 @@ void DeoptManager::PerformGlobalUndeoptimization(art::Thread* self) { kDeoptManagerInstrumentationKey); } +jvmtiError DeoptManager::AddDeoptimizeThreadMethods(art::ScopedObjectAccessUnchecked& soa, jthread jtarget) { + art::Locks::thread_list_lock_->ExclusiveLock(soa.Self()); + art::Thread* target = nullptr; + jvmtiError err = OK; + if (!ThreadUtil::GetNativeThread(jtarget, soa, &target, &err)) { + art::Locks::thread_list_lock_->ExclusiveUnlock(soa.Self()); + return err; + } + // We don't need additional locking here because we hold the Thread_list_lock_. + target->SetForceInterpreterCount(target->ForceInterpreterCount() + 1); + if (target->ForceInterpreterCount() == 1) { + struct DeoptClosure : public art::Closure { + public: + explicit DeoptClosure(DeoptManager* man) : man_(man) {} + void Run(art::Thread* self) override REQUIRES_SHARED(art::Locks::mutator_lock_) { + man_->DeoptimizeThread(self); + } + + private: + DeoptManager* man_; + }; + DeoptClosure c(this); + target->RequestSynchronousCheckpoint(&c); + } else { + art::Locks::thread_list_lock_->ExclusiveUnlock(soa.Self()); + } + return OK; +} + +jvmtiError DeoptManager::RemoveDeoptimizeThreadMethods(art::ScopedObjectAccessUnchecked& soa, jthread jtarget) { + art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_); + art::Thread* target = nullptr; + jvmtiError err = OK; + if (!ThreadUtil::GetNativeThread(jtarget, soa, &target, &err)) { + return err; + } + // We don't need additional locking here because we hold the Thread_list_lock_. + DCHECK_GT(target->ForceInterpreterCount(), 0u); + target->DecrementForceInterpreterCount(); + return OK; +} void DeoptManager::RemoveDeoptimizationRequester() { art::Thread* self = art::Thread::Current(); -- cgit v1.2.3-59-g8ed1b