Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove repeated PL_stack_sp derefs in Perl_eval_sv/Perl_call_sv
Reduce scope of local SP and remove excessive reads and writes to PL_stack_sp in Perl_eval_sv/Perl_call_sv. EXTEND macro refetches the possibly realloced SP on its own, Perl_stack_grow returns the new SP as a retval and therefore in a register. By using PL_stack_sp instead of Perl_stack_grow, an extra redundant mem read is done. Also dont keep SP around for long periods unused, it wastes a C stack slot or non-vol reg and makes the callframe bigger. The EXTEND could be placed in the !(flags & G_METHOD_NAMED) branch, but that will be done in another patch for bisectability. VC 2003 -O1 machine code sizes of the functions Perl_eval_sv before 0x28a after 0x286 Perl_call_sv before 0x3cd after 0x3cb The savings look small since in x86 "*var+=4" and "var+=4" are the same number of bytes to encode the instruction, only the mod R/M bitfield vals are different. RISC CPUs benefit more from this patch. commit c106c2b "G_METHOD_NAMED flag for call_method and call_sv" added skipping the push SV onto stack The EXTEND and PL_stack_sp direct manipulation code is from commit a0d0e21 "perl 5.000". The reason is unknown why it did "SV** sp = stack_sp;" and later "EXTEND(stack_sp, 1);" instead of using SP, since EXTEND at that time, and to this day requires C auto sp be in scope.
- Loading branch information