VM::InstructionSequence.load のバグ

[email protected][email protected]$$$^$9!%e(B

e$B:rF|$Ne(BRejectRejectKaigie$B$GH/I=$7$?e(BVM::InstructionSequence.loade$B$N%P%0$rJse(B
e$B9p$7$^$9!%e(B

$ruby_custom -v
ruby 1.9.0 (2008-06-23 revision 16869) [x86_64-linux]

loade$B$GDj5A$7$?%a%=%C%I$r$KEO$k0z?t$,$:$l$F$$$^$9!%e(B

VM::InstructionSequence.load(
VM::InstructionSequence.compile(
def f(a,b,c);p(a,b,c);end
).to_a).eval
f(1,2,3)
2
3
nil
=> [2, 3, nil]

e$B$^$?!$e(Bloade$B$G%V%m%C%/$r;H$&$H%V%m%C%/$N0z?t$K$*[email protected]?t$,EO$j$^$9!%e(B

VM::InstructionSequence.load(
VM::InstructionSequence.compile(
[1,2,3].each{|x|p x}
).to_a).eval
70014636118636
70014636118636
70014636118636
=> [1, 2, 3]

e$B%o%J%Y$H?=$7$^$9!#e(B

2008/06/23 21:15 Shumpei A. [email protected]:

e$B:rF|$Ne(BRejectRejectKaigie$B$GH/I=$7$?e(BVM::InstructionSequence.loade$B$N%P%0$rJse(B
e$B9p$7$^$9!%e(B

VM::InstructionSequence.load e$B$J$s$F$"$k$s$G$9$M!#e(B
e$B%3%a%s%H%"%&%H$5$l$F$$$k<BAu$r;X$7$F%P%[email protected]$C$F$$$$$N$+$I$&$+J,$+$j$^$;$s$,e(B
[email protected]$5$s$N<($5$l$?%3!<%I$,F0$/$h$&$K$9$k$J$i$3$s$J46$8$G$7$g$&$+!#e(B

e$B<BAu$rFI$`$H!"e(Biseq e$B$O>o$Ke(B local_size == local_table_size + 1
e$B$N$h$&[email protected]$C$?$N$Ge(B
e$B$=$N$h$&$KJQ99$7$?$N$G$9$,!FI$_4V0c$($F$$$?$iITET9g$,$$k$+$b$7$l$^$;$s!#e(B

Index: compile.c

compile.c (revision 17547)
+++ compile.c (working copy)
@@ -4983,22 +4983,16 @@
VALUE exception, VALUE body)
{
int i;

  • int opt = 0;
    ID *tbl;
    struct st_table *labels_table = st_init_numtable();

    DECL_ANCHOR(anchor);

    INIT_ANCHOR(anchor);

  • if (iseq->type == ISEQ_TYPE_METHOD ||

  • iseq->type == ISEQ_TYPE_TOP ||

  • iseq->type == ISEQ_TYPE_CLASS) {

  • opt = 1;

  • }

  • iseq->local_table_size = opt + RARRAY_LEN(locals);

  • iseq->local_table_size = RARRAY_LEN(locals);
    iseq->local_table = tbl = (ID *)ALLOC_N(ID *,
    iseq->local_table_size);
  • iseq->local_size = opt + iseq->local_table_size;
  • iseq->local_size = iseq->local_table_size + 1;

    for (i=0; i<RARRAY_LEN(locals); i++) {
    VALUE lv = RARRAY_PTR(locals)[i];

[email protected]$G$9!%e(B

wanabe wrote:

VM::InstructionSequence.load e$B$J$s$F$"$k$s$G$9$M!#e(B
e$B%3%a%s%H%"%&%H$5$l$F$$$k<BAu$r;X$7$F%P%[email protected]$C$F$$$$$N$+$I$&$+J,$+$j$^$;$s$,e(B
[email protected]$5$s$N<($5$l$?%3!<%I$,F0$/$h$&$K$9$k$J$i$3$s$J46$8$G$7$g$&$+!#e(B

e$B!!%3%a%s%H%"%&%H$7$F$$$k$N$G!$%F%9%H$,$J$$$N$G!$B>$NJQ99$K$D$$$F$$$Je(B
e$B$$$s$G$9$M!%e(B

e$B<BAu$rFI$`$H!"e(Biseq e$B$O>o$Ke(B local_size == local_table_size + 1 e$B$N$h$&[email protected]$C$?$N$Ge(B
e$B$=$N$h$&$KJQ99$7$?$N$G$9$,!FI$_4V0c$($F$$$?$iITET9g$,$$k$+$b$7$l$^$;$s!#e(B

e$B!!:G6a!$$=$&JQ$o$j$^$7$?!%$3$l$G$h$$$h$&$J5$$,$9$k$s$G%3%_%C%H$7$F$$e(B
[email protected]$1$^$9$+!%e(B