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
- separate cold validation and error construction from the hot path,
- keep call sites stable enough for useful profiling feedback,
- avoid accidental interface polymorphism inside tight loops,
- verify inlining and generated code rather than assuming it.
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.