Filename | /usr/lib/x86_64-linux-gnu/perl/5.28/DynaLoader.pm |
Statements | Executed 103 statements in 3.85ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 1 | 1 | 1.30ms | 1.30ms | dl_load_file (xsub) | DynaLoader::
2 | 1 | 1 | 714µs | 714µs | CORE:ftsize (opcode) | DynaLoader::
2 | 2 | 2 | 161µs | 2.38ms | bootstrap | DynaLoader::
10 | 1 | 1 | 58µs | 58µs | CORE:ftdir (opcode) | DynaLoader::
4 | 2 | 1 | 52µs | 52µs | CORE:subst (opcode) | DynaLoader::
1 | 1 | 1 | 11µs | 31µs | BEGIN@21 | DynaLoader::
2 | 1 | 1 | 9µs | 9µs | dl_install_xsub (xsub) | DynaLoader::
1 | 1 | 1 | 8µs | 8µs | BEGIN@17 | DynaLoader::
2 | 1 | 1 | 5µs | 5µs | dl_find_symbol (xsub) | DynaLoader::
2 | 1 | 1 | 5µs | 5µs | CORE:ftfile (opcode) | DynaLoader::
2 | 1 | 1 | 4µs | 4µs | dl_load_flags | DynaLoader::
0 | 0 | 0 | 0s | 0s | bootstrap_inherit | DynaLoader::
0 | 0 | 0 | 0s | 0s | croak | DynaLoader::
0 | 0 | 0 | 0s | 0s | dl_expandspec | DynaLoader::
0 | 0 | 0 | 0s | 0s | dl_find_symbol_anywhere | DynaLoader::
0 | 0 | 0 | 0s | 0s | dl_findfile | DynaLoader::
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 | |||||
3 | package 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 | ||||
18 | 1 | 5µs | $VERSION = '1.45'; | ||
19 | 1 | 17µs | 1 | 8µs | } # spent 8µs making 1 call to DynaLoader::BEGIN@17 |
20 | |||||
21 | 2 | 1.37ms | 2 | 51µs | # spent 31µs (11+20) within DynaLoader::BEGIN@21 which was called:
# once (11µs+20µs) by RBM::BEGIN@22 at line 21 # spent 31µs making 1 call to DynaLoader::BEGIN@21
# spent 20µs making 1 call to Config::import |
22 | |||||
23 | # enable debug/trace messages from DynaLoader perl code | ||||
24 | 1 | 900ns | $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 | |||||
38 | 2 | 5µs | # spent 4µs within DynaLoader::dl_load_flags which was called 2 times, avg 2µs/call:
# 2 times (4µs+0s) by DynaLoader::bootstrap at line 185, avg 2µs/call | ||
39 | |||||
40 | 1 | 11µs | 3 | 7µs | ($dl_dlext, $dl_so, $dlsrc) = @Config::Config{qw(dlext so dlsrc)}; # spent 7µs making 3 calls to Config::FETCH, avg 2µs/call |
41 | |||||
42 | 1 | 200ns | $do_expand = 0; | ||
43 | |||||
44 | 1 | 400ns | @dl_require_symbols = (); # names of symbols we need | ||
45 | 1 | 100ns | @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 | |||||
55 | 1 | 5µs | 1 | 2µs | push(@dl_library_path, split(' ', $Config::Config{libpth})); # spent 2µs making 1 call to Config::FETCH |
56 | |||||
57 | 1 | 2µs | 1 | 1µs | my $ldlibpthname = $Config::Config{ldlibpthname}; # spent 1µs making 1 call to Config::FETCH |
58 | 1 | 2µs | 1 | 1µs | my $ldlibpthname_defined = defined $Config::Config{ldlibpthname}; # spent 1µs making 1 call to Config::FETCH |
59 | 1 | 2µs | 1 | 1µs | my $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 | |||||
64 | 1 | 600ns | if ($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 | |||||
71 | 1 | 300ns | if ($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 | ||||
79 | 1 | 500ns | boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) && | ||
80 | !defined(&dl_error); | ||||
81 | |||||
82 | 1 | 100ns | if ($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 | |||||
88 | 1 | 48µs | 1; # End of main code | ||
89 | |||||
90 | sub croak { require Carp; Carp::croak(@_) } | ||||
91 | |||||
92 | sub 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 2.38ms (161µs+2.22) within DynaLoader::bootstrap which was called 2 times, avg 1.19ms/call:
# once (75µs+1.20ms) by RBM::BEGIN@22 at line 20 of Data/UUID.pm
# once (86µs+1.02ms) by Template::Stash::XS::BEGIN@21 at line 26 of Template/Stash/XS.pm | ||||
101 | # use local vars to enable $module.bs script to edit values | ||||
102 | 2 | 3µs | local(@args) = @_; | ||
103 | 2 | 1µs | local($module) = $args[0]; | ||
104 | 2 | 1µs | local(@dirs, $file); | ||
105 | |||||
106 | 2 | 700ns | 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. | ||||
113 | 2 | 2µ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 | |||||
119 | 2 | 4µs | my @modparts = split(/::/,$module); | ||
120 | 2 | 1µs | my $modfname = $modparts[-1]; | ||
121 | 2 | 1µs | 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. | ||||
126 | 2 | 600ns | $modfname = &mod2fname(\@modparts) if defined &mod2fname; | ||
127 | |||||
128 | |||||
129 | |||||
130 | 2 | 4µs | my $modpname = join('/',@modparts); | ||
131 | |||||
132 | 2 | 1µs | print STDERR "DynaLoader::bootstrap for $module ", | ||
133 | "(auto/$modpname/$modfname.$dl_dlext)\n" | ||||
134 | if $dl_debug; | ||||
135 | |||||
136 | 2 | 400ns | my $dir; | ||
137 | 2 | 3µs | foreach (@INC) { | ||
138 | |||||
139 | 10 | 4µs | $dir = "$_/auto/$modpname"; | ||
140 | |||||
141 | 10 | 79µs | 10 | 58µs | next unless -d $dir; # skip over uninteresting directories # spent 58µs making 10 calls to DynaLoader::CORE:ftdir, avg 6µs/call |
142 | |||||
143 | # check for common cases to avoid autoload of dl_findfile | ||||
144 | 2 | 2µs | my $try = "$dir/$modfname.$dl_dlext"; | ||
145 | 2 | 14µs | 2 | 5µs | last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && $try); # spent 5µs making 2 calls to DynaLoader::CORE:ftfile, avg 2µ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 | ||||
151 | 2 | 700ns | $file = dl_findfile(map("-L$_",@dirs,@INC), $modfname) unless $file; | ||
152 | |||||
153 | 2 | 600ns | 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 | |||||
157 | 2 | 1µs | my $bootname = "boot_$module"; | ||
158 | 2 | 14µs | 2 | 8µs | $bootname =~ s/\W/_/g; # spent 8µs making 2 calls to DynaLoader::CORE:subst, avg 4µs/call |
159 | 2 | 3µ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. | ||||
166 | 2 | 2µs | my $bs = "$dir/$modfname_orig"; | ||
167 | 2 | 48µs | 2 | 44µs | $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library # spent 44µs making 2 calls to DynaLoader::CORE:subst, avg 22µs/call |
168 | 2 | 724µs | 2 | 714µs | if (-s $bs) { # only read file if it's not empty # spent 714µs making 2 calls to DynaLoader::CORE:ftsize, avg 357µ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 | |||||
174 | 2 | 700ns | 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 | |||||
185 | 2 | 14µs | 2 | 4µs | my $flags = $module->dl_load_flags; # spent 4µs making 2 calls to DynaLoader::dl_load_flags, avg 2µs/call |
186 | |||||
187 | 2 | 1.32ms | 2 | 1.30ms | my $libref = dl_load_file($file, $flags) or # spent 1.30ms making 2 calls to DynaLoader::dl_load_file, avg 651µs/call |
188 | croak("Can't load '$file' for module $module: ".dl_error()); | ||||
189 | |||||
190 | 2 | 2µs | push(@dl_librefs,$libref); # record loaded object | ||
191 | |||||
192 | 2 | 13µs | 2 | 5µ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 | |||||
195 | 2 | 2µs | push(@dl_modules, $module); # record loaded module | ||
196 | |||||
197 | 2 | 17µs | 2 | 9µs | boot: # spent 9µs making 2 calls to DynaLoader::dl_install_xsub, avg 5µs/call |
198 | my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file); | ||||
199 | |||||
200 | # See comment block above | ||||
201 | |||||
202 | 2 | 1µs | push(@dl_shared_objects, $file); # record files loaded | ||
203 | |||||
204 | 2 | 94µs | 2 | 73µs | &$xs(@args); # spent 56µs making 1 call to Data::UUID::bootstrap
# spent 17µs making 1 call to Template::Stash::XS::bootstrap |
205 | } | ||||
206 | |||||
207 | sub 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 | |||||
279 | sub 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 | |||||
300 | sub 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 58µs within DynaLoader::CORE:ftdir which was called 10 times, avg 6µs/call:
# 10 times (58µs+0s) by DynaLoader::bootstrap at line 141, avg 6µs/call | |||||
# spent 5µs within DynaLoader::CORE:ftfile which was called 2 times, avg 2µs/call:
# 2 times (5µs+0s) by DynaLoader::bootstrap at line 145, avg 2µs/call | |||||
# spent 714µs within DynaLoader::CORE:ftsize which was called 2 times, avg 357µs/call:
# 2 times (714µs+0s) by DynaLoader::bootstrap at line 168, avg 357µ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 | |||||
# spent 9µs within DynaLoader::dl_install_xsub which was called 2 times, avg 5µs/call:
# 2 times (9µs+0s) by DynaLoader::bootstrap at line 197, avg 5µs/call | |||||
# spent 1.30ms within DynaLoader::dl_load_file which was called 2 times, avg 651µs/call:
# 2 times (1.30ms+0s) by DynaLoader::bootstrap at line 187, avg 651µs/call |