5 Mar 2007 05:06
monomorphisation pass
I have added a monomorphisation pass to the optimisation process. This pass is currently done before inlining, and makes monomorphic clones of Felix functions, procedures, classes, and variables. Types other than classes, and primitives are not monomorphised. The main reason for doing all this is so that polymorphic calls to virtual functions of typeclasses become monomorphic which allows them to be instantiated, and subsequently inlined, so that there is zero performance penalty for using virtual functions. Strangely this didn't fix the dispatch to 'ge' in Takfp .. well not so strangely, since this was monomorphic anyhow. The reason is probably that the dispatch is an "apply_prim" which isn't considered for inlining. The actual intent is to do a round of polymorphic inlining first, THEN monomorphise, then do another round of inlining. The first round is mainly to reduce the total number of functions that the monomorphisation has to handle, the second round inlines virtual functions that couldn't be instantiated in the first round. This job took over a weak and uncovered numerous difficulties in the representation. By the far the most difficult issue in general is that the algebraic data types used by the compiler have invariants, and ones which change depending on the processing phase .. and these currently have to be 'remembered'.(Continue reading)
RSS Feed