← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:10 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2/darwin-2level/DynaLoader.pm
StatementsExecuted 171 statements in 2.53ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
411493┬Ás493┬ÁsDynaLoader::::dl_load_fileDynaLoader::dl_load_file (xsub)
433270┬Ás1.20msDynaLoader::::bootstrapDynaLoader::bootstrap
821130┬Ás130┬ÁsDynaLoader::::CORE:substDynaLoader::CORE:subst (opcode)
61133┬Ás33┬ÁsDynaLoader::::CORE:ftdirDynaLoader::CORE:ftdir (opcode)
82131┬Ás31┬ÁsDynaLoader::::dl_find_symbolDynaLoader::dl_find_symbol (xsub)
41121┬Ás21┬ÁsDynaLoader::::dl_install_xsubDynaLoader::dl_install_xsub (xsub)
11118┬Ás18┬ÁsDynaLoader::::BEGIN@18DynaLoader::BEGIN@18
41116┬Ás16┬ÁsDynaLoader::::CORE:ftsizeDynaLoader::CORE:ftsize (opcode)
41115┬Ás15┬ÁsDynaLoader::::CORE:ftfileDynaLoader::CORE:ftfile (opcode)
1119┬Ás19┬ÁsDynaLoader::::BEGIN@22DynaLoader::BEGIN@22
4115┬Ás5┬ÁsDynaLoader::::dl_load_flagsDynaLoader::dl_load_flags
4115┬Ás5┬ÁsDynaLoader::::dl_undef_symbolsDynaLoader::dl_undef_symbols (xsub)
0000s0sDynaLoader::::bootstrap_inheritDynaLoader::bootstrap_inherit
0000s0sDynaLoader::::croakDynaLoader::croak
0000s0sDynaLoader::::dl_expandspecDynaLoader::dl_expandspec
0000s0sDynaLoader::::dl_find_symbol_anywhereDynaLoader::dl_find_symbol_anywhere
0000s0sDynaLoader::::dl_findfileDynaLoader::dl_findfile
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2# Generated from DynaLoader_pm.PL
3
4package DynaLoader;
5
6# And Gandalf said: 'Many folk like to know beforehand what is to
7# be set on the table; but those who have laboured to prepare the
8# feast like to keep their secret; for wonder makes the words of
9# praise louder.'
10
11# (Quote from Tolkien suggested by Anno Siegel.)
12#
13# See pod text at end of file for documentation.
14# See also ext/DynaLoader/README in source tree for other information.
15#
16# Tim.Bunce@ig.co.uk, August 1994
17
18
# spent 18┬Ás within DynaLoader::BEGIN@18 which was called: # once (18┬Ás+0s) by Pod::Usage::BEGIN@21 at line 20
BEGIN {
1918┬Ás $VERSION = '1.18';
20118┬Ás118┬Ás}
# spent 18┬Ás making 1 call to DynaLoader::BEGIN@18
21
2221.24ms229┬Ás
# spent 19┬Ás (9+10) within DynaLoader::BEGIN@22 which was called: # once (9┬Ás+10┬Ás) by Pod::Usage::BEGIN@21 at line 22
use Config;
# spent 19┬Ás making 1 call to DynaLoader::BEGIN@22 # spent 10┬Ás making 1 call to Config::import
23
24# enable debug/trace messages from DynaLoader perl code
2511┬Ás$dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug;
26
27#
28# Flags to alter dl_load_file behaviour. Assigned bits:
29# 0x01 make symbols available for linking later dl_load_file's.
30# (only known to work on Solaris 2 using dlopen(RTLD_GLOBAL))
31# (ignored under VMS; effect is built-in to image linking)
32#
33# This is called as a class method $module->dl_load_flags. The
34# definition here will be inherited and result on "default" loading
35# behaviour unless a sub-class of DynaLoader defines its own version.
36#
37
38413┬Ás
# spent 5┬Ás within DynaLoader::dl_load_flags which was called 4 times, avg 1┬Ás/call: # 4 times (5┬Ás+0s) by DynaLoader::bootstrap at line 194, avg 1┬Ás/call
sub dl_load_flags { 0x00 }
39
40112┬Ás38┬Ás($dl_dlext, $dl_so, $dlsrc) = @Config::Config{qw(dlext so dlsrc)};
# spent 8┬Ás making 3 calls to Config::FETCH, avg 3┬Ás/call
41
42
431100ns$do_expand = 0;
44
451700ns@dl_require_symbols = (); # names of symbols we need
461100ns@dl_resolve_using = (); # names of files to link with
471100ns@dl_library_path = (); # path to look for files
48
49#XSLoader.pm may have added elements before we were required
50#@dl_shared_objects = (); # shared objects for symbols we have
51#@dl_librefs = (); # things we have loaded
52#@dl_modules = (); # Modules we have loaded
53
54# This is a fix to support DLD's unfortunate desire to relink -lc
551200ns@dl_resolve_using = dl_findfile('-lc') if $dlsrc eq "dl_dld.xs";
56
57# Initialise @dl_library_path with the 'standard' library path
58# for this platform as determined by Configure.
59
6014┬Ás12┬Áspush(@dl_library_path, split(' ', $Config::Config{libpth}));
# spent 2┬Ás making 1 call to Config::FETCH
61
62
6313┬Ás12┬Ásmy $ldlibpthname = $Config::Config{ldlibpthname};
# spent 2┬Ás making 1 call to Config::FETCH
6412┬Ás12┬Ásmy $ldlibpthname_defined = defined $Config::Config{ldlibpthname};
# spent 2┬Ás making 1 call to Config::FETCH
6512┬Ás12┬Ásmy $pthsep = $Config::Config{path_sep};
# spent 2┬Ás making 1 call to Config::FETCH
66
67# Add to @dl_library_path any extra directories we can gather from environment
68# during runtime.
69
701400nsif ($ldlibpthname_defined &&
71 exists $ENV{$ldlibpthname}) {
72 push(@dl_library_path, split(/$pthsep/, $ENV{$ldlibpthname}));
73}
74
75# E.g. HP-UX supports both its native SHLIB_PATH *and* LD_LIBRARY_PATH.
76
771500nsif ($ldlibpthname_defined &&
78 $ldlibpthname ne 'LD_LIBRARY_PATH' &&
79 exists $ENV{LD_LIBRARY_PATH}) {
80 push(@dl_library_path, split(/$pthsep/, $ENV{LD_LIBRARY_PATH}));
81}
82
83
84# No prizes for guessing why we don't say 'bootstrap DynaLoader;' here.
85# NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB
861400nsboot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) &&
87 !defined(&dl_error);
88
891100nsif ($dl_debug) {
90 print STDERR "DynaLoader.pm loaded (@INC, @dl_library_path)\n";
91 print STDERR "DynaLoader not linked into this perl\n"
92 unless defined(&boot_DynaLoader);
93}
94
95112┬Ás1; # End of main code
96
97
98sub croak { require Carp; Carp::croak(@_) }
99
100sub bootstrap_inherit {
10121┬Ás my $module = $_[0];
10226┬Ás local *isa = *{"$module\::ISA"};
103218┬Ás local @isa = (@isa, 'DynaLoader');
104 # Cannot goto due to delocalization. Will report errors on a wrong line?
105212┬Ás2652┬Ás bootstrap(@_);
# spent 652┬Ás making 2 calls to DynaLoader::bootstrap, avg 326┬Ás/call
106}
107
108
# spent 1.20ms (270┬Ás+927┬Ás) within DynaLoader::bootstrap which was called 4 times, avg 299┬Ás/call: # 2 times (143┬Ás+510┬Ás) by List::MoreUtils::XS::BEGIN@10 or Pod::Usage::BEGIN@21 at line 105, avg 326┬Ás/call # once (69┬Ás+230┬Ás) by PPI::Token::BEGIN@24 at line 88 of Params/Util.pm # once (58┬Ás+188┬Ás) by PPI::Element::BEGIN@25 at line 16 of Clone.pm
sub bootstrap {
109 # use local vars to enable $module.bs script to edit values
11045┬Ás local(@args) = @_;
11142┬Ás local($module) = $args[0];
11244┬Ás local(@dirs, $file);
113
1144600ns unless ($module) {
115 require Carp;
116 Carp::confess("Usage: DynaLoader::bootstrap(module)");
117 }
118
119 # A common error on platforms which don't support dynamic loading.
120 # Since it's fatal and potentially confusing we give a detailed message.
12142┬Ás croak("Can't load module $module, dynamic loading not available in this perl.\n".
122 " (You may need to build a new perl executable which either supports\n".
123 " dynamic loading or has the $module module statically linked into it.)\n")
124 unless defined(&dl_load_file);
125
- -
12846┬Ás my @modparts = split(/::/,$module);
12942┬Ás my $modfname = $modparts[-1];
130
131 # Some systems have restrictions on files names for DLL's etc.
132 # mod2fname returns appropriate file base name (typically truncated)
133 # It may also edit @modparts if required.
13441┬Ás $modfname = &mod2fname(\@modparts) if defined &mod2fname;
135
136
137
13843┬Ás my $modpname = join('/',@modparts);
139
1404800ns print STDERR "DynaLoader::bootstrap for $module ",
141 "(auto/$modpname/$modfname.$dl_dlext)\n"
142 if $dl_debug;
143
14443┬Ás foreach (@INC) {
145
14664┬Ás my $dir = "$_/auto/$modpname";
147
148655┬Ás633┬Ás next unless -d $dir; # skip over uninteresting directories
# spent 33┬Ás making 6 calls to DynaLoader::CORE:ftdir, avg 5┬Ás/call
149
150 # check for common cases to avoid autoload of dl_findfile
15145┬Ás my $try = "$dir/$modfname.$dl_dlext";
152431┬Ás415┬Ás last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && $try);
# spent 15┬Ás making 4 calls to DynaLoader::CORE:ftfile, avg 4┬Ás/call
153
154 # no luck here, save dir for possible later dl_findfile search
155 push @dirs, $dir;
156 }
157 # last resort, let dl_findfile have a go in all known locations
1584600ns $file = dl_findfile(map("-L$_",@dirs,@INC), $modfname) unless $file;
159
1604400ns croak("Can't locate loadable object for module $module in \@INC (\@INC contains: @INC)")
161 unless $file; # wording similar to error from 'require'
162
163
16443┬Ás my $bootname = "boot_$module";
165416┬Ás47┬Ás $bootname =~ s/\W/_/g;
# spent 7┬Ás making 4 calls to DynaLoader::CORE:subst, avg 2┬Ás/call
16644┬Ás @dl_require_symbols = ($bootname);
167
168 # Execute optional '.bootstrap' perl script for this module.
169 # The .bs file can be used to configure @dl_resolve_using etc to
170 # match the needs of the individual module on this architecture.
17142┬Ás my $bs = $file;
1724132┬Ás4124┬Ás $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library
# spent 124┬Ás making 4 calls to DynaLoader::CORE:subst, avg 31┬Ás/call
173426┬Ás416┬Ás if (-s $bs) { # only read file if it's not empty
# spent 16┬Ás making 4 calls to DynaLoader::CORE:ftsize, avg 4┬Ás/call
174 print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug;
175 eval { do $bs; };
176 warn "$bs: $@\n" if $@;
177 }
178
1794400ns my $boot_symbol_ref;
180
181
182437┬Ás424┬Ás if ($boot_symbol_ref = dl_find_symbol(0, $bootname)) {
# spent 24┬Ás making 4 calls to DynaLoader::dl_find_symbol, avg 6┬Ás/call
183 goto boot; #extension library has already been loaded, e.g. darwin
184 }
185
186
187 # Many dynamic extension loading problems will appear to come from
188 # this section of code: XYZ failed at line 123 of DynaLoader.pm.
189 # Often these errors are actually occurring in the initialisation
190 # C code of the extension XS file. Perl reports the error as being
191 # in this perl code simply because this was the last perl code
192 # it executed.
193
1944529┬Ás8498┬Ás my $libref = dl_load_file($file, $module->dl_load_flags) or
# spent 493┬Ás making 4 calls to DynaLoader::dl_load_file, avg 123┬Ás/call # spent 5┬Ás making 4 calls to DynaLoader::dl_load_flags, avg 1┬Ás/call
195 croak("Can't load '$file' for module $module: ".dl_error());
196
19743┬Ás push(@dl_librefs,$libref); # record loaded object
198
199418┬Ás45┬Ás my @unresolved = dl_undef_symbols();
# spent 5┬Ás making 4 calls to DynaLoader::dl_undef_symbols, avg 1┬Ás/call
20041┬Ás if (@unresolved) {
201 require Carp;
202 Carp::carp("Undefined symbols present after loading $file: @unresolved\n");
203 }
204
205416┬Ás47┬Ás $boot_symbol_ref = dl_find_symbol($libref, $bootname) or
# spent 7┬Ás making 4 calls to DynaLoader::dl_find_symbol, avg 2┬Ás/call
206 croak("Can't find '$bootname' symbol in $file\n");
207
20843┬Ás push(@dl_modules, $module); # record loaded module
209
210435┬Ás421┬Ás boot:
# spent 21┬Ás making 4 calls to DynaLoader::dl_install_xsub, avg 5┬Ás/call
211 my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
212
213 # See comment block above
214
21546┬Ás push(@dl_shared_objects, $file); # record files loaded
216
2174219┬Ás4177┬Ás &$xs(@args);
# spent 94┬Ás making 1 call to List::MoreUtils::bootstrap # spent 36┬Ás making 1 call to Cwd::bootstrap # spent 28┬Ás making 1 call to Params::Util::bootstrap # spent 18┬Ás making 1 call to Clone::bootstrap
218}
219
220sub dl_findfile {
221 # Read ext/DynaLoader/DynaLoader.doc for detailed information.
222 # This function does not automatically consider the architecture
223 # or the perl library auto directories.
224 my (@args) = @_;
225 my (@dirs, $dir); # which directories to search
226 my (@found); # full paths to real files we have found
227 #my $dl_ext= 'bundle'; # $Config::Config{'dlext'} suffix for perl extensions
228 #my $dl_so = 'dylib'; # $Config::Config{'so'} suffix for shared libraries
229
230 print STDERR "dl_findfile(@args)\n" if $dl_debug;
231
232 # accumulate directories but process files as they appear
233 arg: foreach(@args) {
234 # Special fast case: full filepath requires no search
235
236
237 if (m:/: && -f $_) {
238 push(@found,$_);
239 last arg unless wantarray;
240 next;
241 }
242
243
244 # Deal with directories first:
245 # Using a -L prefix is the preferred option (faster and more robust)
246 if (m:^-L:) { s/^-L//; push(@dirs, $_); next; }
247
248 # Otherwise we try to try to spot directories by a heuristic
249 # (this is a more complicated issue than it first appears)
250 if (m:/: && -d $_) { push(@dirs, $_); next; }
251
252
253
254 # Only files should get this far...
255 my(@names, $name); # what filenames to look for
256 if (m:-l: ) { # convert -lname to appropriate library name
257 s/-l//;
258 push(@names,"lib$_.$dl_so");
259 push(@names,"lib$_.a");
260 } else { # Umm, a bare name. Try various alternatives:
261 # these should be ordered with the most likely first
262 push(@names,"$_.$dl_dlext") unless m/\.$dl_dlext$/o;
263 push(@names,"$_.$dl_so") unless m/\.$dl_so$/o;
264
265 push(@names,"lib$_.$dl_so") unless m:/:;
266 push(@names,"$_.a") if !m/\.a$/ and $dlsrc eq "dl_dld.xs";
267 push(@names, $_);
268 }
269 my $dirsep = '/';
270
271 foreach $dir (@dirs, @dl_library_path) {
272 next unless -d $dir;
273
274 foreach $name (@names) {
275 my($file) = "$dir$dirsep$name";
276 print STDERR " checking in $dir for $name\n" if $dl_debug;
277 $file = ($do_expand) ? dl_expandspec($file) : (-f $file && $file);
278 #$file = _check_file($file);
279 if ($file) {
280 push(@found, $file);
281 next arg; # no need to look any further
282 }
283 }
284 }
285 }
286 if ($dl_debug) {
287 foreach(@dirs) {
288 print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_;
289 }
290 print STDERR "dl_findfile found: @found\n";
291 }
292 return $found[0] unless wantarray;
293 @found;
294}
295
- -
298sub dl_expandspec {
299 my($spec) = @_;
300 # Optional function invoked if DynaLoader.pm sets $do_expand.
301 # Most systems do not require or use this function.
302 # Some systems may implement it in the dl_*.xs file in which case
303 # this Perl version should be excluded at build time.
304
305 # This function is designed to deal with systems which treat some
306 # 'filenames' in a special way. For example VMS 'Logical Names'
307 # (something like unix environment variables - but different).
308 # This function should recognise such names and expand them into
309 # full file paths.
310 # Must return undef if $spec is invalid or file does not exist.
311
312 my $file = $spec; # default output to input
313
314 return undef unless -f $file;
315 print STDERR "dl_expandspec($spec) => $file\n" if $dl_debug;
316 $file;
317}
318
319sub dl_find_symbol_anywhere
320{
321 my $sym = shift;
322 my $libref;
323 foreach $libref (@dl_librefs) {
324 my $symref = dl_find_symbol($libref,$sym);
325 return $symref if $symref;
326 }
327 return undef;
328}
329
330__END__
 
# spent 33┬Ás within DynaLoader::CORE:ftdir which was called 6 times, avg 5┬Ás/call: # 6 times (33┬Ás+0s) by DynaLoader::bootstrap at line 148, avg 5┬Ás/call
sub DynaLoader::CORE:ftdir; # opcode
# spent 15┬Ás within DynaLoader::CORE:ftfile which was called 4 times, avg 4┬Ás/call: # 4 times (15┬Ás+0s) by DynaLoader::bootstrap at line 152, avg 4┬Ás/call
sub DynaLoader::CORE:ftfile; # opcode
# spent 16┬Ás within DynaLoader::CORE:ftsize which was called 4 times, avg 4┬Ás/call: # 4 times (16┬Ás+0s) by DynaLoader::bootstrap at line 173, avg 4┬Ás/call
sub DynaLoader::CORE:ftsize; # opcode
# spent 130┬Ás within DynaLoader::CORE:subst which was called 8 times, avg 16┬Ás/call: # 4 times (124┬Ás+0s) by DynaLoader::bootstrap at line 172, avg 31┬Ás/call # 4 times (7┬Ás+0s) by DynaLoader::bootstrap at line 165, avg 2┬Ás/call
sub DynaLoader::CORE:subst; # opcode
# spent 31┬Ás within DynaLoader::dl_find_symbol which was called 8 times, avg 4┬Ás/call: # 4 times (24┬Ás+0s) by DynaLoader::bootstrap at line 182, avg 6┬Ás/call # 4 times (7┬Ás+0s) by DynaLoader::bootstrap at line 205, avg 2┬Ás/call
sub DynaLoader::dl_find_symbol; # xsub
# spent 21┬Ás within DynaLoader::dl_install_xsub which was called 4 times, avg 5┬Ás/call: # 4 times (21┬Ás+0s) by DynaLoader::bootstrap at line 210, avg 5┬Ás/call
sub DynaLoader::dl_install_xsub; # xsub
# spent 493┬Ás within DynaLoader::dl_load_file which was called 4 times, avg 123┬Ás/call: # 4 times (493┬Ás+0s) by DynaLoader::bootstrap at line 194, avg 123┬Ás/call
sub DynaLoader::dl_load_file; # xsub
# spent 5┬Ás within DynaLoader::dl_undef_symbols which was called 4 times, avg 1┬Ás/call: # 4 times (5┬Ás+0s) by DynaLoader::bootstrap at line 199, avg 1┬Ás/call
sub DynaLoader::dl_undef_symbols; # xsub