RFR: 8266642: improve ResolvedMethodTable hash function [v6]

Denghui Dong ddong at openjdk.java.net
Fri May 14 12:04:56 UTC 2021


On Fri, 14 May 2021 10:02:31 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:

>> Denghui Dong has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   use ClassLoaderData* as factor
>
> What about the following variant?
> 
> 
> diff --git a/src/hotspot/share/classfile/classLoaderData.hpp b/src/hotspot/share/classfile/classLoaderData.hpp
> index 6fd5b9b8203..f1f1c82f591 100644
> --- a/src/hotspot/share/classfile/classLoaderData.hpp
> +++ b/src/hotspot/share/classfile/classLoaderData.hpp
> @@ -325,6 +325,11 @@ class ClassLoaderData : public CHeapObj<mtClass> {
>    const char* loader_name_and_id() const;
>    Symbol* name_and_id() const { return _name_and_id; }
>  
> +  unsigned identity_hash() const {
> +    unsigned addr_bits = (unsigned)((uintptr_t)this >> (LogMinObjAlignmentInBytes + 3));
> +    return addr_bits;
> +  }
> +
>    JFR_ONLY(DEFINE_TRACE_ID_METHODS;)
>  };
>  
> diff --git a/src/hotspot/share/prims/resolvedMethodTable.cpp b/src/hotspot/share/prims/resolvedMethodTable.cpp
> index 5e5761094f1..527a39f3646 100644
> --- a/src/hotspot/share/prims/resolvedMethodTable.cpp
> +++ b/src/hotspot/share/prims/resolvedMethodTable.cpp
> @@ -23,6 +23,7 @@
>   */
>  
>  #include "precompiled.hpp"
> +#include "classfile/classLoaderData.hpp"
>  #include "classfile/javaClasses.hpp"
>  #include "gc/shared/oopStorage.inline.hpp"
>  #include "gc/shared/oopStorageSet.hpp"
> @@ -53,7 +54,8 @@ static const size_t GROW_HINT = 32;
>  static const size_t ResolvedMethodTableSizeLog = 10;
>  
>  unsigned int method_hash(const Method* method) {
> -  unsigned int hash = method->klass_name()->identity_hash();
> +  unsigned int hash = method->method_holder()->class_loader_data()->identity_hash();
> +  hash = (hash * 31) ^ method->klass_name()->identity_hash();
>    hash = (hash * 31) ^ method->name()->identity_hash();
>    hash = (hash * 31) ^ method->signature()->identity_hash();
>    return hash;

@iwanowww 
It's okay for me, updated.

Thanks

-------------

PR: https://git.openjdk.java.net/jdk/pull/3901


More information about the hotspot-runtime-dev mailing list