Version 3 (modified by ehuelsmann, 13 years ago) (diff)


Compilation phases

The compiler makes 3 passes for a full compilation:

  • precompile (applies to both the compiler and interpreter)
  • p1
  • p2

The precompiler

The precompiler does a number of source code transforms which are semantically equal, in order to reduce the number of permutations the compiler should accomodate for. By no means the list below is limitative, but these are the ones I found so far:

  • expansion of multiple SETF pairs into separate SETF statements
  • the same for SETQ
  • expansion of lambda expressions in the operator position into explicit FUNCALLs

Compilation phase 1: p1

Honestly, I have no idea what the difference is between p1 and p2, except for what is specified below.

Compilation phase 2: p2

This phase creates the compilation output.

It does this by:

  1. Creating java byte code
  2. Analyzing the byte code, deleting unused branches (jvm.lisp::OPTIMIZE-CODE)
  3. Optimize byte code by walking the byte codes, replacing inefficient sequences with more efficient ones
  4. Writing out a file according to the format specified for .class files

It's unclear to me whether this is a single '.cls' file or that this applies to a full file compile.