eregon / virtual-machines-research-graph

A Virtual Machine Research Overview as a Graph
https://eregon.github.io/virtual-machines-research-graph/
MIT License
25 stars 2 forks source link

A few more interpreter optimizations #3

Open mikaelpatel opened 4 years ago

mikaelpatel commented 4 years ago

First, thanks for putting together this reference material.

I would like to contribute with some additional threaded interpreter optimizations.

  1. Token mapping. Merge call into the inner interpreter.
  2. Tail call reduction. Call followed by return is reduced to jump.

I have implemented a number of threaded interpreters over the years. The latest for the Arduino community can be found at https://github.com/mikaelpatel/Arduino-FVM. It contains the above optimizations and some additional tricks. See section https://github.com/mikaelpatel/Arduino-FVM#optimizations

Cheers!

smarr commented 4 years ago

@mikaelpatel thanks. Do you have specific papers in mind? All entries are backed by academic work, and I think, it would be great to keep it that way.

mikaelpatel commented 4 years ago

@smarr Really liked that the graph are "clickable" with reference papers. There are "classics" on tail call optimization, https://en.wikipedia.org/wiki/Tail_call. I have not written up how FVM uses this. So I do not have a paper to contribute. Thought I would leave the selection of paper to you.

Adding nesting (eg forth colon/function call) to the inner interpreter by mapping of the token (or address) domain is a very old trick that I have previously used for modulization, http://soton.mpeforth.com/flag/jfar/vol4/no2/article27.pdf and https://www.worldcat.org/title/what-should-a-programming-environment-for-threaded-interpretive-languages-provide/oclc/020568221

Many of the ideas are from LISP and especially the INTERLISP-D programming environment.

Cheers!

mikaelpatel commented 4 years ago

Ref. https://github.com/ForthHub/discussion/issues/41

smarr commented 4 years ago

I am currently working on moving to a bibtex database to back these graphs.

If you would have bibtex entries, I'd be happy to integrate them here: https://github.com/eregon/virtual-machines-research-graph/pull/4