--- old/src/share/vm/runtime/synchronizer.cpp 2015-10-08 22:16:04.632898826 +0200 +++ new/src/share/vm/runtime/synchronizer.cpp 2015-10-08 22:16:04.581900044 +0200 @@ -160,6 +160,7 @@ 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(); @@ -210,6 +211,7 @@ 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(); @@ -256,6 +258,7 @@ 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); @@ -275,6 +278,8 @@ 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) { @@ -314,6 +319,7 @@ // 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"); @@ -364,6 +370,7 @@ // 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"); @@ -377,6 +384,7 @@ // 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"); @@ -392,6 +400,7 @@ 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"); @@ -404,6 +413,7 @@ // 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); @@ -446,6 +456,7 @@ // 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"); @@ -466,6 +477,7 @@ } 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"); @@ -478,6 +490,7 @@ } 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"); @@ -492,6 +505,7 @@ // 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"); @@ -669,6 +683,7 @@ } 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 @@ -782,6 +797,7 @@ 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"); @@ -854,6 +870,7 @@ // 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); @@ -1275,6 +1292,7 @@ // 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"); @@ -1289,6 +1307,7 @@ 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"); @@ -1307,7 +1326,7 @@ 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; } @@ -1513,6 +1532,7 @@ 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"); @@ -1798,6 +1818,7 @@ for (int i = 1; i < _BLOCKSIZE; i++) { mid = (ObjectMonitor *)(block + i); oop object = (oop) mid->object(); + if (object != NULL) { mid->verify(); }