< prev index next >

src/hotspot/share/runtime/synchronizer.cpp

Print this page

 975     value = 1;            // for sensitivity testing
 976   } else if (hashCode == 3) {
 977     value = ++GVars.hc_sequence;
 978   } else if (hashCode == 4) {
 979     value = cast_from_oop<intptr_t>(obj);
 980   } else {
 981     // Marsaglia's xor-shift scheme with thread-specific state
 982     // This is probably the best overall implementation -- we'll
 983     // likely make this the default in future releases.
 984     unsigned t = current->_hashStateX;
 985     t ^= (t << 11);
 986     current->_hashStateX = current->_hashStateY;
 987     current->_hashStateY = current->_hashStateZ;
 988     current->_hashStateZ = current->_hashStateW;
 989     unsigned v = current->_hashStateW;
 990     v = (v ^ (v >> 19)) ^ (t ^ (t >> 8));
 991     current->_hashStateW = v;
 992     value = v;
 993   }
 994 
 995   value &= markWord::hash_mask;
 996   if (value == 0) value = 0xBAD;
 997   assert(value != markWord::no_hash, "invariant");
 998   return value;
 999 }
1000 
1001 intptr_t ObjectSynchronizer::FastHashCode(Thread* current, oop obj) {
1002 
1003   while (true) {
1004     ObjectMonitor* monitor = nullptr;
1005     markWord temp, test;
1006     intptr_t hash;
1007     markWord mark = read_stable_mark(obj);
1008     if (VerifyHeavyMonitors) {
1009       assert(LockingMode == LM_MONITOR, "+VerifyHeavyMonitors requires LockingMode == 0 (LM_MONITOR)");
1010       guarantee((obj->mark().value() & markWord::lock_mask_in_place) != markWord::locked_value, "must not be lightweight/stack-locked");
1011     }
1012     if (mark.is_neutral() || (LockingMode == LM_LIGHTWEIGHT && mark.is_fast_locked())) {
1013       hash = mark.hash();
1014       if (hash != 0) {                     // if it has a hash, just return it
1015         return hash;

 975     value = 1;            // for sensitivity testing
 976   } else if (hashCode == 3) {
 977     value = ++GVars.hc_sequence;
 978   } else if (hashCode == 4) {
 979     value = cast_from_oop<intptr_t>(obj);
 980   } else {
 981     // Marsaglia's xor-shift scheme with thread-specific state
 982     // This is probably the best overall implementation -- we'll
 983     // likely make this the default in future releases.
 984     unsigned t = current->_hashStateX;
 985     t ^= (t << 11);
 986     current->_hashStateX = current->_hashStateY;
 987     current->_hashStateY = current->_hashStateZ;
 988     current->_hashStateZ = current->_hashStateW;
 989     unsigned v = current->_hashStateW;
 990     v = (v ^ (v >> 19)) ^ (t ^ (t >> 8));
 991     current->_hashStateW = v;
 992     value = v;
 993   }
 994 
 995   value &= UseCompactObjectHeaders ? markWord::hash_mask_compact : markWord::hash_mask;
 996   if (value == 0) value = 0xBAD;
 997   assert(value != markWord::no_hash, "invariant");
 998   return value;
 999 }
1000 
1001 intptr_t ObjectSynchronizer::FastHashCode(Thread* current, oop obj) {
1002 
1003   while (true) {
1004     ObjectMonitor* monitor = nullptr;
1005     markWord temp, test;
1006     intptr_t hash;
1007     markWord mark = read_stable_mark(obj);
1008     if (VerifyHeavyMonitors) {
1009       assert(LockingMode == LM_MONITOR, "+VerifyHeavyMonitors requires LockingMode == 0 (LM_MONITOR)");
1010       guarantee((obj->mark().value() & markWord::lock_mask_in_place) != markWord::locked_value, "must not be lightweight/stack-locked");
1011     }
1012     if (mark.is_neutral() || (LockingMode == LM_LIGHTWEIGHT && mark.is_fast_locked())) {
1013       hash = mark.hash();
1014       if (hash != 0) {                     // if it has a hash, just return it
1015         return hash;
< prev index next >