207 } 208 209 #ifndef PRODUCT 210 // Overloaded versions for internal test. 211 juint AltHashing::murmur3_32(const jbyte* data, int len) { 212 return murmur3_32(0, data, len); 213 } 214 215 juint AltHashing::murmur3_32(const jchar* data, int len) { 216 return murmur3_32(0, data, len); 217 } 218 219 // Internal test for alternate hashing. Translated from JDK version 220 // test/sun/misc/Hashing.java 221 static const jbyte ONE_BYTE[] = { (jbyte) 0x80}; 222 static const jbyte TWO_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81}; 223 static const jchar ONE_CHAR[] = { (jchar) 0x8180}; 224 static const jbyte THREE_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82}; 225 static const jbyte FOUR_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, (jbyte) 0x83}; 226 static const jchar TWO_CHAR[] = { (jchar) 0x8180, (jchar) 0x8382}; 227 static const jint ONE_INT[] = { 0x83828180}; 228 static const jbyte SIX_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, (jbyte) 0x83, (jbyte) 0x84, (jbyte) 0x85}; 229 static const jchar THREE_CHAR[] = { (jchar) 0x8180, (jchar) 0x8382, (jchar) 0x8584}; 230 static const jbyte EIGHT_BYTE[] = { 231 (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, 232 (jbyte) 0x83, (jbyte) 0x84, (jbyte) 0x85, 233 (jbyte) 0x86, (jbyte) 0x87}; 234 static const jchar FOUR_CHAR[] = { 235 (jchar) 0x8180, (jchar) 0x8382, 236 (jchar) 0x8584, (jchar) 0x8786}; 237 238 static const jint TWO_INT[] = { 0x83828180, 0x87868584}; 239 240 static const juint MURMUR3_32_X86_CHECK_VALUE = 0xB0F57EE3; 241 242 void AltHashing::testMurmur3_32_ByteArray() { 243 // printf("testMurmur3_32_ByteArray\n"); 244 245 jbyte vector[256]; 246 jbyte hashes[4 * 256]; 247 248 for (int i = 0; i < 256; i++) { 249 vector[i] = (jbyte) i; 250 } 251 252 // Hash subranges {}, {0}, {0,1}, {0,1,2}, ..., {0,...,255} 253 for (int i = 0; i < 256; i++) { 254 juint hash = murmur3_32(256 - i, vector, i); 255 hashes[i * 4] = (jbyte) hash; 256 hashes[i * 4 + 1] = (jbyte)(hash >> 8); 257 hashes[i * 4 + 2] = (jbyte)(hash >> 16); 258 hashes[i * 4 + 3] = (jbyte)(hash >> 24); | 207 } 208 209 #ifndef PRODUCT 210 // Overloaded versions for internal test. 211 juint AltHashing::murmur3_32(const jbyte* data, int len) { 212 return murmur3_32(0, data, len); 213 } 214 215 juint AltHashing::murmur3_32(const jchar* data, int len) { 216 return murmur3_32(0, data, len); 217 } 218 219 // Internal test for alternate hashing. Translated from JDK version 220 // test/sun/misc/Hashing.java 221 static const jbyte ONE_BYTE[] = { (jbyte) 0x80}; 222 static const jbyte TWO_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81}; 223 static const jchar ONE_CHAR[] = { (jchar) 0x8180}; 224 static const jbyte THREE_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82}; 225 static const jbyte FOUR_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, (jbyte) 0x83}; 226 static const jchar TWO_CHAR[] = { (jchar) 0x8180, (jchar) 0x8382}; 227 static const jint ONE_INT[] = { (jint)0x83828180}; 228 static const jbyte SIX_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, (jbyte) 0x83, (jbyte) 0x84, (jbyte) 0x85}; 229 static const jchar THREE_CHAR[] = { (jchar) 0x8180, (jchar) 0x8382, (jchar) 0x8584}; 230 static const jbyte EIGHT_BYTE[] = { 231 (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, 232 (jbyte) 0x83, (jbyte) 0x84, (jbyte) 0x85, 233 (jbyte) 0x86, (jbyte) 0x87}; 234 static const jchar FOUR_CHAR[] = { 235 (jchar) 0x8180, (jchar) 0x8382, 236 (jchar) 0x8584, (jchar) 0x8786}; 237 238 static const jint TWO_INT[] = { (jint)0x83828180, (jint)0x87868584}; 239 240 static const juint MURMUR3_32_X86_CHECK_VALUE = 0xB0F57EE3; 241 242 void AltHashing::testMurmur3_32_ByteArray() { 243 // printf("testMurmur3_32_ByteArray\n"); 244 245 jbyte vector[256]; 246 jbyte hashes[4 * 256]; 247 248 for (int i = 0; i < 256; i++) { 249 vector[i] = (jbyte) i; 250 } 251 252 // Hash subranges {}, {0}, {0,1}, {0,1,2}, ..., {0,...,255} 253 for (int i = 0; i < 256; i++) { 254 juint hash = murmur3_32(256 - i, vector, i); 255 hashes[i * 4] = (jbyte) hash; 256 hashes[i * 4 + 1] = (jbyte)(hash >> 8); 257 hashes[i * 4 + 2] = (jbyte)(hash >> 16); 258 hashes[i * 4 + 3] = (jbyte)(hash >> 24); |