autodie icon indicating copy to clipboard operation
autodie copied to clipboard

Implement wrapper subs in C or XS

Open nthykier opened this issue 10 years ago • 3 comments

The idea to implement autodie in C was mentioned in https://github.com/schwern/perl5i/issues/102. While it may just improve the speed in itself, it may also open the door to cache subs much more aggressively. According to [1], XS are invisible in "caller" so a lot of issues we have preventing reuse /might/ just disappear once the checker sub "disappears" from the call stack.

~Niels

[1] http://perl5.git.perl.org/perl.git/commitdiff/1d56df500dec0bf9de438b0fa225eb363b006dcf

nthykier avatar Jul 26 '13 17:07 nthykier

If we have skilled C/XS folks, we may even be able to wrap say/print. :)

pjf avatar Sep 21 '13 02:09 pjf

On 2013-09-21 04:40, Paul Fenwick wrote:

If we have skilled C/XS folks, we may even be able to wrap say/print. :)

I think to wrap say or print, we pretty much have to swipe it out at the op-code level. The problem with these is that there is no prototype that can describe their call interface, so we need perl's parse to "translate" the call for us and the substitute print with "checked_print". That said, if/once we start doing XS stuff, we can probably get away with doing this for all CORE subs we check. I am pretty sure we can do this in a resuable manner[1] and with less runtime overhead than PP.

~Niels

[1] In particular, if we are messing with op tree, we won't need leak guards.

nthykier avatar Sep 21 '13 07:09 nthykier

For reference, @schwern wrote some code for including autodie behaviour directly in perl code (see evalEmpire/perl5ic/issues/16 and https://github.com/evalEmpire/perl5ic/tree/autodie)

nthykier avatar Dec 31 '14 12:12 nthykier