67 } |
68 } |
68 return index; |
69 return index; |
69 } |
70 } |
70 |
71 |
71 // Hash code. Any better algorithm? |
72 // Hash code. Any better algorithm? |
72 int NativeCallStack::hash() const { |
73 unsigned int NativeCallStack::hash() const { |
73 long hash_val = _hash_value; |
74 uintptr_t hash_val = _hash_value; |
74 if (hash_val == 0) { |
75 if (hash_val == 0) { |
75 long pc; |
76 for (int index = 0; index < NMT_TrackingStackDepth; index++) { |
76 int index; |
77 if (_stack[index] == NULL) break; |
77 for (index = 0; index < NMT_TrackingStackDepth; index ++) { |
78 hash_val += (uintptr_t)_stack[index]; |
78 pc = (long)_stack[index]; |
|
79 if (pc == 0) break; |
|
80 hash_val += pc; |
|
81 } |
79 } |
82 |
80 |
83 NativeCallStack* p = const_cast<NativeCallStack*>(this); |
81 NativeCallStack* p = const_cast<NativeCallStack*>(this); |
84 p->_hash_value = (int)(hash_val & 0xFFFFFFFF); |
82 p->_hash_value = (unsigned int)(hash_val & 0xFFFFFFFF); |
85 } |
83 } |
86 return _hash_value; |
84 return _hash_value; |
87 } |
85 } |
88 |
86 |
89 void NativeCallStack::print_on(outputStream* out) const { |
87 void NativeCallStack::print_on(outputStream* out) const { |