< prev index next >
src/share/vm/utilities/nativeCallStack.cpp
Print this page
rev 7899 : imported patch nmtfix
@@ -53,10 +53,11 @@
_stack[index] = pc[index];
}
for (; index < NMT_TrackingStackDepth; index ++) {
_stack[index] = NULL;
}
+ _hash_value = 0;
}
// number of stack frames captured
int NativeCallStack::frames() const {
int index;
@@ -67,23 +68,20 @@
}
return index;
}
// 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;
}
void NativeCallStack::print_on(outputStream* out) const {
< prev index next >