1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

compile.c: drop freezestring insn on String#-@

Followup to r62039 and remove the redundant freezestring
insn which was preventing deduplication from String#-@

* compile.c (iseq_peephole_optimize): drop freezestring insn on String#-@
  [ruby-core:85542] [Bug #14475]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2018-02-14 22:35:13 +00:00
parent dc9ce32864
commit 7606806cd9
2 changed files with 18 additions and 3 deletions

View file

@ -2851,11 +2851,11 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
struct rb_call_info *ci = (struct rb_call_info *)OPERAND_AT(niobj, 0);
/*
* freezestring debug_info
* send <:+@, 0, ARG_SIMPLE>
* send <:+@, 0, ARG_SIMPLE> # :-@, too
* =>
* send <:+@, 0, ARG_SIMPLE>
* send <:+@, 0, ARG_SIMPLE> # :-@, too
*/
if (ci->mid == idUPlus &&
if ((ci->mid == idUPlus || ci->mid == idUMinus) &&
(ci->flag & VM_CALL_ARGS_SIMPLE) &&
ci->orig_argc == 0) {
ELEM_REMOVE(list);

View file

@ -568,6 +568,21 @@ class TestRubyOptimization < Test::Unit::TestCase
end
end
def test_peephole_dstr
code = "#{<<~'begin;'}\n#{<<~'end;'}"
begin;
exp = (-'a').object_id
z = 'a'
exp == (-"#{z}").object_id
end;
[ false, true ].each do |fsl|
iseq = RubyVM::InstructionSequence.compile(code,
frozen_string_literal: fsl)
assert_equal(true, iseq.eval,
"[ruby-core:85542] [Bug #14475] fsl: #{fsl}")
end
end
def test_branch_condition_backquote
bug = '[ruby-core:80740] [Bug #13444] redefined backquote should be called'
class << self