提交 c1942f3d 编写于 作者: K kevinw

8069124: runtime/NMT/MallocSiteHashOverflow.java failing in nightlies

Reviewed-by: ctornqvi, coleenp, gtriantafill, dholmes
上级 a5ed4e7f
...@@ -136,7 +136,7 @@ bool MallocSiteTable::walk(MallocSiteWalker* walker) { ...@@ -136,7 +136,7 @@ bool MallocSiteTable::walk(MallocSiteWalker* walker) {
MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, size_t* bucket_idx, MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, size_t* bucket_idx,
size_t* pos_idx, MEMFLAGS flags) { size_t* pos_idx, MEMFLAGS flags) {
assert(flags != mtNone, "Should have a real memory type"); 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"); assert(index >= 0, "Negative index");
*bucket_idx = (size_t)index; *bucket_idx = (size_t)index;
*pos_idx = 0; *pos_idx = 0;
......
...@@ -245,8 +245,7 @@ class MallocSiteTable : AllStatic { ...@@ -245,8 +245,7 @@ class MallocSiteTable : AllStatic {
static MallocSite* malloc_site(size_t bucket_idx, size_t pos_idx); static MallocSite* malloc_site(size_t bucket_idx, size_t pos_idx);
static bool walk(MallocSiteWalker* walker); static bool walk(MallocSiteWalker* walker);
static inline int hash_to_index(int hash) { static inline unsigned int hash_to_index(unsigned int hash) {
hash = (hash > 0) ? hash : (-hash);
return (hash % table_size); return (hash % table_size);
} }
......
...@@ -55,6 +55,7 @@ NativeCallStack::NativeCallStack(address* pc, int frameCount) { ...@@ -55,6 +55,7 @@ NativeCallStack::NativeCallStack(address* pc, int frameCount) {
for (; index < NMT_TrackingStackDepth; index ++) { for (; index < NMT_TrackingStackDepth; index ++) {
_stack[index] = NULL; _stack[index] = NULL;
} }
_hash_value = 0;
} }
// number of stack frames captured // number of stack frames captured
...@@ -69,19 +70,16 @@ int NativeCallStack::frames() const { ...@@ -69,19 +70,16 @@ int NativeCallStack::frames() const {
} }
// Hash code. Any better algorithm? // Hash code. Any better algorithm?
int NativeCallStack::hash() const { unsigned int NativeCallStack::hash() const {
long hash_val = _hash_value; uintptr_t hash_val = _hash_value;
if (hash_val == 0) { if (hash_val == 0) {
long pc; for (int index = 0; index < NMT_TrackingStackDepth; index++) {
int index; if (_stack[index] == NULL) break;
for (index = 0; index < NMT_TrackingStackDepth; index ++) { hash_val += (uintptr_t)_stack[index];
pc = (long)_stack[index];
if (pc == 0) break;
hash_val += pc;
} }
NativeCallStack* p = const_cast<NativeCallStack*>(this); NativeCallStack* p = const_cast<NativeCallStack*>(this);
p->_hash_value = (int)(hash_val & 0xFFFFFFFF); p->_hash_value = (unsigned int)(hash_val & 0xFFFFFFFF);
} }
return _hash_value; return _hash_value;
} }
......
...@@ -56,8 +56,8 @@ class NativeCallStack : public StackObj { ...@@ -56,8 +56,8 @@ class NativeCallStack : public StackObj {
static const NativeCallStack EMPTY_STACK; static const NativeCallStack EMPTY_STACK;
private: private:
address _stack[NMT_TrackingStackDepth]; address _stack[NMT_TrackingStackDepth];
int _hash_value; unsigned int _hash_value;
public: public:
NativeCallStack(int toSkip = 0, bool fillStack = false); NativeCallStack(int toSkip = 0, bool fillStack = false);
...@@ -89,7 +89,7 @@ class NativeCallStack : public StackObj { ...@@ -89,7 +89,7 @@ class NativeCallStack : public StackObj {
} }
// Hash code. Any better algorithm? // Hash code. Any better algorithm?
int hash() const; unsigned int hash() const;
void print_on(outputStream* out) const; void print_on(outputStream* out) const;
void print_on(outputStream* out, int indent) const; void print_on(outputStream* out, int indent) const;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册