OpenJDK / jdk8u / jdk8u-dev / hotspot
changeset 8662:fc1c693e80bb
8069124: runtime/NMT/MallocSiteHashOverflow.java failing in nightlies
Reviewed-by: ctornqvi, coleenp, gtriantafill, dholmes
author | kevinw |
---|---|
date | Mon, 25 Jun 2018 07:59:51 -0700 |
parents | 0fa4c2b668b9 |
children | 6c864bb55b0b |
files | src/share/vm/services/mallocSiteTable.cpp src/share/vm/services/mallocSiteTable.hpp src/share/vm/utilities/nativeCallStack.cpp src/share/vm/utilities/nativeCallStack.hpp |
diffstat | 4 files changed, 12 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/vm/services/mallocSiteTable.cpp Fri Jun 22 01:55:23 2018 -0700 +++ b/src/share/vm/services/mallocSiteTable.cpp Mon Jun 25 07:59:51 2018 -0700 @@ -136,7 +136,7 @@ MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, size_t* bucket_idx, size_t* pos_idx, MEMFLAGS flags) { assert(flags != mtNone, "Should have a real memory type"); - int index = hash_to_index(key.hash()); + unsigned int index = hash_to_index(key.hash()); assert(index >= 0, "Negative index"); *bucket_idx = (size_t)index; *pos_idx = 0;
--- a/src/share/vm/services/mallocSiteTable.hpp Fri Jun 22 01:55:23 2018 -0700 +++ b/src/share/vm/services/mallocSiteTable.hpp Mon Jun 25 07:59:51 2018 -0700 @@ -245,8 +245,7 @@ static MallocSite* malloc_site(size_t bucket_idx, size_t pos_idx); static bool walk(MallocSiteWalker* walker); - static inline int hash_to_index(int hash) { - hash = (hash > 0) ? hash : (-hash); + static inline unsigned int hash_to_index(unsigned int hash) { return (hash % table_size); }
--- a/src/share/vm/utilities/nativeCallStack.cpp Fri Jun 22 01:55:23 2018 -0700 +++ b/src/share/vm/utilities/nativeCallStack.cpp Mon Jun 25 07:59:51 2018 -0700 @@ -55,6 +55,7 @@ for (; index < NMT_TrackingStackDepth; index ++) { _stack[index] = NULL; } + _hash_value = 0; } // number of stack frames captured @@ -69,19 +70,16 @@ } // Hash code. Any better algorithm? -int NativeCallStack::hash() const { - long hash_val = _hash_value; +unsigned int NativeCallStack::hash() const { + uintptr_t hash_val = _hash_value; if (hash_val == 0) { - long pc; - int index; - for (index = 0; index < NMT_TrackingStackDepth; index ++) { - pc = (long)_stack[index]; - if (pc == 0) break; - hash_val += pc; + for (int index = 0; index < NMT_TrackingStackDepth; index++) { + if (_stack[index] == NULL) break; + hash_val += (uintptr_t)_stack[index]; } NativeCallStack* p = const_cast<NativeCallStack*>(this); - p->_hash_value = (int)(hash_val & 0xFFFFFFFF); + p->_hash_value = (unsigned int)(hash_val & 0xFFFFFFFF); } return _hash_value; }
--- a/src/share/vm/utilities/nativeCallStack.hpp Fri Jun 22 01:55:23 2018 -0700 +++ b/src/share/vm/utilities/nativeCallStack.hpp Mon Jun 25 07:59:51 2018 -0700 @@ -56,8 +56,8 @@ static const NativeCallStack EMPTY_STACK; private: - address _stack[NMT_TrackingStackDepth]; - int _hash_value; + address _stack[NMT_TrackingStackDepth]; + unsigned int _hash_value; public: NativeCallStack(int toSkip = 0, bool fillStack = false); @@ -89,7 +89,7 @@ } // Hash code. Any better algorithm? - int hash() const; + unsigned int hash() const; void print_on(outputStream* out) const; void print_on(outputStream* out, int indent) const;