mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 00:27:57 +00:00
This commit:
1. Renames the various dtrace probe macros into a consistent and
self-documenting pattern, e.g.
ENTRY_PROBE => PERL_DTRACE_PROBE_ENTRY
RETURN_PROBE => PERL_DTRACE_PROBE_RETURN
Since they're supposed to be defined only under PERL_CORE, this shouldn't
break anything that's not being naughty.
2. Implement the main body of these macros using a real function.
They were formerly defined along the lines of
if (PERL_SUB_ENTRY_ENABLED())
PERL_SUB_ENTRY(...);
The PERL_SUB_ENTRY() part is a macro generated by the dtrace system, which
for example on linux expands to a large bunch of assembly directives.
Replace the direct macro with a function wrapper, e.g.
if (PERL_SUB_ENTRY_ENABLED())
Perl_dtrace_probe_call(aTHX_ cv, TRUE);
This reduces to once the number of times the macro is expanded.
The new functions also take simpler args and then process the values they
need using intermediate temporary vars to avoid huge macro expansions.
For example
ENTRY_PROBE(CvNAMED(cv)
? HEK_KEY(CvNAME_HEK(cv))
: GvENAME(CvGV(cv)),
CopFILE((const COP *)CvSTART(cv)),
CopLINE((const COP *)CvSTART(cv)),
CopSTASHPV((const COP *)CvSTART(cv)));
is now
PERL_DTRACE_PROBE_ENTRY(cv);
This reduces the executable size by 1K on -O2 -Dusedtrace builds,
and by 45K on -DDEBUGGING -Dusedtrace builds.
55 lines
1.7 KiB
C
55 lines
1.7 KiB
C
/* mydtrace.h
|
|
*
|
|
* Copyright (C) 2008, 2010, 2011 by Larry Wall and others
|
|
*
|
|
* You may distribute under the terms of either the GNU General Public
|
|
* License or the Artistic License, as specified in the README file.
|
|
*
|
|
* Provides macros that wrap the various DTrace probes we use. We add
|
|
* an extra level of wrapping to encapsulate the _ENABLED tests.
|
|
*/
|
|
|
|
#if defined(USE_DTRACE) && defined(PERL_CORE)
|
|
|
|
# include "perldtrace.h"
|
|
|
|
# define PERL_DTRACE_PROBE_ENTRY(cv) \
|
|
if (PERL_SUB_ENTRY_ENABLED()) \
|
|
Perl_dtrace_probe_call(aTHX_ cv, TRUE);
|
|
|
|
# define PERL_DTRACE_PROBE_RETURN(cv) \
|
|
if (PERL_SUB_ENTRY_ENABLED()) \
|
|
Perl_dtrace_probe_call(aTHX_ cv, FALSE);
|
|
|
|
# define PERL_DTRACE_PROBE_FILE_LOADING(name) \
|
|
if (PERL_SUB_ENTRY_ENABLED()) \
|
|
Perl_dtrace_probe_load(aTHX_ name, TRUE);
|
|
|
|
# define PERL_DTRACE_PROBE_FILE_LOADED(name) \
|
|
if (PERL_SUB_ENTRY_ENABLED()) \
|
|
Perl_dtrace_probe_load(aTHX_ name, FALSE);
|
|
|
|
# define PERL_DTRACE_PROBE_OP(op) \
|
|
if (PERL_OP_ENTRY_ENABLED()) \
|
|
Perl_dtrace_probe_op(aTHX_ op);
|
|
|
|
# define PERL_DTRACE_PROBE_PHASE(phase) \
|
|
if (PERL_OP_ENTRY_ENABLED()) \
|
|
Perl_dtrace_probe_phase(aTHX_ phase);
|
|
|
|
#else
|
|
|
|
/* NOPs */
|
|
# define PERL_DTRACE_PROBE_ENTRY(cv)
|
|
# define PERL_DTRACE_PROBE_RETURN(cv)
|
|
# define PERL_DTRACE_PROBE_FILE_LOADING(cv)
|
|
# define PERL_DTRACE_PROBE_FILE_LOADED(cv)
|
|
# define PERL_DTRACE_PROBE_OP(op)
|
|
# define PERL_DTRACE_PROBE_PHASE(phase)
|
|
|
|
#endif
|
|
|
|
/*
|
|
* ex: set ts=8 sts=4 sw=4 et:
|
|
*/
|