coleenp@3865: /* minqi@6351: * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. coleenp@3865: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. coleenp@3865: * coleenp@3865: * This code is free software; you can redistribute it and/or modify it coleenp@3865: * under the terms of the GNU General Public License version 2 only, as coleenp@3865: * published by the Free Software Foundation. coleenp@3865: * coleenp@3865: * This code is distributed in the hope that it will be useful, but WITHOUT coleenp@3865: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or coleenp@3865: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License coleenp@3865: * version 2 for more details (a copy is included in the LICENSE file that coleenp@3865: * accompanied this code). coleenp@3865: * coleenp@3865: * You should have received a copy of the GNU General Public License version coleenp@3865: * 2 along with this work; if not, write to the Free Software Foundation, coleenp@3865: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. coleenp@3865: * coleenp@3865: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA coleenp@3865: * or visit www.oracle.com if you need additional information or have any coleenp@3865: * questions. coleenp@3865: * coleenp@3865: */ coleenp@3865: coleenp@3865: #ifndef SHARE_VM_CLASSFILE_ALTHASHING_HPP coleenp@3865: #define SHARE_VM_CLASSFILE_ALTHASHING_HPP coleenp@3865: coleenp@3865: #include "prims/jni.h" coleenp@3865: #include "classfile/symbolTable.hpp" coleenp@3865: coleenp@3865: /** coleenp@3865: * Hashing utilities. coleenp@3865: * coleenp@3865: * Implementation of Murmur3 hashing. coleenp@3865: * This code was translated from src/share/classes/sun/misc/Hashing.java coleenp@3865: * code in the JDK. coleenp@3865: */ coleenp@3865: coleenp@3865: class AltHashing : AllStatic { coleenp@3865: coleenp@3865: // utility function copied from java/lang/Integer minqi@6351: static juint Integer_rotateLeft(juint i, int distance) { minqi@6351: return (i << distance) | (i >> (32-distance)); coleenp@3865: } minqi@6351: static juint murmur3_32(const int* data, int len); minqi@6351: static juint murmur3_32(juint seed, const int* data, int len); coleenp@3865: coleenp@3865: #ifndef PRODUCT coleenp@3865: // Hashing functions used for internal testing minqi@6351: static juint murmur3_32(const jbyte* data, int len); minqi@6351: static juint murmur3_32(const jchar* data, int len); coleenp@3865: static void testMurmur3_32_ByteArray(); coleenp@3865: static void testEquivalentHashes(); coleenp@3865: #endif // PRODUCT coleenp@3865: coleenp@3865: public: minqi@6351: static juint compute_seed(); minqi@6351: static juint murmur3_32(juint seed, const jbyte* data, int len); minqi@6351: static juint murmur3_32(juint seed, const jchar* data, int len); coleenp@3865: NOT_PRODUCT(static void test_alt_hash();) coleenp@3865: }; coleenp@3865: #endif // SHARE_VM_CLASSFILE_ALTHASHING_HPP