-
Notifications
You must be signed in to change notification settings - Fork 937
Closed
Labels
Description
Describe the feature
Improve stack walking to account for the epilogue of JIT-compiled methods.
The epilogue of a compiled methods removes the top frame off the stack, performs a safepoint poll and returns. During execution of this sequence, stack pointer is incremented, and the invariant previous_sp = current_sp + frame_size no longer holds true. This results in stack unwinding failures when sampling hits the epilogue. StackWalker::walkVM needs to handle such situations to reduce the number of broken stacks with unknown frames.
The epilogue is different across various HotSpot versions.
x86
JDK 8
0x00007feaa1415030: add $0x40,%rsp
0x00007feaa1415034: pop %rbp
0x00007feaa1415035: test %eax,0x16ca8fc5(%rip) ; {poll_return}
0x00007feaa141503b: ret
JDK 11
0x00007cfe0d9c249a: add $0x40,%rsp
0x00007cfe0d9c249e: pop %rbp
0x00007cfe0d9c249f: mov 0x108(%r15),%r10
0x00007cfe0d9c24a6: test %eax,(%r10) ; {poll_return}
0x00007cfe0d9c24a9: ret
JDK 17-25
0x00007ceff427eb72: add $0x40,%rsp
0x00007ceff427eb76: pop %rbp
0x00007ceff427eb77: cmp 0x348(%r15),%rsp ; {poll_return}
0x00007ceff427eb7e: ja 0x00007ceff427ebcc
0x00007ceff427eb84: ret
Note: the size of cmp instruction can be either 4 bytes (cmp 0x28(%r15),%rsp) or 7 bytes (cmp 0x348(%r15),%rsp).
AArch64
JDK 8
0x0000ffff88247058: ldp x29, x30, [sp, #32]
0x0000ffff8824705c: add sp, sp, #0x30
0x0000ffff88247060: adrp x8, 0x0000ffff97b66000 ; {poll_return}
0x0000ffff88247064: ldr wzr, [x8] ; {poll_return}
0x0000ffff88247068: ret
JDK 11
0x0000ffff9fedb468: ldp x29, x30, [sp, #32]
0x0000ffff9fedb46c: add sp, sp, #0x30
0x0000ffff9fedb470: ldr x8, [x28, #264]
0x0000ffff9fedb474: ldr wzr, [x8] ; {poll_return}
0x0000ffff9fedb478: ret
JDK 17-25
0x0000ffffa940efa0: ldp x29, x30, [sp, #32]
0x0000ffffa940efa4: add sp, sp, #0x30
0x0000ffffa940efa8: ldr x8, [x28, #832] ; {poll_return}
0x0000ffffa940efac: cmp sp, x8
0x0000ffffa940efb0: b.hi 0x0000ffffa940efd4
0x0000ffffa940efb4: ret
Use Case
- Reduce the number of
unknownframes. - Fix sporadic failures of
recoverytests withcstack=vmoption.
Proposed Solution
Use pattern matching to detect the epilogue.
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change