@@ -1004,11 +1004,11 @@ invoke_bmethod(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const struct
10041004static inline VALUE
10051005invoke_iseq_block_from_c (rb_thread_t * th , const struct rb_captured_block * captured ,
10061006 VALUE self , int argc , const VALUE * argv , VALUE passed_block_handler ,
1007- const rb_cref_t * cref , int is_lambda )
1007+ const rb_cref_t * cref , VALUE additional_type )
10081008{
10091009 const rb_iseq_t * iseq = rb_iseq_check (captured -> code .iseq );
10101010 int i , opt_pc ;
1011- VALUE type = VM_FRAME_MAGIC_BLOCK | ( is_lambda ? VM_FRAME_FLAG_LAMBDA : 0 ) ;
1011+ VALUE type = VM_FRAME_MAGIC_BLOCK | additional_type ;
10121012 rb_control_frame_t * cfp = th -> ec .cfp ;
10131013 VALUE * sp = cfp -> sp ;
10141014 const rb_callable_method_entry_t * me = th -> passed_bmethod_me ;
@@ -1021,7 +1021,7 @@ invoke_iseq_block_from_c(rb_thread_t *th, const struct rb_captured_block *captur
10211021 }
10221022
10231023 opt_pc = vm_yield_setup_args (th , iseq , argc , sp , passed_block_handler ,
1024- (is_lambda ? arg_setup_method : arg_setup_block ));
1024+ (( type & VM_FRAME_FLAG_LAMBDA ) ? arg_setup_method : arg_setup_block ));
10251025 cfp -> sp = sp ;
10261026
10271027 if (me == NULL ) {
@@ -1038,14 +1038,16 @@ invoke_block_from_c_bh(rb_thread_t *th, VALUE block_handler,
10381038 VALUE passed_block_handler , const rb_cref_t * cref ,
10391039 int is_lambda , int force_blockarg )
10401040{
1041+ VALUE additional_type = is_lambda ? VM_FRAME_FLAG_LAMBDA : 0 ;
1042+
10411043 again :
10421044 switch (vm_block_handler_type (block_handler )) {
10431045 case block_handler_type_iseq :
10441046 {
10451047 const struct rb_captured_block * captured = VM_BH_TO_ISEQ_BLOCK (block_handler );
10461048 return invoke_iseq_block_from_c (th , captured , captured -> self ,
10471049 argc , argv , passed_block_handler ,
1048- cref , is_lambda );
1050+ cref , additional_type );
10491051 }
10501052 case block_handler_type_ifunc :
10511053 return vm_yield_with_cfunc (th , VM_BH_TO_IFUNC_BLOCK (block_handler ),
@@ -1055,8 +1057,11 @@ invoke_block_from_c_bh(rb_thread_t *th, VALUE block_handler,
10551057 return vm_yield_with_symbol (th , VM_BH_TO_SYMBOL (block_handler ),
10561058 argc , argv , passed_block_handler );
10571059 case block_handler_type_proc :
1058- if (force_blockarg == FALSE) {
1059- is_lambda = block_proc_is_lambda (VM_BH_TO_PROC (block_handler ));
1060+ if (force_blockarg == FALSE && block_proc_is_lambda (VM_BH_TO_PROC (block_handler ))) {
1061+ additional_type = VM_FRAME_FLAG_LAMBDA ;
1062+ }
1063+ else {
1064+ additional_type = VM_FRAME_FLAG_PROC ;
10601065 }
10611066 block_handler = vm_proc_to_block_handler (VM_BH_TO_PROC (block_handler ));
10621067 goto again ;
@@ -1114,17 +1119,23 @@ invoke_block_from_c_proc(rb_thread_t *th, const rb_proc_t *proc,
11141119 VALUE passed_block_handler , int is_lambda )
11151120{
11161121 const struct rb_block * block = & proc -> block ;
1122+ VALUE additional_type = is_lambda ? VM_FRAME_FLAG_LAMBDA : VM_FRAME_FLAG_PROC ;
11171123
11181124 again :
11191125 switch (vm_block_type (block )) {
11201126 case block_type_iseq :
1121- return invoke_iseq_block_from_c (th , & block -> as .captured , self , argc , argv , passed_block_handler , NULL , is_lambda );
1127+ return invoke_iseq_block_from_c (th , & block -> as .captured , self , argc , argv , passed_block_handler , NULL , additional_type );
11221128 case block_type_ifunc :
11231129 return vm_yield_with_cfunc (th , & block -> as .captured , self , argc , argv , passed_block_handler );
11241130 case block_type_symbol :
11251131 return vm_yield_with_symbol (th , block -> as .symbol , argc , argv , passed_block_handler );
11261132 case block_type_proc :
1127- is_lambda = block_proc_is_lambda (block -> as .proc );
1133+ if (block_proc_is_lambda (block -> as .proc )) {
1134+ additional_type = VM_FRAME_FLAG_LAMBDA ;
1135+ }
1136+ else {
1137+ additional_type = VM_FRAME_FLAG_PROC ;
1138+ }
11281139 block = vm_proc_block (block -> as .proc );
11291140 goto again ;
11301141 }
0 commit comments