summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-12 21:34:12 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-12 21:34:12 (GMT)
commit1972a3136c52393b9597f2eb6262e9ccd11e84b8 (patch)
treef38c7c6f29fc699525069a7128292e891e6b9790 /vm.c
parentbb2cec10c0c0ea7c806204cb313db772f2607cb2 (diff)
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
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c54
1 files changed, 19 insertions, 35 deletions
diff --git a/vm.c b/vm.c
index 7591f97..341b04d 100644
--- a/vm.c
+++ b/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
};