< prev index next >
src/share/vm/runtime/synchronizer.cpp
Print this page
rev 9362 : 8258669: fastdebug jvm crashes when do event based tracing for monitor inflation
Reviewed-by: duke
*** 214,224 ****
TEVENT (fast_exit: release stacklock) ;
return;
}
}
! ObjectSynchronizer::inflate(THREAD, object)->exit (true, THREAD) ;
}
// -----------------------------------------------------------------------------
// Interpreter/Compiler Slow Case
// This routine is used to handle interpreter/compiler slow case
--- 214,226 ----
TEVENT (fast_exit: release stacklock) ;
return;
}
}
! ObjectSynchronizer::inflate(THREAD,
! object,
! inflate_cause_vm_internal)->exit(true, THREAD);
}
// -----------------------------------------------------------------------------
// Interpreter/Compiler Slow Case
// This routine is used to handle interpreter/compiler slow case
*** 256,266 ****
// The object header will never be displaced to this lock,
// so it does not matter what the value is, except that it
// must be non-zero to avoid looking like a re-entrant lock,
// and must not look locked either.
lock->set_displaced_header(markOopDesc::unused_mark());
! ObjectSynchronizer::inflate(THREAD, obj())->enter(THREAD);
}
// This routine is used to handle interpreter/compiler slow case
// We don't need to use fast path here, because it must have
// failed in the interpreter/compiler code. Simply use the heavy
--- 258,270 ----
// The object header will never be displaced to this lock,
// so it does not matter what the value is, except that it
// must be non-zero to avoid looking like a re-entrant lock,
// and must not look locked either.
lock->set_displaced_header(markOopDesc::unused_mark());
! ObjectSynchronizer::inflate(THREAD,
! obj(),
! inflate_cause_monitor_enter)->enter(THREAD);
}
// This routine is used to handle interpreter/compiler slow case
// We don't need to use fast path here, because it must have
// failed in the interpreter/compiler code. Simply use the heavy
*** 286,296 ****
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
! ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD, obj());
return monitor->complete_exit(THREAD);
}
// NOTE: must use heavy weight monitor to handle complete_exit/reenter()
--- 290,302 ----
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
! ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD,
! obj(),
! inflate_cause_vm_internal);
return monitor->complete_exit(THREAD);
}
// NOTE: must use heavy weight monitor to handle complete_exit/reenter()
*** 299,309 ****
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
! ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD, obj());
monitor->reenter(recursion, THREAD);
}
// -----------------------------------------------------------------------------
// JNI locks on java objects
--- 305,317 ----
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
! ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD,
! obj(),
! inflate_cause_vm_internal);
monitor->reenter(recursion, THREAD);
}
// -----------------------------------------------------------------------------
// JNI locks on java objects
*** 314,324 ****
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
THREAD->set_current_pending_monitor_is_from_java(false);
! ObjectSynchronizer::inflate(THREAD, obj())->enter(THREAD);
THREAD->set_current_pending_monitor_is_from_java(true);
}
// NOTE: must use heavy weight monitor to handle jni monitor enter
bool ObjectSynchronizer::jni_try_enter(Handle obj, Thread* THREAD) {
--- 322,332 ----
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
THREAD->set_current_pending_monitor_is_from_java(false);
! ObjectSynchronizer::inflate(THREAD, obj(), inflate_cause_jni_enter)->enter(THREAD);
THREAD->set_current_pending_monitor_is_from_java(true);
}
// NOTE: must use heavy weight monitor to handle jni monitor enter
bool ObjectSynchronizer::jni_try_enter(Handle obj, Thread* THREAD) {
*** 340,350 ****
BiasedLocking::revoke_and_rebias(h_obj, false, THREAD);
obj = h_obj();
}
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
! ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD, obj);
// If this thread has locked the object, exit the monitor. Note: can't use
// monitor->check(CHECK); must exit even if an exception is pending.
if (monitor->check(THREAD)) {
monitor->exit(true, THREAD);
}
--- 348,360 ----
BiasedLocking::revoke_and_rebias(h_obj, false, THREAD);
obj = h_obj();
}
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
! ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD,
! obj,
! inflate_cause_jni_exit);
// If this thread has locked the object, exit the monitor. Note: can't use
// monitor->check(CHECK); must exit even if an exception is pending.
if (monitor->check(THREAD)) {
monitor->exit(true, THREAD);
}
*** 383,393 ****
}
if (millis < 0) {
TEVENT (wait - throw IAX) ;
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "timeout value is negative");
}
! ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD, obj());
DTRACE_MONITOR_WAIT_PROBE(monitor, obj(), THREAD, millis);
monitor->wait(millis, true, THREAD);
/* This dummy call is in place to get around dtrace bug 6254741. Once
that's fixed we can uncomment the following line and remove the call */
--- 393,406 ----
}
if (millis < 0) {
TEVENT (wait - throw IAX) ;
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "timeout value is negative");
}
! ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD,
! obj(),
! inflate_cause_wait);
!
DTRACE_MONITOR_WAIT_PROBE(monitor, obj(), THREAD, millis);
monitor->wait(millis, true, THREAD);
/* This dummy call is in place to get around dtrace bug 6254741. Once
that's fixed we can uncomment the following line and remove the call */
*** 402,412 ****
}
if (millis < 0) {
TEVENT (wait - throw IAX) ;
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "timeout value is negative");
}
! ObjectSynchronizer::inflate(THREAD, obj()) -> wait(millis, false, THREAD) ;
}
void ObjectSynchronizer::notify(Handle obj, TRAPS) {
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
--- 415,427 ----
}
if (millis < 0) {
TEVENT (wait - throw IAX) ;
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "timeout value is negative");
}
! ObjectSynchronizer::inflate(THREAD,
! obj(),
! inflate_cause_wait)->wait(millis, false, THREAD) ;
}
void ObjectSynchronizer::notify(Handle obj, TRAPS) {
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
*** 415,425 ****
markOop mark = obj->mark();
if (mark->has_locker() && THREAD->is_lock_owned((address)mark->locker())) {
return;
}
! ObjectSynchronizer::inflate(THREAD, obj())->notify(THREAD);
}
// NOTE: see comment of notify()
void ObjectSynchronizer::notifyall(Handle obj, TRAPS) {
if (UseBiasedLocking) {
--- 430,442 ----
markOop mark = obj->mark();
if (mark->has_locker() && THREAD->is_lock_owned((address)mark->locker())) {
return;
}
! ObjectSynchronizer::inflate(THREAD,
! obj(),
! inflate_cause_notify)->notify(THREAD);
}
// NOTE: see comment of notify()
void ObjectSynchronizer::notifyall(Handle obj, TRAPS) {
if (UseBiasedLocking) {
*** 429,439 ****
markOop mark = obj->mark();
if (mark->has_locker() && THREAD->is_lock_owned((address)mark->locker())) {
return;
}
! ObjectSynchronizer::inflate(THREAD, obj())->notifyAll(THREAD);
}
// -----------------------------------------------------------------------------
// Hash Code handling
//
--- 446,458 ----
markOop mark = obj->mark();
if (mark->has_locker() && THREAD->is_lock_owned((address)mark->locker())) {
return;
}
! ObjectSynchronizer::inflate(THREAD,
! obj(),
! inflate_cause_notify)->notifyAll(THREAD);
}
// -----------------------------------------------------------------------------
// Hash Code handling
//
*** 684,694 ****
// Any change to stack may not propagate to other threads
// correctly.
}
// Inflate the monitor to set hash code
! monitor = ObjectSynchronizer::inflate(Self, obj);
// Load displaced header and check it has hash code
mark = monitor->header();
assert (mark->is_neutral(), "invariant") ;
hash = mark->hash();
if (hash == 0) {
--- 703,713 ----
// Any change to stack may not propagate to other threads
// correctly.
}
// Inflate the monitor to set hash code
! monitor = ObjectSynchronizer::inflate(Self, obj, inflate_cause_hash_code);
// Load displaced header and check it has hash code
mark = monitor->header();
assert (mark->is_neutral(), "invariant") ;
hash = mark->hash();
if (hash == 0) {
*** 1181,1196 ****
Thread::muxRelease (&ListLock) ;
TEVENT (omFlush) ;
}
static void post_monitor_inflate_event(EventJavaMonitorInflate* event,
! const oop obj) {
assert(event != NULL, "invariant");
assert(event->should_commit(), "invariant");
event->set_monitorClass(obj->klass());
event->set_address((uintptr_t)(void*)obj);
event->commit();
}
// Fast path code shared by multiple functions
ObjectMonitor* ObjectSynchronizer::inflate_helper(oop obj) {
--- 1200,1232 ----
Thread::muxRelease (&ListLock) ;
TEVENT (omFlush) ;
}
+ const char* ObjectSynchronizer::inflate_cause_name(const InflateCause cause) {
+ switch (cause) {
+ case inflate_cause_vm_internal: return "VM Internal";
+ case inflate_cause_monitor_enter: return "Monitor Enter";
+ case inflate_cause_wait: return "Monitor Wait";
+ case inflate_cause_notify: return "Monitor Notify";
+ case inflate_cause_hash_code: return "Monitor Hash Code";
+ case inflate_cause_jni_enter: return "JNI Monitor Enter";
+ case inflate_cause_jni_exit: return "JNI Monitor Exit";
+ default:
+ ShouldNotReachHere();
+ }
+ return "Unknown";
+ }
+
static void post_monitor_inflate_event(EventJavaMonitorInflate* event,
! const oop obj,
! const ObjectSynchronizer::InflateCause cause) {
assert(event != NULL, "invariant");
assert(event->should_commit(), "invariant");
event->set_monitorClass(obj->klass());
event->set_address((uintptr_t)(void*)obj);
+ event->set_cause((u1)cause);
event->commit();
}
// Fast path code shared by multiple functions
ObjectMonitor* ObjectSynchronizer::inflate_helper(oop obj) {
*** 1198,1216 ****
if (mark->has_monitor()) {
assert(ObjectSynchronizer::verify_objmon_isinpool(mark->monitor()), "monitor is invalid");
assert(mark->monitor()->header()->is_neutral(), "monitor must record a good object header");
return mark->monitor();
}
! return ObjectSynchronizer::inflate(Thread::current(), obj);
}
// Note that we could encounter some performance loss through false-sharing as
// multiple locks occupy the same $ line. Padding might be appropriate.
! ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) {
// Inflate mutates the heap ...
// Relaxing assertion for bug 6320749.
assert (Universe::verify_in_progress() ||
!SafepointSynchronize::is_at_safepoint(), "invariant") ;
--- 1234,1256 ----
if (mark->has_monitor()) {
assert(ObjectSynchronizer::verify_objmon_isinpool(mark->monitor()), "monitor is invalid");
assert(mark->monitor()->header()->is_neutral(), "monitor must record a good object header");
return mark->monitor();
}
! return ObjectSynchronizer::inflate(Thread::current(),
! obj,
! inflate_cause_vm_internal);
}
// Note that we could encounter some performance loss through false-sharing as
// multiple locks occupy the same $ line. Padding might be appropriate.
! ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self,
! oop object,
! const InflateCause cause) {
// Inflate mutates the heap ...
// Relaxing assertion for bug 6320749.
assert (Universe::verify_in_progress() ||
!SafepointSynchronize::is_at_safepoint(), "invariant") ;
*** 1345,1355 ****
(void *) object, (intptr_t) object->mark(),
object->klass()->external_name());
}
}
if (event.should_commit()) {
! post_monitor_inflate_event(&event, object);
}
return m ;
}
// CASE: neutral
--- 1385,1395 ----
(void *) object, (intptr_t) object->mark(),
object->klass()->external_name());
}
}
if (event.should_commit()) {
! post_monitor_inflate_event(&event, object, cause);
}
return m ;
}
// CASE: neutral
*** 1398,1408 ****
(void *) object, (intptr_t) object->mark(),
object->klass()->external_name());
}
}
if (event.should_commit()) {
! post_monitor_inflate_event(&event, object);
}
return m ;
}
}
--- 1438,1448 ----
(void *) object, (intptr_t) object->mark(),
object->klass()->external_name());
}
}
if (event.should_commit()) {
! post_monitor_inflate_event(&event, object, cause);
}
return m ;
}
}
< prev index next >