< prev index next >

src/hotspot/share/classfile/altHashing.cpp

Print this page

 38    worldwide. This software is distributed without any warranty.
 39 
 40    You should have received a copy of the CC0 Public Domain Dedication along
 41    with
 42    this software. If not, see
 43    <http://creativecommons.org/publicdomain/zero/1.0/>.
 44  */
 45 
 46 #include "classfile/altHashing.hpp"
 47 #include "classfile/vmClasses.hpp"
 48 #include "oops/klass.inline.hpp"
 49 #include "oops/markWord.hpp"
 50 #include "oops/oop.inline.hpp"
 51 #include "runtime/os.hpp"
 52 
 53 // Get the hash code of the classes mirror if it exists, otherwise just
 54 // return a random number, which is one of the possible hash code used for
 55 // objects.  We don't want to call the synchronizer hash code to install
 56 // this value because it may safepoint.
 57 static intptr_t object_hash(Klass* k) {



 58   intptr_t hc = k->java_mirror()->mark().hash();
 59   return hc != markWord::no_hash ? hc : os::random();
 60 }
 61 
 62 // Seed value used for each alternative hash calculated.
 63 uint64_t AltHashing::compute_seed() {
 64   uint64_t nanos = os::javaTimeNanos();
 65   uint64_t now = os::javaTimeMillis();
 66   uint32_t SEED_MATERIAL[8] = {
 67             (uint32_t) object_hash(vmClasses::String_klass()),
 68             (uint32_t) object_hash(vmClasses::System_klass()),
 69             (uint32_t) os::random(),  // current thread isn't a java thread
 70             (uint32_t) (((uint64_t)nanos) >> 32),
 71             (uint32_t) nanos,
 72             (uint32_t) (((uint64_t)now) >> 32),
 73             (uint32_t) now,
 74             (uint32_t) (os::javaTimeNanos() >> 2)
 75   };
 76 
 77   return halfsiphash_64(SEED_MATERIAL, 8);

 38    worldwide. This software is distributed without any warranty.
 39 
 40    You should have received a copy of the CC0 Public Domain Dedication along
 41    with
 42    this software. If not, see
 43    <http://creativecommons.org/publicdomain/zero/1.0/>.
 44  */
 45 
 46 #include "classfile/altHashing.hpp"
 47 #include "classfile/vmClasses.hpp"
 48 #include "oops/klass.inline.hpp"
 49 #include "oops/markWord.hpp"
 50 #include "oops/oop.inline.hpp"
 51 #include "runtime/os.hpp"
 52 
 53 // Get the hash code of the classes mirror if it exists, otherwise just
 54 // return a random number, which is one of the possible hash code used for
 55 // objects.  We don't want to call the synchronizer hash code to install
 56 // this value because it may safepoint.
 57 static intptr_t object_hash(Klass* k) {
 58   if (UseCompactObjectHeaders) {
 59     return os::random();
 60   }
 61   intptr_t hc = k->java_mirror()->mark().hash();
 62   return hc != markWord::no_hash ? hc : os::random();
 63 }
 64 
 65 // Seed value used for each alternative hash calculated.
 66 uint64_t AltHashing::compute_seed() {
 67   uint64_t nanos = os::javaTimeNanos();
 68   uint64_t now = os::javaTimeMillis();
 69   uint32_t SEED_MATERIAL[8] = {
 70             (uint32_t) object_hash(vmClasses::String_klass()),
 71             (uint32_t) object_hash(vmClasses::System_klass()),
 72             (uint32_t) os::random(),  // current thread isn't a java thread
 73             (uint32_t) (((uint64_t)nanos) >> 32),
 74             (uint32_t) nanos,
 75             (uint32_t) (((uint64_t)now) >> 32),
 76             (uint32_t) now,
 77             (uint32_t) (os::javaTimeNanos() >> 2)
 78   };
 79 
 80   return halfsiphash_64(SEED_MATERIAL, 8);
< prev index next >