src/share/vm/utilities/nativeCallStack.cpp

changeset 9337
fc1c693e80bb
parent 7078
c6211b707068
child 9485
7a6239517d46
equal deleted inserted replaced
9336:0fa4c2b668b9 9337:fc1c693e80bb
53 _stack[index] = pc[index]; 53 _stack[index] = pc[index];
54 } 54 }
55 for (; index < NMT_TrackingStackDepth; index ++) { 55 for (; index < NMT_TrackingStackDepth; index ++) {
56 _stack[index] = NULL; 56 _stack[index] = NULL;
57 } 57 }
58 _hash_value = 0;
58 } 59 }
59 60
60 // number of stack frames captured 61 // number of stack frames captured
61 int NativeCallStack::frames() const { 62 int NativeCallStack::frames() const {
62 int index; 63 int index;
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 {

mercurial