diff options
author | Takashi Kokubun <[email protected]> | 2023-04-01 21:23:36 -0700 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2023-04-01 21:30:42 -0700 |
commit | e45ed2da5046f7ee2a82f332d211ddbd7108fc22 (patch) | |
tree | e65ce9898be564eb21f234351b7c4b77f283b266 /lib/ruby_vm/rjit/compiler.rb | |
parent | 90cdc5b8ba5421bfd183c2bfba16c1fd3ca7e0f5 (diff) |
RJIT: Rewind stack_size on CantCompile and side exits
so that we can take an exit whenever we want.
As a starter, this commit also pops blockarg earlier than some
CantCompile exits.
Diffstat (limited to 'lib/ruby_vm/rjit/compiler.rb')
-rw-r--r-- | lib/ruby_vm/rjit/compiler.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ruby_vm/rjit/compiler.rb b/lib/ruby_vm/rjit/compiler.rb index 357fe7d734..5673926b6f 100644 --- a/lib/ruby_vm/rjit/compiler.rb +++ b/lib/ruby_vm/rjit/compiler.rb @@ -220,6 +220,8 @@ module RubyVM::RJIT while index < iseq.body.iseq_size insn = self.class.decode_insn(iseq.body.iseq_encoded[index]) jit.pc = (iseq.body.iseq_encoded + index).to_i + jit.stack_size_for_pc = ctx.stack_size + jit.side_exit_for_pc.clear # If previous instruction requested to record the boundary if jit.record_boundary_patch_point @@ -243,7 +245,9 @@ module RubyVM::RJIT # TODO: pad nops if entry exit exists (not needed for x86_64?) break when CantCompile - @exit_compiler.compile_side_exit(jit.pc, ctx, asm) + # Rewind stack_size using ctx.with_stack_size to allow stack_size changes + # before you return CantCompile. + @exit_compiler.compile_side_exit(jit.pc, ctx.with_stack_size(jit.stack_size_for_pc), asm) # If this is the first instruction, this block never needs to be invalidated. if block.pc == iseq.body.iseq_encoded.to_i + index * C.VALUE.size |