зеркало из https://github.com/github/ruby.git
proc/env DATA_PTR is never NULL
* proc.c (proc_free): remove, use RUBY_TYPED_DEFAULT_FREE (proc_mark, proc_memsize): remove needless branching * vm.c (env_free): remove, use RUBY_TYPED_DEFAULT_FREE (env_mark, env_memsize): remove needless branching This shows a tiny ~0.5% improvement in benchmark/bm_vm2_newlambda.rb but also removes a lot of code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
bb2cec10c0
Коммит
1972a3136c
|
@ -1,3 +1,11 @@
|
|||
Sat Sep 13 06:13:55 2014 Eric Wong <e@80x24.org>
|
||||
|
||||
* proc.c (proc_free): remove, use RUBY_TYPED_DEFAULT_FREE
|
||||
(proc_mark, proc_memsize): remove needless branching
|
||||
|
||||
* vm.c (env_free): remove, use RUBY_TYPED_DEFAULT_FREE
|
||||
(env_mark, env_memsize): remove needless branching
|
||||
|
||||
Sat Sep 13 05:52:15 2014 Eric Wong <e@80x24.org>
|
||||
|
||||
* proc.c (rb_proc_alloc): inline and move to vm.c
|
||||
|
|
31
proc.c
31
proc.c
|
@ -39,30 +39,17 @@ static int method_min_max_arity(VALUE, int *max);
|
|||
|
||||
#define IS_METHOD_PROC_NODE(node) (nd_type(node) == NODE_IFUNC && (node)->nd_cfnc == bmcall)
|
||||
|
||||
static void
|
||||
proc_free(void *ptr)
|
||||
{
|
||||
RUBY_FREE_ENTER("proc");
|
||||
if (ptr) {
|
||||
ruby_xfree(ptr);
|
||||
}
|
||||
RUBY_FREE_LEAVE("proc");
|
||||
}
|
||||
|
||||
static void
|
||||
proc_mark(void *ptr)
|
||||
{
|
||||
rb_proc_t *proc;
|
||||
rb_proc_t *proc = ptr;
|
||||
RUBY_MARK_ENTER("proc");
|
||||
if (ptr) {
|
||||
proc = ptr;
|
||||
RUBY_MARK_UNLESS_NULL(proc->envval);
|
||||
RUBY_MARK_UNLESS_NULL(proc->blockprocval);
|
||||
RUBY_MARK_UNLESS_NULL(proc->block.proc);
|
||||
RUBY_MARK_UNLESS_NULL(proc->block.self);
|
||||
if (proc->block.iseq && RUBY_VM_IFUNC_P(proc->block.iseq)) {
|
||||
RUBY_MARK_UNLESS_NULL((VALUE)(proc->block.iseq));
|
||||
}
|
||||
RUBY_MARK_UNLESS_NULL(proc->envval);
|
||||
RUBY_MARK_UNLESS_NULL(proc->blockprocval);
|
||||
RUBY_MARK_UNLESS_NULL(proc->block.proc);
|
||||
RUBY_MARK_UNLESS_NULL(proc->block.self);
|
||||
if (proc->block.iseq && RUBY_VM_IFUNC_P(proc->block.iseq)) {
|
||||
RUBY_MARK_UNLESS_NULL((VALUE)(proc->block.iseq));
|
||||
}
|
||||
RUBY_MARK_LEAVE("proc");
|
||||
}
|
||||
|
@ -70,14 +57,14 @@ proc_mark(void *ptr)
|
|||
static size_t
|
||||
proc_memsize(const void *ptr)
|
||||
{
|
||||
return ptr ? sizeof(rb_proc_t) : 0;
|
||||
return sizeof(rb_proc_t);
|
||||
}
|
||||
|
||||
static const rb_data_type_t proc_data_type = {
|
||||
"proc",
|
||||
{
|
||||
proc_mark,
|
||||
proc_free,
|
||||
RUBY_TYPED_DEFAULT_FREE,
|
||||
proc_memsize,
|
||||
},
|
||||
NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
|
||||
|
|
54
vm.c
54
vm.c
|
@ -350,57 +350,41 @@ ruby_vm_run_at_exit_hooks(rb_vm_t *vm)
|
|||
static void
|
||||
env_mark(void * const ptr)
|
||||
{
|
||||
RUBY_MARK_ENTER("env");
|
||||
if (ptr) {
|
||||
const rb_env_t * const env = ptr;
|
||||
const rb_env_t * const env = ptr;
|
||||
|
||||
/* TODO: should mark more restricted range */
|
||||
RUBY_GC_INFO("env->env\n");
|
||||
rb_gc_mark_values((long)env->env_size, env->env);
|
||||
/* TODO: should mark more restricted range */
|
||||
RUBY_GC_INFO("env->env\n");
|
||||
rb_gc_mark_values((long)env->env_size, env->env);
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
static void
|
||||
env_free(void * const ptr)
|
||||
{
|
||||
RUBY_FREE_ENTER("env");
|
||||
if (ptr) {
|
||||
ruby_xfree(ptr);
|
||||
}
|
||||
RUBY_FREE_LEAVE("env");
|
||||
}
|
||||
|
||||
static size_t
|
||||
env_memsize(const void *ptr)
|
||||
{
|
||||
if (ptr) {
|
||||
const rb_env_t * const env = ptr;
|
||||
size_t size = sizeof(rb_env_t);
|
||||
const rb_env_t * const env = ptr;
|
||||
size_t size = sizeof(rb_env_t);
|
||||
|
||||
size += (env->env_size - 1) * sizeof(VALUE);
|
||||
return size;
|
||||
}
|
||||
return 0;
|
||||
size += (env->env_size - 1) * sizeof(VALUE);
|
||||
return size;
|
||||
}
|
||||
|
||||
static const rb_data_type_t env_data_type = {
|
||||
"VM/env",
|
||||
{env_mark, env_free, env_memsize,},
|
||||
{env_mark, RUBY_TYPED_DEFAULT_FREE, env_memsize,},
|
||||
NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче