← Index
NYTProf Performance Profile   « line view »
For rbm/rbm
  Run on Wed Feb 12 20:36:06 2020
Reported on Wed Feb 12 21:42:25 2020

Filename/usr/lib/x86_64-linux-gnu/perl/5.28/DynaLoader.pm
StatementsExecuted 103 statements in 2.12ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
211189µs189µsDynaLoader::::dl_load_fileDynaLoader::dl_load_file (xsub)
222139µs518µsDynaLoader::::bootstrapDynaLoader::bootstrap
42152µs52µsDynaLoader::::CORE:substDynaLoader::CORE:subst (opcode)
101144µs44µsDynaLoader::::CORE:ftdirDynaLoader::CORE:ftdir (opcode)
11116µs35µsDynaLoader::::BEGIN@21DynaLoader::BEGIN@21
1118µs8µsDynaLoader::::BEGIN@17DynaLoader::BEGIN@17
2116µs6µsDynaLoader::::dl_install_xsubDynaLoader::dl_install_xsub (xsub)
2116µs6µsDynaLoader::::CORE:ftsizeDynaLoader::CORE:ftsize (opcode)
2115µs5µsDynaLoader::::CORE:ftfileDynaLoader::CORE:ftfile (opcode)
2115µs5µsDynaLoader::::dl_find_symbolDynaLoader::dl_find_symbol (xsub)
2113µs3µ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 8µs within DynaLoader::BEGIN@17 which was called: # once (8µs+0s) by RBM::BEGIN@22 at line 19
BEGIN {
1814µs $VERSION = '1.45';
191118µs18µs}
# spent 8µs making 1 call to DynaLoader::BEGIN@17
20
2121.44ms253µs
# spent 35µs (16+19) within DynaLoader::BEGIN@21 which was called: # once (16µs+19µs) by RBM::BEGIN@22 at line 21
use Config;
# spent 35µs making 1 call to DynaLoader::BEGIN@21 # spent 19µs making 1 call to Config::import
22
23# enable debug/trace messages from DynaLoader perl code
2411µ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
3827µs
# spent 3µs within DynaLoader::dl_load_flags which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by DynaLoader::bootstrap at line 185, avg 2µs/call
sub dl_load_flags { 0x00 }
39
40111µ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
421200ns$do_expand = 0;
43
441500ns@dl_require_symbols = (); # names of symbols we need
451100ns@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
5515µs11µspush(@dl_library_path, split(' ', $Config::Config{libpth}));
# spent 1µs making 1 call to Config::FETCH
56
5712µs11µsmy $ldlibpthname = $Config::Config{ldlibpthname};
# spent 1µs making 1 call to Config::FETCH
5812µs11µsmy $ldlibpthname_defined = defined $Config::Config{ldlibpthname};
# spent 1µs making 1 call to Config::FETCH
5912µs11µsmy $pthsep = $Config::Config{path_sep};
# spent 1µ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
641800nsif ($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
711400nsif ($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
791500nsboot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) &&
80 !defined(&dl_error);
81
821200nsif ($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
88118µ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 518µs (139+378) within DynaLoader::bootstrap which was called 2 times, avg 259µs/call: # once (77µs+205µs) by Template::Stash::XS::BEGIN@21 at line 26 of Template/Stash/XS.pm # once (62µs+173µs) by RBM::BEGIN@22 at line 20 of Data/UUID.pm
sub bootstrap {
101 # use local vars to enable $module.bs script to edit values
10223µs local(@args) = @_;
10322µs local($module) = $args[0];
10421µs local(@dirs, $file);
105
1062600ns 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.
11322µs 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
11924µs my @modparts = split(/::/,$module);
12022µs my $modfname = $modparts[-1];
1212600ns 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.
1262700ns $modfname = &mod2fname(\@modparts) if defined &mod2fname;
127
128
129
13023µs my $modpname = join('/',@modparts);
131
1322900ns print STDERR "DynaLoader::bootstrap for $module ",
133 "(auto/$modpname/$modfname.$dl_dlext)\n"
134 if $dl_debug;
135
1362600ns my $dir;
13723µs foreach (@INC) {
138
139104µs $dir = "$_/auto/$modpname";
140
1411064µs1044µs next unless -d $dir; # skip over uninteresting directories
# spent 44µs making 10 calls to DynaLoader::CORE:ftdir, avg 4µs/call
142
143 # check for common cases to avoid autoload of dl_findfile
14422µs my $try = "$dir/$modfname.$dl_dlext";
145214µs25µs last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && $try);
# spent 5µs making 2 calls to DynaLoader::CORE:ftfile, avg 3µs/call
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
1512400ns $file = dl_findfile(map("-L$_",@dirs,@INC), $modfname) unless $file;
152
1532500ns 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
15721µs my $bootname = "boot_$module";
158214µs27µs $bootname =~ s/\W/_/g;
# spent 7µs making 2 calls to DynaLoader::CORE:subst, avg 4µs/call
15922µs @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.
16621µs my $bs = "$dir/$modfname_orig";
167249µs245µs $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library
# spent 45µs making 2 calls to DynaLoader::CORE:subst, avg 23µs/call
168212µs26µs if (-s $bs) { # only read file if it's not empty
# spent 6µs making 2 calls to DynaLoader::CORE:ftsize, avg 3µs/call
169 print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug;
170 eval { local @INC = ('.'); do $bs; };
171 warn "$bs: $@\n" if $@;
172 }
173
1742400ns 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
18529µs23µs my $flags = $module->dl_load_flags;
# spent 3µs making 2 calls to DynaLoader::dl_load_flags, avg 2µs/call
186
1872201µs2189µs my $libref = dl_load_file($file, $flags) or
# spent 189µs making 2 calls to DynaLoader::dl_load_file, avg 95µs/call
188 croak("Can't load '$file' for module $module: ".dl_error());
189
19022µs push(@dl_librefs,$libref); # record loaded object
191
192211µs25µs $boot_symbol_ref = dl_find_symbol($libref, $bootname) or
# spent 5µs making 2 calls to DynaLoader::dl_find_symbol, avg 2µs/call
193 croak("Can't find '$bootname' symbol in $file\n");
194
19521µs push(@dl_modules, $module); # record loaded module
196
197214µs26µs boot:
# spent 6µs making 2 calls to DynaLoader::dl_install_xsub, avg 3µs/call
198 my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
199
200 # See comment block above
201
2022800ns push(@dl_shared_objects, $file); # record files loaded
203
204285µs268µs &$xs(@args);
# spent 49µs making 1 call to Data::UUID::bootstrap # spent 19µs making 1 call to Template::Stash::XS::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 ( 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 ( s{^-l}{} ) { # convert -lname to appropriate library name
243 push(@names, "lib$_.$dl_so", "lib$_.a");
244 } else { # Umm, a bare name. Try various alternatives:
245 # these should be ordered with the most likely first
246 push(@names,"$_.$dl_dlext") unless m/\.$dl_dlext$/o;
247 push(@names,"$_.$dl_so") unless m/\.$dl_so$/o;
248
249 push(@names,"lib$_.$dl_so") unless m:/:;
250 push(@names, $_);
251 }
252 my $dirsep = '/';
253
254 foreach $dir (@dirs, @dl_library_path) {
255 next unless -d $dir;
256
257 foreach $name (@names) {
258 my($file) = "$dir$dirsep$name";
259 print STDERR " checking in $dir for $name\n" if $dl_debug;
260 $file = ($do_expand) ? dl_expandspec($file) : (-f $file && $file);
261 #$file = _check_file($file);
262 if ($file) {
263 push(@found, $file);
264 next arg; # no need to look any further
265 }
266 }
267 }
268 }
269 if ($dl_debug) {
270 foreach(@dirs) {
271 print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_;
272 }
273 print STDERR "dl_findfile found: @found\n";
274 }
275 return $found[0] unless wantarray;
276 @found;
277}
278
279sub dl_expandspec {
280 my($spec) = @_;
281 # Optional function invoked if DynaLoader.pm sets $do_expand.
282 # Most systems do not require or use this function.
283 # Some systems may implement it in the dl_*.xs file in which case
284 # this Perl version should be excluded at build time.
285
286 # This function is designed to deal with systems which treat some
287 # 'filenames' in a special way. For example VMS 'Logical Names'
288 # (something like unix environment variables - but different).
289 # This function should recognise such names and expand them into
290 # full file paths.
291 # Must return undef if $spec is invalid or file does not exist.
292
293 my $file = $spec; # default output to input
294
295 return undef unless -f $file;
296 print STDERR "dl_expandspec($spec) => $file\n" if $dl_debug;
297 $file;
298}
299
300sub dl_find_symbol_anywhere
301{
302 my $sym = shift;
303 my $libref;
304 foreach $libref (@dl_librefs) {
305 my $symref = dl_find_symbol($libref,$sym,1);
306 return $symref if $symref;
307 }
308 return undef;
309}
310
311__END__
 
