From 845b3cfbf486f037e93ef520e344c3451e9559fc Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 25 Jan 2018 12:00:00 +0000 Subject: [PATCH] compile.c: unnecessary freezing * compile.c (iseq_peephole_optimize): get rid of freezing dynamically created string to be duplicated immediately. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/compile.c b/compile.c index 04a32556f2..490ddd5951 100644 --- a/compile.c +++ b/compile.c @@ -2832,6 +2832,22 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal } } + if (IS_INSN_ID(iobj, freezestring) && + IS_NEXT_INSN_ID(&iobj->link, send)) { + INSN *niobj = (INSN *)iobj->link.next; + struct rb_call_info *ci = (struct rb_call_info *)OPERAND_AT(niobj, 0); + /* + * freezestring debug_info + * send <:+@, 0, ARG_SIMPLE> + * => + * send <:+@, 0, ARG_SIMPLE> + */ + if ((ci->flag & VM_CALL_ARGS_SIMPLE) && ci->orig_argc == 0) { + ELEM_REMOVE(list); + return COMPILE_OK; + } + } + if (do_tailcallopt && (IS_INSN_ID(iobj, send) || IS_INSN_ID(iobj, opt_aref_with) ||