< prev index next >
src/share/vm/gc/shared/referencePendingListLocker.cpp
Print this page
@@ -103,11 +103,11 @@
ml.wait(Monitor::_no_safepoint_check_flag);
}
}
void ReferencePendingListLockerThread::receive_and_handle_messages() {
- ReferencePendingListLocker pending_list_locker;
+ ReferencePendingListLockerFromJava pending_list_locker;
MonitorLockerEx ml(&_monitor);
// Main loop, never terminates
for (;;) {
// Wait for message
@@ -152,24 +152,28 @@
bool ReferencePendingListLocker::is_initialized() {
return _is_initialized;
}
bool ReferencePendingListLocker::is_locked_by_self() {
+ return ReferencePendingListLockerFromJava::is_locked_by_self();
+}
+
+bool ReferencePendingListLockerFromJava::is_locked_by_self() {
oop pending_list_lock = java_lang_ref_Reference::pending_list_lock();
if (pending_list_lock == NULL) {
return false;
}
JavaThread* thread = JavaThread::current();
Handle handle(thread, pending_list_lock);
return ObjectSynchronizer::current_thread_holds_lock(thread, handle);
}
-void ReferencePendingListLocker::lock() {
+void ReferencePendingListLockerFromJava::lock() {
assert(!Heap_lock->owned_by_self(), "Heap_lock must not be owned by requesting thread");
+ assert(Thread::current()->is_Java_thread(), "Must be");
- if (Thread::current()->is_Java_thread()) {
assert(java_lang_ref_Reference::pending_list_lock() != NULL, "Not initialized");
// We may enter this with a pending exception
PRESERVE_EXCEPTION_MARK;
@@ -184,19 +188,25 @@
assert(is_locked_by_self(), "Locking failed");
if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION;
}
+}
+
+void ReferencePendingListLocker::lock() {
+ if (Thread::current()->is_Java_thread()) {
+ _locker.lock();
} else {
// Delegate operation to locker thread
assert(_locker_thread != NULL, "Locker thread not created");
_locker_thread->lock();
}
}
-void ReferencePendingListLocker::unlock() {
- if (Thread::current()->is_Java_thread()) {
+void ReferencePendingListLockerFromJava::unlock() {
+ assert(Thread::current()->is_Java_thread(), "Must be");
+
assert(java_lang_ref_Reference::pending_list_lock() != NULL, "Not initialized");
// We may enter this with a pending exception
PRESERVE_EXCEPTION_MARK;
@@ -216,10 +226,15 @@
assert(!is_locked_by_self(), "Unlocking failed");
if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION;
}
+}
+
+void ReferencePendingListLocker::unlock() {
+ if (Thread::current()->is_Java_thread()) {
+ _locker.unlock();
} else {
// Delegate operation to locker thread
assert(_locker_thread != NULL, "Locker thread not created");
_locker_thread->unlock();
}
< prev index next >