Ravi Mohan's Blog

Saturday, June 17, 2006

[DevNote] Interpreter To Compiler

I generally use a wiki (moinmoin in case anyone is interested) on my laptop to keep notes on various projects I work on. However the wiki has not been transferred from my old laptop to my new one. With all the travellng I am doing, this won't get done till the next month or so. Meanwhile I'll use this blog to record (some of) my dev notes (when i can get net access ...sigh.....). Since Blogger doesn't support tagging or categories, I'll prepend a "[DevNote]" string to the title of the post so readers can ignore the post if they wish. These notes are likely to be cryptic and incoherent and most readers should just skip them.

To transform an interpreter to a compiler,

  1. Rewrite interpreter in CPS form.
  2. Identify Compile time and Runtime actions(CPAs and RTAs)
  3. Abstract RTAs into separate 'action procedures'.Use thunks to wrap any weird control structures where necessary
  4. Abstract Continuation Building procedures (CBPs)
  5. Convert RTAs and CBPs into records. Now the eval on the parse tree spits out a datastructure.
  6. Write an evaluator for the resulting data structure making sure to (a) implement register spilling (b) 'flatten' code to generate "assembly like" code.
  7. TODO : investigate the pros and cons of Bottom Up Rewriting Systems (BURS) vs the scheme above vs generating a (gcc) RTL like intermediate language
  8. TODO : investigate the effects on stack discipline and garbage collection when the various schemes are adopted . Which is more convenient?

No comments: