--- a/hotspot/src/share/vm/runtime/thread.cpp Fri Aug 29 08:14:19 2014 -0700
+++ b/hotspot/src/share/vm/runtime/thread.cpp Wed Sep 10 11:48:20 2014 -0600
@@ -148,7 +148,7 @@
size_t aligned_size = size + (alignment - sizeof(intptr_t));
void* real_malloc_addr = throw_excpt? AllocateHeap(aligned_size, flags, CURRENT_PC)
: AllocateHeap(aligned_size, flags, CURRENT_PC,
- AllocFailStrategy::RETURN_NULL);
+ AllocFailStrategy::RETURN_NULL);
void* aligned_addr = (void*) align_size_up((intptr_t) real_malloc_addr, alignment);
assert(((uintptr_t) aligned_addr + (uintptr_t) size) <=
((uintptr_t) real_malloc_addr + (uintptr_t) aligned_size),
@@ -365,7 +365,7 @@
#ifdef ASSERT
// Private method to check for dangling thread pointer
void check_for_dangling_thread_pointer(Thread *thread) {
- assert(!thread->is_Java_thread() || Thread::current() == thread || Threads_lock->owned_by_self(),
+ assert(!thread->is_Java_thread() || Thread::current() == thread || Threads_lock->owned_by_self(),
"possibility of dangling Thread pointer");
}
#endif
@@ -517,8 +517,8 @@
ResourceMark rm;
tty->print_cr(
- "Failed wait_for_ext_suspend_completion(thread=%s, debug_bits=%x)",
- jt->get_thread_name(), *bits);
+ "Failed wait_for_ext_suspend_completion(thread=%s, debug_bits=%x)",
+ jt->get_thread_name(), *bits);
guarantee(!AssertOnSuspendWaitFailure, "external suspend wait failed");
}
@@ -654,7 +654,7 @@
// Returns true if the thread is externally suspended and false otherwise.
//
bool JavaThread::wait_for_ext_suspend_completion(int retries, int delay,
- uint32_t *bits) {
+ uint32_t *bits) {
TraceSuspendDebugBits tsdb(this, true /* is_wait */,
false /* !called_by_wait */, bits);
@@ -759,8 +759,8 @@
bool gotframe = false;
// self suspension saves needed state.
if (has_last_Java_frame() && _anchor.walkable()) {
- *_fr = pd_last_frame();
- gotframe = true;
+ *_fr = pd_last_frame();
+ gotframe = true;
}
return gotframe;
}
@@ -790,7 +790,7 @@
} else {
guarantee(res == strong_roots_parity, "Or else what?");
assert(SharedHeap::heap()->workers()->active_workers() > 0,
- "Should only fail when parallel.");
+ "Should only fail when parallel.");
return false;
}
}
@@ -882,38 +882,38 @@
// invoke the vm-thread (i.e., and oop allocation). In that case, we also have to make sure that
// no threads which allow_vm_block's are held
void Thread::check_for_valid_safepoint_state(bool potential_vm_operation) {
- // Check if current thread is allowed to block at a safepoint
- if (!(_allow_safepoint_count == 0))
- fatal("Possible safepoint reached by thread that does not allow it");
- if (is_Java_thread() && ((JavaThread*)this)->thread_state() != _thread_in_vm) {
- fatal("LEAF method calling lock?");
- }
+ // Check if current thread is allowed to block at a safepoint
+ if (!(_allow_safepoint_count == 0))
+ fatal("Possible safepoint reached by thread that does not allow it");
+ if (is_Java_thread() && ((JavaThread*)this)->thread_state() != _thread_in_vm) {
+ fatal("LEAF method calling lock?");
+ }
#ifdef ASSERT
- if (potential_vm_operation && is_Java_thread()
- && !Universe::is_bootstrapping()) {
- // Make sure we do not hold any locks that the VM thread also uses.
- // This could potentially lead to deadlocks
- for (Monitor *cur = _owned_locks; cur; cur = cur->next()) {
- // Threads_lock is special, since the safepoint synchronization will not start before this is
- // acquired. Hence, a JavaThread cannot be holding it at a safepoint. So is VMOperationRequest_lock,
- // since it is used to transfer control between JavaThreads and the VMThread
- // Do not *exclude* any locks unless you are absolutely sure it is correct. Ask someone else first!
- if ((cur->allow_vm_block() &&
- cur != Threads_lock &&
- cur != Compile_lock && // Temporary: should not be necessary when we get separate compilation
- cur != VMOperationRequest_lock &&
- cur != VMOperationQueue_lock) ||
- cur->rank() == Mutex::special) {
- fatal(err_msg("Thread holding lock at safepoint that vm can block on: %s", cur->name()));
- }
+ if (potential_vm_operation && is_Java_thread()
+ && !Universe::is_bootstrapping()) {
+ // Make sure we do not hold any locks that the VM thread also uses.
+ // This could potentially lead to deadlocks
+ for (Monitor *cur = _owned_locks; cur; cur = cur->next()) {
+ // Threads_lock is special, since the safepoint synchronization will not start before this is
+ // acquired. Hence, a JavaThread cannot be holding it at a safepoint. So is VMOperationRequest_lock,
+ // since it is used to transfer control between JavaThreads and the VMThread
+ // Do not *exclude* any locks unless you are absolutely sure it is correct. Ask someone else first!
+ if ((cur->allow_vm_block() &&
+ cur != Threads_lock &&
+ cur != Compile_lock && // Temporary: should not be necessary when we get separate compilation
+ cur != VMOperationRequest_lock &&
+ cur != VMOperationQueue_lock) ||
+ cur->rank() == Mutex::special) {
+ fatal(err_msg("Thread holding lock at safepoint that vm can block on: %s", cur->name()));
}
}
-
- if (GCALotAtAllSafepoints) {
- // We could enter a safepoint here and thus have a gc
- InterfaceSupport::check_gc_alot();
- }
+ }
+
+ if (GCALotAtAllSafepoints) {
+ // We could enter a safepoint here and thus have a gc
+ InterfaceSupport::check_gc_alot();
+ }
#endif
}
#endif
@@ -947,7 +947,7 @@
}
bool Thread::set_as_starting_thread() {
- // NOTE: this must be called inside the main thread.
+ // NOTE: this must be called inside the main thread.
return os::create_main_thread((JavaThread*)this);
}
@@ -1004,12 +1004,12 @@
JavaValue result(T_VOID);
JavaCalls::call_special(&result, thread_oop,
- klass,
- vmSymbols::object_initializer_name(),
- vmSymbols::threadgroup_string_void_signature(),
- thread_group,
- string,
- CHECK_NULL);
+ klass,
+ vmSymbols::object_initializer_name(),
+ vmSymbols::threadgroup_string_void_signature(),
+ thread_group,
+ string,
+ CHECK_NULL);
return thread_oop();
}
@@ -1019,7 +1019,7 @@
JavaValue result(T_VOID);
JavaCalls::call_static(&result, klass, vmSymbols::initializeSystemClass_name(),
- vmSymbols::void_method_signature(), CHECK);
+ vmSymbols::void_method_signature(), CHECK);
}
char java_runtime_name[128] = "";
@@ -1028,7 +1028,7 @@
// extract the JRE name from sun.misc.Version.java_runtime_name
static const char* get_java_runtime_name(TRAPS) {
Klass* k = SystemDictionary::find(vmSymbols::sun_misc_Version(),
- Handle(), Handle(), CHECK_AND_CLEAR_NULL);
+ Handle(), Handle(), CHECK_AND_CLEAR_NULL);
fieldDescriptor fd;
bool found = k != NULL &&
InstanceKlass::cast(k)->find_local_field(vmSymbols::java_runtime_name_name(),
@@ -1049,7 +1049,7 @@
// extract the JRE version from sun.misc.Version.java_runtime_version
static const char* get_java_runtime_version(TRAPS) {
Klass* k = SystemDictionary::find(vmSymbols::sun_misc_Version(),
- Handle(), Handle(), CHECK_AND_CLEAR_NULL);
+ Handle(), Handle(), CHECK_AND_CLEAR_NULL);
fieldDescriptor fd;
bool found = k != NULL &&
InstanceKlass::cast(k)->find_local_field(vmSymbols::java_runtime_version_name(),
@@ -1075,8 +1075,8 @@
if (klass.not_null()) {
JavaValue result(T_VOID);
JavaCalls::call_static(&result, klass, vmSymbols::run_method_name(),
- vmSymbols::void_method_signature(),
- CHECK);
+ vmSymbols::void_method_signature(),
+ CHECK);
}
}
@@ -1146,7 +1146,7 @@
if (daemon) {
- java_lang_Thread::set_daemon(thread_oop());
+ java_lang_Thread::set_daemon(thread_oop());
}
if (HAS_PENDING_EXCEPTION) {
@@ -1157,12 +1157,12 @@
Handle threadObj(this, this->threadObj());
JavaCalls::call_special(&result,
- thread_group,
- group,
- vmSymbols::add_method_name(),
- vmSymbols::thread_void_signature(),
- threadObj, // Arg 1
- THREAD);
+ thread_group,
+ group,
+ vmSymbols::add_method_name(),
+ vmSymbols::thread_void_signature(),
+ threadObj, // Arg 1
+ THREAD);
}
@@ -1246,25 +1246,25 @@
jlong now = os::javaTimeNanos();
if (remaining == 0) {
- // if we didn't have any tasks we could have waited for a long time
- // consider the time_slept zero and reset time_before_loop
- time_slept = 0;
- time_before_loop = now;
+ // if we didn't have any tasks we could have waited for a long time
+ // consider the time_slept zero and reset time_before_loop
+ time_slept = 0;
+ time_before_loop = now;
} else {
- // need to recalculate since we might have new tasks in _tasks
- time_slept = (int) ((now - time_before_loop) / 1000000);
+ // need to recalculate since we might have new tasks in _tasks
+ time_slept = (int) ((now - time_before_loop) / 1000000);
}
// Change to task list or spurious wakeup of some kind
if (timedout || _should_terminate) {
- break;
+ break;
}
remaining = PeriodicTask::time_to_wait();
if (remaining == 0) {
- // Last task was just disenrolled so loop around and wait until
- // another task gets enrolled
- continue;
+ // Last task was just disenrolled so loop around and wait until
+ // another task gets enrolled
+ continue;
}
remaining -= time_slept;
@@ -1302,13 +1302,13 @@
for (;;) {
if (!ShowMessageBoxOnError
- && (OnError == NULL || OnError[0] == '\0')
- && Arguments::abort_hook() == NULL) {
- os::sleep(this, 2 * 60 * 1000, false);
- fdStream err(defaultStream::output_fd());
- err.print_raw_cr("# [ timer expired, abort... ]");
- // skip atexit/vm_exit/vm_abort hooks
- os::die();
+ && (OnError == NULL || OnError[0] == '\0')
+ && Arguments::abort_hook() == NULL) {
+ os::sleep(this, 2 * 60 * 1000, false);
+ fdStream err(defaultStream::output_fd());
+ err.print_raw_cr("# [ timer expired, abort... ]");
+ // skip atexit/vm_exit/vm_abort hooks
+ os::die();
}
// Wake up 5 seconds later, the fatal handler may reset OnError or
@@ -1486,10 +1486,10 @@
#endif // INCLUDE_ALL_GCS
JavaThread::JavaThread(bool is_attaching_via_jni) :
- Thread()
+ Thread()
#if INCLUDE_ALL_GCS
- , _satb_mark_queue(&_satb_mark_queue_set),
- _dirty_card_queue(&_dirty_card_queue_set)
+ , _satb_mark_queue(&_satb_mark_queue_set),
+ _dirty_card_queue(&_dirty_card_queue_set)
#endif // INCLUDE_ALL_GCS
{
initialize();
@@ -1543,10 +1543,10 @@
static void compiler_thread_entry(JavaThread* thread, TRAPS);
JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) :
- Thread()
+ Thread()
#if INCLUDE_ALL_GCS
- , _satb_mark_queue(&_satb_mark_queue_set),
- _dirty_card_queue(&_dirty_card_queue_set)
+ , _satb_mark_queue(&_satb_mark_queue_set),
+ _dirty_card_queue(&_dirty_card_queue_set)
#endif // INCLUDE_ALL_GCS
{
if (TraceThreadEvents) {
@@ -1575,7 +1575,7 @@
JavaThread::~JavaThread() {
if (TraceThreadEvents) {
- tty->print_cr("terminate thread %p", this);
+ tty->print_cr("terminate thread %p", this);
}
// JSR166 -- return the parker to the free list
@@ -1649,8 +1649,8 @@
EventThreadStart event;
if (event.should_commit()) {
- event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
- event.commit();
+ event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
+ event.commit();
}
// We call another function to do the rest so we are sure that the stack addresses used
@@ -1742,10 +1742,10 @@
if (HAS_PENDING_EXCEPTION) {
ResourceMark rm(this);
jio_fprintf(defaultStream::error_stream(),
- "\nException: %s thrown from the UncaughtExceptionHandler"
- " in thread \"%s\"\n",
- pending_exception()->klass()->external_name(),
- get_thread_name());
+ "\nException: %s thrown from the UncaughtExceptionHandler"
+ " in thread \"%s\"\n",
+ pending_exception()->klass()->external_name(),
+ get_thread_name());
CLEAR_PENDING_EXCEPTION;
}
}
@@ -1754,8 +1754,8 @@
// from java_lang_Thread object
EventThreadEnd event;
if (event.should_commit()) {
- event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
- event.commit();
+ event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
+ event.commit();
}
// Call after last event on thread
@@ -1771,10 +1771,10 @@
JavaValue result(T_VOID);
KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass());
JavaCalls::call_virtual(&result,
- threadObj, thread_klass,
- vmSymbols::exit_method_name(),
- vmSymbols::void_method_signature(),
- THREAD);
+ threadObj, thread_klass,
+ vmSymbols::exit_method_name(),
+ vmSymbols::void_method_signature(),
+ THREAD);
CLEAR_PENDING_EXCEPTION;
}
}
@@ -2062,22 +2062,22 @@
condition = _no_async_condition; // done
switch (thread_state()) {
case _thread_in_vm:
- {
- JavaThread* THREAD = this;
- THROW_MSG(vmSymbols::java_lang_InternalError(), "a fault occurred in an unsafe memory access operation");
- }
+ {
+ JavaThread* THREAD = this;
+ THROW_MSG(vmSymbols::java_lang_InternalError(), "a fault occurred in an unsafe memory access operation");
+ }
case _thread_in_native:
- {
- ThreadInVMfromNative tiv(this);
- JavaThread* THREAD = this;
- THROW_MSG(vmSymbols::java_lang_InternalError(), "a fault occurred in an unsafe memory access operation");
- }
+ {
+ ThreadInVMfromNative tiv(this);
+ JavaThread* THREAD = this;
+ THROW_MSG(vmSymbols::java_lang_InternalError(), "a fault occurred in an unsafe memory access operation");
+ }
case _thread_in_Java:
- {
- ThreadInVMfromJava tiv(this);
- JavaThread* THREAD = this;
- THROW_MSG(vmSymbols::java_lang_InternalError(), "a fault occurred in a recent unsafe memory access operation in compiled Java code");
- }
+ {
+ ThreadInVMfromJava tiv(this);
+ JavaThread* THREAD = this;
+ THROW_MSG(vmSymbols::java_lang_InternalError(), "a fault occurred in a recent unsafe memory access operation in compiled Java code");
+ }
default:
ShouldNotReachHere();
}
@@ -2170,8 +2170,8 @@
set_pending_async_exception(java_throwable);
if (TraceExceptions) {
- ResourceMark rm;
- tty->print_cr("Pending Async. exception installed of type: %s", InstanceKlass::cast(_pending_async_exception->klass())->external_name());
+ ResourceMark rm;
+ tty->print_cr("Pending Async. exception installed of type: %s", InstanceKlass::cast(_pending_async_exception->klass())->external_name());
}
// for AbortVMOnException flag
NOT_PRODUCT(Exceptions::debug_check_abort(InstanceKlass::cast(_pending_async_exception->klass())->external_name()));
@@ -2198,7 +2198,7 @@
void JavaThread::java_suspend() {
{ MutexLocker mu(Threads_lock);
if (!Threads::includes(this) || is_exiting() || this->threadObj() == NULL) {
- return;
+ return;
}
}
@@ -2241,18 +2241,18 @@
// we are in the process of exiting so don't suspend
if (is_exiting()) {
- clear_external_suspend();
- return ret;
+ clear_external_suspend();
+ return ret;
}
assert(_anchor.walkable() ||
- (is_Java_thread() && !((JavaThread*)this)->has_last_Java_frame()),
- "must have walkable stack");
+ (is_Java_thread() && !((JavaThread*)this)->has_last_Java_frame()),
+ "must have walkable stack");
MutexLockerEx ml(SR_lock(), Mutex::_no_safepoint_check_flag);
assert(!this->is_ext_suspended(),
- "a thread trying to self-suspend should not already be suspended");
+ "a thread trying to self-suspend should not already be suspended");
if (this->is_suspend_equivalent()) {
// If we are self-suspending as a result of the lifting of a
@@ -2289,12 +2289,12 @@
// hence doesn't need protection from concurrent access at this stage
void JavaThread::verify_not_published() {
if (!Threads_lock->owned_by_self()) {
- MutexLockerEx ml(Threads_lock, Mutex::_no_safepoint_check_flag);
- assert(!Threads::includes(this),
+ MutexLockerEx ml(Threads_lock, Mutex::_no_safepoint_check_flag);
+ assert(!Threads::includes(this),
"java thread shouldn't have been published yet!");
}
else {
- assert(!Threads::includes(this),
+ assert(!Threads::includes(this),
"java thread shouldn't have been published yet!");
}
}
@@ -2474,7 +2474,7 @@
if (os::unguard_memory((char *) low_addr, len)) {
_stack_guard_state = stack_guard_unused;
} else {
- warning("Attempt to unprotect stack guard pages failed.");
+ warning("Attempt to unprotect stack guard pages failed.");
}
}
}
@@ -2640,7 +2640,7 @@
// the given JavaThread in its _processed_thread field.
class RememberProcessedThread: public StackObj {
NamedThread* _cur_thr;
-public:
+ public:
RememberProcessedThread(JavaThread* jthr) {
Thread* thread = Thread::current();
if (thread->is_Named_thread()) {
@@ -2669,7 +2669,7 @@
Thread::oops_do(f, cld_f, cf);
assert((!has_last_Java_frame() && java_call_counter() == 0) ||
- (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!");
+ (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!");
if (has_last_Java_frame()) {
// Record JavaThread to GC thread
@@ -2729,7 +2729,7 @@
Thread::nmethods_do(cf); // (super method is a no-op)
assert((!has_last_Java_frame() && java_call_counter() == 0) ||
- (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!");
+ (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!");
if (has_last_Java_frame()) {
// Traverse the execution stack
@@ -2809,7 +2809,7 @@
st->print("JavaThread \"%s\"", get_thread_name_string(buf, buflen));
oop thread_obj = threadObj();
if (thread_obj != NULL) {
- if (java_lang_Thread::is_daemon(thread_obj)) st->print(" daemon");
+ if (java_lang_Thread::is_daemon(thread_obj)) st->print(" daemon");
}
st->print(" [");
st->print("%s", _get_thread_state_name(_thread_state));
@@ -2853,7 +2853,7 @@
}
}
#endif // ASSERT
- return get_thread_name_string();
+ return get_thread_name_string();
}
// Returns a non-NULL representation of this thread's name, or a suitable
@@ -2950,7 +2950,7 @@
Handle thread_oop(Thread::current(),
JNIHandles::resolve_non_null(jni_thread));
assert(InstanceKlass::cast(thread_oop->klass())->is_linked(),
- "must be initialized");
+ "must be initialized");
set_threadObj(thread_oop());
java_lang_Thread::set_thread(thread_oop(), this);
@@ -3383,7 +3383,7 @@
if (!main_thread->set_as_starting_thread()) {
vm_shutdown_during_initialization(
- "Failed necessary internal allocation. Out of swap space");
+ "Failed necessary internal allocation. Out of swap space");
delete main_thread;
*canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
return JNI_ENOMEM;
@@ -3583,17 +3583,17 @@
}
{
- MutexLockerEx ml(PeriodicTask_lock, Mutex::_no_safepoint_check_flag);
- // Make sure the watcher thread can be started by WatcherThread::start()
- // or by dynamic enrollment.
- WatcherThread::make_startable();
- // Start up the WatcherThread if there are any periodic tasks
- // NOTE: All PeriodicTasks should be registered by now. If they
- // aren't, late joiners might appear to start slowly (we might
- // take a while to process their first tick).
- if (PeriodicTask::num_tasks() > 0) {
- WatcherThread::start();
- }
+ MutexLockerEx ml(PeriodicTask_lock, Mutex::_no_safepoint_check_flag);
+ // Make sure the watcher thread can be started by WatcherThread::start()
+ // or by dynamic enrollment.
+ WatcherThread::make_startable();
+ // Start up the WatcherThread if there are any periodic tasks
+ // NOTE: All PeriodicTasks should be registered by now. If they
+ // aren't, late joiners might appear to start slowly (we might
+ // take a while to process their first tick).
+ if (PeriodicTask::num_tasks() > 0) {
+ WatcherThread::start();
+ }
}
// Give os specific code one last chance to start
@@ -3749,10 +3749,10 @@
// Find the Agent_OnUnload function.
Agent_OnUnload_t unload_entry = CAST_TO_FN_PTR(Agent_OnUnload_t,
- os::find_agent_function(agent,
- false,
- on_unload_symbols,
- num_symbol_entries));
+ os::find_agent_function(agent,
+ false,
+ on_unload_symbols,
+ num_symbol_entries));
// Invoke the Agent_OnUnload function
if (unload_entry != NULL) {
@@ -4060,7 +4060,7 @@
bool is_par = sh->n_par_threads() > 0;
assert(!is_par ||
(SharedHeap::heap()->n_par_threads() ==
- SharedHeap::heap()->workers()->active_workers()), "Mismatch");
+ SharedHeap::heap()->workers()->active_workers()), "Mismatch");
int cp = SharedHeap::heap()->strong_roots_parity();
ALL_JAVA_THREADS(p) {
if (p->claim_oops_do(is_par, cp)) {
@@ -4113,9 +4113,9 @@
// Get count Java threads that are waiting to enter the specified monitor.
GrowableArray<JavaThread*>* Threads::get_pending_threads(int count,
- address monitor, bool doLock) {
+ address monitor, bool doLock) {
assert(doLock || SafepointSynchronize::is_at_safepoint(),
- "must grab Threads_lock or be at safepoint");
+ "must grab Threads_lock or be at safepoint");
GrowableArray<JavaThread*>* result = new GrowableArray<JavaThread*>(count);
int i = 0;
@@ -4181,10 +4181,10 @@
st->print_cr("%s", os::local_time_string(buf, sizeof(buf)));
st->print_cr("Full thread dump %s (%s %s):",
- Abstract_VM_Version::vm_name(),
- Abstract_VM_Version::vm_release(),
- Abstract_VM_Version::vm_info_string()
- );
+ Abstract_VM_Version::vm_name(),
+ Abstract_VM_Version::vm_release(),
+ Abstract_VM_Version::vm_info_string()
+ );
st->cr();
#if INCLUDE_ALL_GCS
@@ -4303,7 +4303,7 @@
void Thread::SpinAcquire (volatile int * adr, const char * LockName) {
if (Atomic::cmpxchg (1, adr, 0) == 0) {
- return; // normal fast-path return
+ return; // normal fast-path return
}
// Slow-path : We've encountered contention -- Spin/Yield/Block strategy.
@@ -4311,20 +4311,20 @@
int ctr = 0;
int Yields = 0;
for (;;) {
- while (*adr != 0) {
- ++ctr;
- if ((ctr & 0xFFF) == 0 || !os::is_MP()) {
- if (Yields > 5) {
- os::naked_short_sleep(1);
- } else {
- os::naked_yield();
- ++Yields;
- }
+ while (*adr != 0) {
+ ++ctr;
+ if ((ctr & 0xFFF) == 0 || !os::is_MP()) {
+ if (Yields > 5) {
+ os::naked_short_sleep(1);
} else {
- SpinPause();
+ os::naked_yield();
+ ++Yields;
}
- }
- if (Atomic::cmpxchg(1, adr, 0) == 0) return;
+ } else {
+ SpinPause();
+ }
+ }
+ if (Atomic::cmpxchg(1, adr, 0) == 0) return;
}
}
@@ -4401,45 +4401,45 @@
intptr_t w = Atomic::cmpxchg_ptr(LOCKBIT, Lock, 0);
if (w == 0) return;
if ((w & LOCKBIT) == 0 && Atomic::cmpxchg_ptr (w|LOCKBIT, Lock, w) == w) {
- return;
+ return;
}
TEVENT(muxAcquire - Contention);
ParkEvent * const Self = Thread::current()->_MuxEvent;
assert((intptr_t(Self) & LOCKBIT) == 0, "invariant");
for (;;) {
- int its = (os::is_MP() ? 100 : 0) + 1;
-
- // Optional spin phase: spin-then-park strategy
- while (--its >= 0) {
- w = *Lock;
- if ((w & LOCKBIT) == 0 && Atomic::cmpxchg_ptr (w|LOCKBIT, Lock, w) == w) {
+ int its = (os::is_MP() ? 100 : 0) + 1;
+
+ // Optional spin phase: spin-then-park strategy
+ while (--its >= 0) {
+ w = *Lock;
+ if ((w & LOCKBIT) == 0 && Atomic::cmpxchg_ptr (w|LOCKBIT, Lock, w) == w) {
+ return;
+ }
+ }
+
+ Self->reset();
+ Self->OnList = intptr_t(Lock);
+ // The following fence() isn't _strictly necessary as the subsequent
+ // CAS() both serializes execution and ratifies the fetched *Lock value.
+ OrderAccess::fence();
+ for (;;) {
+ w = *Lock;
+ if ((w & LOCKBIT) == 0) {
+ if (Atomic::cmpxchg_ptr (w|LOCKBIT, Lock, w) == w) {
+ Self->OnList = 0; // hygiene - allows stronger asserts
return;
- }
- }
-
- Self->reset();
- Self->OnList = intptr_t(Lock);
- // The following fence() isn't _strictly necessary as the subsequent
- // CAS() both serializes execution and ratifies the fetched *Lock value.
- OrderAccess::fence();
- for (;;) {
- w = *Lock;
- if ((w & LOCKBIT) == 0) {
- if (Atomic::cmpxchg_ptr (w|LOCKBIT, Lock, w) == w) {
- Self->OnList = 0; // hygiene - allows stronger asserts
- return;
- }
- continue; // Interference -- *Lock changed -- Just retry
}
- assert(w & LOCKBIT, "invariant");
- Self->ListNext = (ParkEvent *) (w & ~LOCKBIT);
- if (Atomic::cmpxchg_ptr(intptr_t(Self)|LOCKBIT, Lock, w) == w) break;
- }
-
- while (Self->OnList != 0) {
- Self->park();
- }
+ continue; // Interference -- *Lock changed -- Just retry
+ }
+ assert(w & LOCKBIT, "invariant");
+ Self->ListNext = (ParkEvent *) (w & ~LOCKBIT);
+ if (Atomic::cmpxchg_ptr(intptr_t(Self)|LOCKBIT, Lock, w) == w) break;
+ }
+
+ while (Self->OnList != 0) {
+ Self->park();
+ }
}
}