next up previous contents
Next: Interpreters Up: Related Work Previous: J-Machine

Dynamic Code Generation

  Usually, executable code is generated by a compiler before the executable is loaded and run. A technique called dynamic or runtime code generation, delays compilation until the executable is already running. For example, a function to perform a matrix multiply is not compiled into its final form until the sizes of the two matrices to be multiplied are known. The sizes can be expressed as constants in the arithmetic routine and the compiler can perform certain optimizations that would not be possible if the sizes were unknown and had to be expressed as variables. Even with the overhead of the compilation step at runtime, it is sometimes worthwhile to consider dynamic code generation, especially in the case when a function will be executed often, after it has been compiled once [46, , , , , , , , , ].

Inserting code at runtime into the kernel is a form of dynamic code generation. The application can manipulate the R-code image, or even compile a higher-level language into R-code, before it inserts the R-code image into the kernel. For example, a broadcast function could hard-code the destination nodes into the R-code image before it is inserted into the kernel. The image would be slightly different on each node, but would not have to do any computations to determine the destinations of a broadcast.



Rolf Riesen
Wed Jan 22 22:24:20 MST 1997