diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-02-08 17:17:36 -0800 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-03-05 22:41:35 -0800 |
| commit | eac44ec212cad8c534292447bdf2fd5b795dcf97 (patch) | |
| tree | 79db34ec651c783a3d56262c69bd27acb9220e97 /lib/ruby_vm | |
| parent | 50bd7326c1a09c9c28f5483299c3f199ac8da7b5 (diff) | |
Implement dup
Diffstat (limited to 'lib/ruby_vm')
| -rw-r--r-- | lib/ruby_vm/mjit/context.rb | 6 | ||||
| -rw-r--r-- | lib/ruby_vm/mjit/insn_compiler.rb | 15 |
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/ruby_vm/mjit/context.rb b/lib/ruby_vm/mjit/context.rb index 86aa03514a..fb9db212d5 100644 --- a/lib/ruby_vm/mjit/context.rb +++ b/lib/ruby_vm/mjit/context.rb @@ -7,16 +7,16 @@ module RubyVM::MJIT def initialize(stack_size: 0, sp_offset: 0, chain_depth: 0) = super def stack_push(size = 1) - opnd = [SP, C.VALUE.size * self.sp_offset] self.stack_size += size self.sp_offset += size - opnd + stack_opnd(0) end def stack_pop(size = 1) + opnd = stack_opnd(0) self.stack_size -= size self.sp_offset -= size - [SP, C.VALUE.size * self.sp_offset] + opnd end def stack_opnd(depth_from_top) diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb index 6f96e57ff1..368358b916 100644 --- a/lib/ruby_vm/mjit/insn_compiler.rb +++ b/lib/ruby_vm/mjit/insn_compiler.rb @@ -56,7 +56,7 @@ module RubyVM::MJIT # newhash # newrange # pop - # dup + when :dup then dup(jit, ctx, asm) # dupn # swap # opt_reverse @@ -222,7 +222,18 @@ module RubyVM::MJIT # newhash # newrange # pop - # dup + + # @param jit [RubyVM::MJIT::JITState] + # @param ctx [RubyVM::MJIT::Context] + # @param asm [RubyVM::MJIT::Assembler] + def dup(jit, ctx, asm) + val1 = ctx.stack_opnd(0) + val2 = ctx.stack_push + asm.mov(:rax, val1) + asm.mov(val2, :rax) + KeepCompiling + end + # dupn # swap # opt_reverse |
