/* * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
Copyright (c) 2012-2021 Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com> Copyright (c) 2012-2014 Daniel J. Bernstein <djb@cr.yp.to>
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
// Get the hash code of the classes mirror if it exists, otherwise just // return a random number, which is one of the possible hash code used for // objects. We don't want to call the synchronizer hash code to install // this value because it may safepoint. static intptr_t object_hash(Klass* k) {
intptr_t hc = k->java_mirror()->mark().hash(); return hc != markWord::no_hash ? hc : os::random();
}
// Seed value used for each alternative hash calculated.
uint64_t AltHashing::compute_seed() {
uint64_t nanos = os::javaTimeNanos();
uint64_t now = os::javaTimeMillis();
uint32_t SEED_MATERIAL[8] = {
(uint32_t) object_hash(vmClasses::String_klass()),
(uint32_t) object_hash(vmClasses::System_klass()),
(uint32_t) os::random(), // current thread isn't a java thread
(uint32_t) (((uint64_t)nanos) >> 32),
(uint32_t) nanos,
(uint32_t) (((uint64_t)now) >> 32),
(uint32_t) now,
(uint32_t) (os::javaTimeNanos() >> 2)
};
return halfsiphash_64(SEED_MATERIAL, 8);
}
// utility function copied from java/lang/Integer static uint32_t Integer_rotateLeft(uint32_t i, int distance) { return (i << distance) | (i >> (32 - distance));
}
if (count > 0) { switch (count) { case 3:
newdata |= (data[off + 2] & 0x0ff) << 16; // fall through case 2:
newdata |= (data[off + 1] & 0x0ff) << 8; // fall through case 1:
newdata |= (data[off] & 0x0ff); // fall through
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.