Skip to content

Commit dc69cf4

Browse files
authored
Unwind AArch64 generated stubs on JDK 26+ (async-profiler#1684)
1 parent abc8b7f commit dc69cf4

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

src/profiler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ void Profiler::addJavaMethod(const void* address, int length, jmethodID method)
117117
}
118118

119119
void Profiler::addRuntimeStub(const void* address, int length, const char* name) {
120+
if (name[0] == 'S' && strncmp(name, "Stub Generator ", 15) == 0) {
121+
name += 15; // useless prefix introduced with JDK-8336658
122+
}
123+
120124
_stubs_lock.lock();
121125
_runtime_stubs.add(address, length, name, true);
122126
_stubs_lock.unlock();

src/stackFrame_aarch64.cpp

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -107,32 +107,32 @@ static inline bool isZeroSizeFrame(const char* name) {
107107
return strncmp(name, "atomic", 6) == 0;
108108
case 'b':
109109
return strncmp(name, "bigInteger", 10) == 0
110-
|| strcmp(name, "base64_encodeBlock") == 0;
110+
|| strncmp(name, "base64_encodeBlock", 18) == 0
111+
|| strcmp(name, "backward_copy_longs") == 0;
111112
case 'c':
112113
return strncmp(name, "copy_", 5) == 0
113114
|| strncmp(name, "compare_long_string_", 20) == 0;
114115
case 'e':
115116
return strcmp(name, "encodeBlock") == 0;
116117
case 'f':
117-
return strcmp(name, "f2hf") == 0;
118+
return strncmp(name, "f2hf", 4) == 0
119+
|| strcmp(name, "forward_copy_longs") == 0
120+
|| strcmp(name, "foward_copy_longs") == 0; // there is a typo in JDK 8
118121
case 'g':
119-
return strcmp(name, "ghash_processBlocks") == 0;
122+
return strncmp(name, "ghash_processBlocks", 19) == 0 && strchr(name + 19, 'w') == NULL;
120123
case 'h':
121-
return strcmp(name, "hf2f") == 0;
124+
return strncmp(name, "hf2f", 4) == 0;
122125
case 'i':
123126
return strncmp(name, "itable", 6) == 0;
124127
case 'l':
125-
return strcmp(name, "large_byte_array_inflate") == 0
128+
return strncmp(name, "large_byte_array_inflate", 24) == 0
126129
|| strncmp(name, "lookup_secondary_supers_", 24) == 0;
127130
case 'm':
128131
return strncmp(name, "md5_implCompress", 16) == 0;
129132
case 's':
130-
return strncmp(name, "sha1_implCompress", 17) == 0
131-
|| strncmp(name, "compare_long_string_same_encoding", 33) == 0
132-
|| strcmp(name, "compare_long_string_LL") == 0
133-
|| strcmp(name, "compare_long_string_UU") == 0;
133+
return strncmp(name, "sha1_implCompress", 17) == 0;
134134
case 'u':
135-
return strcmp(name, "updateBytesAdler32") == 0;
135+
return strncmp(name, "updateBytesAdler32", 18) == 0;
136136
case 'v':
137137
return strncmp(name, "vtable", 6) == 0;
138138
case 'z':
@@ -172,21 +172,6 @@ bool StackFrame::unwindStub(instruction_t* entry, const char* name, uintptr_t& p
172172
// Should be done after isSTP check, since frame size may vary between JVM versions
173173
pc = link();
174174
return true;
175-
} else if (strcmp(name, "forward_copy_longs") == 0
176-
|| strcmp(name, "backward_copy_longs") == 0
177-
// There is a typo in JDK 8
178-
|| strcmp(name, "foward_copy_longs") == 0) {
179-
// These are called from arraycopy stub that maintains the regular frame link
180-
if (&pc == &this->pc() && withinCurrentStack(fp)) {
181-
// Unwind both stub frames for AsyncGetCallTrace
182-
sp = fp + 16;
183-
fp = ((uintptr_t*)sp)[-2];
184-
pc = ((uintptr_t*)sp)[-1] - sizeof(instruction_t);
185-
} else {
186-
// When cstack=vm, unwind stub frames one by one
187-
pc = link();
188-
}
189-
return true;
190175
}
191176
return false;
192177
}

0 commit comments

Comments
 (0)