From d4e28e8fd8906ad1051d61cfc01164cb3629dbb5 Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 1 Jun 2017 00:05:33 +0000 Subject: rename absolute_path to realpath internally and introduce pathobj. * vm_core.h: rename absolute_path to realpath because it is expected name. external APIs (#absolute_path methods) are remained. * vm_core.h: remove rb_iseq_location_struct::path and rb_iseq_location_struct::absolute_path and introduce pathobj. if given path equals to given absolute_path (and most of case it is true), pathobj is simply given path String. If it is not same, pathobj is Array and pathobj[0] is path and pathobj[1] is realpath. This size optimization reduce 8 bytes and sizeof(struct rb_iseq_constant_body) is 200 bytes -> 192 bytes on 64bit CPU. To support this change, the following functions are introduced: * pathobj_path() (defined in vm_core.h) * pathobj_realpath() (ditto) * rb_iseq_path() (decl. in vm_core.h) * rb_iseq_realpath() (ditto) * rb_iseq_pathobj_new() (ditto) * rb_iseq_pathobj_set() (ditto) * vm_core.h (rb_binding_t): use pathobj instead of path. If binding is given at eval methods, realpath (absolute_path) was caller's realpath. However, they should use binding's realpath. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- proc.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'proc.c') diff --git a/proc.c b/proc.c index ba67e3ef6d..8ad703cbd3 100644 --- a/proc.c +++ b/proc.c @@ -276,13 +276,9 @@ static void binding_mark(void *ptr) { rb_binding_t *bind = ptr; - RUBY_MARK_ENTER("binding"); - block_mark(&bind->block); - - RUBY_MARK_UNLESS_NULL(bind->path); - + rb_gc_mark(bind->pathobj); RUBY_MARK_LEAVE("binding"); } @@ -320,7 +316,7 @@ binding_dup(VALUE self) GetBindingPtr(self, src); GetBindingPtr(bindval, dst); dst->block = src->block; - dst->path = src->path; + dst->pathobj = src->pathobj; dst->first_lineno = src->first_lineno; return bindval; } @@ -1073,7 +1069,7 @@ iseq_location(const rb_iseq_t *iseq) if (!iseq) return Qnil; rb_iseq_check(iseq); - loc[0] = iseq->body->location.path; + loc[0] = rb_iseq_path(iseq); loc[1] = iseq->body->location.first_lineno; return rb_ary_new4(2, loc); @@ -1225,7 +1221,7 @@ proc_to_s_(VALUE self, const rb_proc_t *proc) { const rb_iseq_t *iseq = rb_iseq_check(block->as.captured.code.iseq); rb_str_catf(str, "%p@%"PRIsVALUE":%d", (void *)self, - iseq->body->location.path, + rb_iseq_path(iseq), FIX2INT(iseq->body->location.first_lineno)); } break; @@ -2777,12 +2773,12 @@ proc_binding(VALUE self) if (iseq) { rb_iseq_check(iseq); - bind->path = iseq->body->location.path; + bind->pathobj = iseq->body->location.pathobj; bind->first_lineno = FIX2INT(rb_iseq_first_lineno(iseq)); } else { - bind->path = Qnil; - bind->first_lineno = 0; + bind->pathobj = rb_iseq_pathobj_new(rb_fstring_cstr("(binding)"), Qnil); + bind->first_lineno = 1; } return bindval; -- cgit v1.2.3