From d289b8e8c6a730063723a2637c45e93cb4bc9a45 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 25 May 2007 07:03:30 +0000 Subject: * yarvcore.c (Init_VM): wrap already initialized structs to use it directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- yarvcore.c | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) (limited to 'yarvcore.c') diff --git a/yarvcore.c b/yarvcore.c index b266bf6957..0530a36ca0 100644 --- a/yarvcore.c +++ b/yarvcore.c @@ -208,18 +208,6 @@ rb_vm_mark(void *ptr) vm_mark(ptr); } -static VALUE -vm_alloc(VALUE klass) -{ - VALUE volatile obj; - rb_vm_t *vm; - obj = Data_Make_Struct(klass, rb_vm_t, vm_mark, vm_free, vm); - - vm->self = obj; - vm->mark_object_ary = rb_ary_new(); - return obj; -} - static void vm_init2(rb_vm_t *vm) { @@ -548,30 +536,22 @@ Init_VM(void) /* VM bootstrap: phase 2 */ { - /* create vm object */ - VALUE vmval = vm_alloc(rb_cVM); - VALUE thval; - rb_vm_t *vm; - rb_thread_t *th; + rb_vm_t *vm = ruby_current_vm; + rb_thread_t *th = GET_THREAD(); - vm = ruby_current_vm; - - xfree(RDATA(vmval)->data); - RDATA(vmval)->data = vm; - vm->self = vmval; + /* create vm object */ + vm->self = Data_Wrap_Struct(rb_cVM, vm_mark, vm_free, vm); /* create main thread */ - thval = rb_thread_alloc(rb_cThread); - GetThreadPtr(thval, th); + th->self = Data_Wrap_Struct(rb_cThread, thread_mark, thread_free, th); vm->main_thread = th; vm->running_thread = th; - GET_THREAD()->vm = vm; - thread_free(GET_THREAD()); th->vm = vm; + th->top_wrapper = 0; + th->top_self = ruby_top_self; rb_thread_set_current(th); - th->machine_stack_start = rb_gc_stack_start; vm->living_threads = st_init_numtable(); st_insert(vm->living_threads, th->self, (st_data_t) th->thread_id); } -- cgit v1.2.3