ruby-changes:41585
From: normal <ko1@a...>
Date: Tue, 26 Jan 2016 15:22:57 +0900 (JST)
Subject: [ruby-changes:41585] normal:r53659 (trunk): fstring early for internal iseq
normal 2016-01-26 15:23:47 +0900 (Tue, 26 Jan 2016) New Revision: 53659 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53659 Log: 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 Modified files: trunk/ChangeLog trunk/compile.c trunk/iseq.c trunk/vm.c Index: vm.c =================================================================== --- vm.c (revision 53658) +++ vm.c (revision 53659) @@ -885,7 +885,7 @@ rb_binding_add_dynavars(rb_binding_t *bi https://github.com/ruby/ruby/blob/trunk/vm.c#L885 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) https://github.com/ruby/ruby/blob/trunk/vm.c#L2911 { 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; Index: ChangeLog =================================================================== --- ChangeLog (revision 53658) +++ ChangeLog (revision 53659) @@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Jan 26 15:21:37 2016 Eric Wong <e@8...> + + * 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@r...> * compile.c (iseq_peephole_optimize): don't apply tailcall Index: iseq.c =================================================================== --- iseq.c (revision 53658) +++ iseq.c (revision 53659) @@ -442,7 +442,8 @@ rb_iseq_new_main(NODE *node, VALUE path, https://github.com/ruby/ruby/blob/trunk/iseq.c#L442 { 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, V https://github.com/ruby/ruby/blob/trunk/iseq.c#L775 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 *ar https://github.com/ruby/ruby/blob/trunk/iseq.c#L814 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 *ar https://github.com/ruby/ruby/blob/trunk/iseq.c#L826 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)); } /* Index: compile.c =================================================================== --- compile.c (revision 53658) +++ compile.c (revision 53659) @@ -6748,7 +6748,7 @@ caller_location(VALUE *path, VALUE *abso https://github.com/ruby/ruby/blob/trunk/compile.c#L6748 return line; } else { - *path = rb_str_new2("<compiled>"); + *path = rb_fstring_cstr("<compiled>"); *absolute_path = *path; return 1; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/