diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-02-21 00:22:50 -0800 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-05 23:28:59 -0800 |
| commit | 4d85f21ee806910db4661a4112c556618ee14a99 (patch) | |
| tree | 50bcc09304f45672ead637c04e44bb2089c752e3 /lib/ruby_vm | |
| parent | 8d29b0635bd87cb8e0521cb0ffdc617382e3cccb (diff) | |
Implement swap
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 | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb index e718f267d6..b9850f3302 100644 --- a/lib/ruby_vm/mjit/insn_compiler.rb +++ b/lib/ruby_vm/mjit/insn_compiler.rb @@ -22,7 +22,7 @@ module RubyVM::MJIT asm.incr_counter(:mjit_insns_count) asm.comment("Insn: #{insn.name}") - # 56/101 + # 57/101 case insn.name when :nop then nop(jit, ctx, asm) when :getlocal then getlocal(jit, ctx, asm) @@ -62,7 +62,7 @@ module RubyVM::MJIT when :pop then pop(jit, ctx, asm) when :dup then dup(jit, ctx, asm) when :dupn then dupn(jit, ctx, asm) - # swap + when :swap then swap(jit, ctx, asm) # opt_reverse when :topn then topn(jit, ctx, asm) when :setn then setn(jit, ctx, asm) @@ -521,7 +521,21 @@ module RubyVM::MJIT KeepCompiling end - # swap + # @param jit [RubyVM::MJIT::JITState] + # @param ctx [RubyVM::MJIT::Context] + # @param asm [RubyVM::MJIT::Assembler] + def swap(jit, ctx, asm) + stack0_mem = ctx.stack_opnd(0) + stack1_mem = ctx.stack_opnd(1) + + asm.mov(:rax, stack0_mem) + asm.mov(:rcx, stack1_mem) + asm.mov(stack0_mem, :rcx) + asm.mov(stack1_mem, :rax) + + KeepCompiling + end + # opt_reverse # @param jit [RubyVM::MJIT::JITState] |
