summaryrefslogtreecommitdiff
path: root/lib/ruby_vm/mjit/insn_compiler.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2023-02-08 17:42:16 -0800
committerTakashi Kokubun <[email protected]>2023-03-05 22:41:35 -0800
commit091c2ee1acd65bcc17801be6a08dba6b8843ac55 (patch)
treef36d8b26ad81ae1bb3c6163dd52ae13e3d1c77dc /lib/ruby_vm/mjit/insn_compiler.rb
parent557bd8640203efd9056927fbdcfdcfe9e3270235 (diff)
Implement jump
Diffstat (limited to 'lib/ruby_vm/mjit/insn_compiler.rb')
-rw-r--r--lib/ruby_vm/mjit/insn_compiler.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb
index cbf3cfca26..d34b7fa418 100644
--- a/lib/ruby_vm/mjit/insn_compiler.rb
+++ b/lib/ruby_vm/mjit/insn_compiler.rb
@@ -18,7 +18,7 @@ module RubyVM::MJIT
asm.incr_counter(:mjit_insns_count)
asm.comment("Insn: #{insn.name}")
- # 29/101
+ # 30/101
case insn.name
when :nop then nop(jit, ctx, asm)
# getlocal
@@ -82,7 +82,7 @@ module RubyVM::MJIT
# invokeblock
when :leave then leave(jit, ctx, asm)
# throw
- # jump
+ when :jump then jump(jit, ctx, asm)
# branchif
when :branchunless then branchunless(jit, ctx, asm)
# branchnil
@@ -331,7 +331,18 @@ module RubyVM::MJIT
end
# throw
- # jump
+
+ # @param jit [RubyVM::MJIT::JITState]
+ # @param ctx [RubyVM::MJIT::Context]
+ # @param asm [RubyVM::MJIT::Assembler]
+ def jump(jit, ctx, asm)
+ # TODO: check ints for backward branches
+
+ pc = jit.pc + C.VALUE.size * (jit.insn.len + jit.operand(0))
+ stub_next_block(jit.iseq, pc, ctx, asm)
+ EndBlock
+ end
+
# branchif
# @param jit [RubyVM::MJIT::JITState]