;; TAIL-CALL(NARGS) ;; Call procedure in val0. Same as CALL except this discards the ;; caller's arugment frame and shift the callee's argument frame. ;;
関数の末尾呼び出しのために使われ、環境フレームを完成させる前に不要なフレームの削除を行う。
未使用?
不要な環境フレームの破棄と引数フレームの処理を行うtail_call_entryと、通常のCALL処理に分かれる。
src/vm.c 810 CASE(SCM_VM_TAIL_CALL) { ... 818 tail_call_entry: ... 841 } 842 /* FALLTHROUGH */ 843 CASE(SCM_VM_CALL) { ... 1016 }
ここではtail_call_entryの部分のみ取り上げる。CALLの処理はGauche:YAGHG:VM:Insn:CALLを参照。
BEFORE AFTER +=========+ +=========+ : : : : cont ---->+=========+ cont ---->+=========+ | | | | | C#0 | | C#0 | | | | | +=========+ argp ---->+=========+ : : | arg#1 | env ---->+=========+ +---------+ | | : : | E#0 | +---------+ | | | arg#N | +=========+ sp ---->+---------+ : : | | argp ---->+---------+ | | | arg#1 | +---------+ : : env ----> NULL +---------+ | arg#N | sp ---->+---------+ | | | |
(compile-p3 '(gensym)) 0 GREF-TAIL-CALL(0) #<identifier user#gensym>; (gensym) 2 RET