summaryrefslogtreecommitdiff
path: root/lib/ruby_vm
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-01-04 00:12:16 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2023-03-05 22:11:20 -0800
commit1f69ba1d8413abe20e95f74761ba267f0e35c649 (patch)
tree5565b8f3eedbb1502360d27b5b15a5e2bffad413 /lib/ruby_vm
parentee80b2be20ae8a5102ac478f2b0fc0cf8786eaa3 (diff)
Use the actual sp_offset
Diffstat (limited to 'lib/ruby_vm')
-rw-r--r--lib/ruby_vm/mjit/assembler.rb9
-rw-r--r--lib/ruby_vm/mjit/exit_compiler.rb4
-rw-r--r--lib/ruby_vm/mjit/insn_compiler.rb2
3 files changed, 13 insertions, 2 deletions
diff --git a/lib/ruby_vm/mjit/assembler.rb b/lib/ruby_vm/mjit/assembler.rb
index bc42ad1a6a..f23696244d 100644
--- a/lib/ruby_vm/mjit/assembler.rb
+++ b/lib/ruby_vm/mjit/assembler.rb
@@ -215,6 +215,15 @@ module RubyVM::MJIT
mod_rm: ModRM[mod: Mod01, reg: dst_reg, rm: src_reg],
disp: src_disp,
)
+ # MOV r32, imm32 (Mod 11: reg)
+ in Integer => src_imm if r32?(dst_reg) && imm32?(src_imm)
+ # B8+ rd id
+ # OI: Operand 1: opcode + rd (w), Operand 2: imm8/16/32/64
+ insn(
+ opcode: 0xb8,
+ rd: dst_reg,
+ imm: imm32(src_imm),
+ )
# MOV r/m64, imm32 (Mod 11: reg)
in Integer => src_imm if r64?(dst_reg) && imm32?(src_imm)
# REX.W + C7 /0 id
diff --git a/lib/ruby_vm/mjit/exit_compiler.rb b/lib/ruby_vm/mjit/exit_compiler.rb
index d92f8a1588..a1eca9fe23 100644
--- a/lib/ruby_vm/mjit/exit_compiler.rb
+++ b/lib/ruby_vm/mjit/exit_compiler.rb
@@ -45,9 +45,10 @@ module RubyVM::MJIT
end
# @param jit [RubyVM::MJIT::JITState]
+ # @param ctx [RubyVM::MJIT::Context]
# @param asm [RubyVM::MJIT::Assembler]
# @param stub [RubyVM::MJIT::BlockStub]
- def compile_jump_stub(jit, asm, stub)
+ def compile_jump_stub(jit, ctx, asm, stub)
case stub
when BlockStub
asm.comment("block stub hit: #{stub.iseq.body.location.label}@#{C.rb_iseq_path(stub.iseq)}:#{stub.iseq.body.location.first_lineno}")
@@ -57,6 +58,7 @@ module RubyVM::MJIT
# Call rb_mjit_stub_hit
asm.mov(:rdi, to_value(stub))
+ asm.mov(:esi, ctx.sp_offset)
asm.call(C.rb_mjit_stub_hit)
# Jump to the address returned by rb_mjit_stub_hit
diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb
index c17167a4ac..3468be9598 100644
--- a/lib/ruby_vm/mjit/insn_compiler.rb
+++ b/lib/ruby_vm/mjit/insn_compiler.rb
@@ -375,7 +375,7 @@ module RubyVM::MJIT
)
stub_hit = Assembler.new.then do |ocb_asm|
- @exit_compiler.compile_jump_stub(jit, ocb_asm, block_stub)
+ @exit_compiler.compile_jump_stub(jit, ctx, ocb_asm, block_stub)
@ocb.write(ocb_asm)
end