* vm.c: add dummy toplevel frame.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-12-24 21:18:47 +00:00
Родитель 2b402d8243
Коммит a79ce52e08
2 изменённых файлов: 17 добавлений и 20 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Tue Dec 25 06:15:01 2007 Koichi Sasada <ko1@atdot.net>
* vm.c: add dummy toplevel frame.
Tue Dec 25 05:44:56 2007 Eric Hodel <drbrain@segment7.net>
* lib/net/http.rb: Fix uninitialized variable warning.

33
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("<dummy toplevel>");
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();
}