# spent 44µs within DynaLoader::CORE:ftdir which was called 10 times, avg 4µs/call: # 10 times (44µ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 2 times, avg 3µs/call: # 2 times (5µs+0s) by DynaLoader::bootstrap at line 145, avg 3µs/call
sub DynaLoader::CORE:ftfile; # opcode
# spent 6µs within DynaLoader::CORE:ftsize which was called 2 times, avg 3µs/call: # 2 times (6µs+0s) by DynaLoader::bootstrap at line 168, avg 3µs/call
sub DynaLoader::CORE:ftsize; # opcode
# spent 52µs within DynaLoader::CORE:subst which was called 4 times, avg 13µs/call: # 2 times (45µs+0s) by DynaLoader::bootstrap at line 167, avg 23µs/call # 2 times (7µs+0s) by DynaLoader::bootstrap at line 158, avg 4µs/call
sub DynaLoader::CORE:subst; # opcode
# spent 5µs within DynaLoader::dl_find_symbol which was called 2 times, avg 2µs/call: # 2 times (5µs+0s) by DynaLoader::bootstrap at line 192, avg 2µs/call
sub DynaLoader::dl_find_symbol; # xsub
# spent 6µs within DynaLoader::dl_install_xsub which was called 2 times, avg 3µs/call: # 2 times (6µs+0s) by DynaLoader::bootstrap at line 197, avg 3µs/call
sub DynaLoader::dl_install_xsub; # xsub
# spent 189µs within DynaLoader::dl_load_file which was called 2 times, avg 95µs/call: # 2 times (189µs+0s) by DynaLoader::bootstrap at line 187, avg 95µs/call
sub DynaLoader::dl_load_file; # xsub