38
39 if (fillStack) {
40 os::get_native_stack(_stack, NMT_TrackingStackDepth, toSkip);
41 } else {
42 for (int index = 0; index < NMT_TrackingStackDepth; index ++) {
43 _stack[index] = NULL;
44 }
45 }
46 }
47
48 NativeCallStack::NativeCallStack(address* pc, int frameCount) {
49 int frameToCopy = (frameCount < NMT_TrackingStackDepth) ?
50 frameCount : NMT_TrackingStackDepth;
51 int index;
52 for (index = 0; index < frameToCopy; index ++) {
53 _stack[index] = pc[index];
54 }
55 for (; index < NMT_TrackingStackDepth; index ++) {
56 _stack[index] = NULL;
57 }
58 }
59
60 // number of stack frames captured
61 int NativeCallStack::frames() const {
62 int index;
63 for (index = 0; index < NMT_TrackingStackDepth; index ++) {
64 if (_stack[index] == NULL) {
65 break;
66 }
67 }
68 return index;
69 }
70
71 // Hash code. Any better algorithm?
72 int NativeCallStack::hash() const {
73 long hash_val = _hash_value;
74 if (hash_val == 0) {
75 long pc;
76 int index;
77 for (index = 0; index < NMT_TrackingStackDepth; index ++) {
78 pc = (long)_stack[index];
79 if (pc == 0) break;
80 hash_val += pc;
81 }
82
83 NativeCallStack* p = const_cast<NativeCallStack*>(this);
84 p->_hash_value = (int)(hash_val & 0xFFFFFFFF);
85 }
86 return _hash_value;
87 }
88
89 void NativeCallStack::print_on(outputStream* out) const {
90 print_on(out, 0);
91 }
92
93 // Decode and print this call path
94 void NativeCallStack::print_on(outputStream* out, int indent) const {
95 address pc;
96 char buf[1024];
97 int offset;
98 if (is_empty()) {
99 for (int index = 0; index < indent; index ++) out->print(" ");
100 #if PLATFORM_NATIVE_STACK_WALKING_SUPPORTED
101 out->print("[BOOTSTRAP]");
102 #else
103 out->print("[No stack]");
104 #endif
|
38
39 if (fillStack) {
40 os::get_native_stack(_stack, NMT_TrackingStackDepth, toSkip);
41 } else {
42 for (int index = 0; index < NMT_TrackingStackDepth; index ++) {
43 _stack[index] = NULL;
44 }
45 }
46 }
47
48 NativeCallStack::NativeCallStack(address* pc, int frameCount) {
49 int frameToCopy = (frameCount < NMT_TrackingStackDepth) ?
50 frameCount : NMT_TrackingStackDepth;
51 int index;
52 for (index = 0; index < frameToCopy; index ++) {
53 _stack[index] = pc[index];
54 }
55 for (; index < NMT_TrackingStackDepth; index ++) {
56 _stack[index] = NULL;
57 }
58 _hash_value = 0;
59 }
60
61 // number of stack frames captured
62 int NativeCallStack::frames() const {
63 int index;
64 for (index = 0; index < NMT_TrackingStackDepth; index ++) {
65 if (_stack[index] == NULL) {
66 break;
67 }
68 }
69 return index;
70 }
71
72 // Hash code. Any better algorithm?
73 unsigned int NativeCallStack::hash() const {
74 long hash_val = _hash_value;
75 if (hash_val == 0) {
76 long pc;
77 int index;
78 for (index = 0; index < NMT_TrackingStackDepth; index ++) {
79 pc = (long)_stack[index];
80 if (pc == 0) break;
81 hash_val += pc;
82 }
83
84 NativeCallStack* p = const_cast<NativeCallStack*>(this);
85 p->_hash_value = (unsigned int)(hash_val & 0xFFFFFFFF);
86 }
87 return _hash_value;
88 }
89
90 void NativeCallStack::print_on(outputStream* out) const {
91 print_on(out, 0);
92 }
93
94 // Decode and print this call path
95 void NativeCallStack::print_on(outputStream* out, int indent) const {
96 address pc;
97 char buf[1024];
98 int offset;
99 if (is_empty()) {
100 for (int index = 0; index < indent; index ++) out->print(" ");
101 #if PLATFORM_NATIVE_STACK_WALKING_SUPPORTED
102 out->print("[BOOTSTRAP]");
103 #else
104 out->print("[No stack]");
105 #endif
|