# HG changeset patch # User ctornqvi # Date 1424814798 18000 # Tue Feb 24 16:53:18 2015 -0500 # Node ID bc5193ac968161711722f6696151c66ca588d7f4 # Parent 301c5b48a95ad810b67ba4b88df7b08a5375be36 [mq]: nmtfix diff --git a/src/share/vm/services/mallocSiteTable.cpp b/src/share/vm/services/mallocSiteTable.cpp --- a/src/share/vm/services/mallocSiteTable.cpp +++ b/src/share/vm/services/mallocSiteTable.cpp @@ -135,8 +135,7 @@ */ MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, size_t* bucket_idx, size_t* pos_idx) { - int index = hash_to_index(key.hash()); - assert(index >= 0, err_msg("Negative index %d", index)); + unsigned int index = hash_to_index(key.hash()); *bucket_idx = (size_t)index; *pos_idx = 0; diff --git a/src/share/vm/services/mallocSiteTable.hpp b/src/share/vm/services/mallocSiteTable.hpp --- a/src/share/vm/services/mallocSiteTable.hpp +++ b/src/share/vm/services/mallocSiteTable.hpp @@ -238,8 +238,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); } diff --git a/src/share/vm/utilities/nativeCallStack.cpp b/src/share/vm/utilities/nativeCallStack.cpp --- a/src/share/vm/utilities/nativeCallStack.cpp +++ b/src/share/vm/utilities/nativeCallStack.cpp @@ -55,6 +55,7 @@ for (; index < NMT_TrackingStackDepth; index ++) { _stack[index] = NULL; } + _hash_value = 0; } // number of stack frames captured @@ -69,7 +70,7 @@ } // Hash code. Any better algorithm? -int NativeCallStack::hash() const { +unsigned int NativeCallStack::hash() const { long hash_val = _hash_value; if (hash_val == 0) { long pc; @@ -81,7 +82,7 @@ } NativeCallStack* p = const_cast(this); - p->_hash_value = (int)(hash_val & 0xFFFFFFFF); + p->_hash_value = (unsigned int)(hash_val & 0xFFFFFFFF); } return _hash_value; } diff --git a/src/share/vm/utilities/nativeCallStack.hpp b/src/share/vm/utilities/nativeCallStack.hpp --- a/src/share/vm/utilities/nativeCallStack.hpp +++ b/src/share/vm/utilities/nativeCallStack.hpp @@ -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;