Skip to content

Commit 4ea8e5b

Browse files
Remove duplicate CodeCache lookup operation in walkVM (async-profiler#1682)
1 parent 71ad47a commit 4ea8e5b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/stackWalker.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ int StackWalker::walkVM(void* ucontext, ASGCT_CallFrame* frames, int max_depth,
258258
}
259259
prev_sp = sp;
260260

261+
CodeCache* native_lib = NULL;
261262
if (CodeHeap::contains(pc)) {
262263
NMethod* nm = CodeHeap::findNMethod(pc);
263264
if (nm == NULL) {
@@ -403,7 +404,8 @@ int StackWalker::walkVM(void* ucontext, ASGCT_CallFrame* frames, int max_depth,
403404
}
404405
}
405406
} else {
406-
const char* method_name = profiler->findNativeMethod(pc);
407+
native_lib = profiler->findLibraryByAddress(pc);
408+
const char* method_name = native_lib != NULL ? native_lib->binarySearch(pc) : NULL;
407409
char mark;
408410
if (method_name != NULL && (mark = NativeFunc::mark(method_name)) != 0) {
409411
if (mark == MARK_ASYNC_PROFILER && (event_type == MALLOC_SAMPLE || event_type == NATIVE_LOCK_SAMPLE)) {
@@ -421,8 +423,7 @@ int StackWalker::walkVM(void* ucontext, ASGCT_CallFrame* frames, int max_depth,
421423
fillFrame(frames[depth++], BCI_NATIVE_FRAME, method_name);
422424
}
423425

424-
CodeCache* cc = profiler->findLibraryByAddress(pc);
425-
FrameDesc* f = cc != NULL ? cc->findFrameDesc(pc) : &FrameDesc::default_frame;
426+
FrameDesc* f = native_lib != NULL ? native_lib->findFrameDesc(pc) : &FrameDesc::default_frame;
426427

427428
u8 cfa_reg = (u8)f->cfa;
428429
int cfa_off = f->cfa >> 8;

0 commit comments

Comments
 (0)