JIT

Designing JIT-friendly hot paths

Code shape matters when predictable execution depends on successful optimisation.

Keep hot paths legible to the compiler

Very large methods, unstable call sites, megamorphic dispatch and mixed exceptional behaviour make optimisation harder. The code may still compile, but not necessarily into the shape you expected.

Practical constraints

Measure the generated behaviour

Use JITWatch, compilation logs, perfasm and profiles under representative load. Source code is merely a suggestion submitted to several layers of machinery with opinions of their own.