diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-04-01 21:13:15 -0700 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-04-01 21:13:15 -0700 |
commit | 90cdc5b8ba5421bfd183c2bfba16c1fd3ca7e0f5 (patch) | |
tree | 8b6cb06470bd3de74ae2db11a8a75b31599b83d9 | |
parent | 28db75af66f7b8cbbc040a91394b86282702f32c (diff) | |
download | ruby-90cdc5b8ba5421bfd183c2bfba16c1fd3ca7e0f5.tar.gz |
RJIT: Let the caller of jit_push_frame handle stack_pop
because we want to do this way earlier for other types of calls.
-rw-r--r-- | lib/ruby_vm/rjit/insn_compiler.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/ruby_vm/rjit/insn_compiler.rb b/lib/ruby_vm/rjit/insn_compiler.rb index 4836d9a169..62074eafaf 100644 --- a/lib/ruby_vm/rjit/insn_compiler.rb +++ b/lib/ruby_vm/rjit/insn_compiler.rb @@ -4237,7 +4237,7 @@ module RubyVM::RJIT # Number of locals that are not parameters num_locals = iseq.body.local_table_size - num_params - # blockarg is currently popped in jit_push_frame + # blockarg is currently popped later if block_handler == C::VM_BLOCK_HANDLER_NONE && iseq.body.builtin_attrs & C::BUILTIN_ATTR_LEAF != 0 if jit_leaf_builtin_func(jit, ctx, asm, flags, iseq) @@ -4290,6 +4290,11 @@ module RubyVM::RJIT return CantCompile end + # Pop blockarg after all side exits + if flags & C::VM_CALL_ARGS_BLOCKARG != 0 + ctx.stack_pop(1) + end + # Setup the new frame frame_type ||= C::VM_FRAME_MAGIC_METHOD | C::VM_ENV_FLAG_LOCAL jit_push_frame( @@ -4455,6 +4460,11 @@ module RubyVM::RJIT asm.cmp(CFP, :rax) asm.jbe(counted_exit(side_exit(jit, ctx), :send_stackoverflow)) + # Pop blockarg after all side exits + if flags & C::VM_CALL_ARGS_BLOCKARG != 0 + ctx.stack_pop(1) + end + # Push a callee frame. SP register and ctx are not modified inside this. jit_push_frame(jit, ctx, asm, cme, flags, argc, frame_type, block_handler) @@ -4854,7 +4864,7 @@ module RubyVM::RJIT def jit_push_frame(jit, ctx, asm, cme, flags, argc, frame_type, block_handler, iseq: nil, local_size: 0, stack_max: 0, prev_ep: nil) # Save caller SP and PC before pushing a callee frame for backtrace and side exits asm.comment('save SP to caller CFP') - recv_idx = argc + (flags & C::VM_CALL_ARGS_BLOCKARG != 0 ? 1 : 0) # blockarg is not popped yet + recv_idx = argc # blockarg is already popped recv_idx += (block_handler == :captured) ? 0 : 1 # receiver is not on stack when captured->self is used # TODO: consider doing_kw_call if iseq @@ -4868,11 +4878,6 @@ module RubyVM::RJIT end jit_save_pc(jit, asm, comment: 'save PC to caller CFP') - # Pop blockarg after all side exits - if flags & C::VM_CALL_ARGS_BLOCKARG != 0 - ctx.stack_pop(1) - end - local_size.times do |i| asm.comment('set local variables') if i == 0 local_index = ctx.sp_offset + i |