Heart Surgery: HotSpot Debugging at the OS Level
summary
Builds a debug OpenJDK locally in minutes and uses native tools to inspect HotSpot: enabling 1,300 VM options, running count bytecodes: ~3 million on a tiny HelloWorld, and using GDB plus HotSpot helpers like print_native_stack (PNS) and a breakpoint callback to get mixed Java/native stacks. Shows a real JIT bug: C2 emits an ADD with a 32‑bit immediate that wraps a 64‑bit constant for an AtomicLong, and the fix is a change in the AD file and a rebuild that eliminates the wrong zeroed add.
AI-written summary · about
chapters (10)
- 0:00Introduction
- 1:00Building OpenJDK from source
- 4:50Debugging HotSpot with GDB
- 12:30Template interpreter internals
- 20:50Debugging generated code
- 32:50JIT compiler and tiered compilation
- 37:50Debugging JIT-compiled code
- 42:40Fixing the atomic long bug
- 53:20Print opto assembly analysis
- 57:30Fixing the AD file and rebuilding
