FEXPRs vs. vtable: how LispE interpreter works

17 points by Claudius


matheusmoreira

Deeply interesting. LispE is a nice contrast to the usual dynamic type-switching evaluator. Self-evaluating trees was quite elegant as a solution, looks like the object-oriented approach was a really good fit.

As a C programmer, I'm squarely in the evals[] camp since there is no language level dynamic dispatch. This is further complicated by the fact my lisp does expose FEXPRs at the language level, and even makes modular FEXPRs out of things usually inlined in the evaluator, such as if. My evals[] is actually just the normal variable resolution mechanism.

I'm definitely converging towards something that resembles vtables, though. I'm halfway towards implementing shapes for the hash table type, and I've also learned how inline caches work. The final item needed to truly bind these two together is bytecode compilation. I attempted to implement caches and specialized object representations twice now, and was surprised both times by performance regressions, because the deoptimization checks are too expensive without inlining them into bytecode. The tree walking interpreter has become the performance wall.

As for the opaqueness of FEXPRs, I'm hoping that future work on a partial evaluator can work around the issue by pre-evaluating most if not all of the FEXPRs. Languages truly are a lifetime of work...