mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
fstring early for internal iseq
All of the strings created here eventually get converted to fstrings when they are frozen into the iseq. Prepare the fstring early so we may reduce a one or two objects. This is a very minor change, mainly for the '<main>' dedupe. * compile.c (caller_location): use rb_fstring_cstr for "<compiled>" (it is converted to fstring anyways inside rb_iseq_new_with_opt) * iseq.c (iseqw_s_compile): ditto * iseq.c (rb_iseq_new_main): use rb_fstring_cstr for "<main>" * vm.c (Init_VM): ditto, share with with above * iseq.c (iseqw_s_compile_file): rb_fstring before rb_io_t->pathv share "<main>" with above * vm.c (rb_binding_add_dynavars): fstring "<temp>" immediately git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f4ca0739ec
commit
1282a4a895
4 changed files with 22 additions and 8 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Tue Jan 26 15:21:37 2016 Eric Wong <e@80x24.org>
|
||||
|
||||
* compile.c (caller_location): use rb_fstring_cstr for "<compiled>"
|
||||
(it is converted to fstring anyways inside rb_iseq_new_with_opt)
|
||||
* iseq.c (iseqw_s_compile): ditto
|
||||
* iseq.c (rb_iseq_new_main): use rb_fstring_cstr for "<main>"
|
||||
* vm.c (Init_VM): ditto, share with with above
|
||||
* iseq.c (iseqw_s_compile_file): rb_fstring before rb_io_t->pathv
|
||||
share "<main>" with above
|
||||
* vm.c (rb_binding_add_dynavars): fstring "<temp>" immediately
|
||||
|
||||
Tue Jan 26 15:14:01 2016 Kazuki Yamaguchi <k@rhe.jp>
|
||||
|
||||
* compile.c (iseq_peephole_optimize): don't apply tailcall
|
||||
|
|
|
@ -6748,7 +6748,7 @@ caller_location(VALUE *path, VALUE *absolute_path)
|
|||
return line;
|
||||
}
|
||||
else {
|
||||
*path = rb_str_new2("<compiled>");
|
||||
*path = rb_fstring_cstr("<compiled>");
|
||||
*absolute_path = *path;
|
||||
return 1;
|
||||
}
|
||||
|
|
13
iseq.c
13
iseq.c
|
@ -442,7 +442,8 @@ rb_iseq_new_main(NODE *node, VALUE path, VALUE absolute_path)
|
|||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
const rb_iseq_t *parent = th->base_block->iseq;
|
||||
return rb_iseq_new_with_opt(node, rb_str_new2("<main>"), path, absolute_path, INT2FIX(0),
|
||||
return rb_iseq_new_with_opt(node, rb_fstring_cstr("<main>"),
|
||||
path, absolute_path, INT2FIX(0),
|
||||
parent, ISEQ_TYPE_MAIN, &COMPILE_OPTION_DEFAULT);
|
||||
}
|
||||
|
||||
|
@ -774,7 +775,7 @@ iseqw_s_compile(int argc, VALUE *argv, VALUE self)
|
|||
rb_secure(1);
|
||||
|
||||
rb_scan_args(argc, argv, "14", &src, &file, &path, &line, &opt);
|
||||
if (NIL_P(file)) file = rb_str_new2("<compiled>");
|
||||
if (NIL_P(file)) file = rb_fstring_cstr("<compiled>");
|
||||
if (NIL_P(line)) line = INT2FIX(1);
|
||||
|
||||
return iseqw_new(rb_iseq_compile_with_option(src, file, path, line, 0, opt));
|
||||
|
@ -813,6 +814,7 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
|
|||
rb_secure(1);
|
||||
rb_scan_args(argc, argv, "11", &file, &opt);
|
||||
FilePathValue(file);
|
||||
file = rb_fstring(file); /* rb_io_t->pathv gets frozen anyways */
|
||||
fname = StringValueCStr(file);
|
||||
|
||||
f = rb_file_open_str(file, "r");
|
||||
|
@ -824,9 +826,10 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
|
|||
|
||||
make_compile_option(&option, opt);
|
||||
|
||||
return iseqw_new(rb_iseq_new_with_opt(node, rb_str_new2("<main>"), file,
|
||||
rb_realpath_internal(Qnil, file, 1), line, NULL,
|
||||
ISEQ_TYPE_TOP, &option));
|
||||
return iseqw_new(rb_iseq_new_with_opt(node, rb_fstring_cstr("<main>"),
|
||||
file,
|
||||
rb_realpath_internal(Qnil, file, 1),
|
||||
line, NULL, ISEQ_TYPE_TOP, &option));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
4
vm.c
4
vm.c
|
@ -885,7 +885,7 @@ rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars)
|
|||
iseq = rb_iseq_new(node, base_iseq->body->location.label, path, path, base_iseq, ISEQ_TYPE_EVAL);
|
||||
}
|
||||
else {
|
||||
VALUE tempstr = rb_str_new2("<temp>");
|
||||
VALUE tempstr = rb_fstring_cstr("<temp>");
|
||||
iseq = rb_iseq_new_top(node, tempstr, tempstr, tempstr, NULL);
|
||||
}
|
||||
node->u1.tbl = 0; /* reset table */
|
||||
|
@ -2911,7 +2911,7 @@ Init_VM(void)
|
|||
{
|
||||
rb_vm_t *vm = ruby_current_vm;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
VALUE filename = rb_str_new2("<main>");
|
||||
VALUE filename = rb_fstring_cstr("<main>");
|
||||
const rb_iseq_t *iseq = rb_iseq_new(0, filename, filename, Qnil, 0, ISEQ_TYPE_TOP);
|
||||
volatile VALUE th_self;
|
||||
|
||||
|
|
Loading…
Reference in a new issue