Home | History | Annotate | Download | only in runtime

Lines Matching full:monitor

17 #include "monitor.h"
40 * Every Object has a monitor associated with it, but not every Object is
42 * full-fledged monitor until a) there is actual contention or b) wait()
77 * Only one thread can own the monitor at any time. There may be several
81 * TODO: the various members of monitor are not SMP-safe.
89 * Monitor accessor. Extracts a monitor structure pointer from a fat
93 (reinterpret_cast<Monitor*>((x) & ~((LW_HASH_STATE_MASK << LW_HASH_STATE_SHIFT) | LW_SHAPE_MASK)))
103 bool (*Monitor::is_sensitive_thread_hook_)() = NULL;
104 uint32_t Monitor::lock_profiling_threshold_ = 0;
106 bool Monitor::IsSensitiveThread() {
113 void Monitor::Init(uint32_t lock_profiling_threshold, bool (*is_sensitive_thread_hook)()) {
118 Monitor::Monitor(Thread* owner, mirror::Object* obj)
119 : monitor_lock_("a monitor lock", kMonitorLock),
140 Monitor::~Monitor() {
146 * Links a thread into a monitor's wait set. The monitor lock must be
149 void Monitor::AppendToWaitSet(Thread* thread) {
167 * Unlinks a thread from a monitor's wait set. The monitor lock must
170 void Monitor::RemoveFromWaitSet(Thread *thread) {
193 mirror::Object* Monitor::GetObject() {
197 void Monitor::Lock(Thread* self) {
243 // When debugging, save the current monitor holder for future
279 void Monitor::FailedUnlock(mirror::Object* o, Thread* expected_owner, Thread* found_owner,
280 Monitor* monitor) {
290 current_owner = (monitor != NULL) ? monitor->owner_ : NULL;
298 ThrowIllegalMonitorStateExceptionF("unlock of unowned monitor on object of type '%s'"
304 ThrowIllegalMonitorStateExceptionF("unlock of monitor owned by '%s' on object of type '%s'"
305 " (where now the monitor appears unowned) on thread '%s'",
313 ThrowIllegalMonitorStateExceptionF("unlock of monitor owned by '%s' on object of type '%s'"
321 ThrowIllegalMonitorStateExceptionF("unlock of monitor originally owned by '%s' (now"
328 ThrowIllegalMonitorStateExceptionF("unlock of monitor owned by '%s' on object of type '%s'"
338 bool Monitor::Unlock(Thread* self, bool for_wait) {
342 // We own the monitor, so nobody else can be in here.
369 * Wait on a monitor until timeout, interrupt, or notification. Used for
391 void Monitor::Wait(Thread* self, int64_t ms, int32_t ns,
412 void Monitor::WaitWithLock(Thread* self, int64_t ms, int32_t ns,
423 * Add ourselves to the set of threads waiting on this monitor, and
429 * the monitor. Aside from that, the order of member updates is
450 // Pseudo-atomically wait on self's wait_cond_ and release the monitor lock.
453 // Set wait_monitor_ to the monitor object we will be waiting on. When wait_monitor_ is
459 // Release the monitor lock.
493 // Re-acquire the monitor lock.
501 * thread owns the monitor. Aside from that, the order of member
529 void Monitor::Notify(Thread* self) {
540 void Monitor::NotifyWithLock(Thread* self) {
556 void Monitor::NotifyAll(Thread* self) {
567 void Monitor::NotifyAllWithLock() {
578 * Changes the shape of a monitor from thin to fat, preserving the
581 void Monitor::Inflate(Thread* self, mirror::Object* obj) {
587 // Allocate and acquire a new monitor.
588 Monitor* m = new Monitor(self, obj);
589 VLOG(monitor) << "monitor: thread " << self->GetThinLockId()
590 << " created monitor " << m << " for object " << obj;
594 void Monitor::MonitorEnter(Thread* self, mirror::Object* obj) {
635 VLOG(monitor) << StringPrintf("monitor: thread %d spin on lock %p (a %s) owned by %d",
673 VLOG(monitor) << StringPrintf("monitor: thread %d found lock %p surprise-fattened by another thread", threadId, thinp);
679 VLOG(monitor) << StringPrintf("monitor: thread %d spin on lock %p done", threadId, thinp);
685 VLOG(monitor) << StringPrintf("monitor: thread %d fattened lock %p", threadId, thinp);
689 VLOG(monitor) << StringPrintf("monitor: thread %d locking fat lock %p (%p) %p on a %s",
697 bool Monitor::MonitorExit(Thread* self, mirror::Object* obj) {
759 void Monitor::Wait(Thread* self, mirror::Object *obj, int64_t ms, int32_t ns,
778 VLOG(monitor) << StringPrintf("monitor: thread %d fattened lock %p by wait()", self->GetThinLockId(), thinp);
783 void Monitor::Notify(Thread* self, mirror::Object *obj) {
804 void Monitor::NotifyAll(Thread* self, mirror::Object *obj) {
825 uint32_t Monitor::GetThinLockId(uint32_t raw_lock_word) {
834 void Monitor::DescribeWait(std::ostream& os, const Thread* thread) {
848 Monitor* monitor = thread->wait_monitor_;
849 if (monitor != NULL) {
850 object = monitor->obj_;
875 mirror::Object* Monitor::GetContendedMonitor(Thread* thread) {
877 // definition of contended that includes a monitor a thread is trying to enter...
882 // ...but also a monitor that the thread is waiting on.
885 Monitor* monitor = thread->wait_monitor_;
886 if (monitor != NULL) {
887 return monitor->obj_;
893 void Monitor::VisitLocks(StackVisitor* stack_visitor, void (*callback)(mirror::Object*, void*),
928 // Ask the verifier for the dex pcs of all the monitor-enter instructions corresponding to
937 // The verifier works in terms of the dex pcs of the monitor-enter instructions.
944 LOG(FATAL) << "expected monitor-enter @" << dex_pc << "; was "
955 bool Monitor::IsValidLockWord(int32_t lock_word) {
959 Monitor* mon = LW_MONITOR(lock_word);
963 for (Monitor* list_mon : list->list_) {
976 void Monitor::TranslateLocation(const mirror::ArtMethod* method, uint32_t dex_pc,
1014 void MonitorList::Add(Monitor* m) {
1026 Monitor* m = *it;
1028 VLOG(monitor) << "freeing monitor " << m << " belonging to unmarked object " << m->GetObject();
1048 Monitor* monitor = LW_MONITOR(lock_word);
1049 owner = monitor->owner_;
1050 entry_count = 1 + monitor->lock_count_;
1051 for (Thread* waiter = monitor->wait_set_; waiter != NULL; waiter = waiter->wait_next_) {