Compiler review… damn! (2015 March 06)

I have merged the master branch of Vicare into the branch wip-compiler-review, which is a work–in–progress review of the compiler. This merge was somewhat a fight: the code had diverged here and there and many things about the changes in wip-compiler-review have gone out of my mind. I should whip myself into being more organised in the way use branches.

Anyway, I should be somewhat happy of the work I have done on this branch: the code is better understandable, there is a lot more documentation–in–comments, the generated code is a bit better (nothing extraordinary, only a bit better). The thing is: the compiler is detectably slower, even on my Intel Core i5; building the boot image takes unbearably more time. I hate this.

There are three blocks of code that especially slow down boot image building:

  1. The greatly expanded table of primitives used to: validate the number of arguments to which core primitives are applied; replace safe primitives with unsafe primitives when the arguments have the correct type.
  2. The compiler library, which was already big before and now it is bigger.
  3. The expander library, which was already big before I started reorganising it and implementing the tagged language, and now it is bigger.

The compiler does a bit more, there a couple more passes, but, I guess, the true thing is that the compiler’s code does not scale well with the size of the source code. The situation is so bad that I do not want to merge back wip-compiler-review into master. I will have to do some code analysis and change some data representations; I will do it in one of the possible futures.