[前][次][番号順一覧][スレッド一覧]

ruby-changes:46865

From: ko1 <ko1@a...>
Date: Thu, 1 Jun 2017 09:05:40 +0900 (JST)
Subject: [ruby-changes:46865] ko1:r58979 (trunk): rename absolute_path to realpath internally and introduce pathobj.

ko1	2017-06-01 09:05:33 +0900 (Thu, 01 Jun 2017)

  New Revision: 58979

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58979

  Log:
    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.

  Modified files:
    trunk/compile.c
    trunk/debug_counter.h
    trunk/gc.c
    trunk/iseq.c
    trunk/iseq.h
    trunk/proc.c
    trunk/vm.c
    trunk/vm_backtrace.c
    trunk/vm_core.h
    trunk/vm_dump.c
    trunk/vm_eval.c
    trunk/vm_method.c
    trunk/vm_trace.c
Index: compile.c
===================================================================
--- compile.c	(revision 58978)
+++ compile.c	(revision 58979)
@@ -175,9 +175,6 @@ struct iseq_compile_data_ensure_node_sta https://github.com/ruby/ruby/blob/trunk/compile.c#L175
 #define NEW_LABEL(l) new_label_body(iseq, (l))
 #define LABEL_FORMAT "<L%03d>"
 
-#define iseq_path(iseq) ((iseq)->body->location.path)
-#define iseq_absolute_path(iseq) ((iseq)->body->location.absolute_path)
-
 #define NEW_ISEQ(node, name, type, line_no) \
   new_child_iseq(iseq, (node), rb_fstring(name), 0, (type), (line_no))
 
