< prev index next >

src/hotspot/share/runtime/synchronizer.cpp

Print this page

 885     value = 1;            // for sensitivity testing
 886   } else if (hashCode == 3) {
 887     value = ++GVars.hc_sequence;
 888   } else if (hashCode == 4) {
 889     value = cast_from_oop<intptr_t>(obj);
 890   } else {
 891     // Marsaglia's xor-shift scheme with thread-specific state
 892     // This is probably the best overall implementation -- we'll
 893     // likely make this the default in future releases.
 894     unsigned t = current->_hashStateX;
 895     t ^= (t << 11);
 896     current->_hashStateX = current->_hashStateY;
 897     current->_hashStateY = current->_hashStateZ;
 898     current->_hashStateZ = current->_hashStateW;
 899     unsigned v = current->_hashStateW;
 900     v = (v ^ (v >> 19)) ^ (t ^ (t >> 8));
 901     current->_hashStateW = v;
 902     value = v;
 903   }
 904 
 905   value &= markWord::hash_mask;
 906   if (value == 0) value = 0xBAD;
 907   assert(value != markWord::no_hash, "invariant");
 908   return value;
 909 }
 910 
 911 // Can be called from non JavaThreads (e.g., VMThread) for FastHashCode
 912 // calculations as part of JVM/TI tagging.
 913 static bool is_lock_owned(Thread* thread, oop obj) {
 914   assert(LockingMode == LM_LIGHTWEIGHT, "only call this with new lightweight locking enabled");
 915   return thread->is_Java_thread() ? JavaThread::cast(thread)->lock_stack().contains(obj) : false;
 916 }
 917 
 918 intptr_t ObjectSynchronizer::FastHashCode(Thread* current, oop obj) {
 919 
 920   while (true) {
 921     ObjectMonitor* monitor = nullptr;
 922     markWord temp, test;
 923     intptr_t hash;
 924     markWord mark = read_stable_mark(obj);
 925     if (VerifyHeavyMonitors) {

 885     value = 1;            // for sensitivity testing
 886   } else if (hashCode == 3) {
 887     value = ++GVars.hc_sequence;
 888   } else if (hashCode == 4) {
 889     value = cast_from_oop<intptr_t>(obj);
 890   } else {
 891     // Marsaglia's xor-shift scheme with thread-specific state
 892     // This is probably the best overall implementation -- we'll
 893     // likely make this the default in future releases.
 894     unsigned t = current->_hashStateX;
 895     t ^= (t << 11);
 896     current->_hashStateX = current->_hashStateY;
 897     current->_hashStateY = current->_hashStateZ;
 898     current->_hashStateZ = current->_hashStateW;
 899     unsigned v = current->_hashStateW;
 900     v = (v ^ (v >> 19)) ^ (t ^ (t >> 8));
 901     current->_hashStateW = v;
 902     value = v;
 903   }
 904 
 905   value &= UseCompactObjectHeaders ? markWord::hash_mask_compact : markWord::hash_mask;
 906   if (value == 0) value = 0xBAD;
 907   assert(value != markWord::no_hash, "invariant");
 908   return value;
 909 }
 910 
 911 // Can be called from non JavaThreads (e.g., VMThread) for FastHashCode
 912 // calculations as part of JVM/TI tagging.
 913 static bool is_lock_owned(Thread* thread, oop obj) {
 914   assert(LockingMode == LM_LIGHTWEIGHT, "only call this with new lightweight locking enabled");
 915   return thread->is_Java_thread() ? JavaThread::cast(thread)->lock_stack().contains(obj) : false;
 916 }
 917 
 918 intptr_t ObjectSynchronizer::FastHashCode(Thread* current, oop obj) {
 919 
 920   while (true) {
 921     ObjectMonitor* monitor = nullptr;
 922     markWord temp, test;
 923     intptr_t hash;
 924     markWord mark = read_stable_mark(obj);
 925     if (VerifyHeavyMonitors) {
< prev index next >