diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/jni_internal.cc | 1 | ||||
-rw-r--r-- | runtime/monitor.cc | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc index dea30145eb..0bc519e64a 100644 --- a/runtime/jni_internal.cc +++ b/runtime/jni_internal.cc @@ -44,6 +44,7 @@ #include "mirror/object_array-inl.h" #include "mirror/string-inl.h" #include "mirror/throwable.h" +#include "nativebridge/native_bridge.h" #include "parsed_options.h" #include "reflection.h" #include "runtime.h" diff --git a/runtime/monitor.cc b/runtime/monitor.cc index 6123934d3c..bf28166f9f 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -36,6 +36,8 @@ namespace art { +static constexpr uint64_t kLongWaitMs = 100; + /* * Every Object has a monitor associated with it, but not every Object is actually locked. Even * the ones that are locked do not need a full-fledged monitor until a) there is actual contention @@ -242,6 +244,7 @@ void Monitor::Lock(Thread* self) { mirror::ArtMethod* owners_method = locking_method_; uint32_t owners_dex_pc = locking_dex_pc_; // Do this before releasing the lock so that we don't get deflated. + size_t num_waiters = num_waiters_; ++num_waiters_; monitor_lock_.Unlock(self); // Let go of locks in order. self->SetMonitorEnterObject(GetObject()); @@ -263,6 +266,12 @@ void Monitor::Lock(Thread* self) { const char* owners_filename; uint32_t owners_line_number; TranslateLocation(owners_method, owners_dex_pc, &owners_filename, &owners_line_number); + if (wait_ms > kLongWaitMs && owners_method != nullptr) { + LOG(WARNING) << "Long monitor contention event with owner method=" + << PrettyMethod(owners_method) << " from " << owners_filename << ":" + << owners_line_number << " waiters=" << num_waiters << " for " + << PrettyDuration(MsToNs(wait_ms)); + } LogContentionEvent(self, wait_ms, sample_percent, owners_filename, owners_line_number); } } |