summaryrefslogtreecommitdiff
path: root/lib/ruby_vm/mjit/compiler.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2022-12-31 14:14:53 -0800
committerTakashi Kokubun <[email protected]>2023-03-05 22:11:20 -0800
commit2b8d1c93ea4d44fba5997901fc4a50b9436bc8b5 (patch)
treee9fe187e757157932a388acf9cae43a6a4c09d21 /lib/ruby_vm/mjit/compiler.rb
parentd7dba4c51066eb706987356ad6b862a0b60b1aeb (diff)
Support extended registers
and move argument registers to a couple of them.
Diffstat (limited to 'lib/ruby_vm/mjit/compiler.rb')
-rw-r--r--lib/ruby_vm/mjit/compiler.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/ruby_vm/mjit/compiler.rb b/lib/ruby_vm/mjit/compiler.rb
index 6203863218..ac094c7007 100644
--- a/lib/ruby_vm/mjit/compiler.rb
+++ b/lib/ruby_vm/mjit/compiler.rb
@@ -16,9 +16,10 @@ module RubyVM::MJIT
Qnil = Fiddle::Qnil
Qundef = Fiddle::Qundef
- # Fixed registers
- EC = :rdi # TODO: change this
- CFP = :rsi # TODO: change this
+ # Callee-saved registers
+ # TODO: support using r12/r13 here
+ EC = :r14
+ CFP = :r15
SP = :rbx
class Compiler
@@ -64,9 +65,15 @@ module RubyVM::MJIT
asm.comment("MJIT entry")
# Save callee-saved registers used by JITed code
+ asm.push(CFP)
+ asm.push(EC)
asm.push(SP)
- # Load sp to a register
+ # Move arguments EC and CFP to dedicated registers
+ asm.mov(EC, :rdi)
+ asm.mov(CFP, :rsi)
+
+ # Load sp to a dedicated register
asm.mov(SP, [CFP, C.rb_control_frame_t.offsetof(:sp)]) # rbx = cfp->sp
end