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