diff options
Diffstat (limited to 'runtime/monitor.cc')
| -rw-r--r-- | runtime/monitor.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/runtime/monitor.cc b/runtime/monitor.cc index 295e76c4c5..2f590227af 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -42,6 +42,7 @@ #include "thread_list.h" #include "verifier/method_verifier.h" #include "well_known_classes.h" +#include <android-base/properties.h> static_assert(ART_USE_FUTEXES); @@ -116,6 +117,11 @@ Monitor::Monitor(Thread* self, Thread* owner, ObjPtr<mirror::Object> obj, int32_ // with the owner unlocking the thin-lock. CHECK(owner == nullptr || owner == self || owner->IsSuspended()); // The identity hash code is set for the life time of the monitor. + + bool monitor_timeout_enabled = Runtime::Current()->IsMonitorTimeoutEnabled(); + if (monitor_timeout_enabled) { + MaybeEnableTimeout(); + } } Monitor::Monitor(Thread* self, @@ -144,6 +150,11 @@ Monitor::Monitor(Thread* self, // with the owner unlocking the thin-lock. CHECK(owner == nullptr || owner == self || owner->IsSuspended()); // The identity hash code is set for the life time of the monitor. + + bool monitor_timeout_enabled = Runtime::Current()->IsMonitorTimeoutEnabled(); + if (monitor_timeout_enabled) { + MaybeEnableTimeout(); + } } int32_t Monitor::GetHashCode() { @@ -1711,4 +1722,13 @@ MonitorInfo::MonitorInfo(ObjPtr<mirror::Object> obj) : owner_(nullptr), entry_co } } +void Monitor::MaybeEnableTimeout() { + std::string current_package = Runtime::Current()->GetProcessPackageName(); + bool enabled_for_app = android::base::GetBoolProperty("debug.art.monitor.app", false); + if (current_package == "android" || enabled_for_app) { + monitor_lock_.setEnableMonitorTimeout(); + monitor_lock_.setMonitorId(monitor_id_); + } +} + } // namespace art |