2011-09-01から1ヶ月間の記事一覧

もうちょっとアセンブリを読んでサンクを知ろう。

hac::Int->Int hac a=a+1 とhac a=a+2 のアセンブリのdiffを確かめる。 ghc -S test.hs ghc -S test2.hsdiff test.s test2.hs29c29stg_INTLIKE_closure+137,0(%ebp) - > movl $stg_INTLIKE_closure+145,0(%ebp) ……137ってなに…? 145-137=8 2word分遠いポイ…

型シグニチャがあるなしで吐かれるアセンブリはどうかわるか?

hac a=a+1 と、 それに hac::Int->Int をつけたもので比べてみると、 rw-r--r-- 1 ioriveur ioriveur 2126 2011-09-22 19:02 test.s rw-r--r-- 1 ioriveur ioriveur 1176 2011-09-22 19:02 testint.s と、俄然短くなる。行数で比べると119と64の差である。 …

Haskellのインクリメント

Haskellでインクリメントする関数を書いてアセンブリを吐かせて読み取るも挫折. まずはホームグラウンドから. int yar(int a) { return a+1; } が .file "tester.c" .text .globl yar .type yar, @function yar: .LFB0: .cfi_startproc pushl %ebp .cfi_def_…