(OUTLINE) Interpreters Examples: Basic, Lisp FORTH -> Postscript Shell scripts, elisp, Tcl, Perl etc. Benefits: Simplicity, Portability, Fast turn-around. Cost: Execution speed Why are interpreters slow? Elements of cost per instruction: - Access arguments - Do function. - Dispatch (fetch,decode, and start) next instruction Goals in implementation: speed vs. portability. Target architecture very important (even if not directly exposed). - Register-rich? - Memory hierarchy? Costs of using underlying memory-based stack? Ideas for making dispatch cheaper: - threaded code (opcode = address) - inline jump to next code - problems doing this in portable way - building combined instructions - use stack architecture: no explicit args, so no decoding. (in addition: we can't index registers in real machine). - ultimately: inline code sequences (really a simple compiler) Ideas for making argument access cheaper: - specialize instructions based on common literal args - attempt register caching (static or dynamic). - dangers in state space (hence code) explosion. ----------------- Data Layout: Stack: Object instances: Arrays: Classes: Interfaces: