summaryrefslogtreecommitdiff
path: root/vm_backtrace.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-01 00:05:33 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-01 00:05:33 +0000
commit478003f6df40dc79d33c6ec86919f2dde07284be (patch)
tree3c6d414535225ab0eaba19095da58f0fd26371b5 /vm_backtrace.c
parentd0015e4ac6b812ea1681b1f5fa86fbab52a58960 (diff)
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
Diffstat (limited to 'vm_backtrace.c')
-rw-r--r--vm_backtrace.c22
1 files changed, 11 insertions, 11 deletions
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