-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Hi there, I enjoyed reading Profiling and Optimizing an Interpreter: great points all the way!
Just thought I might share about a recent experiment of mine, wrt. AST-walking interpreters, that I dubbed "full linearization". You might want to give a shot at the implementation technique.
If that worked so nicely for C# as the implementation language, who knows, this might benefit Python, too.
Full linearization in LinearLisp
In a nutshell:
You collapse the whole AST in just a single big flat 1-dimension array, that your eval / apply evaluation core runs a cursor over.
All references to objects on the heap (formerly, nodes and children lists, attributes, etc) are now gone. The whole AST is now just an array of integers. Great for cache locality, and turns out, it indeed pays off...
Cheers!