mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 09:34:38 +02:00
8286957: Held monitor count
Reviewed-by: rpressler, eosterlund
This commit is contained in:
parent
1fec62f299
commit
ac399e9777
44 changed files with 407 additions and 238 deletions
|
@ -375,6 +375,7 @@ bool ObjectSynchronizer::quick_enter(oop obj, JavaThread* current,
|
|||
|
||||
if (owner == current) {
|
||||
m->_recursions++;
|
||||
current->inc_held_monitor_count();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -391,6 +392,7 @@ bool ObjectSynchronizer::quick_enter(oop obj, JavaThread* current,
|
|||
|
||||
if (owner == NULL && m->try_set_owner_from(NULL, current) == NULL) {
|
||||
assert(m->_recursions == 0, "invariant");
|
||||
current->inc_held_monitor_count();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -472,6 +474,8 @@ void ObjectSynchronizer::enter(Handle obj, BasicLock* lock, JavaThread* current)
|
|||
handle_sync_on_value_based_class(obj, current);
|
||||
}
|
||||
|
||||
current->inc_held_monitor_count();
|
||||
|
||||
if (!useHeavyMonitors()) {
|
||||
markWord mark = obj->mark();
|
||||
if (mark.is_neutral()) {
|
||||
|
@ -511,6 +515,8 @@ void ObjectSynchronizer::enter(Handle obj, BasicLock* lock, JavaThread* current)
|
|||
}
|
||||
|
||||
void ObjectSynchronizer::exit(oop object, BasicLock* lock, JavaThread* current) {
|
||||
current->dec_held_monitor_count();
|
||||
|
||||
if (!useHeavyMonitors()) {
|
||||
markWord mark = object->mark();
|
||||
|
||||
|
@ -579,8 +585,9 @@ intx ObjectSynchronizer::complete_exit(Handle obj, JavaThread* current) {
|
|||
// The ObjectMonitor* can't be async deflated until ownership is
|
||||
// dropped inside exit() and the ObjectMonitor* must be !is_busy().
|
||||
ObjectMonitor* monitor = inflate(current, obj(), inflate_cause_vm_internal);
|
||||
intptr_t ret_code = monitor->complete_exit(current);
|
||||
return ret_code;
|
||||
intx recur_count = monitor->complete_exit(current);
|
||||
current->dec_held_monitor_count(recur_count + 1);
|
||||
return recur_count;
|
||||
}
|
||||
|
||||
// NOTE: must use heavy weight monitor to handle complete_exit/reenter()
|
||||
|
@ -592,6 +599,7 @@ void ObjectSynchronizer::reenter(Handle obj, intx recursions, JavaThread* curren
|
|||
while (true) {
|
||||
ObjectMonitor* monitor = inflate(current, obj(), inflate_cause_vm_internal);
|
||||
if (monitor->reenter(recursions, current)) {
|
||||
current->inc_held_monitor_count(recursions + 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -613,6 +621,7 @@ void ObjectSynchronizer::jni_enter(Handle obj, JavaThread* current) {
|
|||
while (true) {
|
||||
ObjectMonitor* monitor = inflate(current, obj(), inflate_cause_jni_enter);
|
||||
if (monitor->enter(current)) {
|
||||
current->inc_held_monitor_count(1, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -631,6 +640,7 @@ void ObjectSynchronizer::jni_exit(oop obj, TRAPS) {
|
|||
// monitor even if an exception was already pending.
|
||||
if (monitor->check_owner(THREAD)) {
|
||||
monitor->exit(current);
|
||||
current->dec_held_monitor_count(1, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1577,7 +1587,8 @@ class ReleaseJavaMonitorsClosure: public MonitorClosure {
|
|||
public:
|
||||
ReleaseJavaMonitorsClosure(JavaThread* thread) : _thread(thread) {}
|
||||
void do_monitor(ObjectMonitor* mid) {
|
||||
(void)mid->complete_exit(_thread);
|
||||
intx rec = mid->complete_exit(_thread);
|
||||
_thread->dec_held_monitor_count(rec + 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1603,6 +1614,9 @@ void ObjectSynchronizer::release_monitors_owned_by_thread(JavaThread* current) {
|
|||
ObjectSynchronizer::monitors_iterate(&rjmc, current);
|
||||
assert(!current->has_pending_exception(), "Should not be possible");
|
||||
current->clear_pending_exception();
|
||||
assert(current->held_monitor_count() == 0, "Should not be possible");
|
||||
// All monitors (including entered via JNI) have been unlocked above, so we need to clear jni count.
|
||||
current->clear_jni_monitor_count();
|
||||
}
|
||||
|
||||
const char* ObjectSynchronizer::inflate_cause_name(const InflateCause cause) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue