Runtime code generation in JVM and CLR

The Java Virtual Machine (JVM) and the Common Language Runtime (CLR) are bytecode-based abstract stack machines. Since modern implementations include highly optimizing just-in-time (JIT) compilers, these machines are excellent targets for runtime code generation: the generation of new program code just prior to its execution.

Here we present several complete examples of runtime code generation on these platforms. The purpose of this work is to investigate the suitability of these technologies that have recently entered the mainstream, and that can be expected to be widely available in the near future.

Further information about the examples, and results from experiments made with them, can be found here:

Useful resources

Overview of example programs

What is generatedC# versionJava version
A very simple methodRTCG1.cs 
A method with integer argument and,
Methods that contain loops, for
Specialized versions of the power,
Specialized evaluator for polynomialsRTCG5.cs 
Specialized evaluator for arithmetic expressionsRTCG6.cs 
Large methods, for timing of code,
Specialized sparse matrix
Specialized AES encryption/decryption routinesAesFast.cs, AesGen.cs 
Efficient delegate objects in Java,,

Peter Sestoft ( 2002-09-23, 2006-02-24