1.1 --- a/src/share/vm/classfile/altHashing.hpp Sat Oct 24 16:18:50 2020 +0800 1.2 +++ b/src/share/vm/classfile/altHashing.hpp Sat Oct 24 16:43:47 2020 +0800 1.3 @@ -26,37 +26,30 @@ 1.4 #define SHARE_VM_CLASSFILE_ALTHASHING_HPP 1.5 1.6 #include "prims/jni.h" 1.7 -#include "classfile/symbolTable.hpp" 1.8 +#include "memory/allocation.hpp" 1.9 1.10 /** 1.11 - * Hashing utilities. 1.12 - * 1.13 - * Implementation of Murmur3 hashing. 1.14 - * This code was translated from src/share/classes/sun/misc/Hashing.java 1.15 - * code in the JDK. 1.16 + * Implementation of alternate more secure hashing. 1.17 */ 1.18 1.19 class AltHashing : AllStatic { 1.20 1.21 - // utility function copied from java/lang/Integer 1.22 - static juint Integer_rotateLeft(juint i, int distance) { 1.23 - return (i << distance) | (i >> (32-distance)); 1.24 - } 1.25 - static juint murmur3_32(const int* data, int len); 1.26 - static juint murmur3_32(juint seed, const int* data, int len); 1.27 + // For the seed computation 1.28 + static uint64_t halfsiphash_64(const uint32_t* data, int len); 1.29 + static uint64_t halfsiphash_64(uint64_t seed, const uint32_t* data, int len); 1.30 + #ifndef PRODUCT 1.31 + // Hashing functions used for internal testing 1.32 + static void testHalfsiphash_32_ByteArray(); 1.33 + static void testHalfsiphash_32_CharArray(); 1.34 + static void testHalfsiphash_64_FromReference(); 1.35 + #endif // PRODUCT 1.36 + public: 1.37 + static uint64_t compute_seed(); 1.38 1.39 -#ifndef PRODUCT 1.40 - // Hashing functions used for internal testing 1.41 - static juint murmur3_32(const jbyte* data, int len); 1.42 - static juint murmur3_32(const jchar* data, int len); 1.43 - static void testMurmur3_32_ByteArray(); 1.44 - static void testEquivalentHashes(); 1.45 -#endif // PRODUCT 1.46 - 1.47 - public: 1.48 - static juint compute_seed(); 1.49 - static juint murmur3_32(juint seed, const jbyte* data, int len); 1.50 - static juint murmur3_32(juint seed, const jchar* data, int len); 1.51 + // For Symbols 1.52 + static uint32_t halfsiphash_32(uint64_t seed, const uint8_t* data, int len); 1.53 + // For Strings 1.54 + static uint32_t halfsiphash_32(uint64_t seed, const uint16_t* data, int len); 1.55 NOT_PRODUCT(static void test_alt_hash();) 1.56 }; 1.57 #endif // SHARE_VM_CLASSFILE_ALTHASHING_HPP