Skip to content

Commit 3fbcd66

Browse files
bulk88mauke
authored andcommitted
pp_hot.c: shave off some CPU instructions in pp_const()
CC is MSVC 2022 x64 -O1. Before, 0x67 bytes long. After, 0x5E bytes long. This savings obtained by not digging inside PL_op AKA my_perl->Iop->op_*** twice, and the CC not having save a C auto var around a function call. I profiled Perl_pp_const() to be between #2 to #4 most executed pp_*() function, per process on any workload. For extra details about this commit see the GH PR associated with this commit. There is an alternative I privately prototyped but I decided not to finish 3/4s of the way which is creating pre/post arg eval variants of function/macro rpp_xpush_1(). It was getting too invasive and complex by lines of src code modified to finish, so that conceptual fix isn't done here, and something best left for the future.
1 parent 934ce78 commit 3fbcd66

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pp_hot.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ Perl_rpp_free_2_(pTHX_ SV *const sv1, SV *const sv2,
224224

225225
PP(pp_const)
226226
{
227-
rpp_xpush_1(cSVOP_sv);
227+
rpp_extend(1); /* Keep together all PL_op derefs (cSVOP_sv/NORMAL) */
228+
SV* sv = cSVOP_sv; /* in this hot pp op. stack_grow() is a function. */
229+
rpp_push_1(sv); /* Previously rpp_xpush_1(). */
228230
return NORMAL;
229231
}
230232

0 commit comments

Comments
 (0)