~ubuntu-branches/ubuntu/precise/ruby1.9/precise

« back to all changes in this revision

Viewing changes to yarvcore.c

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-05-26 21:02:58 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070526210258-nkfg24tdre4e3tqw
Tags: 1.9.0+20070526-1
new upstream snapshot. (2006-07-26)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
  yarvcore.h - 
4
4
 
5
 
  $Author: ko1 $
6
 
  $Date: 2007-05-21 13:46:51 +0900 (月, 21  5月 2007) $
 
5
  $Author: nobu $
 
6
  $Date: 2007-05-25 16:03:30 +0900 (金, 25  5月 2007) $
7
7
  created at: 04/01/01 01:17:22 JST
8
8
 
9
9
  Copyright (C) 2004-2006 Koichi Sasada
12
12
 
13
13
#include "ruby.h"
14
14
#include "node.h"
15
 
 
16
15
#include "yarvcore.h"
17
16
#include "gc.h"
18
17
 
192
191
        MARK_UNLESS_NULL(vm->mark_object_ary);
193
192
        MARK_UNLESS_NULL(vm->last_status);
194
193
        MARK_UNLESS_NULL(vm->loaded_features);
195
 
        if (vm->loading_table) rb_mark_tbl(vm->loading_table);
 
194
 
 
195
        if (vm->loading_table) {
 
196
            rb_mark_tbl(vm->loading_table);
 
197
        }
196
198
 
197
199
        mark_event_hooks(vm->event_hooks);
198
200
    }
200
202
    MARK_REPORT_LEAVE("vm");
201
203
}
202
204
 
203
 
static VALUE
204
 
vm_alloc(VALUE klass)
 
205
void
 
206
rb_vm_mark(void *ptr)
205
207
{
206
 
    VALUE volatile obj;
207
 
    rb_vm_t *vm;
208
 
    obj = Data_Make_Struct(klass, rb_vm_t, vm_mark, vm_free, vm);
209
 
 
210
 
    vm->self = obj;
211
 
    vm->mark_object_ary = rb_ary_new();
212
 
    return obj;
 
208
    vm_mark(ptr);
213
209
}
214
210
 
215
211
static void
311
307
    MARK_REPORT_LEAVE("thread");
312
308
}
313
309
 
 
310
void
 
311
rb_thread_mark(void *ptr)
 
312
{
 
313
    thread_mark(ptr);
 
314
}
 
315
 
314
316
static VALUE
315
317
thread_alloc(VALUE klass)
316
318
{
534
536
 
535
537
    /* VM bootstrap: phase 2 */
536
538
    {
 
539
        rb_vm_t *vm = ruby_current_vm;
 
540
        rb_thread_t *th = GET_THREAD();
 
541
 
537
542
        /* create vm object */
538
 
        VALUE vmval = vm_alloc(rb_cVM);
539
 
        VALUE thval;
540
 
        rb_vm_t *vm;
541
 
        rb_thread_t *th;
542
 
 
543
 
        vm = ruby_current_vm;
544
 
 
545
 
        xfree(RDATA(vmval)->data);
546
 
        RDATA(vmval)->data = vm;
547
 
        vm->self = vmval;
 
543
        vm->self = Data_Wrap_Struct(rb_cVM, vm_mark, vm_free, vm);
548
544
 
549
545
        /* create main thread */
550
 
        thval = rb_thread_alloc(rb_cThread);
551
 
        GetThreadPtr(thval, th);
 
546
        th->self = Data_Wrap_Struct(rb_cThread, thread_mark, thread_free, th);
552
547
 
553
548
        vm->main_thread = th;
554
549
        vm->running_thread = th;
555
 
        GET_THREAD()->vm = vm;
556
 
        thread_free(GET_THREAD());
557
550
        th->vm = vm;
 
551
        th->top_wrapper = 0;
 
552
        th->top_self = ruby_top_self;
558
553
        rb_thread_set_current(th);
559
554
 
560
 
        th->machine_stack_start = rb_gc_stack_start;
561
555
        vm->living_threads = st_init_numtable();
562
556
        st_insert(vm->living_threads, th->self, (st_data_t) th->thread_id);
563
557
    }