From 478003f6df40dc79d33c6ec86919f2dde07284be 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 --- vm_backtrace.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'vm_backtrace.c') diff --git a/vm_backtrace.c b/vm_backtrace.c index 5c1cca5aef..ac9a59e4ba 100644 --- a/vm_backtrace.c +++ b/vm_backtrace.c @@ -232,7 +232,7 @@ location_path(rb_backtrace_location_t *loc) switch (loc->type) { case LOCATION_TYPE_ISEQ: case LOCATION_TYPE_ISEQ_CALCED: - return loc->body.iseq.iseq->body->location.path; + return rb_iseq_path(loc->body.iseq.iseq); case LOCATION_TYPE_CFUNC: if (loc->body.cfunc.prev_loc) { return location_path(loc->body.cfunc.prev_loc); @@ -260,20 +260,20 @@ location_path_m(VALUE self) } static VALUE -location_absolute_path(rb_backtrace_location_t *loc) +location_realpath(rb_backtrace_location_t *loc) { switch (loc->type) { case LOCATION_TYPE_ISEQ: case LOCATION_TYPE_ISEQ_CALCED: - return loc->body.iseq.iseq->body->location.absolute_path; + return rb_iseq_realpath(loc->body.iseq.iseq); case LOCATION_TYPE_CFUNC: if (loc->body.cfunc.prev_loc) { - return location_absolute_path(loc->body.cfunc.prev_loc); + return location_realpath(loc->body.cfunc.prev_loc); } return Qnil; case LOCATION_TYPE_IFUNC: default: - rb_bug("location_absolute_path: unreachable"); + rb_bug("location_realpath: unreachable"); UNREACHABLE; } } @@ -286,7 +286,7 @@ location_absolute_path(rb_backtrace_location_t *loc) static VALUE location_absolute_path_m(VALUE self) { - return location_absolute_path(location_ptr(self)); + return location_realpath(location_ptr(self)); } static VALUE @@ -314,20 +314,20 @@ location_to_str(rb_backtrace_location_t *loc) switch (loc->type) { case LOCATION_TYPE_ISEQ: - file = loc->body.iseq.iseq->body->location.path; + file = rb_iseq_path(loc->body.iseq.iseq); name = loc->body.iseq.iseq->body->location.label; lineno = loc->body.iseq.lineno.lineno = calc_lineno(loc->body.iseq.iseq, loc->body.iseq.lineno.pc); loc->type = LOCATION_TYPE_ISEQ_CALCED; break; case LOCATION_TYPE_ISEQ_CALCED: - file = loc->body.iseq.iseq->body->location.path; + file = rb_iseq_path(loc->body.iseq.iseq); lineno = loc->body.iseq.lineno.lineno; name = loc->body.iseq.iseq->body->location.label; break; case LOCATION_TYPE_CFUNC: if (loc->body.cfunc.prev_loc) { - file = loc->body.cfunc.prev_loc->body.iseq.iseq->body->location.path; + file = rb_iseq_path(loc->body.cfunc.prev_loc->body.iseq.iseq); lineno = location_lineno(loc->body.cfunc.prev_loc); } else { @@ -686,7 +686,7 @@ oldbt_iter_iseq(void *ptr, const rb_control_frame_t *cfp) const rb_iseq_t *iseq = cfp->iseq; const VALUE *pc = cfp->pc; struct oldbt_arg *arg = (struct oldbt_arg *)ptr; - VALUE file = arg->filename = iseq->body->location.path; + VALUE file = arg->filename = rb_iseq_path(iseq); VALUE name = iseq->body->location.label; int lineno = arg->lineno = calc_lineno(iseq, pc); @@ -1314,7 +1314,7 @@ VALUE rb_profile_frame_absolute_path(VALUE frame) { const rb_iseq_t *iseq = frame2iseq(frame); - return iseq ? rb_iseq_absolute_path(iseq) : Qnil; + return iseq ? rb_iseq_realpath(iseq) : Qnil; } VALUE -- cgit v1.2.3