8244777: ClassLoaderStats VM Op uses constant hash value

Thu, 14 May 2020 08:48:36 +0200

author
stuefe
date
Thu, 14 May 2020 08:48:36 +0200
changeset 9918
1848821ee85d
parent 9917
60ba2af705dc
child 9919
e8a0af9fc1cb

8244777: ClassLoaderStats VM Op uses constant hash value
Reviewed-by: coleenp, jbachorik

src/share/vm/classfile/classLoaderStats.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/classfile/classLoaderStats.hpp	Tue May 19 05:11:26 2020 +0100
     1.2 +++ b/src/share/vm/classfile/classLoaderStats.hpp	Thu May 14 08:48:36 2020 +0200
     1.3 @@ -101,8 +101,17 @@
     1.4    }
     1.5  
     1.6    static unsigned oop_hash(oop const& s1) {
     1.7 -    unsigned hash = (unsigned)((uintptr_t)&s1);
     1.8 -    return hash ^ (hash >> LogMinObjAlignment);
     1.9 +    // Robert Jenkins 1996 & Thomas Wang 1997
    1.10 +    // http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
    1.11 +    uintptr_t tmp = cast_from_oop<uintptr_t>(s1);
    1.12 +    unsigned hash = (unsigned)tmp;
    1.13 +    hash = ~hash + (hash << 15);
    1.14 +    hash = hash ^ (hash >> 12);
    1.15 +    hash = hash + (hash << 2);
    1.16 +    hash = hash ^ (hash >> 4);
    1.17 +    hash = hash * 2057;
    1.18 +    hash = hash ^ (hash >> 16);
    1.19 +    return hash;
    1.20    }
    1.21  
    1.22    typedef ResourceHashtable<oop, ClassLoaderStats*,

mercurial