static void cont_free(void *ptr) { RUBY_FREE_ENTER("cont"); if (ptr) { rb_context_t *cont = ptr; RUBY_FREE_UNLESS_NULL(cont->saved_thread.stack); fflush(stdout); #if FIBER_USE_NATIVE if (cont->type == CONTINUATION_CONTEXT) { /* cont */ ruby_xfree(cont->ensure_array); RUBY_FREE_UNLESS_NULL(cont->machine.stack); } else { /* fiber */ rb_fiber_t *fib = (rb_fiber_t*)cont; #ifdef _WIN32 if (GET_THREAD()->fiber != fib && cont->type != ROOT_FIBER_CONTEXT) { /* don't delete root fiber handle */ rb_fiber_t *fib = (rb_fiber_t*)cont; if (fib->fib_handle) { DeleteFiber(fib->fib_handle); } } #else /* not WIN32 */ if (GET_THREAD()->fiber != fib) { rb_fiber_t *fib = (rb_fiber_t*)cont; if (fib->ss_sp) { if (cont->type == ROOT_FIBER_CONTEXT) { rb_bug("Illegal root fiber parameter"); } munmap((void*)fib->ss_sp, fib->ss_size); } } else { /* It may reached here when finalize */ /* TODO examine whether it is a bug */ /* rb_bug("cont_free: release self"); */ } #endif } #else /* not FIBER_USE_NATIVE */ ruby_xfree(cont->ensure_array); RUBY_FREE_UNLESS_NULL(cont->machine.stack); #endif #ifdef __ia64 RUBY_FREE_UNLESS_NULL(cont->machine.register_stack); #endif RUBY_FREE_UNLESS_NULL(cont->vm_stack); /* free rb_cont_t or rb_fiber_t */ ruby_xfree(ptr); } RUBY_FREE_LEAVE("cont"); }
static void cont_free(void *ptr) { RUBY_FREE_ENTER("cont"); if (ptr) { rb_context_t *cont = ptr; RUBY_FREE_UNLESS_NULL(cont->saved_thread.stack); fflush(stdout); RUBY_FREE_UNLESS_NULL(cont->machine_stack); #ifdef __ia64 RUBY_FREE_UNLESS_NULL(cont->machine_register_stack); #endif RUBY_FREE_UNLESS_NULL(cont->vm_stack); /* free rb_cont_t or rb_fiber_t */ ruby_xfree(ptr); } RUBY_FREE_LEAVE("cont"); }
static void env_free(void * const ptr) { RUBY_FREE_ENTER("env"); if (ptr) { const rb_env_t * const env = ptr; RUBY_FREE_UNLESS_NULL(env->env); ruby_xfree(ptr); } RUBY_FREE_LEAVE("env"); }
static void cont_free(void *ptr) { RUBY_FREE_ENTER("cont"); if (ptr) { rb_context_t *cont = ptr; RUBY_FREE_UNLESS_NULL(cont->saved_thread.stack); RUBY_FREE_UNLESS_NULL(cont->machine_stack); #ifdef __ia64 RUBY_FREE_UNLESS_NULL(cont->machine_register_stack); #endif RUBY_FREE_UNLESS_NULL(cont->vm_stack); if (cont->type == FIBER_CONTEXT) { st_free_table(cont->saved_thread.local_storage); } ruby_xfree(ptr); } RUBY_FREE_LEAVE("cont"); }
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"); }