summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-25 12:00:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-25 12:00:00 +0000
commit845b3cfbf486f037e93ef520e344c3451e9559fc (patch)
tree6fb8278934594a7322b4579652762811e6852a6b /compile.c
parent07decad25f969908f7b2cc97208548605e35c5db (diff)
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
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c16
1 files changed, 16 insertions, 0 deletions
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) ||