Notes on debugging HotSpot's JIT compilation (2023)

  • I don't really see why:

      public class TestJIT {
        public static void main(String[] args) {
            for (int i = 0; i < 20_000; i++) {
                payload();
            }
        }
    
        public static int payload(int a, int b) {
            return a + b;
        }
      }
    
    shouldn't be optimized into a 'no-op'. The end-effect is the same.

  • Excellent. Next time I’ll have something to refer to when making memes like this one: https://twitter.com/_saagarjha/status/1576961522936340480. Maybe I can avoid building OpenJDK too!

  • Some self-advertising of a linux tool I made which can display perf record data with Java JIT disassembly (doesn't need hsdis): https://github.com/dzaima/grr?tab=readme-ov-file#java-jit