Patch for

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

Fiber e$B$N%H%C%W%U%l!<%`$Ke(B ISeq e$B$r2C$($k%Q%C%A$r=q$-$^$7$?!#e(B
e$B$D$$$G$J$N$Ge(B Thread e$B$bF1MM$K$7$^$7$?!#e(B
test_knownbug.rb e$B$Ne(B [ruby-dev:34128]
e$B$H$"$k%F%9%H$,DL$k$h$&$K$J$j$^$9!#e(B

e$B%P%C%/%H%l!<%9BP:v$Ge(B iseq->filename e$B$Ke(B nil
e$B$rF~$l$F$7$^$$$^$7$?$,e(B
e$B!JIaDL$Ke(B filename
e$B$rF~$l$k$H!"e(BFiber.new(method(:load)).resume e$B$Ge(B
e$B!!%U%!%$%kL>$,6uJ8;zNs!"9THV9f$,e(B 0 e$B$J$I$HI=<($5$l$k!Ke(B
e$BK\Mh$O$I$&BP=h$9$k$N$,%9%^!<%H$J$N$G$7$g$&$+!#e(B

Index: eval_error.c

— eval_error.c (revision 15933)
+++ eval_error.c (working copy)
@@ -10,11 +10,11 @@
rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);

 if (cfp) {
  • return RSTRING_PTR(cfp->iseq->filename);
  • if (!NIL_P(cfp->iseq->filename)) {
  •  return RSTRING_PTR(cfp->iseq->filename);
    
  • }
    }
  • else {
  • return 0;
  • }
  • return 0;
    }

int
Index: cont.c

— cont.c (revision 15933)
+++ cont.c (working copy)
@@ -501,6 +501,8 @@
rb_context_t *cont = fiber_alloc(klass);
VALUE contval = cont->self;
rb_thread_t *th = &cont->saved_thread;

  • VALUE filename = rb_str_new2("");

  • VALUE iseq = rb_iseq_new(0, filename, Qnil, 0, ISEQ_TYPE_TOP);

    /* initialize */
    cont->vm_stack = 0;
    @@ -509,18 +511,7 @@
    th->stack_size = FIBER_VM_STACK_SIZE;
    th->stack = ALLOC_N(VALUE, th->stack_size);

  • th->cfp = (void *)(th->stack + th->stack_size);
  • th->cfp–;
  • th->cfp->pc = 0;
  • th->cfp->sp = th->stack + 1;
  • th->cfp->bp = 0;
  • th->cfp->lfp = th->stack;
  • *th->cfp->lfp = 0;
  • th->cfp->dfp = th->stack;
  • th->cfp->self = Qnil;
  • th->cfp->flag = 0;
  • th->cfp->iseq = 0;
  • th->cfp->proc = 0;
  • vm_set_branch_frame(th, iseq);
    th->cfp->block_iseq = 0;
    th->tag = 0;
    th->local_storage = st_init_numtable();
    Index: vm.c
    ===================================================================
    — vm.c (revision 15933)
    +++ vm.c (working copy)
    @@ -1666,6 +1666,17 @@
    return obj;
    }

+void
+vm_set_branch_frame(rb_thread_t *th, VALUE iseqval)
+{

  • rb_iseq_t *iseq;
  • th->cfp = (void *)(th->stack + th->stack_size);
  • GetISeqPtr(iseqval, iseq);
  • vm_push_frame(th, iseq, FRAME_MAGIC_TOP, th->top_self, 0,
  •  iseq->iseq_encoded, th->stack, 0, iseq->local_size);
    

+}
+
static void
th_init2(rb_thread_t *th)
{
@@ -1687,24 +1698,37 @@
}

static void
-th_init(rb_thread_t *th)
+th_init(rb_thread_t *th, VALUE iseq)
{

  • th_init2(th);
  • /* allocate thread stack */
  • th->stack_size = RUBY_VM_THREAD_STACK_SIZE;
  • th->stack = thread_recycle_stack(th->stack_size);
  • vm_set_branch_frame(th, iseq);
  • th->status = THREAD_RUNNABLE;
  • th->errinfo = Qnil;

+#if USE_VALUE_CACHE

  • th->value_cache_ptr = &th->value_cache[0];
    +#endif
    }

static VALUE
ruby_thread_init(VALUE self)
{

  • VALUE filename = rb_str_new2("");
  • VALUE iseq = rb_iseq_new(0, filename, Qnil, 0, ISEQ_TYPE_TOP);
    rb_thread_t *th;
    rb_vm_t *vm = GET_THREAD()->vm;
    GetThreadPtr(self, th);
  • th_init(th);
    th->self = self;
    th->vm = vm;

    th->top_wrapper = 0;
    th->top_self = rb_vm_top_self();

  • th_init(th, iseq);
    return self;
    }

Index: vm_dump.c

— vm_dump.c (revision 15933)
+++ vm_dump.c (working copy)
@@ -102,7 +102,12 @@
line = vm_get_sourceline(cfp);
if (line) {
char fn[MAX_POSBUF+1];

  • snprintf(fn, MAX_POSBUF, “%s”, RSTRING_PTR(cfp->iseq->filename));
  • VALUE filename = cfp->iseq->filename;
  • if (NIL_P(filename)) {
  •    filename = cfp->iseq->name;
    
  • }
  • snprintf(fn, MAX_POSBUF, “%s”, RSTRING_PTR(filename));
    snprintf(posbuf, MAX_POSBUF, “%s:%d”, fn, line);
    }
    }

e$B%o%J%Y$G$9!#e(B

e$B$9$$^$;$s!"BjL>$r%%9$7$^$7$?!#e(B
e$BFbMF$+$i$o$+$k$H;W$$$^$9$,!"e(Bpatch for [ruby-dev:34128]e$B$G$9!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:34353] Re: patch for”
on Sat, 12 Apr 2008 15:32:09 +0900, wanabe [email protected]
writes:

|e$B$9$$^$;$s!"BjL>$r%%9$7$^$7$?!#e(B
|e$BFbMF$+$i$o$+$k$H;W$$$^$9$,!"e(Bpatch for [ruby-dev:34128]e$B$G$9!#e(B

e$B%o%J%Y$5$s$,%_%9$7$?$N$G$O$J$/!"%j%9%H%5!<%P$,e(BSubjecte$B$+$i%?%0e(B
e$B$r>C5n$9$k=hM}$K0z$C$+$+$C$A$c$C$?$N$@$H;W$$$^$9!#e(B

e$B!!$5$5$@$G$9!%e(B

e$B!!H?1~$,CY$/$F$9$_$^$;$s!%e(B

wanabe wrote:

Fiber e$B$N%H%C%W%U%l!<%`$Ke(B ISeq e$B$r2C$($k%Q%C%A$r=q$-$^$7$?!#e(B
e$B$D$$$G$J$N$Ge(B Thread e$B$bF1MM$K$7$^$7$?!#e(B
test_knownbug.rb e$B$Ne(B [ruby-dev:34128] e$B$H$"$k%F%9%H$,DL$k$h$&$K$J$j$^$9!#e(B

e$B!!%@%!<$rF~$l$F$k$H;W$&$s$G$9$,!$Kh2sI,MW$J$b$s$G$7$g$&$+!%$"$s$^$je(B
e$BLdBj$H2r7h$rM}2r$7$F$$$^$;$s!$$9$
$^$;$s!%e(B

e$B%P%C%/%H%l!<%9BP:v$Ge(B iseq->filename e$B$Ke(B nil e$B$rF~$l$F$7$^$$$^$7$?$,e(B
e$B!JIaDL$Ke(B filename e$B$rF~$l$k$H!"e(BFiber.new(method(:load)).resume e$B$Ge(B
e$B!!%U%!%$%kL>$,6uJ8;zNs!"9THV9f$,e(B 0 e$B$J$I$HI=<($5$l$k!Ke(B
e$BK\Mh$O$I$&BP=h$9$k$N$,%9%^!<%H$J$N$G$7$g$&$+!#e(B

e$B!!%U%!%$%kL>$rF~$l$?$N$K!V%U%!%$%kL>$,6uJ8;zNs!"9THV9f$,e(B
0e$B!W$G$9$+!)e(B
e$B!!$d$C$F$_$J$$$H$o$+$i$J$$$J!%e(B

e$B!!e(Bvm_set_branch_frame(rb_thread_t *th, VALUE iseqval)
e$B$NL>A0$O5$$K$Je(B
e$B$j$^$7$?!%e(B

e$B!!$"$H!$e(Bth_init() e$B$O%3%T!<$G$9$+!%e(B

e$B!!$b$75$$K$5$l$J$1$l$P!$$3$l$r;29M$K;d$NJ}$GBP1~$7$?$$$H;W$&$N$G$9e(B
e$B$,!$$h$m$7$$$G$7$g$&$+!%e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:34352] patch for”
on Sat, 12 Apr 2008 15:22:54 +0900, wanabe [email protected]
writes:

|Fiber e$B$N%H%C%W%U%l!<%`$Ke(B ISeq e$B$r2C$($k%Q%C%A$r=q$-$^$7$?!#e(B
|e$B$D$$$G$J$N$Ge(B Thread e$B$bF1MM$K$7$^$7$?!#e(B
|test_knownbug.rb e$B$Ne(B [ruby-dev:34128] e$B$H$"$k%F%9%H$,DL$k$h$&$K$J$j$^$9!#e(B

e$B$3$l!“<h$j9~$_$?$$$s$G$9$,!”$5$5$@$/$s$N%A%'%C%/$rBT$C$?J}$,e(B
e$B$h$$$N$+$7$i!)e(B

e$B%o%J%Y$G$9!#e(B

08/04/14 e$B$Ke(B SASADA Koichi[email protected] e$B$5$s$O=q$-$^$7$?e(B:

Fiber e$B$N%H%C%W%U%l!<%`$Ke(B ISeq e$B$r2C$($k%Q%C%A$r=q$-$^$7$?!#e(B
e$B!JCfN,!Ke(B
e$B!!%@%!<$rF~$l$F$k$H;W$&$s$G$9$,!$Kh2sI,MW$J$b$s$G$7$g$&$+!%$"$s$^$je(B
e$BLdBj$H2r7h$rM}2r$7$F$$$^$;$s!$$9$
$^$;$s!%e(B

e$B3N$+e(B vm_get_ruby_level_cfp()
e$B$,;_$^$C$F$/$l$:$Ke(B0e$B$rJV$9;v$,LdBj$@$C$?5$$,$7$^$9!#e(B
[ruby-dev:34128]e$B!!$K$h$l$Pe(B “abc”.enum_for(:scan, /./).next
e$B$,Mn$A$kBeI=Nc$N$h$&$G$9!#e(B

vm_set_branch_frame(rb_thread_t *th, VALUE iseqval) e$B$NL>A0$O5$$K$Je(B
e$B$j$^$7$?!%e(B

e$B<+J,$G$b$=$&;W$$$^$9!#;W$$$D$+$J$+$C$?$N$GE,Ev$K$D$1$^$7$?!#e(B

e$B$"$H!$e(Bth_init() e$B$O%3%T!<$G$9$+!%e(B

e$B$=$&$G$9!#e(B

e$B$b$75$$K$5$l$J$1$l$P!$$3$l$r;29M$K;d$NJ}$GBP1~$7$?$$$H;W$&$N$G$9e(B
e$B$,!$$h$m$7$$$G$7$g$&$+!%e(B

e$B$<$R$4j$$$7$^$9!#e(B
e$BAw$C$?%Q%C%A$O$H$j$"$($:F0$/$@$1$NBeJ
$G$9$N$G!#e(B