You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
de-mathom Perl_sv_taint() part 4 add SvTAINTTC() tailcall API
Perl_newSVnv/Perl_newSViv/Perl_newSVuv, currently have to save the fresh
SV *, either on C stack, or in non volatile registers, around the
possible Perl_sv_taint() fn call inside SvTAINT(). If Perl_sv_taint()
returns its SV * argument, and assigns it back to the same C var, now
these 3 performance critical SV allocator functions, after plucking
the SV head from the arena, these 3 function never ever have to
store the fresh SV * back to C stack for any reason during their execution.
This optimization removes pop/push pairs of the C compiler saving
non-volatile registers and restoring them at function entry and exit since
after SvTAINTTC() change, NO variables AT ALL, have to be saved around
any function calls in Perl_newSVnv/Perl_newSViv/Perl_newSVuv. Also the
SV head *, after being delinked/removed from an areana, can now be
stored through the whole function, in the x86 EAX/x64 RAX register, and
pass through to the caller, without a final (non vol) reg to
(vol retval reg) mov/copy cpu op.
Remember eax/rax/retval registers, are always wiped after each fn call,
but the refactoring of SvTAINTTC() conviently returns the
SV * back to us, in the ABI return register, and we let the fresh
SV * glide through on the "heavy" Perl_sv_taint() branch, from
Perl_sv_taint() to Perl_newSViv()'s caller, without touching it, 0
machine code ops.
Few code sites were changed from SvTAINT() to SvTAINTTC(), to keep this
patch smaller, and the Perl_sv_set*vXXX() category of functions, all have
void return types and can't be chained. Also the Perl_sv_taint() branch
can be tail called or converted to a JMP insted of CALL, if the CC/OS/ABI
wants to now.
This is the final part of speeding up
Perl_newSVnv/Perl_newSViv/Perl_newSVuv there is nothing else to remove or
optimze.
0 commit comments