← Index
NYTProf Performance Profile   « line view »
For scripts/bench.pl
  Run on Mon Oct 22 16:48:56 2018
Reported on Mon Oct 22 16:49:10 2018

Filename/usr/lib/x86_64-linux-gnu/perl/5.26/DynaLoader.pm
StatementsExecuted 64 statements in 2.83ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.49ms3.45msDynaLoader::::BEGIN@21DynaLoader::BEGIN@21
111104µs342µsDynaLoader::::bootstrapDynaLoader::bootstrap
111100µs100µsDynaLoader::::dl_load_fileDynaLoader::dl_load_file (xsub)
22132µs32µsDynaLoader::::CORE:substDynaLoader::CORE:subst (opcode)
71131µs31µsDynaLoader::::CORE:ftdirDynaLoader::CORE:ftdir (opcode)
11120µs20µsDynaLoader::::BEGIN@17DynaLoader::BEGIN@17
1115µs5µsDynaLoader::::CORE:ftfileDynaLoader::CORE:ftfile (opcode)
1114µs4µsDynaLoader::::CORE:ftsizeDynaLoader::CORE:ftsize (opcode)
1114µs4µsDynaLoader::::dl_install_xsubDynaLoader::dl_install_xsub (xsub)
1113µs3µsDynaLoader::::dl_find_symbolDynaLoader::dl_find_symbol (xsub)
1112µs2µsDynaLoader::::dl_load_flagsDynaLoader::dl_load_flags
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# Generated from DynaLoader_pm.PL, this file is unique for every OS
2
3package DynaLoader;
4
5# And Gandalf said: 'Many folk like to know beforehand what is to
6# be set on the table; but those who have laboured to prepare the
7# feast like to keep their secret; for wonder makes the words of
8# praise louder.'
9
10# (Quote from Tolkien suggested by Anno Siegel.)
11#
12# See pod text at end of file for documentation.
13# See also ext/DynaLoader/README in source tree for other information.
14#
15# Tim.Bunce@ig.co.uk, August 1994
16
17
# spent 20µs within DynaLoader::BEGIN@17 which was called: # once (20µs+0s) by main::BEGIN@27 at line 19
BEGIN {
18111µs $VERSION = '1.42';
19152µs120µs}
# spent 20µs making 1 call to DynaLoader::BEGIN@17
20
2122.34ms23.47ms
# spent 3.45ms (1.49+1.97) within DynaLoader::BEGIN@21 which was called: # once (1.49ms+1.97ms) by main::BEGIN@27 at line 21
use Config;
# spent 3.45ms making 1 call to DynaLoader::BEGIN@21 # spent 17µs making 1 call to Config::import
22
23# enable debug/trace messages from DynaLoader perl code
2412µs$dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug;
25
26#
27# Flags to alter dl_load_file behaviour. Assigned bits:
28# 0x01 make symbols available for linking later dl_load_file's.
29# (only known to work on Solaris 2 using dlopen(RTLD_GLOBAL))
30# (ignored under VMS; effect is built-in to image linking)
31# (ignored under Android; the linker always uses RTLD_LOCAL)
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
3813µs
# spent 2µs within DynaLoader::dl_load_flags which was called: # once (2µs+0s) by DynaLoader::bootstrap at line 185
sub dl_load_flags { 0x00 }
39
40131µs322µs($dl_dlext, $dl_so, $dlsrc) = @Config::Config{qw(dlext so dlsrc)};
# spent 22µs making 3 calls to Config::FETCH, avg 8µs/call
41
421300ns$do_expand = 0;
43
4411µs@dl_require_symbols = (); # names of symbols we need
451400ns@dl_library_path = (); # path to look for files
46
47#XSLoader.pm may have added elements before we were required
48#@dl_shared_objects = (); # shared objects for symbols we have
49#@dl_librefs = (); # things we have loaded
50#@dl_modules = (); # Modules we have loaded
51
52# Initialise @dl_library_path with the 'standard' library path
53# for this platform as determined by Configure.
54
55110µs12µspush(@dl_library_path, split(' ', $Config::Config{libpth}));
# spent 2µs making 1 call to Config::FETCH
56
5713µs13µsmy $ldlibpthname = $Config::Config{ldlibpthname};
# spent 3µs making 1 call to Config::FETCH
5813µs11µsmy $ldlibpthname_defined = defined $Config::Config{ldlibpthname};
# spent 1µs making 1 call to Config::FETCH
5912µs12µsmy $pthsep = $Config::Config{path_sep};
# spent 2µs making 1 call to Config::FETCH
60
61# Add to @dl_library_path any extra directories we can gather from environment
62# during runtime.
63
6411µsif ($ldlibpthname_defined &&
65 exists $ENV{$ldlibpthname}) {
66 push(@dl_library_path, split(/$pthsep/, $ENV{$ldlibpthname}));
67}
68
69# E.g. HP-UX supports both its native SHLIB_PATH *and* LD_LIBRARY_PATH.
70
711600nsif ($ldlibpthname_defined &&
72 $ldlibpthname ne 'LD_LIBRARY_PATH' &&
73 exists $ENV{LD_LIBRARY_PATH}) {
74 push(@dl_library_path, split(/$pthsep/, $ENV{LD_LIBRARY_PATH}));
75}
76
77# No prizes for guessing why we don't say 'bootstrap DynaLoader;' here.
78# NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB
7911µsboot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) &&
80 !defined(&dl_error);
81
821300nsif ($dl_debug) {
83 print STDERR "DynaLoader.pm loaded (@INC, @dl_library_path)\n";
84 print STDERR "DynaLoader not linked into this perl\n"
85 unless defined(&boot_DynaLoader);
86}
87
88129µs1; # End of main code
89
90sub croak { require Carp; Carp::croak(@_) }
91
92sub bootstrap_inherit {
93 my $module = $_[0];
94 local *isa = *{"$module\::ISA"};
95 local @isa = (@isa, 'DynaLoader');
96 # Cannot goto due to delocalization. Will report errors on a wrong line?
97 bootstrap(@_);
98}
99
100
# spent 342µs (104+238) within DynaLoader::bootstrap which was called: # once (104µs+238µs) by main::BEGIN@27 at line 72 of Time/HiRes.pm
sub bootstrap {
101 # use local vars to enable $module.bs script to edit values
10212µs local(@args) = @_;
1031800ns local($module) = $args[0];
1041500ns local(@dirs, $file);
105
1061400ns unless ($module) {
107 require Carp;
108 Carp::confess("Usage: DynaLoader::bootstrap(module)");
109 }
110
111 # A common error on platforms which don't support dynamic loading.
112 # Since it's fatal and potentially confusing we give a detailed message.
1131400ns croak("Can't load module $module, dynamic loading not available in this perl.\n".
114 " (You may need to build a new perl executable which either supports\n".
115 " dynamic loading or has the $module module statically linked into it.)\n")
116 unless defined(&dl_load_file);
117
118
11912µs my @modparts = split(/::/,$module);
1201800ns my $modfname = $modparts[-1];
1211400ns my $modfname_orig = $modfname; # For .bs file search
122
123 # Some systems have restrictions on files names for DLL's etc.
124 # mod2fname returns appropriate file base name (typically truncated)
125 # It may also edit @modparts if required.
1261400ns $modfname = &mod2fname(\@modparts) if defined &mod2fname;
127
128
129
13012µs my $modpname = join('/',@modparts);
131
1321300ns print STDERR "DynaLoader::bootstrap for $module ",
133 "(auto/$modpname/$modfname.$dl_dlext)\n"
134 if $dl_debug;
135
1361200ns my $dir;
13712µs foreach (@INC) {
138
13976µs $dir = "$_/auto/$modpname";
140
141752µs731µs next unless -d $dir; # skip over uninteresting directories
# spent 31µs making 7 calls to DynaLoader::CORE:ftdir, avg 4µs/call
142
143 # check for common cases to avoid autoload of dl_findfile
14412µs my $try = "$dir/$modfname.$dl_dlext";
145113µs15µs last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && $try);
# spent 5µs making 1 call to DynaLoader::CORE:ftfile
146
147 # no luck here, save dir for possible later dl_findfile search
148 push @dirs, $dir;
149 }
150 # last resort, let dl_findfile have a go in all known locations
1511200ns $file = dl_findfile(map("-L$_",@dirs,@INC), $modfname) unless $file;
152
1531200ns croak("Can't locate loadable object for module $module in \@INC (\@INC contains: @INC)")
154 unless $file; # wording similar to error from 'require'
155
156
15711µs my $bootname = "boot_$module";
158110µs16µs $bootname =~ s/\W/_/g;
# spent 6µs making 1 call to DynaLoader::CORE:subst
1591800ns @dl_require_symbols = ($bootname);
160
161 # Execute optional '.bootstrap' perl script for this module.
162 # The .bs file can be used to configure @dl_resolve_using etc to
163 # match the needs of the individual module on this architecture.
164 # N.B. The .bs file does not following the naming convention used
165 # by mod2fname.
16611µs my $bs = "$dir/$modfname_orig";
167129µs126µs $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library
# spent 26µs making 1 call to DynaLoader::CORE:subst
16819µs14µs if (-s $bs) { # only read file if it's not empty
# spent 4µs making 1 call to DynaLoader::CORE:ftsize
169 print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug;
170 eval { local @INC = ('.'); do $bs; };
171 warn "$bs: $@\n" if $@;
172 }
173
1741200ns my $boot_symbol_ref;
175
176
177
178 # Many dynamic extension loading problems will appear to come from
179 # this section of code: XYZ failed at line 123 of DynaLoader.pm.
180 # Often these errors are actually occurring in the initialisation
181 # C code of the extension XS file. Perl reports the error as being
182 # in this perl code simply because this was the last perl code
183 # it executed.
184
18516µs12µs my $flags = $module->dl_load_flags;
# spent 2µs making 1 call to DynaLoader::dl_load_flags
186
1871108µs1100µs my $libref = dl_load_file($file, $flags) or
# spent 100µs making 1 call to DynaLoader::dl_load_file
188 croak("Can't load '$file' for module $module: ".dl_error());
189
1901900ns push(@dl_librefs,$libref); # record loaded object
191
19217µs13µs $boot_symbol_ref = dl_find_symbol($libref, $bootname) or
# spent 3µs making 1 call to DynaLoader::dl_find_symbol
193 croak("Can't find '$bootname' symbol in $file\n");
194
1951600ns push(@dl_modules, $module); # record loaded module
196
197111µs14µs boot:
# spent 4µs making 1 call to DynaLoader::dl_install_xsub
198 my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
199
200 # See comment block above
201
2021400ns push(@dl_shared_objects, $file); # record files loaded
203
204168µs157µs &$xs(@args);
# spent 57µs making 1 call to Time::HiRes::bootstrap
205}
206
207sub dl_findfile {
208 # This function does not automatically consider the architecture
209 # or the perl library auto directories.
210 my (@args) = @_;
211 my (@dirs, $dir); # which directories to search
212 my (@found); # full paths to real files we have found
213 #my $dl_ext= 'so'; # $Config::Config{'dlext'} suffix for perl extensions
214 #my $dl_so = 'so'; # $Config::Config{'so'} suffix for shared libraries
215
216 print STDERR "dl_findfile(@args)\n" if $dl_debug;
217
218 # accumulate directories but process files as they appear
219 arg: foreach(@args) {
220 # Special fast case: full filepath requires no search
221
222
223 if (m:/: && -f $_) {
224 push(@found,$_);
225 last arg unless wantarray;
226 next;
227 }
228
229
230 # Deal with directories first:
231 # Using a -L prefix is the preferred option (faster and more robust)
232 if (m:^-L:) { s/^-L//; push(@dirs, $_); next; }
233
234 # Otherwise we try to try to spot directories by a heuristic
235 # (this is a more complicated issue than it first appears)
236 if (m:/: && -d $_) { push(@dirs, $_); next; }
237
238
239
240 # Only files should get this far...
241 my(@names, $name); # what filenames to look for
242 if (m:-l: ) { # convert -lname to appropriate library name
243 s/-l//;
244 push(@names,"lib$_.$dl_so");
245 push(@names,"lib$_.a");
246 } else { # Umm, a bare name. Try various alternatives:
247 # these should be ordered with the most likely first
248 push(@names,"$_.$dl_dlext") unless m/\.$dl_dlext$/o;
249 push(@names,"$_.$dl_so") unless m/\.$dl_so$/o;
250
251 push(@names,"lib$_.$dl_so") unless m:/:;
252 push(@names, $_);
253 }
254 my $dirsep = '/';
255
256 foreach $dir (@dirs, @dl_library_path) {
257 next unless -d $dir;
258
259 foreach $name (@names) {
260 my($file) = "$dir$dirsep$name";
261 print STDERR " checking in $dir for $name\n" if $dl_debug;
262 $file = ($do_expand) ? dl_expandspec($file) : (-f $file && $file);
263 #$file = _check_file($file);
264 if ($file) {
265 push(@found, $file);
266 next arg; # no need to look any further
267 }
268 }
269 }
270 }
271 if ($dl_debug) {
272 foreach(@dirs) {
273 print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_;
274 }
275 print STDERR "dl_findfile found: @found\n";
276 }
277 return $found[0] unless wantarray;
278 @found;
279}
280
281sub dl_expandspec {
282 my($spec) = @_;
283 # Optional function invoked if DynaLoader.pm sets $do_expand.
284 # Most systems do not require or use this function.
285 # Some systems may implement it in the dl_*.xs file in which case
286 # this Perl version should be excluded at build time.
287
288 # This function is designed to deal with systems which treat some
289 # 'filenames' in a special way. For example VMS 'Logical Names'
290 # (something like unix environment variables - but different).
291 # This function should recognise such names and expand them into
292 # full file paths.
293 # Must return undef if $spec is invalid or file does not exist.
294
295 my $file = $spec; # default output to input
296
297 return undef unless -f $file;
298 print STDERR "dl_expandspec($spec) => $file\n" if $dl_debug;
299 $file;
300}
301
302sub dl_find_symbol_anywhere
303{
304 my $sym = shift;
305 my $libref;
306 foreach $libref (@dl_librefs) {
307 my $symref = dl_find_symbol($libref,$sym,1);
308 return $symref if $symref;
309 }
310 return undef;
311}
312
313__END__
 
# spent 31µs within DynaLoader::CORE:ftdir which was called 7 times, avg 4µs/call: # 7 times (31µs+0s) by DynaLoader::bootstrap at line 141, avg 4µs/call
sub DynaLoader::CORE:ftdir; # opcode
# spent 5µs within DynaLoader::CORE:ftfile which was called: # once (5µs+0s) by DynaLoader::bootstrap at line 145
sub DynaLoader::CORE:ftfile; # opcode
# spent 4µs within DynaLoader::CORE:ftsize which was called: # once (4µs+0s) by DynaLoader::bootstrap at line 168
sub DynaLoader::CORE:ftsize; # opcode
# spent 32µs within DynaLoader::CORE:subst which was called 2 times, avg 16µs/call: # once (26µs+0s) by DynaLoader::bootstrap at line 167 # once (6µs+0s) by DynaLoader::bootstrap at line 158
sub DynaLoader::CORE:subst; # opcode
# spent 3µs within DynaLoader::dl_find_symbol which was called: # once (3µs+0s) by DynaLoader::bootstrap at line 192
sub DynaLoader::dl_find_symbol; # xsub
# spent 4µs within DynaLoader::dl_install_xsub which was called: # once (4µs+0s) by DynaLoader::bootstrap at line 197
sub DynaLoader::dl_install_xsub; # xsub
# spent 100µs within DynaLoader::dl_load_file which was called: # once (100µs+0s) by DynaLoader::bootstrap at line 187
sub DynaLoader::dl_load_file; # xsub