Minimal impl of Zinc Abstract Machine?

I’m trying (unsuccessfully) to read https://xavierleroy.org/publi/ZINC.pdf

I have implemented SECD machine - Wikipedia before.

I understand the SECD is expensive (in terms of heap usage) for currying, and the ZINC is supposed to solve this problem.

Is there a minimal/toy ZINC VM for a toy language somewhere? I’m looking for something that is just the VM part (no lexer, parser, type checker, codegen), and perferably < 1k LOC to read.

Thanks!

1 Like

I.e. something of the form:

  1. here is the struct/type that represents the full Zinc VM state

  2. here is an enum representing the set of Zinc VM instrs

  3. here are impls of (Zinc_VM_State, Instr) -> (Zinc_Vm_State)

You may be interested by https://cadmium.x9c.fr/distrib/caml-instructions.pdf (but note that this documents a more recent version of the VM, so there are a few differences with what is in the ZINC paper).

If you are comfortable with C, you can also take a look at the original Caml Light implementation (which should be rather close to what is described in the ZINC paper). The interpreter is < 1k LOC.

Cheers,
Nicolas

6 Likes