summaryrefslogtreecommitdiff
path: root/lib/ruby_vm/mjit/insn_compiler.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2023-01-07 13:39:33 -0800
committerTakashi Kokubun <[email protected]>2023-03-05 22:11:20 -0800
commit850303ded65e2a949732a6a7d037079d610d22a6 (patch)
treedc6acf8c74bcf75db67b9a56f4e0c6cf070289d4 /lib/ruby_vm/mjit/insn_compiler.rb
parent62d36dd1277bdfeac609f89bc64589e8856421b8 (diff)
Implement putself
Diffstat (limited to 'lib/ruby_vm/mjit/insn_compiler.rb')
-rw-r--r--lib/ruby_vm/mjit/insn_compiler.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb
index 19bb607637..c13287f74c 100644
--- a/lib/ruby_vm/mjit/insn_compiler.rb
+++ b/lib/ruby_vm/mjit/insn_compiler.rb
@@ -17,7 +17,7 @@ module RubyVM::MJIT
asm.incr_counter(:mjit_insns_count)
asm.comment("Insn: #{insn.name}")
- # 6/101
+ # 7/101
case insn.name
# nop
# getlocal
@@ -37,7 +37,7 @@ module RubyVM::MJIT
# getglobal
# setglobal
when :putnil then putnil(jit, ctx, asm)
- # putself
+ when :putself then putself(jit, ctx, asm)
when :putobject then putobject(jit, ctx, asm)
# putspecialobject
# putstring
@@ -153,7 +153,16 @@ module RubyVM::MJIT
KeepCompiling
end
- # putself
+ # @param jit [RubyVM::MJIT::JITState]
+ # @param ctx [RubyVM::MJIT::Context]
+ # @param asm [RubyVM::MJIT::Assembler]
+ def putself(jit, ctx, asm)
+ raise 'sp_offset != stack_size' if ctx.sp_offset != ctx.stack_size # TODO: handle this
+ asm.mov(:rax, [CFP, C.rb_control_frame_t.offsetof(:self)])
+ asm.mov([SP, C.VALUE.size * ctx.stack_size], :rax)
+ ctx.stack_push(1)
+ KeepCompiling
+ end
# @param jit [RubyVM::MJIT::JITState]
# @param ctx [RubyVM::MJIT::Context]
@@ -260,7 +269,7 @@ module RubyVM::MJIT
ctx.stack_pop(1)
# Set stubs
- # TODO: reuse already-compiled blocks
+ # TODO: reuse already-compiled blocks jumped from different blocks
branch_stub = BranchStub.new(
iseq: jit.iseq,
ctx: ctx.dup,