diff options
author | 2018-07-26 08:28:36 -0700 | |
---|---|---|
committer | 2018-07-26 11:33:25 -0700 | |
commit | c98f83e301451cb7a62aab21a7dfcddc8eb17c42 (patch) | |
tree | 18d0477a315cf35352e4c44b3a66ce5d185a5fc4 /openjdkjvmti/ti_extension.cc | |
parent | f5dcd31d89282b6c9324fdc960e6e7e2281c16f1 (diff) |
Add raw_monitor_enter_no_suspend extension
In some circumstances it is useful to be able to lock a jvmti-monitor
without having to worry about the suspension state of the current
thread. This adds an extension
com.android.art.concurrent.raw_monitor_enter_no_suspend that allows
one to do that. This function will gain the monitor lock and return
even if the current thread is suspended. The normal RawMonitorLock
will not return unless the thread is not in a suspended state.
Test: ./test.py --host
Bug: 76205593
Change-Id: I9d9fcd586d1d2555f4adc8ac85597daa3dfcb0c4
Diffstat (limited to 'openjdkjvmti/ti_extension.cc')
-rw-r--r-- | openjdkjvmti/ti_extension.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/openjdkjvmti/ti_extension.cc b/openjdkjvmti/ti_extension.cc index 5b1a16c3ff..c61d6e585c 100644 --- a/openjdkjvmti/ti_extension.cc +++ b/openjdkjvmti/ti_extension.cc @@ -39,6 +39,7 @@ #include "ti_class.h" #include "ti_ddms.h" #include "ti_heap.h" +#include "ti_monitor.h" #include "thread-inl.h" namespace openjdkjvmti { @@ -252,6 +253,25 @@ jvmtiError ExtensionUtil::GetExtensionFunctions(jvmtiEnv* env, if (error != ERR(NONE)) { return error; } + + // Raw monitors no suspend + error = add_extension( + reinterpret_cast<jvmtiExtensionFunction>(MonitorUtil::RawMonitorEnterNoSuspend), + "com.android.art.concurrent.raw_monitor_enter_no_suspend", + "Normally entering a monitor will not return until both the monitor is locked and the" + " current thread is not suspended. This method will return once the monitor is locked" + " even if the thread is suspended. Note that using rawMonitorWait will wait until the" + " thread is not suspended again on wakeup and so should be avoided.", + { + { "raw_monitor", JVMTI_KIND_IN_PTR, JVMTI_TYPE_CVOID, false }, + }, + { + ERR(NULL_POINTER), + ERR(INVALID_MONITOR), + }); + if (error != ERR(NONE)) { + return error; + } // Copy into output buffer. *extension_count_ptr = ext_vector.size(); |