comparison src/share/vm/runtime/mutex.cpp @ 14909:4ca6dc0799b6

Backout jdk9 merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 01 Apr 2014 13:57:07 +0200
parents c86519f8d826
children 51c6ce89d4dd
comparison
equal deleted inserted replaced
14908:8db6e76cb658 14909:4ca6dc0799b6
1 1
2 /* 2 /*
3 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * 5 *
6 * This code is free software; you can redistribute it and/or modify it 6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as 7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
278 x ^= ((unsigned)x) >> 21; 278 x ^= ((unsigned)x) >> 21;
279 x ^= x << 7 ; 279 x ^= x << 7 ;
280 return x & 0x7FFFFFFF ; 280 return x & 0x7FFFFFFF ;
281 } 281 }
282 282
283 static inline jint MarsagliaXOR (jint * const a) {
284 jint x = *a ;
285 if (x == 0) x = UNS(a)|1 ;
286 x ^= x << 6;
287 x ^= ((unsigned)x) >> 21;
288 x ^= x << 7 ;
289 *a = x ;
290 return x & 0x7FFFFFFF ;
291 }
292
283 static int Stall (int its) { 293 static int Stall (int its) {
284 static volatile jint rv = 1 ; 294 static volatile jint rv = 1 ;
285 volatile int OnFrame = 0 ; 295 volatile int OnFrame = 0 ;
286 jint v = rv ^ UNS(OnFrame) ; 296 jint v = rv ^ UNS(OnFrame) ;
287 while (--its >= 0) { 297 while (--its >= 0) {
495 505
496 assert (_OnDeck == ESelf, "invariant") ; 506 assert (_OnDeck == ESelf, "invariant") ;
497 _OnDeck = NULL ; 507 _OnDeck = NULL ;
498 508
499 // Note that we current drop the inner lock (clear OnDeck) in the slow-path 509 // Note that we current drop the inner lock (clear OnDeck) in the slow-path
500 // epilogue immediately after having acquired the outer lock. 510 // epilog immediately after having acquired the outer lock.
501 // But instead we could consider the following optimizations: 511 // But instead we could consider the following optimizations:
502 // A. Shift or defer dropping the inner lock until the subsequent IUnlock() operation. 512 // A. Shift or defer dropping the inner lock until the subsequent IUnlock() operation.
503 // This might avoid potential reacquisition of the inner lock in IUlock(). 513 // This might avoid potential reacquisition of the inner lock in IUlock().
504 // B. While still holding the inner lock, attempt to opportunistically select 514 // B. While still holding the inner lock, attempt to opportunistically select
505 // and unlink the next ONDECK thread from the EntryList. 515 // and unlink the next ONDECK thread from the EntryList.
919 // Try a brief spin to avoid passing thru thread state transition ... 929 // Try a brief spin to avoid passing thru thread state transition ...
920 if (TrySpin (Self)) goto Exeunt ; 930 if (TrySpin (Self)) goto Exeunt ;
921 931
922 check_block_state(Self); 932 check_block_state(Self);
923 if (Self->is_Java_thread()) { 933 if (Self->is_Java_thread()) {
924 // Horrible dictu - we suffer through a state transition 934 // Horribile dictu - we suffer through a state transition
925 assert(rank() > Mutex::special, "Potential deadlock with special or lesser rank mutex"); 935 assert(rank() > Mutex::special, "Potential deadlock with special or lesser rank mutex");
926 ThreadBlockInVM tbivm ((JavaThread *) Self) ; 936 ThreadBlockInVM tbivm ((JavaThread *) Self) ;
927 ILock (Self) ; 937 ILock (Self) ;
928 } else { 938 } else {
929 // Mirabile dictu 939 // Mirabile dictu
951 void Monitor::lock_without_safepoint_check () { 961 void Monitor::lock_without_safepoint_check () {
952 lock_without_safepoint_check (Thread::current()) ; 962 lock_without_safepoint_check (Thread::current()) ;
953 } 963 }
954 964
955 965
956 // Returns true if thread succeeds in grabbing the lock, otherwise false. 966 // Returns true if thread succeceed [sic] in grabbing the lock, otherwise false.
957 967
958 bool Monitor::try_lock() { 968 bool Monitor::try_lock() {
959 Thread * const Self = Thread::current(); 969 Thread * const Self = Thread::current();
960 debug_only(check_prelock_state(Self)); 970 debug_only(check_prelock_state(Self));
961 // assert(!thread->is_inside_signal_handler(), "don't lock inside signal handler"); 971 // assert(!thread->is_inside_signal_handler(), "don't lock inside signal handler");