diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-06-13 16:25:53 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-06-13 16:25:53 +0200 |
commit | f4adce6b773b2b6071e0d1627f4dce6ec0c3caa7 (patch) | |
tree | c61960499dde384574634e2800cc162d2d657900 | |
parent | 74f0b5509afd269c59f1396fde551295bbeec7d5 (diff) | |
download | perl-f4adce6b773b2b6071e0d1627f4dce6ec0c3caa7.tar.gz |
Merge flags and argc parameters to S_tied_handle_method().
This generates slightly smaller object code overall, which means that the "hot"
code (the non-overloaded paths through the ops) will be smaller, and hence more
likely to stay in the CPU cache.
-rw-r--r-- | embed.fnc | 2 | ||||
-rw-r--r-- | pp_sys.c | 26 | ||||
-rw-r--r-- | proto.h | 2 |
3 files changed, 18 insertions, 12 deletions
@@ -1718,7 +1718,7 @@ sR |int |dooneliner |NN const char *cmd|NN const char *filename s |SV * |space_join_names_mortal|NN char *const *array so |OP * |tied_handle_method|NN const char *const methname|NN SV **sp \ |NN IO *const io|NN MAGIC *const mg \ - |const U32 flags|unsigned int argc|... + |const U32 flags|... #endif #if defined(PERL_IN_REGCOMP_C) || defined(PERL_DECL_PROT) @@ -552,26 +552,30 @@ PP(pp_open) RETURN; } -/* This is private to this function, which is private to this file. +/* These are private to this function, which is private to this file. Use 0x04 rather than the next available bit, to help the compiler if the architecture can generate more efficient instructions. */ #define MORTALIZE_NOT_NEEDED 0x04 +#define TIED_HANDLE_ARGC_SHIFT 3 static OP * S_tied_handle_method(pTHX_ const char *const methname, SV **sp, - IO *const io, MAGIC *const mg, const U32 flags, - unsigned int argc, ...) + IO *const io, MAGIC *const mg, const U32 flags, ...) { + U32 argc = flags >> TIED_HANDLE_ARGC_SHIFT; + PERL_ARGS_ASSERT_TIED_HANDLE_METHOD; + /* Ensure that our flag bits do not overlap. */ assert((MORTALIZE_NOT_NEEDED & G_WANT) == 0); + assert((G_WANT >> TIED_HANDLE_ARGC_SHIFT) == 0); PUSHMARK(sp); PUSHs(SvTIED_obj(MUTABLE_SV(io), mg)); if (argc) { const U32 mortalize_not_needed = flags & MORTALIZE_NOT_NEEDED; va_list args; - va_start(args, argc); + va_start(args, flags); do { SV *const arg = va_arg(args, SV *); if(mortalize_not_needed) @@ -590,11 +594,11 @@ S_tied_handle_method(pTHX_ const char *const methname, SV **sp, } #define tied_handle_method(a,b,c,d) \ - S_tied_handle_method(aTHX_ a,b,c,d,G_SCALAR,0) + S_tied_handle_method(aTHX_ a,b,c,d,G_SCALAR) #define tied_handle_method1(a,b,c,d,e) \ - S_tied_handle_method(aTHX_ a,b,c,d,G_SCALAR,1,e) + S_tied_handle_method(aTHX_ a,b,c,d,G_SCALAR | (1 << TIED_HANDLE_ARGC_SHIFT),e) #define tied_handle_method2(a,b,c,d,e,f) \ - S_tied_handle_method(aTHX_ a,b,c,d,G_SCALAR,2,e,f) + S_tied_handle_method(aTHX_ a,b,c,d,G_SCALAR | (2 << TIED_HANDLE_ARGC_SHIFT), e,f) PP(pp_close) { @@ -763,8 +767,10 @@ PP(pp_binmode) figure out. Although, as it's a static function, in theory it could. */ return S_tied_handle_method(aTHX_ "BINMODE", SP, io, mg, - G_SCALAR|MORTALIZE_NOT_NEEDED, - discp ? 1 : 0, discp); + G_SCALAR|MORTALIZE_NOT_NEEDED + | (discp + ? (1 << TIED_HANDLE_ARGC_SHIFT) : 0), + discp); } } @@ -1229,7 +1235,7 @@ PP(pp_getc) MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { const U32 gimme = GIMME_V; - S_tied_handle_method(aTHX_ "GETC", SP, io, mg, gimme, 0); + S_tied_handle_method(aTHX_ "GETC", SP, io, mg, gimme); if (gimme == G_SCALAR) { SPAGAIN; SvSetMagicSV_nosteal(TARG, TOPs); @@ -5350,7 +5350,7 @@ STATIC SV * S_space_join_names_mortal(pTHX_ char *const *array) #define PERL_ARGS_ASSERT_SPACE_JOIN_NAMES_MORTAL \ assert(array) -STATIC OP * S_tied_handle_method(pTHX_ const char *const methname, SV **sp, IO *const io, MAGIC *const mg, const U32 flags, unsigned int argc, ...) +STATIC OP * S_tied_handle_method(pTHX_ const char *const methname, SV **sp, IO *const io, MAGIC *const mg, const U32 flags, ...) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2) __attribute__nonnull__(pTHX_3) |