diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-03 22:45:25 -0800 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-05 23:28:59 -0800 |
| commit | f2ef352ee0bfa65cef8242740ab7ba5a831d1934 (patch) | |
| tree | 517d6ebe9b21e3aed600fe1025f499ecb4f185ac /lib/ruby_vm | |
| parent | 89f8e20aa410fa0728b638a92adca114a71706c0 (diff) | |
Implement opt_str_freeze
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7448
Diffstat (limited to 'lib/ruby_vm')
| -rw-r--r-- | lib/ruby_vm/mjit/insn_compiler.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb index fa6ab2071c..d245ff2ce2 100644 --- a/lib/ruby_vm/mjit/insn_compiler.rb +++ b/lib/ruby_vm/mjit/insn_compiler.rb @@ -24,7 +24,7 @@ module RubyVM::MJIT asm.incr_counter(:mjit_insns_count) asm.comment("Insn: #{insn.name}") - # 69/101 + # 70/101 case insn.name when :nop then nop(jit, ctx, asm) when :getlocal then getlocal(jit, ctx, asm) @@ -79,7 +79,7 @@ module RubyVM::MJIT when :send then send(jit, ctx, asm) when :opt_send_without_block then opt_send_without_block(jit, ctx, asm) when :objtostring then objtostring(jit, ctx, asm) - # opt_str_freeze + when :opt_str_freeze then opt_str_freeze(jit, ctx, asm) when :opt_nil_p then opt_nil_p(jit, ctx, asm) # opt_str_uminus # opt_newarray_max @@ -1016,7 +1016,23 @@ module RubyVM::MJIT end end - # opt_str_freeze + # @param jit [RubyVM::MJIT::JITState] + # @param ctx [RubyVM::MJIT::Context] + # @param asm [RubyVM::MJIT::Assembler] + def opt_str_freeze(jit, ctx, asm) + unless Invariants.assume_bop_not_redefined(jit, C.STRING_REDEFINED_OP_FLAG, C.BOP_FREEZE) + return CantCompile; + end + + str = jit.operand(0, ruby: true) + + # Push the return value onto the stack + stack_ret = ctx.stack_push + asm.mov(:rax, to_value(str)) + asm.mov(stack_ret, :rax) + + KeepCompiling + end # @param jit [RubyVM::MJIT::JITState] # @param ctx [RubyVM::MJIT::Context] |
