ruby-changes:42041
From: nobu <ko1@a...>
Date: Tue, 15 Mar 2016 15:42:33 +0900 (JST)
Subject: [ruby-changes:42041] nobu:r54115 (trunk): gc.c: rb_objspace_of
nobu 2016-03-15 15:42:29 +0900 (Tue, 15 Mar 2016) New Revision: 54115 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54115 Log: gc.c: rb_objspace_of * gc.c (rb_objspace_of): macro to get the objspace from a thread. Modified files: trunk/gc.c Index: gc.c =================================================================== --- gc.c (revision 54114) +++ gc.c (revision 54115) @@ -693,9 +693,11 @@ struct heap_page { https://github.com/ruby/ruby/blob/trunk/gc.c#L693 /* Aliases */ #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE -#define rb_objspace (*GET_VM()->objspace) +#define rb_objspace (*rb_objspace_of(GET_VM())) +#define rb_objspace_of(vm) ((vm)->objspace) #else static rb_objspace_t rb_objspace = {{GC_MALLOC_LIMIT_MIN}}; +#define rb_objspace_of(vm) (&rb_objspace) #endif #define ruby_initial_gc_stress gc_params.gc_stress @@ -2729,7 +2731,7 @@ finalize_deferred(rb_objspace_t *objspac https://github.com/ruby/ruby/blob/trunk/gc.c#L2731 static void gc_finalize_deferred(void *dmy) { - rb_objspace_t *objspace = &rb_objspace; + rb_objspace_t *objspace = dmy; if (ATOMIC_EXCHANGE(finalizing, 1)) return; finalize_deferred(objspace); ATOMIC_SET(finalizing, 0); @@ -2743,9 +2745,9 @@ rb_gc_finalize_deferred(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L2745 } static void -gc_finalize_deferred_register(void) +gc_finalize_deferred_register(rb_objspace_t *objspace) { - if (rb_postponed_job_register_one(0, gc_finalize_deferred, 0) == 0) { + if (rb_postponed_job_register_one(0, gc_finalize_deferred, objspace) == 0) { rb_bug("gc_finalize_deferred_register: can't register finalizer."); } } @@ -3439,7 +3441,7 @@ gc_page_sweep(rb_objspace_t *objspace, r https://github.com/ruby/ruby/blob/trunk/gc.c#L3441 if (heap_pages_deferred_final && !finalizing) { rb_thread_t *th = GET_THREAD(); if (th) { - gc_finalize_deferred_register(); + gc_finalize_deferred_register(rb_objspace_of(th->vm)); } } @@ -4144,7 +4146,7 @@ mark_current_machine_context(rb_objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L4146 void rb_gc_mark_machine_stack(rb_thread_t *th) { - rb_objspace_t *objspace = &rb_objspace; + rb_objspace_t *objspace = rb_objspace_of(th->vm); VALUE *stack_start, *stack_end; GET_STACK_BOUNDS(stack_start, stack_end, 0); @@ -7457,7 +7459,7 @@ void https://github.com/ruby/ruby/blob/trunk/gc.c#L7459 rb_memerror(void) { rb_thread_t *th = GET_THREAD(); - rb_objspace_t *objspace = &rb_objspace; + rb_objspace_t *objspace = rb_objspace_of(th->vm); if (during_gc) gc_exit(objspace, "rb_memerror"); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/