< prev index next >

src/hotspot/share/runtime/objectMonitor.cpp

Print this page
rev 55936 : [mq]: 8229212.cr0

*** 1141,1175 **** guarantee(_recursions == 0, "reenter recursion"); _recursions = recursions; return; } ! ! // ----------------------------------------------------------------------------- ! // A macro is used below because there may already be a pending ! // exception which should not abort the execution of the routines ! // which use this (which is why we don't put this into check_slow and ! // call it with a CHECK argument). ! ! #define CHECK_OWNER() \ ! do { \ ! if (THREAD != _owner) { \ ! if (THREAD->is_lock_owned((address) _owner)) { \ ! _owner = THREAD; /* Convert from basiclock addr to Thread addr */ \ ! _recursions = 0; \ ! } else { \ ! THROW(vmSymbols::java_lang_IllegalMonitorStateException()); \ ! } \ ! } \ ! } while (false) ! ! // check_slow() is a misnomer. It's called to simply to throw an IMSX exception. ! // TODO-FIXME: remove check_slow() -- it's likely dead. ! ! void ObjectMonitor::check_slow(TRAPS) { ! assert(THREAD != _owner && !THREAD->is_lock_owned((address) _owner), "must not be owner"); ! THROW_MSG(vmSymbols::java_lang_IllegalMonitorStateException(), "current thread not owner"); } static void post_monitor_wait_event(EventJavaMonitorWait* event, ObjectMonitor* monitor, jlong notifier_tid, --- 1141,1168 ---- guarantee(_recursions == 0, "reenter recursion"); _recursions = recursions; return; } ! // Returns true if the specified thread owns the ObjectMonitor. Otherwise ! // returns false and throws IllegalMonitorStateException (IMSE). This ! // function is not called with CHECK because we want the IMSE to be the ! // only exception that is thrown from the call site when false is returned. ! // If an IMSE needs to be thrown, then it takes precedence over any pending ! // exception at the call sites. If true is returned, then we don't throw ! // any exception (pending or otherwise) at the call site. ! bool ObjectMonitor::check_owner_and_throw_IMSE_if_not(Thread* THREAD) { ! if (_owner == THREAD) { ! return true; ! } ! if (THREAD->is_lock_owned((address)_owner)) { ! _owner = THREAD; // convert from BasicLock addr to Thread addr ! _recursions = 0; ! return true; ! } ! THROW_MSG_(vmSymbols::java_lang_IllegalMonitorStateException(), ! "current thread is not owner", false); } static void post_monitor_wait_event(EventJavaMonitorWait* event, ObjectMonitor* monitor, jlong notifier_tid,
*** 1195,1206 **** assert(Self->is_Java_thread(), "Must be Java thread!"); JavaThread *jt = (JavaThread *)THREAD; assert(InitDone, "Unexpectedly not initialized"); ! // Throw IMSX or IEX. ! CHECK_OWNER(); EventJavaMonitorWait event; // check for a pending interrupt if (interruptible && Thread::is_interrupted(Self, true) && !HAS_PENDING_EXCEPTION) { --- 1188,1201 ---- assert(Self->is_Java_thread(), "Must be Java thread!"); JavaThread *jt = (JavaThread *)THREAD; assert(InitDone, "Unexpectedly not initialized"); ! if (!check_owner_and_throw_IMSE_if_not(THREAD)) { ! assert(HAS_PENDING_EXCEPTION, "expected a pending exception here."); ! return; ! } EventJavaMonitorWait event; // check for a pending interrupt if (interruptible && Thread::is_interrupted(Self, true) && !HAS_PENDING_EXCEPTION) {
*** 1475,1485 **** // When the "minimum wait" is set to a small non-zero timeout value // and the program does not hang whereas it did absent "minimum wait", // that suggests a lost wakeup bug. void ObjectMonitor::notify(TRAPS) { ! CHECK_OWNER(); if (_WaitSet == NULL) { return; } DTRACE_MONITOR_PROBE(notify, this, object(), THREAD); INotify(THREAD); --- 1470,1483 ---- // When the "minimum wait" is set to a small non-zero timeout value // and the program does not hang whereas it did absent "minimum wait", // that suggests a lost wakeup bug. void ObjectMonitor::notify(TRAPS) { ! if (!check_owner_and_throw_IMSE_if_not(THREAD)) { ! assert(HAS_PENDING_EXCEPTION, "expected a pending exception here."); ! return; ! } if (_WaitSet == NULL) { return; } DTRACE_MONITOR_PROBE(notify, this, object(), THREAD); INotify(THREAD);
*** 1493,1503 **** // that in prepend-mode we invert the order of the waiters. Let's say that the // waitset is "ABCD" and the EntryList is "XYZ". After a notifyAll() in prepend // mode the waitset will be empty and the EntryList will be "DCBAXYZ". void ObjectMonitor::notifyAll(TRAPS) { ! CHECK_OWNER(); if (_WaitSet == NULL) { return; } DTRACE_MONITOR_PROBE(notifyAll, this, object(), THREAD); --- 1491,1504 ---- // that in prepend-mode we invert the order of the waiters. Let's say that the // waitset is "ABCD" and the EntryList is "XYZ". After a notifyAll() in prepend // mode the waitset will be empty and the EntryList will be "DCBAXYZ". void ObjectMonitor::notifyAll(TRAPS) { ! if (!check_owner_and_throw_IMSE_if_not(THREAD)) { ! assert(HAS_PENDING_EXCEPTION, "expected a pending exception here."); ! return; ! } if (_WaitSet == NULL) { return; } DTRACE_MONITOR_PROBE(notifyAll, this, object(), THREAD);
< prev index next >