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 "precompiled.hpp"
47 #include "classfile/altHashing.hpp"
48 #include "classfile/vmClasses.hpp"
49 #include "oops/klass.inline.hpp"
50 #include "oops/markWord.hpp"
51 #include "oops/oop.inline.hpp"
52 #include "runtime/os.hpp"
53
54 // Get the hash code of the classes mirror if it exists, otherwise just
55 // return a random number, which is one of the possible hash code used for
56 // objects. We don't want to call the synchronizer hash code to install
57 // this value because it may safepoint.
58 static intptr_t object_hash(Klass* k) {
59 intptr_t hc = k->java_mirror()->mark().hash();
60 return hc != markWord::no_hash ? hc : os::random();
61 }
62
63 // Seed value used for each alternative hash calculated.
64 uint64_t AltHashing::compute_seed() {
65 uint64_t nanos = os::javaTimeNanos();
66 uint64_t now = os::javaTimeMillis();
67 uint32_t SEED_MATERIAL[8] = {
68 (uint32_t) object_hash(vmClasses::String_klass()),
69 (uint32_t) object_hash(vmClasses::System_klass()),
70 (uint32_t) os::random(), // current thread isn't a java thread
71 (uint32_t) (((uint64_t)nanos) >> 32),
72 (uint32_t) nanos,
73 (uint32_t) (((uint64_t)now) >> 32),
74 (uint32_t) now,
75 (uint32_t) (os::javaTimeNanos() >> 2)
76 };
77
78 return halfsiphash_64(SEED_MATERIAL, 8);
|
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 "precompiled.hpp"
47 #include "classfile/altHashing.hpp"
48 #include "classfile/vmClasses.hpp"
49 #include "oops/klass.inline.hpp"
50 #include "oops/markWord.hpp"
51 #include "oops/oop.inline.hpp"
52 #include "runtime/os.hpp"
53
54 // Get the hash code of the classes mirror if it exists, otherwise just
55 // return a random number, which is one of the possible hash code used for
56 // objects. We don't want to call the synchronizer hash code to install
57 // this value because it may safepoint.
58 static intptr_t object_hash(Klass* k) {
59 if (UseCompactObjectHeaders) {
60 return os::random();
61 }
62 intptr_t hc = k->java_mirror()->mark().hash();
63 return hc != markWord::no_hash ? hc : os::random();
64 }
65
66 // Seed value used for each alternative hash calculated.
67 uint64_t AltHashing::compute_seed() {
68 uint64_t nanos = os::javaTimeNanos();
69 uint64_t now = os::javaTimeMillis();
70 uint32_t SEED_MATERIAL[8] = {
71 (uint32_t) object_hash(vmClasses::String_klass()),
72 (uint32_t) object_hash(vmClasses::System_klass()),
73 (uint32_t) os::random(), // current thread isn't a java thread
74 (uint32_t) (((uint64_t)nanos) >> 32),
75 (uint32_t) nanos,
76 (uint32_t) (((uint64_t)now) >> 32),
77 (uint32_t) now,
78 (uint32_t) (os::javaTimeNanos() >> 2)
79 };
80
81 return halfsiphash_64(SEED_MATERIAL, 8);
|