• dearblue's avatar
    Reorganize `mcall()` in `mruby-method`. · 4c196dcd
    dearblue authored
    Use `mrb_exec_irep()`. If possible, re-entry into the VM will be suppressed.
    
    Note that due to the effect of being a tail-call, the backtrace of `Method#call` will be lost, and it will look as if the target method was called directly.
    
    This change fixes the problem of infinite loops when redefining methods that make block calls using `mruby-method`.
    
    ```console
    % bin/mruby -e 'mm = method(:proc); define_method(:proc, ->(*a, &b) { mm.call(*a, &b) }); p proc { 1 }'
    trace (most recent call last):
            [257] -e:1
            [256] -e:1:in proc
            [255] -e:1:in proc
            ...SNIP...
            [1] -e:1:in proc
    -e:1:in proc: stack level too deep (SystemStackError)
    ```
    4c196dcd
method.c 16.3 KB