Open4

関数型言語向けの抽象機械

だめぽだめぽ

SECD機械

Modern SECD機械

D (dump)がない。環境の参照に名前ではなくde Bruijn indexを使う。

FAM (The Functional Abstract Machine)

The instructions of the machine are not supposed to be interpreted, but assembled into machine code and then executed.

とある。

状態:Argument Pointer, Frame Pointer, Stack Pointer, Trap Pointer, Program Counter, Environment Pointer

クロージャーに関する操作:Closure, DumClosure, RecClosure, GetGlobal, GetLiteral, FunId, FunComp

関数呼び出し:SaveFrame, ApplFrame, RestFrame, TailApply

CAM (The Categorical Abstract Machine)

状態:Term, Code, Stack

2要素版:Stack, Code

主な命令:fst, snd, push, swap, cons, app, cur (curry), quote

ZINC

Caml Lightを経てOCamlになるやつ。

カリー化と部分適用が効率的らしい。

Spineless Tagless G-machine

非正格な言語向け。

GHCで使われていたやつ。なお今のGHCにはtagがあるほか、push/enterからeval/applyに代わっている。

CEK Machine

control, environment, continuation

だめぽだめぽ

論文メモ

だめぽだめぽ

要件

ソース言語:Standard ML

  • 末尾呼び出しの最適化(TCO)が必須
  • 副作用(可変な参照セルと配列、例外)がある
  • 評価順は左から右
  • 複数引数はタプルで表現する;カリー化と部分適用はそこまで重要視しない
  • LunarMLの拡張として、マルチショットな限定継続も実装したい
だめぽだめぽ

各種処理系のVM

Gauche

Poly/ML

Chibi-Scheme

Emacs Lisp

CLISP