-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Let's do actual work on https://docs.google.com/document/d/1Hvxf6NMPaCUd-1iqm_968SuHN1Vf8dLZQyHjvPyVE0Q/edit
There are currently a few Go
interpreters on the market:
llgoi
, a JIT-enabled interpreter built on top of LLVM andllgo
ssainterp
, an interpreter built on top ofgolang.org/x/tools/go/ssa
sbinet/go-eval
, a package salvaged from pre-Go1
- various REPLs that compile on the fly Go statements and execute them,
- etc...
The high-level view of this proposal is to describe a naive interactive interpreter for Go, loosely based on the design and implementation of Dis
[1], [2], the virtual machine of the Inferno OS.
Knowing Go
lineage, then, why not?
Dis
is a register-based interpreter.
It's not alone in the register-based space: one of the most known register-based VM is Lua. See: here and there for inspirations.
Alternatively, we could base the design on a stack-based VM such as CPython's.
See here and there for some inspirations.
Stack-based VMs are somewhat easier to implement but literature would seem to indicate register-based VMs are more performance friendly.
Working at the bytecode level, with program counters, instructions and frames, should allow us to reuse a fair amount of the cmd/compile
infrastructure of the official Go compiler, and to also provide a non-interactive interpreter (i.e.: interpreting whole programs.)
PS: design proposal is here: #2
PPS: additional reddit comments at https://www.reddit.com/r/golang/comments/4zu6bc/gointerpreter_design_proposal_of_a_vm_for_go
other VMs: