ruby/lib/mjit/insn_compiler.rb
2023-03-05 22:11:20 -08:00

26 lines
531 B
Ruby

module RubyVM::MJIT
# ec: rdi
# cfp: rsi
# sp: rbx
# scratch regs: rax
class InsnCompiler
# Ruby constants
Qnil = Fiddle::Qnil
def putnil(asm)
asm.mov([:rbx], Qnil)
KeepCompiling
end
def leave(asm)
# pop the current frame (ec->cfp++)
asm.add(:rsi, C.rb_control_frame_t.size) # rsi = cfp + 1
asm.mov([:rdi, C.rb_execution_context_t.offsetof(:cfp)], :rsi) # ec->cfp = rsi
# return a value
asm.mov(:rax, 1001)
asm.ret
EndBlock
end
end
end