зеркало из https://github.com/github/ruby.git
remove branches in dmark and dfree GC callbacks
dmark and dfree callbacks are never called in gc.c for NULL DATA_PTR values, not even for zombie objects. * compile.c (ibf_loader_mark): remove branch for pointer validity * compile.c (ibf_loader_free): ditto * cont.c (cont_free): ditto * cont.c (fiber_free): ditto * dir.c (dir_free): ditto * ext/stringio/stringio.c (strio_mark): ditto * proc.c (binding_free): ditto * thread_sync.c (mutex_free): ditto * vm.c (thread_free): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
3a55e8a436
Коммит
cad4591086
18
compile.c
18
compile.c
|
@ -8631,22 +8631,18 @@ ibf_load_setup(struct ibf_load *load, VALUE loader_obj, VALUE str)
|
|||
static void
|
||||
ibf_loader_mark(void *ptr)
|
||||
{
|
||||
if (ptr) {
|
||||
struct ibf_load *load = (struct ibf_load *)ptr;
|
||||
rb_gc_mark(load->str);
|
||||
rb_gc_mark(load->iseq_list);
|
||||
rb_gc_mark(load->obj_list);
|
||||
}
|
||||
struct ibf_load *load = (struct ibf_load *)ptr;
|
||||
rb_gc_mark(load->str);
|
||||
rb_gc_mark(load->iseq_list);
|
||||
rb_gc_mark(load->obj_list);
|
||||
}
|
||||
|
||||
static void
|
||||
ibf_loader_free(void *ptr)
|
||||
{
|
||||
if (ptr) {
|
||||
struct ibf_load *load = (struct ibf_load *)ptr;
|
||||
ruby_xfree(load->id_list);
|
||||
ruby_xfree(load);
|
||||
}
|
||||
struct ibf_load *load = (struct ibf_load *)ptr;
|
||||
ruby_xfree(load->id_list);
|
||||
ruby_xfree(load);
|
||||
}
|
||||
|
||||
static size_t
|
||||
|
|
95
cont.c
95
cont.c
|
@ -218,55 +218,54 @@ cont_mark(void *ptr)
|
|||
static void
|
||||
cont_free(void *ptr)
|
||||
{
|
||||
rb_context_t *cont = 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->saved_thread.stack);
|
||||
#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;
|
||||
const rb_thread_t *const th = GET_THREAD();
|
||||
#ifdef _WIN32
|
||||
if (th && th->fiber != fib && cont->type != ROOT_FIBER_CONTEXT) {
|
||||
/* don't delete root fiber handle */
|
||||
if (fib->fib_handle) {
|
||||
DeleteFiber(fib->fib_handle);
|
||||
}
|
||||
}
|
||||
#else /* not WIN32 */
|
||||
if (th && th->fiber != fib) {
|
||||
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 */
|
||||
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;
|
||||
const rb_thread_t *const th = GET_THREAD();
|
||||
#ifdef _WIN32
|
||||
if (th && th->fiber != fib && cont->type != ROOT_FIBER_CONTEXT) {
|
||||
/* don't delete root fiber handle */
|
||||
if (fib->fib_handle) {
|
||||
DeleteFiber(fib->fib_handle);
|
||||
}
|
||||
}
|
||||
#else /* not WIN32 */
|
||||
if (th && th->fiber != fib) {
|
||||
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);
|
||||
RUBY_FREE_UNLESS_NULL(cont->machine.register_stack);
|
||||
#endif
|
||||
RUBY_FREE_UNLESS_NULL(cont->vm_stack);
|
||||
RUBY_FREE_UNLESS_NULL(cont->vm_stack);
|
||||
|
||||
/* free rb_cont_t or rb_fiber_t */
|
||||
ruby_xfree(ptr);
|
||||
}
|
||||
/* free rb_cont_t or rb_fiber_t */
|
||||
ruby_xfree(ptr);
|
||||
RUBY_FREE_LEAVE("cont");
|
||||
}
|
||||
|
||||
|
@ -317,16 +316,14 @@ fiber_mark(void *ptr)
|
|||
static void
|
||||
fiber_free(void *ptr)
|
||||
{
|
||||
rb_fiber_t *fib = ptr;
|
||||
RUBY_FREE_ENTER("fiber");
|
||||
if (ptr) {
|
||||
rb_fiber_t *fib = ptr;
|
||||
if (fib->cont.type != ROOT_FIBER_CONTEXT &&
|
||||
fib->cont.saved_thread.local_storage) {
|
||||
st_free_table(fib->cont.saved_thread.local_storage);
|
||||
}
|
||||
|
||||
cont_free(&fib->cont);
|
||||
if (fib->cont.type != ROOT_FIBER_CONTEXT &&
|
||||
fib->cont.saved_thread.local_storage) {
|
||||
st_free_table(fib->cont.saved_thread.local_storage);
|
||||
}
|
||||
|
||||
cont_free(&fib->cont);
|
||||
RUBY_FREE_LEAVE("fiber");
|
||||
}
|
||||
|
||||
|
|
5
dir.c
5
dir.c
|
@ -436,9 +436,8 @@ static void
|
|||
dir_free(void *ptr)
|
||||
{
|
||||
struct dir_data *dir = ptr;
|
||||
if (dir) {
|
||||
if (dir->dir) closedir(dir->dir);
|
||||
}
|
||||
|
||||
if (dir->dir) closedir(dir->dir);
|
||||
xfree(dir);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,9 +52,8 @@ static void
|
|||
strio_mark(void *p)
|
||||
{
|
||||
struct StringIO *ptr = p;
|
||||
if (ptr) {
|
||||
rb_gc_mark(ptr->string);
|
||||
}
|
||||
|
||||
rb_gc_mark(ptr->string);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
8
proc.c
8
proc.c
|
@ -265,12 +265,10 @@ rb_proc_lambda_p(VALUE procval)
|
|||
static void
|
||||
binding_free(void *ptr)
|
||||
{
|
||||
rb_binding_t *bind;
|
||||
RUBY_FREE_ENTER("binding");
|
||||
if (ptr) {
|
||||
bind = ptr;
|
||||
ruby_xfree(bind);
|
||||
}
|
||||
|
||||
ruby_xfree(ptr);
|
||||
|
||||
RUBY_FREE_LEAVE("binding");
|
||||
}
|
||||
|
||||
|
|
|
@ -54,16 +54,14 @@ static const char* rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t volatile *t
|
|||
static void
|
||||
mutex_free(void *ptr)
|
||||
{
|
||||
if (ptr) {
|
||||
rb_mutex_t *mutex = ptr;
|
||||
if (mutex->th) {
|
||||
/* rb_warn("free locked mutex"); */
|
||||
const char *err = rb_mutex_unlock_th(mutex, mutex->th);
|
||||
if (err) rb_bug("%s", err);
|
||||
}
|
||||
native_mutex_destroy(&mutex->lock);
|
||||
native_cond_destroy(&mutex->cond);
|
||||
rb_mutex_t *mutex = ptr;
|
||||
if (mutex->th) {
|
||||
/* rb_warn("free locked mutex"); */
|
||||
const char *err = rb_mutex_unlock_th(mutex, mutex->th);
|
||||
if (err) rb_bug("%s", err);
|
||||
}
|
||||
native_mutex_destroy(&mutex->lock);
|
||||
native_cond_destroy(&mutex->cond);
|
||||
ruby_xfree(ptr);
|
||||
}
|
||||
|
||||
|
|
61
vm.c
61
vm.c
|
@ -2346,41 +2346,38 @@ rb_thread_mark(void *ptr)
|
|||
static void
|
||||
thread_free(void *ptr)
|
||||
{
|
||||
rb_thread_t *th;
|
||||
rb_thread_t *th = ptr;
|
||||
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;
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче