counter
static - 素人がプログラミングを勉強していたブログ
Big Sky :: Re: static - 素人がプログラミングを勉強するブログ
ベンチは面倒なので dis 結果だけ。
[print(RegExp(n+1)) & dis(x) & print() for([n, x] in Iterator([ function f(r)'i'in(r=/_/)?++r.i:r.i=0, (function g(s)function f()s++)(0), function (r)++(r=/_/).i||(r.i=0), function f(r)++f.i||(f.i=0), function f()f.i=f.i+1|0, function f()~(f.i=~-f.i), function()/_/.lastIndex++, ].map(function test(x){ if(x()!==0|x()!==1|x()!==2) throw x; return x })))]
/1/ flags: LAMBDA EXPR_CLOSURE INTERPRETED main: 00000: string "i" 00003: regexp null 00006: setarg 0 00009: group 00010: in 00011: ifeq 23 (12) 00014: getarg 0 00017: incprop "i" 00020: goto 30 (10) 00023: getarg 0 00026: zero 00027: setprop "i" 00030: return 00031: stop Source notes: 0: 11 [ 11] xdelta 1: 11 [ 0] cond offset 9 3: 17 [ 6] pcbase offset 3 5: 27 [ 10] xdelta 6: 27 [ 0] pcbase offset 4 /2/ flags: LAMBDA EXPR_CLOSURE INTERPRETED main: 00000: nameinc "s" 00003: return 00004: stop Source notes: /3/ flags: LAMBDA EXPR_CLOSURE INTERPRETED main: 00000: regexp null 00003: setarg 0 00006: group 00007: incprop "i" 00010: or 21 (11) 00013: getarg 0 00016: zero 00017: setprop "i" 00020: group 00021: return 00022: stop Source notes: 0: 7 [ 7] pcbase offset 7 2: 17 [ 10] xdelta 3: 17 [ 0] pcbase offset 4 /4/ flags: LAMBDA EXPR_CLOSURE INTERPRETED main: 00000: name "f" 00003: incprop "i" 00006: or 17 (11) 00009: name "f" 00012: zero 00013: setprop "i" 00016: group 00017: return 00018: stop Source notes: 0: 3 [ 3] pcbase offset 3 2: 13 [ 10] xdelta 3: 13 [ 0] pcbase offset 4 /5/ flags: LAMBDA EXPR_CLOSURE INTERPRETED main: 00000: name "f" 00003: name "f" 00006: getprop "i" 00009: one 00010: add 00011: zero 00012: bitor 00013: setprop "i" 00016: return 00017: stop Source notes: 0: 6 [ 6] pcbase offset 3 2: 13 [ 7] pcbase offset 13 /6/ flags: LAMBDA EXPR_CLOSURE INTERPRETED main: 00000: name "f" 00003: name "f" 00006: getprop "i" 00009: neg 00010: bitnot 00011: setprop "i" 00014: group 00015: bitnot 00016: return 00017: stop Source notes: 0: 6 [ 6] pcbase offset 3 2: 11 [ 5] pcbase offset 11 /7/ flags: LAMBDA EXPR_CLOSURE INTERPRETED main: 00000: regexp null 00003: propinc "lastIndex" 00006: return 00007: stop Source notes: 0: 3 [ 3] pcbase offset 3
ステップ数だけ見れば 2 > 7 > 5, 6 > 4 > 3 > 1 。
2 は 7 より一命令少ないけどスコープ登るからほとんど変わらないのかな。