@@ -5497,12 +5497,6 @@ vm_invoke_proc_block(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp,
54975497 return vm_invoke_block (ec , reg_cfp , calling , ci , is_lambda , block_handler );
54985498}
54995499
5500- enum rb_block_handler_type
5501- rb_vm_block_handler_type (VALUE block_handler )
5502- {
5503- return vm_block_handler_type (block_handler );
5504- }
5505-
55065500static inline VALUE
55075501vm_invoke_block (rb_execution_context_t * ec , rb_control_frame_t * reg_cfp ,
55085502 struct rb_calling_info * calling , const struct rb_callinfo * ci ,
@@ -6065,10 +6059,30 @@ vm_define_method(const rb_execution_context_t *ec, VALUE obj, ID id, VALUE iseqv
60656059 }
60666060}
60676061
6062+ // Return the untagged block handler:
6063+ // * If it's an ISEQ or an IFUNC, fetch it from its rb_captured_block
6064+ // * If it's a PROC or SYMBOL, return it as is
6065+ static VALUE
6066+ rb_vm_untag_block_handler (VALUE block_handler )
6067+ {
6068+ switch (vm_block_handler_type (block_handler )) {
6069+ case block_handler_type_iseq :
6070+ case block_handler_type_ifunc : {
6071+ struct rb_captured_block * captured = VM_TAGGED_PTR_REF (block_handler , 0x03 );
6072+ return captured -> code .val ;
6073+ }
6074+ case block_handler_type_proc :
6075+ case block_handler_type_symbol :
6076+ return block_handler ;
6077+ default :
6078+ rb_bug ("rb_vm_untag_block_handler: unreachable" );
6079+ }
6080+ }
6081+
60686082VALUE
6069- rb_vm_get_block_handler (rb_control_frame_t * reg_cfp )
6083+ rb_vm_get_untagged_block_handler (rb_control_frame_t * reg_cfp )
60706084{
6071- return VM_CF_BLOCK_HANDLER (reg_cfp );
6085+ return rb_vm_untag_block_handler ( VM_CF_BLOCK_HANDLER (reg_cfp ) );
60726086}
60736087
60746088static VALUE
0 commit comments