summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-03-09 21:55:14 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2023-03-09 21:55:14 -0800
commit35fd79ac3713478c8114a498d3536c05ad832063 (patch)
treef324c6c2f763cb7be824f3d058672f8dc4401ad6 /lib
parent5e27d82dd0d25b5df907203112955eeb0d764b02 (diff)
RJIT: Lazily compile global ocb
Diffstat (limited to 'lib')
-rw-r--r--lib/ruby_vm/rjit/compiler.rb14
-rw-r--r--lib/ruby_vm/rjit/insn_compiler.rb14
2 files changed, 16 insertions, 12 deletions
diff --git a/lib/ruby_vm/rjit/compiler.rb b/lib/ruby_vm/rjit/compiler.rb
index d69f55cefc..9e0454edaa 100644
--- a/lib/ruby_vm/rjit/compiler.rb
+++ b/lib/ruby_vm/rjit/compiler.rb
@@ -47,11 +47,6 @@ module RubyVM::RJIT
@exit_compiler = ExitCompiler.new
@insn_compiler = InsnCompiler.new(@cb, @ocb, @exit_compiler)
Invariants.initialize(@cb, @ocb, self, @exit_compiler)
-
- @leave_exit = Assembler.new.then do |asm|
- @exit_compiler.compile_leave_exit(asm)
- @ocb.write(asm)
- end
end
# Compile an ISEQ from its entry point.
@@ -208,7 +203,7 @@ module RubyVM::RJIT
asm.mov(SP, [CFP, C.rb_control_frame_t.offsetof(:sp)]) # rbx = cfp->sp
# Setup cfp->jit_return
- asm.mov(:rax, @leave_exit)
+ asm.mov(:rax, leave_exit)
asm.mov([CFP, C.rb_control_frame_t.offsetof(:jit_return)], :rax)
end
@@ -265,6 +260,13 @@ module RubyVM::RJIT
set_block(iseq, block)
end
+ def leave_exit
+ @leave_exit ||= Assembler.new.then do |asm|
+ @exit_compiler.compile_leave_exit(asm)
+ @ocb.write(asm)
+ end
+ end
+
def incr_counter(name)
if C.rjit_opts.stats
C.rb_rjit_counters[name][0] += 1
diff --git a/lib/ruby_vm/rjit/insn_compiler.rb b/lib/ruby_vm/rjit/insn_compiler.rb
index 413d781841..761dd8f527 100644
--- a/lib/ruby_vm/rjit/insn_compiler.rb
+++ b/lib/ruby_vm/rjit/insn_compiler.rb
@@ -6,11 +6,6 @@ module RubyVM::RJIT
@ocb = ocb
@exit_compiler = exit_compiler
- @full_cfunc_return = Assembler.new.then do |asm|
- @exit_compiler.compile_full_cfunc_return(asm)
- @ocb.write(asm)
- end
-
@cfunc_codegen_table = {}
register_cfunc_codegen_funcs
# freeze # workaround a binding.irb issue. TODO: resurrect this
@@ -3357,7 +3352,7 @@ module RubyVM::RJIT
asm.call(:rax) # TODO: use rel32 if close enough
ctx.stack_pop(1 + argc)
- Invariants.record_global_inval_patch(asm, @full_cfunc_return)
+ Invariants.record_global_inval_patch(asm, full_cfunc_return)
asm.comment('push the return value')
stack_ret = ctx.stack_push
@@ -3966,5 +3961,12 @@ module RubyVM::RJIT
GC_REFS << obj
C.to_value(obj)
end
+
+ def full_cfunc_return
+ @full_cfunc_return ||= Assembler.new.then do |asm|
+ @exit_compiler.compile_full_cfunc_return(asm)
+ @ocb.write(asm)
+ end
+ end
end
end