Compiler interface

Compilation is handled through the joeq.Compiler.CompilerInterface interface. All compilers implement this interface.

Reference compiler

The reference compiler was designed to be as easy to get correct as possible. It generates code in an incredibly brain dead fashion. Each bytecode corresponds to a sequence of machine code instructions which correctly implements that bytecode.

Despite its simplicity, it does implement one advanced feature: code backpatching. This is to support dynamic loading and linking. At code generation time, the compiler does not know field offsets, vtable offsets, or addresses for references to unloaded or unresolved classes. When the compiler reaches one of these unknowns, it generates a call to a run time routine, which loads/resolves/initializes the class in question and backpatches the code to use the offset/address directly, then re-executes the newly patched code.

The backpatch mechanism is also used to reroute calls to newly dynamically compiled methods. When a call is made to an old copy of a method, a runtime routine backpatches the call to refer to the new copy.

The reference compiler is contained in The backpatch mechanism is contained in

Quad compiler

The Quad compiler is the primary compiler for advanced compilation and code analysis. Click here to find much more information on the Quad representation.