2323#include < string.h>
2424#include < sys/syscall.h>
2525
26- #include " counters.h"
27- #include " tsc.h"
28-
2926#ifdef __APPLE__
3027#define REG (l, m ) _ucontext->uc_mcontext->__ss.__##m
3128#else
@@ -60,7 +57,6 @@ void StackFrame::ret() { pc() = link(); }
6057
6158bool StackFrame::unwindStub (instruction_t *entry, const char *name,
6259 uintptr_t &pc, uintptr_t &sp, uintptr_t &fp) {
63- const u64 startTime = TSC::ticks ();
6460 instruction_t *ip = (instruction_t *)pc;
6561 if (ip == entry || *ip == 0xd65f03c0 || strncmp (name, " itable" , 6 ) == 0 ||
6662 strncmp (name, " vtable" , 6 ) == 0 ||
@@ -71,12 +67,6 @@ bool StackFrame::unwindStub(instruction_t *entry, const char *name,
7167 strcmp (name, " atomic entry points" ) == 0 ||
7268 strcmp (name, " InlineCacheBuffer" ) == 0 ) {
7369 pc = link ();
74-
75- const u64 endTime = TSC::ticks ();
76- const u64 duration = TSC::ticks_to_millis (endTime - startTime);
77- if (duration > 1 ) {
78- Counters::increment (UNWINDING_TIME, duration);
79- }
8070 return true ;
8171 } else if (strcmp (name, " forward_copy_longs" ) == 0 ||
8272 strcmp (name, " backward_copy_longs" ) == 0
@@ -93,12 +83,6 @@ bool StackFrame::unwindStub(instruction_t *entry, const char *name,
9383 // When cstack=vm, unwind stub frames one by one
9484 pc = link ();
9585 }
96-
97- const u64 endTime = TSC::ticks ();
98- const u64 duration = TSC::ticks_to_millis (endTime - startTime);
99- if (duration > 1 ) {
100- Counters::increment (UNWINDING_TIME, duration);
101- }
10286 return true ;
10387 } else if (entry != NULL && entry[0 ] == 0xa9bf7bfd ) {
10488 // The stub begins with
@@ -107,44 +91,20 @@ bool StackFrame::unwindStub(instruction_t *entry, const char *name,
10791 if (ip == entry + 1 ) {
10892 sp += 16 ;
10993 pc = ((uintptr_t *)sp)[-1 ];
110-
111- const u64 endTime = TSC::ticks ();
112- const u64 duration = TSC::ticks_to_millis (endTime - startTime);
113- if (duration > 1 ) {
114- Counters::increment (UNWINDING_TIME, duration);
115- }
11694 return true ;
11795 } else if (entry[1 ] == 0x910003fd && withinCurrentStack (fp)) {
11896 sp = fp + 16 ;
11997 fp = ((uintptr_t *)sp)[-2 ];
12098 pc = ((uintptr_t *)sp)[-1 ];
121-
122- const u64 endTime = TSC::ticks ();
123- const u64 duration = TSC::ticks_to_millis (endTime - startTime);
124- if (duration > 1 ) {
125- Counters::increment (UNWINDING_TIME, duration);
126- }
12799 return true ;
128100 }
129101 } else if (strncmp (name, " indexof_linear_" , 15 ) == 0 &&
130102 entry != NULL && entry[0 ] == 0xa9be57f4 && entry[1 ] == 0xa9015ff6 ) {
131- // JDK-8189103: String.indexOf intrinsic.
132- // Entry and exit are covered by the very first 'if', in all other cases SP is 4 words off.
133- sp += 32 ;
134- pc = link ();
135-
136- const u64 endTime = TSC::ticks ();
137- const u64 duration = TSC::ticks_to_millis (endTime - startTime);
138- if (duration > 1 ) {
139- Counters::increment (UNWINDING_TIME, duration);
140- }
103+ // JDK-8189103: String.indexOf intrinsic.
104+ // Entry and exit are covered by the very first 'if', in all other cases SP is 4 words off.
105+ sp += 32 ;
106+ pc = link ();
141107 return true ;
142- }
143-
144- const u64 endTime = TSC::ticks ();
145- const u64 duration = TSC::ticks_to_millis (endTime - startTime);
146- if (duration > 1 ) {
147- Counters::increment (UNWINDING_TIME, duration);
148108 }
149109 return false ;
150110}
@@ -157,7 +117,6 @@ static inline bool isEntryBarrier(instruction_t *ip) {
157117
158118bool StackFrame::unwindCompiled (NMethod *nm, uintptr_t &pc, uintptr_t &sp,
159119 uintptr_t &fp) {
160- const u64 startTime = TSC::ticks ();
161120 instruction_t *ip = (instruction_t *)pc;
162121 instruction_t *entry = (instruction_t *)nm->entry ();
163122 if ((*ip & 0xffe07fff ) == 0xa9007bfd ) {
@@ -166,71 +125,34 @@ bool StackFrame::unwindCompiled(NMethod *nm, uintptr_t &pc, uintptr_t &sp,
166125 unsigned int offset = (*ip >> 12 ) & 0x1f8 ;
167126 sp += offset + 16 ;
168127 pc = link ();
169-
170- const u64 endTime = TSC::ticks ();
171- const u64 duration = TSC::ticks_to_millis (endTime - startTime);
172- if (duration > 1 ) {
173- Counters::increment (UNWINDING_TIME, duration);
174- }
175128 } else if (ip > entry && ip[0 ] == 0x910003fd && ip[-1 ] == 0xa9bf7bfd ) {
176129 // stp x29, x30, [sp, #-16]!
177130 // mov x29, sp
178131 sp += 16 ;
179132 pc = ((uintptr_t *)sp)[-1 ];
180-
181- const u64 endTime = TSC::ticks ();
182- const u64 duration = TSC::ticks_to_millis (endTime - startTime);
183- if (duration > 1 ) {
184- Counters::increment (UNWINDING_TIME, duration);
185- }
186133 } else if (ip > entry + 3 && !nm->isFrameCompleteAt (ip) &&
187134 (isEntryBarrier (ip) || isEntryBarrier (ip + 1 ))) {
188135 // Frame should be complete at this point
189136 sp += nm->frameSize () * sizeof (void *);
190137 fp = ((uintptr_t *)sp)[-2 ];
191138 pc = ((uintptr_t *)sp)[-1 ];
192-
193- const u64 endTime = TSC::ticks ();
194- const u64 duration = TSC::ticks_to_millis (endTime - startTime);
195- if (duration > 1 ) {
196- Counters::increment (UNWINDING_TIME, duration);
197- }
198139 } else {
199140 // Just try
200141 pc = link ();
201142 }
202-
203- const u64 endTime = TSC::ticks ();
204- const u64 duration = TSC::ticks_to_millis (endTime - startTime);
205- if (duration > 1 ) {
206- Counters::increment (UNWINDING_TIME, duration);
207- }
208143 return true ;
209144}
210145
211146bool StackFrame::unwindAtomicStub (const void *& pc) {
212147 // VM threads may call generated atomic stubs, which are not normally walkable
213- const u64 startTime = TSC::ticks ();
214148 const void * lr = (const void *)link ();
215149 if (VMStructs::libjvm ()->contains (lr)) {
216150 NMethod* nm = CodeHeap::findNMethod (pc);
217151 if (nm != NULL && strncmp (nm->name (), " Stub" , 4 ) == 0 ) {
218152 pc = lr;
219-
220- const u64 endTime = TSC::ticks ();
221- const u64 duration = TSC::ticks_to_millis (endTime - startTime);
222- if (duration > 1 ) {
223- Counters::increment (UNWINDING_TIME, duration);
224- }
225153 return true ;
226154 }
227155 }
228-
229- const u64 endTime = TSC::ticks ();
230- const u64 duration = TSC::ticks_to_millis (endTime - startTime);
231- if (duration > 1 ) {
232- Counters::increment (UNWINDING_TIME, duration);
233- }
234156 return false ;
235157}
236158
0 commit comments