@@ -328,7 +325,7 @@ static void https://github.com/ruby/ruby/blob/trunk/compile.c#L325
 append_compile_error(rb_iseq_t *iseq, int line, const char *fmt, ...)
 {
     VALUE err_info = ISEQ_COMPILE_DATA(iseq)->err_info;
-    VALUE file = iseq->body->location.path;
+    VALUE file = rb_iseq_path(iseq);
     VALUE err = err_info == Qtrue ? Qfalse : err_info;
     va_list args;
 
@@ -349,7 +346,7 @@ compile_bug(rb_iseq_t *iseq, int line, c https://github.com/ruby/ruby/blob/trunk/compile.c#L346
 {
     va_list args;
     va_start(args, fmt);
-    rb_report_bug_valist(iseq->body->location.path, line, fmt, args);
+    rb_report_bug_valist(rb_iseq_path(iseq), line, fmt, args);
     va_end(args);
     abort();
 }
@@ -532,7 +529,7 @@ iseq_add_mark_object(const rb_iseq_t *is https://github.com/ruby/ruby/blob/trunk/compile.c#L529
     return COMPILE_OK;
 }
 
-#define ruby_sourcefile		RSTRING_PTR(iseq->body->location.path)
+#define ruby_sourcefile		RSTRING_PTR(rb_iseq_path(iseq))
 
 static int
 iseq_add_mark_object_compile_time(const rb_iseq_t *iseq, VALUE v)
@@ -1116,7 +1113,7 @@ new_child_iseq(rb_iseq_t *iseq, NODE *no https://github.com/ruby/ruby/blob/trunk/compile.c#L1113
 
     debugs("[new_child_iseq]> ---------------------------------------\n");
     ret_iseq = rb_iseq_new_with_opt(node, name,
-				    iseq_path(iseq), iseq_absolute_path(iseq),
+				    rb_iseq_path(iseq), rb_iseq_realpath(iseq),
 				    INT2FIX(line_no), parent, type, ISEQ_COMPILE_DATA(iseq)->option);
     debugs("[new_child_iseq]< ---------------------------------------\n");
     iseq_add_mark_object(iseq, (VALUE)ret_iseq);
@@ -5809,7 +5806,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L5806
 	    }
 	    else {
 		if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
-		    VALUE debug_info = rb_ary_new_from_args(2, iseq->body->location.path, INT2FIX(line));
+		    VALUE debug_info = rb_ary_new_from_args(2, rb_iseq_path(iseq), INT2FIX(line));
 		    VALUE str = rb_str_dup(node->nd_lit);
 		    rb_ivar_set(str, id_debug_created_info, rb_obj_freeze(debug_info));
 		    ADD_INSN1(ret, line, putobject, rb_obj_freeze(str));
@@ -5832,7 +5829,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L5829
 	    if (ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal) {
 		VALUE debug_info = Qnil;
 		if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
-		    debug_info = rb_ary_new_from_args(2, iseq->body->location.path, INT2FIX(line));
+		    debug_info = rb_ary_new_from_args(2, rb_iseq_path(iseq), INT2FIX(line));
 		    iseq_add_mark_object_compile_time(iseq, rb_obj_freeze(debug_info));
 		}
 		ADD_INSN1(ret, line, freezestring, debug_info);
@@ -7148,7 +7145,7 @@ rb_local_defined(ID id, const struct rb_ https://github.com/ruby/ruby/blob/trunk/compile.c#L7145
 }
 
 static int
-caller_location(VALUE *path, VALUE *absolute_path)
+caller_location(VALUE *path, VALUE *realpath)
 {
     const rb_thread_t *const th = GET_THREAD();
     const rb_control_frame_t *const cfp =
@@ -7156,13 +7153,13 @@ caller_location(VALUE *path, VALUE *abso https://github.com/ruby/ruby/blob/trunk/compile.c#L7153
 
     if (cfp) {
 	int line = rb_vm_get_sourceline(cfp);
-	*path = cfp->iseq->body->location.path;
-	*absolute_path = cfp->iseq->body->location.absolute_path;
+	*path = rb_iseq_path(cfp->iseq);
+	*realpath = rb_iseq_realpath(cfp->iseq);
 	return line;
     }
     else {
 	*path = rb_fstring_cstr("<compiled>");
-	*absolute_path = *path;
+	*realpath = *path;
 	return 1;
     }
 }
@@ -7177,14 +7174,14 @@ static const rb_iseq_t * https://github.com/ruby/ruby/blob/trunk/compile.c#L7174
 method_for_self(VALUE name, VALUE arg, rb_insn_func_t func,
 		VALUE (*build)(rb_iseq_t *, LINK_ANCHOR *const, VALUE))
 {
-    VALUE path, absolute_path;
+    VALUE path, realpath;
     accessor_args acc;
 
     acc.arg = arg;
     acc.func = func;
-    acc.line = caller_location(&path, &absolute_path);
+    acc.line = caller_location(&path, &realpath);
     return rb_iseq_new_with_opt((NODE *)IFUNC_NEW(build, (VALUE)&acc, 0),
-				rb_sym2str(name), path, absolute_path,
+				rb_sym2str(name), path, realpath,
 				INT2FIX(acc.line), 0, ISEQ_TYPE_METHOD, 0);
 }
 
@@ -7797,8 +7794,7 @@ ibf_dump_iseq_each(struct ibf_dump *dump https://github.com/ruby/ruby/blob/trunk/compile.c#L7794
     struct rb_iseq_constant_body dump_body;
     dump_body = *iseq->body;
 
-    dump_body.location.path = ibf_dump_object(dump, dump_body.location.path);
-    dump_body.location.absolute_path = ibf_dump_object(dump, dump_body.location.absolute_path);
+    dump_body.location.pathobj = ibf_dump_object(dump, dump_body.location.pathobj); /* TODO: freeze */
     dump_body.location.base_label = ibf_dump_object(dump, dump_body.location.base_label);
     dump_body.location.label = ibf_dump_object(dump, dump_body.location.label);
 
@@ -7847,8 +7843,7 @@ ibf_load_iseq_each(const struct ibf_load https://github.com/ruby/ruby/blob/trunk/compile.c#L7843
 
     RB_OBJ_WRITE(iseq, &load_body->mark_ary, iseq_mark_ary_create((int)body->mark_ary));
 
-    RB_OBJ_WRITE(iseq, &load_body->location.path,          ibf_load_location_str(load, body->location.path));
-    RB_OBJ_WRITE(iseq, &load_body->location.absolute_path, ibf_load_location_str(load, body->location.absolute_path));
+    RB_OBJ_WRITE(iseq, &load_body->location.pathobj,       ibf_load_location_str(load, body->location.pathobj));
     RB_OBJ_WRITE(iseq, &load_body->location.base_label,    ibf_load_location_str(load, body->location.base_label));
     RB_OBJ_WRITE(iseq, &load_body->location.label,         ibf_load_location_str(load, body->location.label));
     load_body->location.first_lineno = body->location.first_lineno;
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 58978)
+++ vm_eval.c	(revision 58979)
@@ -1296,20 +1296,20 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1296
 	rb_cref_t *cref = cref_arg;
 	rb_binding_t *bind = 0;
 	const rb_iseq_t *iseq;
-	VALUE absolute_path = Qnil;
+	VALUE realpath = Qnil;
 	VALUE fname;
 
 	if (file != Qundef) {
-	    absolute_path = file;
+	    realpath = file;
 	}
 
 	if (!NIL_P(scope)) {
 	    bind = Check_TypedStruct(scope, &ruby_binding_data_type);
 
-	    if (NIL_P(absolute_path) && !NIL_P(bind->path)) {
-		file = bind->path;
+	    if (NIL_P(realpath)) {
+		file = pathobj_path(bind->pathobj);
+		realpath = pathobj_realpath(bind->pathobj);
 		line = bind->first_lineno;
-		absolute_path = rb_current_realfilepath();
 	    }
 	    base_block = &bind->block;
 	}
@@ -1332,13 +1332,8 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1332
 	    fname = rb_usascii_str_new_cstr("(eval)");
 	}
 
-	if (RTEST(fname))
-	    fname = rb_fstring(fname);
-	if (RTEST(absolute_path))
-	    absolute_path = rb_fstring(absolute_path);
-
 	/* make eval iseq */
-	iseq = rb_iseq_compile_with_option(src, fname, absolute_path, INT2FIX(line), base_block, Qnil);
+	iseq = rb_iseq_compile_with_option(src, fname, realpath, INT2FIX(line), base_block, Qnil);
 
 	if (!iseq) {
 	    rb_exc_raise(adjust_backtrace_in_eval(th, th->errinfo));
@@ -2180,7 +2175,7 @@ rb_current_realfilepath(void) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2175
     rb_thread_t *th = GET_THREAD();
     rb_control_frame_t *cfp = th->ec.cfp;
     cfp = vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
-    if (cfp != 0) return cfp->iseq->body->location.absolute_path;
+    if (cfp != 0) return rb_iseq_realpath(cfp->iseq);
     return Qnil;
 }
 
Index: vm_trace.c
===================================================================
--- vm_trace.c	(revision 58978)
+++ vm_trace.c	(revision 58979)
@@ -753,7 +753,7 @@ fill_path_and_lineno(rb_trace_arg_t *tra https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L753
 	rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(trace_arg->th, trace_arg->cfp);
 
 	if (cfp) {
-	    trace_arg->path = cfp->iseq->body->location.path;
+	    trace_arg->path = rb_iseq_path(cfp->iseq);
 	    trace_arg->lineno = rb_vm_get_sourceline(cfp);
 	}
 	else {
Index: gc.c
===================================================================
--- gc.c	(revision 58978)
+++ gc.c	(revision 58979)
@@ -9210,7 +9210,7 @@ rb_raw_iseq_info(char *buff, const int b https://github.com/ruby/ruby/blob/trunk/gc.c#L9210
     if (iseq->body->location.label) {
 	snprintf(buff, buff_size, "%s %s@%s:%d", buff,
 		 RSTRING_PTR(iseq->body->location.label),
-		 RSTRING_PTR(iseq->body->location.path),
+		 RSTRING_PTR(rb_iseq_path(iseq)),
 		 FIX2INT(iseq->body->location.first_lineno));
     }
 }
Index: vm_dump.c
===================================================================
--- vm_dump.c	(revision 58978)
+++ vm_dump.c	(revision 58979)
@@ -107,7 +107,7 @@ control_frame_dump(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L107
 	    iseq_name = RSTRING_PTR(cfp->iseq->body->location.label);
 	    line = rb_vm_get_sourceline(cfp);
 	    if (line) {
-		snprintf(posbuf, MAX_POSBUF, "%s:%d", RSTRING_PTR(cfp->iseq->body->location.path), line);
+		snprintf(posbuf, MAX_POSBUF, "%s:%d", RSTRING_PTR(rb_iseq_path(cfp->iseq)), line);
 	    }
 	}
     }
Index: debug_counter.h
===================================================================
--- debug_counter.h	(revision 58978)
+++ debug_counter.h	(revision 58979)
@@ -61,6 +61,11 @@ RB_DEBUG_COUNTER(obj_ary_embed) https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L61
 
 RB_DEBUG_COUNTER(obj_obj_ptr)
 RB_DEBUG_COUNTER(obj_obj_embed)
+
+/* load */
+RB_DEBUG_COUNTER(load_files)
+RB_DEBUG_COUNTER(load_path_is_not_realpath)
+
 #endif
 
 #ifndef RUBY_DEBUG_COUNTER_H
Index: vm.c
===================================================================
--- vm.c	(revision 58978)
+++ vm.c	(revision 58979)
@@ -902,7 +902,7 @@ rb_vm_make_binding(rb_thread_t *th, cons https://github.com/ruby/ruby/blob/trunk/vm.c#L902
     vm_bind_update_env(bind, envval);
     bind->block.as.captured.self = cfp->self;
     bind->block.as.captured.code.iseq = cfp->iseq;
-    bind->path = ruby_level_cfp->iseq->body->location.path;
+    bind->pathobj = ruby_level_cfp->iseq->body->location.pathobj;
     bind->first_lineno = rb_vm_get_sourceline(ruby_level_cfp);
 
     return bindval;
@@ -911,7 +911,9 @@ rb_vm_make_binding(rb_thread_t *th, cons https://github.com/ruby/ruby/blob/trunk/vm.c#L911
 const VALUE *
 rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars)
 {
-    VALUE envval, path = bind->path;
+    VALUE envval, pathobj = bind->pathobj;
+    VALUE path = pathobj_path(pathobj);
+    VALUE realpath = pathobj_realpath(pathobj);
     const struct rb_block *base_block;
     const rb_env_t *env;
     rb_thread_t *th = GET_THREAD();
@@ -932,7 +934,7 @@ rb_binding_add_dynavars(rb_binding_t *bi https://github.com/ruby/ruby/blob/trunk/vm.c#L934
     node = NEW_NODE(NODE_SCOPE, dyns, 0, 0);
 
     if (base_iseq) {
-	iseq = rb_iseq_new(node, base_iseq->body->location.label, path, path, base_iseq, ISEQ_TYPE_EVAL);
+	iseq = rb_iseq_new(node, base_iseq->body->location.label, path, realpath, base_iseq, ISEQ_TYPE_EVAL);
     }
     else {
 	VALUE tempstr = rb_fstring_cstr("<temp>");
@@ -1234,7 +1236,7 @@ rb_sourcefilename(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L1236
     rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec.cfp);
 
     if (cfp) {
-	return cfp->iseq->body->location.path;
+	return rb_iseq_path(cfp->iseq);
     }
     else {
 	return Qnil;
@@ -1248,7 +1250,7 @@ rb_sourcefile(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L1250
     rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec.cfp);
 
     if (cfp) {
-	return RSTRING_PTR(cfp->iseq->body->location.path);
+	return RSTRING_PTR(rb_iseq_path(cfp->iseq));
     }
     else {
 	return 0;
@@ -1277,7 +1279,7 @@ rb_source_location(int *pline) https://github.com/ruby/ruby/blob/trunk/vm.c#L1279
 
     if (cfp) {
 	if (pline) *pline = rb_vm_get_sourceline(cfp);
-	return cfp->iseq->body->location.path;
+	return rb_iseq_path(cfp->iseq);
     }
     else {
 	if (pline) *pline = 0;
@@ -2060,7 +2062,7 @@ rb_thread_current_status(const rb_thread https://github.com/ruby/ruby/blob/trunk/vm.c#L2062
 	    const rb_iseq_t *iseq = cfp->iseq;
 	    int line_no = rb_vm_get_sourceline(cfp);
 	    str = rb_sprintf("%"PRIsVALUE":%d:in `%"PRIsVALUE"'",
-			     iseq->body->location.path, line_no, iseq->body->location.label);
+			     rb_iseq_path(iseq), line_no, iseq->body->location.label);
 	}
     }
     else if ((me = rb_vm_frame_method_entry(cfp)) && me->def->original_id) {
@@ -3085,7 +3087,8 @@ rb_vm_set_progname(VALUE filename) https://github.com/ruby/ruby/blob/trunk/vm.c#L3087
     rb_thread_t *th = GET_VM()->main_thread;
     rb_control_frame_t *cfp = (void *)(th->ec.stack + th->ec.stack_size);
     --cfp;
-    RB_OBJ_WRITE(cfp->iseq, &cfp->iseq->body->location.path, filename);
+
+    rb_iseq_pathobj_set(cfp->iseq, rb_str_dup(filename), rb_iseq_realpath(cfp->iseq));
 }
 
 extern const struct st_hash_type rb_fstring_hash_type;
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 58978)
+++ vm_method.c	(revision 58979)
@@ -267,7 +267,7 @@ method_definition_set(const rb_method_en https://github.com/ruby/ruby/blob/trunk/vm_method.c#L267
 		cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec.cfp);
 
 		if (cfp && (line = rb_vm_get_sourceline(cfp))) {
-		    VALUE location = rb_ary_new3(2, cfp->iseq->body->location.path, INT2FIX(line));
+		    VALUE location = rb_ary_new3(2, rb_iseq_path(cfp->iseq), INT2FIX(line));
 		    RB_OBJ_WRITE(me, &def->body.attr.location, rb_ary_freeze(location));
 		}
 		else {
@@ -558,7 +558,7 @@ rb_method_entry_make(VALUE klass, ID mid https://github.com/ruby/ruby/blob/trunk/vm_method.c#L558
 		break;
 	    }
 	    if (iseq) {
-		rb_compile_warning(RSTRING_PTR(iseq->body->location.path),
+		rb_compile_warning(RSTRING_PTR(rb_iseq_path(iseq)),
 				   FIX2INT(iseq->body->location.first_lineno),
 				   "previous definition of %"PRIsVALUE" was here",
 				   rb_id2str(old_def->original_id));
Index: iseq.c
===================================================================
--- iseq.c	(revision 58978)
+++ iseq.c	(revision 58979)
@@ -107,16 +107,13 @@ rb_iseq_mark(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L107
 {
     RUBY_MARK_ENTER("iseq");
 
-    RUBY_GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->body->location.label), RSTRING_PTR(iseq->body->location.path));
-
     if (iseq->body) {
 	const struct rb_iseq_constant_body *body = iseq->body;
 
 	RUBY_MARK_UNLESS_NULL(body->mark_ary);
 	rb_gc_mark(body->location.label);
 	rb_gc_mark(body->location.base_label);
-	rb_gc_mark(body->location.path);
-	RUBY_MARK_UNLESS_NULL(body->location.absolute_path);
+	rb_gc_mark(body->location.pathobj);
 	RUBY_MARK_UNLESS_NULL((VALUE)body->parent_iseq);
     }
 
@@ -216,17 +213,38 @@ iseq_alloc(void) https://github.com/ruby/ruby/blob/trunk/iseq.c#L213
     return iseq;
 }
 
-static rb_iseq_location_t *
-iseq_location_setup(rb_iseq_t *iseq, VALUE path, VALUE absolute_path, VALUE name, VALUE first_lineno)
+VALUE
+rb_iseq_pathobj_new(VALUE path, VALUE realpath)
 {
-    rb_iseq_location_t *loc = &iseq->body->location;
-    RB_OBJ_WRITE(iseq, &loc->path, path);
-    if (RTEST(absolute_path) && rb_str_cmp(path, absolute_path) == 0) {
-	RB_OBJ_WRITE(iseq, &loc->absolute_path, path);
+    VALUE pathobj;
+    VM_ASSERT(RB_TYPE_P(path, T_STRING));
+    VM_ASSERT(realpath == Qnil || RB_TYPE_P(realpath, T_STRING));
+
+    if (path == realpath ||
+	(!NIL_P(realpath) && rb_str_cmp(path, realpath) == 0)) {
+	pathobj = rb_fstring(path);
     }
     else {
-	RB_OBJ_WRITE(iseq, &loc->absolute_path, absolute_path);
+	if (!NIL_P(realpath)) realpath = rb_fstring(realpath);
+	pathobj = rb_ary_new_from_args(2, rb_fstring(path), realpath);
+	rb_obj_freeze(pathobj);
     }
+    return pathobj;
+}
+
+void
+rb_iseq_pathobj_set(const rb_iseq_t *iseq, VALUE path, VALUE realpath)
+{
+    RB_OBJ_WRITE(iseq, &iseq->body->location.pathobj,
+		 rb_iseq_pathobj_new(path, realpath));
+}
+
+static rb_iseq_location_t *
+iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno)
+{
+    rb_iseq_location_t *loc = &iseq->body->location;
+
+    rb_iseq_pathobj_set(iseq, path, realpath);
     RB_OBJ_WRITE(iseq, &loc->label, name);
     RB_OBJ_WRITE(iseq, &loc->base_label, name);
     loc->first_lineno = first_lineno;
@@ -267,7 +285,7 @@ rb_iseq_add_mark_object(const rb_iseq_t https://github.com/ruby/ruby/blob/trunk/iseq.c#L285
 
 static VALUE
 prepare_iseq_build(rb_iseq_t *iseq,
-		   VALUE name, VALUE path, VALUE absolute_path, VALUE first_lineno,
+		   VALUE name, VALUE path, VALUE realpath, VALUE first_lineno,
 		   const rb_iseq_t *parent, enum iseq_type type,
 		   const rb_compile_option_t *option)
 {
@@ -281,9 +299,7 @@ prepare_iseq_build(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/iseq.c#L299
     set_relation(iseq, parent);
 
     name = rb_fstring(name);
-    path = rb_fstring(path);
-    if (RTEST(absolute_path)) absolute_path = rb_fstring(absolute_path);
-    iseq_location_setup(iseq, path, absolute_path, name, first_lineno);
+    iseq_location_setup(iseq, name, path, realpath, first_lineno);
     if (iseq != iseq->body->local_iseq) {
 	RB_OBJ_WRITE(iseq, &iseq->body->location.base_label, iseq->body->local_iseq->body->location.label);
     }
@@ -311,7 +327,7 @@ prepare_iseq_build(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/iseq.c#L327
     if (option->coverage_enabled) {
 	VALUE coverages = rb_get_coverages();
 	if (RTEST(coverages)) {
-	    coverage = rb_hash_lookup(coverages, path);
+	    coverage = rb_hash_lookup(coverages, rb_iseq_path(iseq));
 	    if (NIL_P(coverage)) coverage = Qfalse;
 	}
     }
@@ -329,8 +345,9 @@ cleanup_iseq_build(rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L345
     compile_data_free(data);
 
     if (RTEST(err)) {
+	VALUE path = pathobj_path(iseq->body->location.pathobj);
 	if (err == Qtrue) err = rb_exc_new_cstr(rb_eSyntaxError, "compile error");
-	rb_funcallv(err, rb_intern("set_backtrace"), 1, &iseq->body->location.path);
+	rb_funcallv(err, rb_intern("set_backtrace"), 1, &path);
 	rb_exc_raise(err);
     }
     return Qtrue;
@@ -438,25 +455,25 @@ make_compile_option_value(rb_compile_opt https://github.com/ruby/ruby/blob/trunk/iseq.c#L455
 }
 
 rb_iseq_t *
-rb_iseq_new(NODE *node, VALUE name, VALUE path, VALUE absolute_path,
+rb_iseq_new(NODE *node, VALUE name, VALUE path, VALUE realpath,
 	    const rb_iseq_t *parent, enum iseq_type type)
 {
-    return rb_iseq_new_with_opt(node, name, path, absolute_path, INT2FIX(0), parent, type,
+    return rb_iseq_new_with_opt(node, name, path, realpath, INT2FIX(0), parent, type,
 				&COMPILE_OPTION_DEFAULT);
 }
 
 rb_iseq_t *
-rb_iseq_new_top(NODE *node, VALUE name, VALUE path, VALUE absolute_path, const rb_iseq_t *parent)
+rb_iseq_new_top(NODE *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
 {
-    return rb_iseq_new_with_opt(node, name, path, absolute_path, INT2FIX(0), parent, ISEQ_TYPE_TOP,
+    return rb_iseq_new_with_opt(node,  (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]