Mercurial > hg > graal-compiler
comparison src/share/vm/classfile/altHashing.hpp @ 14340:cd6b3f1a94ff
8033792: AltHashing used jint for imprecise bit shifting
Summary: AltHashing used jint the way of juint in bit shifting which could lead loss of precision. Fix by change _seed defined as juint.
Reviewed-by: coleenp, ccheung
Contributed-by: yumin.qi@oracle.com
author | minqi |
---|---|
date | Mon, 10 Feb 2014 21:29:14 -0800 |
parents | e9140bf80b4a |
children | 4ca6dc0799b6 |
comparison
equal
deleted
inserted
replaced
14339:9bfa5faf122e | 14340:cd6b3f1a94ff |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
37 */ | 37 */ |
38 | 38 |
39 class AltHashing : AllStatic { | 39 class AltHashing : AllStatic { |
40 | 40 |
41 // utility function copied from java/lang/Integer | 41 // utility function copied from java/lang/Integer |
42 static jint Integer_rotateLeft(jint i, int distance) { | 42 static juint Integer_rotateLeft(juint i, int distance) { |
43 return (i << distance) | (((juint)i) >> (32-distance)); | 43 return (i << distance) | (i >> (32-distance)); |
44 } | 44 } |
45 static jint murmur3_32(const int* data, int len); | 45 static juint murmur3_32(const int* data, int len); |
46 static jint murmur3_32(jint seed, const int* data, int len); | 46 static juint murmur3_32(juint seed, const int* data, int len); |
47 | 47 |
48 #ifndef PRODUCT | 48 #ifndef PRODUCT |
49 // Hashing functions used for internal testing | 49 // Hashing functions used for internal testing |
50 static jint murmur3_32(const jbyte* data, int len); | 50 static juint murmur3_32(const jbyte* data, int len); |
51 static jint murmur3_32(const jchar* data, int len); | 51 static juint murmur3_32(const jchar* data, int len); |
52 static void testMurmur3_32_ByteArray(); | 52 static void testMurmur3_32_ByteArray(); |
53 static void testEquivalentHashes(); | 53 static void testEquivalentHashes(); |
54 #endif // PRODUCT | 54 #endif // PRODUCT |
55 | 55 |
56 public: | 56 public: |
57 static jint compute_seed(); | 57 static juint compute_seed(); |
58 static jint murmur3_32(jint seed, const jbyte* data, int len); | 58 static juint murmur3_32(juint seed, const jbyte* data, int len); |
59 static jint murmur3_32(jint seed, const jchar* data, int len); | 59 static juint murmur3_32(juint seed, const jchar* data, int len); |
60 NOT_PRODUCT(static void test_alt_hash();) | 60 NOT_PRODUCT(static void test_alt_hash();) |
61 }; | 61 }; |
62 #endif // SHARE_VM_CLASSFILE_ALTHASHING_HPP | 62 #endif // SHARE_VM_CLASSFILE_ALTHASHING_HPP |