Tips for generating bytecode

Basic information is in Chapter 7 of the JVM Spec..

In this context, "compiler" = "JIT", and usually more specifically refers to the server (or final tier) JIT.

Getting solid performance measurements is surprisingly tricky. Take extra care with micro-benchmarks.

Constants

Low-level safety checks

Loops

Profiling

Profiling is performed at the bytecode level in the interpreter and tier one compiler. The compiler leans heavily on profile data to motivate optimistic optimizations.

Deoptimization

Deoptimization is the process of changing an optimized stack frame to an unoptimized one. With respect to compiled methods, it is also the process of throwing away code with invalid optimistic optimizations, and replacing it by less-optimized, more robust code. A method may in principle be deoptimized dozens of times.

Methods

Intrinsics

There are lots of intrinsic methods. See library_call.cpp and vmSymbols.hpp.

Miscellanous