Wednesday, January 12, 2011

Revision 100

On December 16th, I checked the code into a new SVN repository. I had previously used CVS, but even for me some things are too old-fashioned.

And today, I committed revision 100. Some revisions are only 1 or 2 line bug fixes, others are dozens of added lines.

Major achievements since I last posted are:
  • exporting of meta data in the form of java annotations (for the Prelude with its many classes, types and instances some 8000 lines of annotations are written, which causes the compiler to spend  1 or 2 CPU seconds in the pretty printer alone)
  • import of the java compiled meta data from class files. This takes only a few milliseconds.
  • Type checker infers and validates class constraints more or less correct.
The day is not so far anymore when the first real java code line will be written! Up to now, it's only annotations followed by an empty placeholder class.

Incidentally, with revision 100 the compiler can parse and type check its own grammar, which is currently 35798 lines or  225832 tokens. This takes 90 seconds, which is quite long compared to 80 seconds with the old compiler especially when one takes into account that we have no strictness checking and code generation yet.

Apparently, the unoptimized monadic style has its costs. No wonder, as it is essentially a series of tail calls, which are currently implemented with two runtime functions tcLoop and tcGoto that throw and catch TailCallExceptions. It looks like the JIT can't do a very good job in the presence of exceptions.
Hopefully, the new code and runtime will be better suited for tail call intensive code.


  1. A potential performance trick when using exceptions for flow control is to throw a user-defined exception class which overrides fillInStackTrace to return "this".


  2. I used to go one step further and throwed pre-fabricated exception objects, thus eliminating the overhead of creating a new one each time.

    Note that this post is about the Frege2 runtime. Frege2 was the predecessor of the current Frege3, and had serios flaws both in the language and in the runtime.

    Nowadays, the parser parses itself in 7s (on the very same machine).


Comments will be censored by me as I see fit, most likely if they contain insults or propaganda for ideologies I do not like. Comments that are on topic will not be censored. If I leave a comment uncensored this does not imply that I agree with the opinions expressed therein.