From a79ce52e085e3c61250ee817ba8b2d1df81e779b Mon Sep 17 00:00:00 2001 From: ko1 Date: Mon, 24 Dec 2007 21:18:47 +0000 Subject: * vm.c: add dummy toplevel frame. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ vm.c | 33 +++++++++++++-------------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index f730d35a9c..59ae417cf9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue Dec 25 06:15:01 2007 Koichi Sasada + + * vm.c: add dummy toplevel frame. + Tue Dec 25 05:44:56 2007 Eric Hodel * lib/net/http.rb: Fix uninitialized variable warning. diff --git a/vm.c b/vm.c index 3fa51c27f5..2ef4d79001 100644 --- a/vm.c +++ b/vm.c @@ -1412,10 +1412,10 @@ rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, rb_block_t *blockp { rb_thread_t *th = GET_THREAD(); rb_control_frame_t *reg_cfp = th->cfp; - volatile VALUE iseq = rb_iseq_new(0, filename, filename, 0, ISEQ_TYPE_TOP); + volatile VALUE iseqval = rb_iseq_new(0, filename, filename, 0, ISEQ_TYPE_TOP); VALUE val; - vm_push_frame(th, DATA_PTR(iseq), FRAME_MAGIC_TOP, + vm_push_frame(th, DATA_PTR(iseqval), FRAME_MAGIC_TOP, recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 1); val = (*func)(arg); @@ -1666,23 +1666,7 @@ th_init2(rb_thread_t *th) th->cfp = (void *)(th->stack + th->stack_size); vm_push_frame(th, 0, FRAME_MAGIC_TOP, Qnil, 0, 0, - th->stack, 0, 0); - vm_push_frame(th, 0, FRAME_MAGIC_TOP, Qnil, 0, 0, - th->cfp->sp, 0, 0); - -#if 0 - th->cfp->pc = 0; - th->cfp->sp = th->stack; - 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; - th->cfp->block_iseq = 0; -#endif + th->stack, 0, 1); th->status = THREAD_RUNNABLE; th->errinfo = Qnil; @@ -1823,7 +1807,10 @@ Init_VM(void) { rb_vm_t *vm = ruby_current_vm; rb_thread_t *th = GET_THREAD(); + VALUE filename = rb_str_new2(""); + volatile VALUE iseqval = rb_iseq_new(0, filename, filename, 0, ISEQ_TYPE_TOP); volatile VALUE th_self; + rb_iseq_t *iseq; /* create vm object */ vm->self = Data_Wrap_Struct(rb_cVM, rb_vm_mark, vm_free, vm); @@ -1831,7 +1818,6 @@ Init_VM(void) /* create main thread */ th_self = th->self = Data_Wrap_Struct(rb_cThread, rb_thread_mark, thread_free, th); - vm->main_thread = th; vm->running_thread = th; th->vm = vm; @@ -1841,6 +1827,13 @@ Init_VM(void) vm->living_threads = st_init_numtable(); st_insert(vm->living_threads, th_self, (st_data_t) th->thread_id); + + rb_register_mark_object(iseqval); + GetISeqPtr(iseqval, iseq); + th->cfp->iseq = iseq; + th->cfp->pc = iseq->iseq_encoded; + (th->cfp+1)->iseq = iseq; + (th->cfp+1)->pc = iseq->iseq_encoded; } vm_init_redefined_flag(); } -- cgit v1.2.3