< prev index next >
src/share/vm/runtime/synchronizer.cpp
Print this page
@@ -158,10 +158,11 @@
bool ObjectSynchronizer::quick_notify(oopDesc * obj, Thread * self, bool all) {
assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
assert(self->is_Java_thread(), "invariant");
assert(((JavaThread *) self)->thread_state() == _thread_in_Java, "invariant");
+ assert(obj == oopDesc::bs()->write_barrier(obj), "expect to-space copy");
No_Safepoint_Verifier nsv;
if (obj == NULL) return false; // slow-path for invalid obj
const markOop mark = obj->mark();
if (mark->has_locker() && self->is_lock_owned((address)mark->locker())) {
@@ -208,10 +209,11 @@
bool ObjectSynchronizer::quick_enter(oop obj, Thread * Self,
BasicLock * Lock) {
assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
assert(Self->is_Java_thread(), "invariant");
assert(((JavaThread *) Self)->thread_state() == _thread_in_Java, "invariant");
+ assert(obj == oopDesc::bs()->write_barrier(obj), "expect to-space copy");
No_Safepoint_Verifier nsv;
if (obj == NULL) return false; // Need to throw NPE
const markOop mark = obj->mark();
if (mark->has_monitor()) {
@@ -254,10 +256,11 @@
// if the following function is changed. The implementation is
// extremely sensitive to race condition. Be careful.
void ObjectSynchronizer::fast_enter(Handle obj, BasicLock* lock,
bool attempt_rebias, TRAPS) {
+ assert(obj() == oopDesc::bs()->write_barrier(obj()), "expect to-space copy");
if (UseBiasedLocking) {
if (!SafepointSynchronize::is_at_safepoint()) {
BiasedLocking::Condition cond = BiasedLocking::revoke_and_rebias(obj, attempt_rebias, THREAD);
if (cond == BiasedLocking::BIAS_REVOKED_AND_REBIASED) {
return;
@@ -273,10 +276,12 @@
}
void ObjectSynchronizer::fast_exit(oop object, BasicLock* lock, TRAPS) {
assert(!object->mark()->has_bias_pattern(), "should not see bias pattern here");
// if displaced header is null, the previous enter is recursive enter, no-op
+ assert(object == oopDesc::bs()->write_barrier(object), "expect to-space copy");
+
markOop dhw = lock->displaced_header();
markOop mark;
if (dhw == NULL) {
// Recursive stack-lock.
// Diagnostics -- Could be: stack-locked, inflating, inflated.
@@ -312,10 +317,11 @@
// Interpreter/Compiler Slow Case
// This routine is used to handle interpreter/compiler slow case
// We don't need to use fast path here, because it must have been
// failed in the interpreter/compiler code.
void ObjectSynchronizer::slow_enter(Handle obj, BasicLock* lock, TRAPS) {
+ assert(obj() == oopDesc::bs()->write_barrier(obj()), "expect to-space copy");
markOop mark = obj->mark();
assert(!mark->has_bias_pattern(), "should not see bias pattern here");
if (mark->is_neutral()) {
// Anticipate successful CAS -- the ST of the displaced mark must
@@ -362,10 +368,11 @@
// 4) reenter lock1 with original recursion count
// 5) lock lock2
// NOTE: must use heavy weight monitor to handle complete_exit/reenter()
intptr_t ObjectSynchronizer::complete_exit(Handle obj, TRAPS) {
TEVENT(complete_exit);
+ assert(obj() == oopDesc::bs()->write_barrier(obj()), "expect to-space copy");
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
@@ -375,10 +382,11 @@
}
// NOTE: must use heavy weight monitor to handle complete_exit/reenter()
void ObjectSynchronizer::reenter(Handle obj, intptr_t recursion, TRAPS) {
TEVENT(reenter);
+ assert(obj() == oopDesc::bs()->write_barrier(obj()), "expect to-space copy");
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
@@ -390,10 +398,11 @@
// JNI locks on java objects
// NOTE: must use heavy weight monitor to handle jni monitor enter
void ObjectSynchronizer::jni_enter(Handle obj, TRAPS) {
// the current locking is from JNI instead of Java code
TEVENT(jni_enter);
+ assert(obj() == oopDesc::bs()->write_barrier(obj()), "expect to-space copy");
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);
@@ -402,10 +411,11 @@
}
// NOTE: must use heavy weight monitor to handle jni monitor exit
void ObjectSynchronizer::jni_exit(oop obj, Thread* THREAD) {
TEVENT(jni_exit);
+ assert(obj == oopDesc::bs()->write_barrier(obj), "expect to-space copy");
if (UseBiasedLocking) {
Handle h_obj(THREAD, obj);
BiasedLocking::revoke_and_rebias(h_obj, false, THREAD);
obj = h_obj();
}
@@ -444,10 +454,11 @@
// -----------------------------------------------------------------------------
// Wait/Notify/NotifyAll
// NOTE: must use heavy weight monitor to handle wait()
int ObjectSynchronizer::wait(Handle obj, jlong millis, TRAPS) {
+ assert(obj() == oopDesc::bs()->write_barrier(obj()), "expect to-space copy");
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
if (millis < 0) {
@@ -464,10 +475,11 @@
// DTRACE_MONITOR_PROBE(waited, monitor, obj(), THREAD);
return dtrace_waited_probe(monitor, obj, THREAD);
}
void ObjectSynchronizer::waitUninterruptibly(Handle obj, jlong millis, TRAPS) {
+ assert(obj() == oopDesc::bs()->write_barrier(obj()), "expect to-space copy");
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
if (millis < 0) {
@@ -476,10 +488,11 @@
}
ObjectSynchronizer::inflate(THREAD, obj()) -> wait(millis, false, THREAD);
}
void ObjectSynchronizer::notify(Handle obj, TRAPS) {
+ assert(obj() == oopDesc::bs()->write_barrier(obj()), "expect to-space copy");
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
@@ -490,10 +503,11 @@
ObjectSynchronizer::inflate(THREAD, obj())->notify(THREAD);
}
// NOTE: see comment of notify()
void ObjectSynchronizer::notifyall(Handle obj, TRAPS) {
+ assert(obj() == oopDesc::bs()->write_barrier(obj()), "expect to-space copy");
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(obj, false, THREAD);
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
@@ -667,10 +681,11 @@
TEVENT(hashCode: GENERATE);
return value;
}
intptr_t ObjectSynchronizer::FastHashCode(Thread * Self, oop obj) {
+ assert(obj == oopDesc::bs()->write_barrier(obj), "expect to-space copy");
if (UseBiasedLocking) {
// NOTE: many places throughout the JVM do not expect a safepoint
// to be taken here, in particular most operations on perm gen
// objects. However, we only ever bias Java instances and all of
// the call sites of identity_hash that might revoke biases have
@@ -780,10 +795,11 @@
}
bool ObjectSynchronizer::current_thread_holds_lock(JavaThread* thread,
Handle h_obj) {
+ assert(h_obj() == oopDesc::bs()->write_barrier(h_obj()), "expect to-space copy");
if (UseBiasedLocking) {
BiasedLocking::revoke_and_rebias(h_obj, false, thread);
assert(!h_obj->mark()->has_bias_pattern(), "biases should be revoked by now");
}
@@ -852,10 +868,11 @@
return owner_none; // it's unlocked
}
// FIXME: jvmti should call this
JavaThread* ObjectSynchronizer::get_lock_owner(Handle h_obj, bool doLock) {
+ assert(h_obj() == oopDesc::bs()->write_barrier(h_obj()), "expect to-space copy");
if (UseBiasedLocking) {
if (SafepointSynchronize::is_at_safepoint()) {
BiasedLocking::revoke_at_safepoint(h_obj);
} else {
BiasedLocking::revoke_and_rebias(h_obj, false, JavaThread::current());
@@ -1273,10 +1290,11 @@
TEVENT(omFlush);
}
// Fast path code shared by multiple functions
ObjectMonitor* ObjectSynchronizer::inflate_helper(oop obj) {
+ assert(obj == oopDesc::bs()->write_barrier(obj), "expect to-space copy");
markOop mark = obj->mark();
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();
@@ -1287,10 +1305,11 @@
ObjectMonitor * NOINLINE ObjectSynchronizer::inflate(Thread * Self,
oop object) {
// Inflate mutates the heap ...
// Relaxing assertion for bug 6320749.
+ assert(object == oopDesc::bs()->write_barrier(object), "expect to-space copy");
assert(Universe::verify_in_progress() ||
!SafepointSynchronize::is_at_safepoint(), "invariant");
for (;;) {
const markOop mark = object->mark();
@@ -1305,11 +1324,11 @@
// CASE: inflated
if (mark->has_monitor()) {
ObjectMonitor * inf = mark->monitor();
assert(inf->header()->is_neutral(), "invariant");
- assert(inf->object() == object, "invariant");
+ assert((oop) inf->object() == object, "invariant");
assert(ObjectSynchronizer::verify_objmon_isinpool(inf), "monitor is invalid");
return inf;
}
// CASE: inflation in progress - inflating over a stack-lock.
@@ -1511,10 +1530,11 @@
bool ObjectSynchronizer::deflate_monitor(ObjectMonitor* mid, oop obj,
ObjectMonitor** freeHeadp,
ObjectMonitor** freeTailp) {
bool deflated;
// Normal case ... The monitor is associated with obj.
+ assert(obj == oopDesc::bs()->write_barrier(obj), "expect to-space copy");
guarantee(obj->mark() == markOopDesc::encode(mid), "invariant");
guarantee(mid == obj->mark()->monitor(), "invariant");
guarantee(mid->header()->is_neutral(), "invariant");
if (mid->is_busy()) {
@@ -1796,10 +1816,11 @@
while (block) {
assert(block->object() == CHAINMARKER, "must be a block header");
for (int i = 1; i < _BLOCKSIZE; i++) {
mid = (ObjectMonitor *)(block + i);
oop object = (oop) mid->object();
+
if (object != NULL) {
mid->verify();
}
}
block = (PaddedEnd<ObjectMonitor> *) block->FreeNext;
< prev index next >