What Lies Beneath
summary
A tiny Java program loads constant CafeBabe and 0xDEADBEEF, divides and calls add to produce 255, and the bytecode travels from javap view through a template interpreter to x86 where an elaborate integer.MIN_VALUE ÷ -1 check inflates the assembly. Removing the small add yields ~25% faster manually; letting the JIT inline and constant-fold drops runtime to about 2% of the original. Measurements use JMH with hardware counters via perf, and JITWatch exposes what the compiler actually emits.
AI-written summary · about
chapters (16)
- 0:00Intro
- 0:30Maurice Naftalin
- 1:05What Lies Beneath
- 3:30Java to Bytecode
- 11:06java ... -XX:+PrintInterpreter
- 17:03Improving Our Program...
- 20:15Without Inlining (-XX:-Inline)
- 22:51JIT Optimisations
- 25:23A Pile of Cache...
- 26:02The Memory Hierarchy
- 28:46Stride Prefetching
- 29:46Data-Dependent Loads
- 31:49Measuring Cache-Friendliness
- 34:41Primitive Array
- 37:18Conclusions
- 39:28Digging Deeper...
related talks
54mWhat Lies Beneath
47mWhat Lies Beneath
01h 07mFrom Java to Assembly: Down the Rabbit Hole
45mMinimal Values Under the Hood
46mJava vs CPU
44mJIT Me Baby One More Time
53mWell there's your problem! Your engine's missing! A look under Java's hood
53mFrom functional programming to assembly - the cost of abstractions....
