@@ -61,6 +61,10 @@ rb_vm_control_frame_block_ptr(rb_control_frame_t *cfp)
6161 return VM_CF_BLOCK_PTR (cfp );
6262}
6363
64+ static VALUE
65+ vm_invoke_proc (rb_thread_t * th , rb_proc_t * proc , VALUE self , VALUE defined_class ,
66+ int argc , const VALUE * argv , const rb_block_t * blockptr );
67+
6468#include "vm_insnhelper.h"
6569#include "vm_insnhelper.c"
6670#include "vm_exec.h"
@@ -577,7 +581,8 @@ rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass)
577581static inline VALUE
578582invoke_block_from_c (rb_thread_t * th , const rb_block_t * block ,
579583 VALUE self , int argc , const VALUE * argv ,
580- const rb_block_t * blockptr , const NODE * cref )
584+ const rb_block_t * blockptr , const NODE * cref ,
585+ VALUE defined_class )
581586{
582587 if (SPECIAL_CONST_P (block -> iseq ))
583588 return Qnil ;
@@ -599,7 +604,7 @@ invoke_block_from_c(rb_thread_t *th, const rb_block_t *block,
599604 type == VM_FRAME_MAGIC_LAMBDA );
600605
601606 vm_push_frame (th , iseq , type | VM_FRAME_FLAG_FINISH ,
602- self , block -> klass , /* th->passed_defined_class, */
607+ self , defined_class ,
603608 VM_ENVVAL_PREV_EP_PTR (block -> ep ),
604609 iseq -> iseq_encoded + opt_pc ,
605610 cfp -> sp + arg_size , iseq -> local_size - arg_size ,
@@ -633,19 +638,21 @@ static inline VALUE
633638vm_yield_with_cref (rb_thread_t * th , int argc , const VALUE * argv , const NODE * cref )
634639{
635640 const rb_block_t * blockptr = check_block (th );
636- return invoke_block_from_c (th , blockptr , blockptr -> self , argc , argv , 0 , cref );
641+ return invoke_block_from_c (th , blockptr , blockptr -> self , argc , argv , 0 , cref ,
642+ blockptr -> klass );
637643}
638644
639645static inline VALUE
640646vm_yield (rb_thread_t * th , int argc , const VALUE * argv )
641647{
642648 const rb_block_t * blockptr = check_block (th );
643- return invoke_block_from_c (th , blockptr , blockptr -> self , argc , argv , 0 , 0 );
649+ return invoke_block_from_c (th , blockptr , blockptr -> self , argc , argv , 0 , 0 ,
650+ blockptr -> klass );
644651}
645652
646- VALUE
647- rb_vm_invoke_proc (rb_thread_t * th , rb_proc_t * proc , VALUE self ,
648- int argc , const VALUE * argv , const rb_block_t * blockptr )
653+ static VALUE
654+ vm_invoke_proc (rb_thread_t * th , rb_proc_t * proc , VALUE self , VALUE defined_class ,
655+ int argc , const VALUE * argv , const rb_block_t * blockptr )
649656{
650657 VALUE val = Qundef ;
651658 int state ;
@@ -656,7 +663,8 @@ rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self,
656663 if (!proc -> is_from_method ) {
657664 th -> safe_level = proc -> safe_level ;
658665 }
659- val = invoke_block_from_c (th , & proc -> block , self , argc , argv , blockptr , 0 );
666+ val = invoke_block_from_c (th , & proc -> block , self , argc , argv , blockptr , 0 ,
667+ defined_class );
660668 }
661669 TH_POP_TAG ();
662670
@@ -670,6 +678,14 @@ rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self,
670678 return val ;
671679}
672680
681+ VALUE
682+ rb_vm_invoke_proc (rb_thread_t * th , rb_proc_t * proc ,
683+ int argc , const VALUE * argv , const rb_block_t * blockptr )
684+ {
685+ return vm_invoke_proc (th , proc , proc -> block .self , proc -> block .klass ,
686+ argc , argv , blockptr );
687+ }
688+
673689/* special variable */
674690
675691static rb_control_frame_t *
0 commit comments