summaryrefslogtreecommitdiff
path: root/mathoms.c
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2013-11-07 21:33:57 -0500
committerFather Chrysostomos <sprout@cpan.org>2013-11-10 11:00:09 -0800
commitae103e099635e075f433d5302425673c4fe7badf (patch)
treeae4c3b7873aca7341649470ab487642df86183f7 /mathoms.c
parent8c1c815e4165396cc6aa6c9c18de1f0e2cbeecf1 (diff)
downloadperl-ae103e099635e075f433d5302425673c4fe7badf.tar.gz
fix multi-eval of Perl_custom_op_xop in XopENTRY
Commit 1830b3d9c8 introduced a flaw where XopENTRY calls Perl_custom_op_xop twice to retrieve the same XOP *. This is inefficient and causes extra machine code. Since I found no CPAN or upstream=blead usage of Perl_custom_op_xop, and its previous docs say it isn't 100% public, it is being converted to a macro. Most usage of Perl_custom_op_xop is to conditionally fetch a member of the XOP struct, which was previously implemented by XopENTRY. Move the XopENTRY logic and picking defaults to an expanded version of Perl_custom_op_xop. The union allows Perl_custom_op_get_field to return its result in 1 register, since the union is similar to a void * or IV, but with the machine code overhead of casting, if any, being done in the callee (Perl_custom_op_get_field), not the caller. Perl_custom_op_get_field can also return the XOP * without looking inside it to implement Perl_custom_op_xop. XopENTRYCUSTOM is a wrapper around Perl_custom_op_get_field with XopENTRY-like usage. XopENTRY is used by the OP_* macros, which are heavily used (but rarely called, since custom ops are rare) by Perl lang warnings system. The vararg warning arguments are usually evaluted no matter if the warning will be printed to STDERR or not. Since some people like to ignore warnings or run no strict; and warnings branches are frequent in pp_*, it is beneficial to make the OP_* macros smaller in machine code. The design of Perl_custom_op_get_field supports these goals. This commit does not pass judgement on Ben Morrow's unclear public or private API designation of Perl_custom_op_xop, and whether Perl_custom_op_xop should deprecated and removed from public API. It was trivial to leave a form of Perl_custom_op_xop in the new design. XOPe enums are identical to XOPf constants so no conversion has to be done between the field selector parameter and the field flag to test in machine code. ASSUME and NOT_REACHED are being introduced. The closest to the 2 previously was "assert(0)". Perl has not used ASSUME or CC specific versions of it before. Clang, GCC >= 4.5, and Visual C are supported. For completeness, ARMCC's __promise was added, but Perl is not known to have any support for ARMCC by this commiter. This patch is part of perl #115032.
Diffstat (limited to 'mathoms.c')
-rw-r--r--mathoms.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mathoms.c b/mathoms.c
index cfb0d5be25..b5ae5197bb 100644
--- a/mathoms.c
+++ b/mathoms.c
@@ -1151,14 +1151,14 @@ const char*
Perl_custom_op_name(pTHX_ const OP* o)
{
PERL_ARGS_ASSERT_CUSTOM_OP_NAME;
- return XopENTRY(Perl_custom_op_xop(aTHX_ o), xop_name);
+ return XopENTRYCUSTOM(o, xop_name);
}
const char*
Perl_custom_op_desc(pTHX_ const OP* o)
{
PERL_ARGS_ASSERT_CUSTOM_OP_DESC;
- return XopENTRY(Perl_custom_op_xop(aTHX_ o), xop_desc);
+ return XopENTRYCUSTOM(o, xop_desc);
}
CV *