static void env_mark(void * const ptr) { RUBY_MARK_ENTER("env"); if (ptr) { const rb_env_t * const env = ptr; if (env->env) { /* TODO: should mark more restricted range */ RUBY_GC_INFO("env->env\n"); rb_gc_mark_locations(env->env, env->env + env->env_size); } RUBY_GC_INFO("env->prev_envval\n"); RUBY_MARK_UNLESS_NULL(env->prev_envval); RUBY_MARK_UNLESS_NULL(env->block.self); RUBY_MARK_UNLESS_NULL(env->block.proc); if (env->block.iseq) { if (BUILTIN_TYPE(env->block.iseq) == T_NODE) { RUBY_MARK_UNLESS_NULL((VALUE)env->block.iseq); } else { RUBY_MARK_UNLESS_NULL(env->block.iseq->self); } } } RUBY_MARK_LEAVE("env"); }
void rb_vm_mark(void *ptr) { int i; RUBY_MARK_ENTER("vm"); RUBY_GC_INFO("-------------------------------------------------\n"); if (ptr) { rb_vm_t *vm = ptr; if (vm->living_threads) { st_foreach(vm->living_threads, vm_mark_each_thread_func, 0); } RUBY_MARK_UNLESS_NULL(vm->thgroup_default); RUBY_MARK_UNLESS_NULL(vm->mark_object_ary); RUBY_MARK_UNLESS_NULL(vm->load_path); RUBY_MARK_UNLESS_NULL(vm->loaded_features); RUBY_MARK_UNLESS_NULL(vm->top_self); RUBY_MARK_UNLESS_NULL(vm->coverages); rb_gc_mark_locations(vm->special_exceptions, vm->special_exceptions + ruby_special_error_count); if (vm->loading_table) { rb_mark_tbl(vm->loading_table); } mark_event_hooks(vm->event_hooks); for (i = 0; i < RUBY_NSIG; i++) { if (vm->trap_list[i].cmd) rb_gc_mark(vm->trap_list[i].cmd); } } RUBY_MARK_LEAVE("vm"); }
static void thread_free(void *ptr) { rb_thread_t *th; RUBY_FREE_ENTER("thread"); if (ptr) { th = ptr; if (!th->root_fiber) { RUBY_FREE_UNLESS_NULL(th->stack); } if (th->locking_mutex != Qfalse) { rb_bug("thread_free: locking_mutex must be NULL (%p:%ld)", (void *)th, th->locking_mutex); } if (th->keeping_mutexes != NULL) { rb_bug("thread_free: keeping_mutexes must be NULL (%p:%p)", (void *)th, th->keeping_mutexes); } if (th->local_storage) { st_free_table(th->local_storage); } #if USE_VALUE_CACHE { VALUE *ptr = th->value_cache_ptr; while (*ptr) { VALUE v = *ptr; RBASIC(v)->flags = 0; RBASIC(v)->klass = 0; ptr++; } } #endif if (th->vm && th->vm->main_thread == th) { RUBY_GC_INFO("main thread\n"); } else { #ifdef USE_SIGALTSTACK if (th->altstack) { free(th->altstack); } #endif ruby_xfree(ptr); } } RUBY_FREE_LEAVE("thread"); }
static void thread_free(void *ptr) { rb_thread_t *th; RUBY_FREE_ENTER("thread"); if (ptr) { th = ptr; if (!th->root_fiber) { RUBY_FREE_UNLESS_NULL(th->stack); } if (th->locking_mutex != Qfalse) { rb_bug("thread_free: locking_mutex must be NULL (%p:%p)", (void *)th, (void *)th->locking_mutex); } if (th->keeping_mutexes != NULL) { rb_bug("thread_free: keeping_mutexes must be NULL (%p:%p)", (void *)th, (void *)th->keeping_mutexes); } if (th->local_storage) { st_free_table(th->local_storage); } if (th->vm && th->vm->main_thread == th) { RUBY_GC_INFO("main thread\n"); } else { #ifdef USE_SIGALTSTACK if (th->altstack) { free(th->altstack); } #endif ruby_xfree(ptr); } if (ruby_current_thread == th) ruby_current_thread = NULL; } RUBY_FREE_LEAVE("thread"); }