Define constants for magic registers

This commit is contained in:
Takashi Kokubun 2022-12-23 16:23:21 -08:00
parent 783f730773
commit 5db2ef5e14
2 changed files with 16 additions and 11 deletions

View file

@ -7,7 +7,7 @@ module RubyVM::MJIT
# @param ctx [RubyVM::MJIT::Context]
# @param asm [RubyVM::MJIT::X86Assembler]
def putnil(ctx, asm)
asm.mov([:rbx], Qnil)
asm.mov([SP], Qnil)
ctx.stack_size += 1
KeepCompiling
end
@ -19,14 +19,14 @@ module RubyVM::MJIT
# TODO: Check interrupts
# 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
asm.add(CFP, C.rb_control_frame_t.size) # cfp = cfp + 1
asm.mov([EC, C.rb_execution_context_t.offsetof(:cfp)], CFP) # ec->cfp = cfp
# Return a value
asm.mov(:rax, [:rbx])
asm.mov(:rax, [SP])
# Restore callee-saved registers
asm.pop(:rbx)
asm.pop(SP)
asm.ret
EndBlock