gauche 0.8.14

つい先日バージョンアップしたばかりだったけど、せっかくなので 0.8.14 に追随。
先日作ったばっかりの表を新しいバージョンでも試してみた(http://d.hatena.ne.jp/cranebird/20081005/1223169496)。
以下パス1,2,3の出力には compile-p1, compile-p2, compile-p3 を使用している。

ざっと表を見比べてみると少しだけだけどバージョン間での違いが見つかった。

(if #t 12 13)
;; pass 1, 2 までは 0.8.13, 0.8.14 とも同じ
($if ($const #t)
  ($const 12)
  ($const 13))
;; pass3 0.8.13
main_code (name=%toplevel, code=0x577c60, size=8, const=0, stack=0):
args: #f
     0 CONST #t
     2 BF 6                     ; (if #t 12 13)
     4 CONSTI(12) 
     5 RET 
     6 CONSTI(13) 
     7 RET 
;; pass3 0.8.14
main_code (name=%toplevel, code=0x74db38, size=2, const=0, stack=0):
args: #f
     0 CONSTI(12) 
     1 RET 
(if #t
 (if 12 13 4) 17)
;; => pass1, 2
($if ($const #t)
  ($if ($const 12)
    ($const 13)
    ($const 4))
  ($const 17))
;; => pass3 0.8.13
main_code (name=%toplevel, code=0xb8e00, size=13, const=0, stack=0):
args: #f
     0 CONST #t
     2 BF 11                    ; (if #t (if 12 13 4) 17)
     4 CONSTI(12) 
     5 BF 9                     ; (if 12 13 4)
     7 CONSTI(13) 
     8 RET 
     9 CONSTI(4) 
    10 RET 
    11 CONSTI(17) 
    12 RET

;; => pass3 0.8.14
main_code (name=%toplevel, code=0x74daf8, size=2, const=0, stack=0):
args: #f
     0 CONSTI(13) 
     1 RET

他は (and 1 2) みたいなのも 0.8.14 では定数になっているようだ。ほほう。
ここらへんが VM の改良と関係あるのかしら。ソースをばりばり読めればそこに書いているのだろうけど。
もっと大量にテストデータ作っておけば他にも差が分かったかもしれないなぁ、惜しいことをした。

※上の違いが意味のある違いかどうかは未確認。まだ gaucheコンパイラをちゃんと読んでいない。見た目は違うけど実行される際は実は一緒、という可能性あり。

追記。ChangeLog にあるこれかな?src/compile.scm を読み解くにはまだ時間がかかるけど、データから辿り着いた(らしい)というのはなんとなく嬉しい。

2008-07-28 Shiro Kawai

* src/compile.scm (pack-iform): Fixed a bug handling $RECEIVE node.
(pass3/branch-core): Added an optimization to cut the unreachable
branch of $if. Such $if may occur as a result of macro expansion.