8047104: cleanup misc issues prior to Contended Locking reorder and cache

Checkpoint misc cleanups for Contended Locking prior to first optimization bucket.

Reviewed-by: dholmes, sspitsyn, dice
This commit is contained in:
Daniel D. Daugherty 2014-07-03 11:07:51 -07:00
parent a145a396fc
commit 2876714328
16 changed files with 173 additions and 200 deletions

View file

@ -5457,22 +5457,12 @@ static struct timespec* compute_abstime(timespec* abstime, jlong millis) {
return abstime;
}
// Test-and-clear _Event, always leaves _Event set to 0, returns immediately.
// Conceptually TryPark() should be equivalent to park(0).
int os::PlatformEvent::TryPark() {
for (;;) {
const int v = _Event;
guarantee((v == 0) || (v == 1), "invariant");
if (Atomic::cmpxchg(0, &_Event, v) == v) return v;
}
}
void os::PlatformEvent::park() { // AKA "down()"
// Invariant: Only the thread associated with the Event/PlatformEvent
// may call park().
// TODO: assert that _Assoc != NULL or _Assoc == Self
assert(_nParked == 0, "invariant");
int v;
for (;;) {
v = _Event;
@ -5572,8 +5562,7 @@ void os::PlatformEvent::unpark() {
// 1 :=> 1
// -1 :=> either 0 or 1; must signal target thread
// That is, we can safely transition _Event from -1 to either
// 0 or 1. Forcing 1 is slightly more efficient for back-to-back
// unpark() calls.
// 0 or 1.
// See also: "Semaphores in Plan 9" by Mullender & Cox
//
// Note: Forcing a transition from "-1" to "1" on an unpark() means
@ -5801,10 +5790,9 @@ void Parker::park(bool isAbsolute, jlong time) {
}
void Parker::unpark() {
int s, status;
status = pthread_mutex_lock(_mutex);
int status = pthread_mutex_lock(_mutex);
assert(status == 0, "invariant");
s = _counter;
const int s = _counter;
_counter = 1;
if (s < 1) {
// thread might be parked