Filename | /usr/lib/perl/5.18/DynaLoader.pm |
Statements | Executed 145 statements in 2.28ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
3 | 3 | 3 | 212µs | 606µs | bootstrap | DynaLoader::
3 | 1 | 1 | 146µs | 146µs | dl_load_file (xsub) | DynaLoader::
6 | 2 | 1 | 61µs | 61µs | CORE:subst (opcode) | DynaLoader::
15 | 1 | 1 | 42µs | 42µs | CORE:ftdir (opcode) | DynaLoader::
3 | 1 | 1 | 16µs | 16µs | dl_install_xsub (xsub) | DynaLoader::
1 | 1 | 1 | 10µs | 10µs | BEGIN@17 | DynaLoader::
3 | 1 | 1 | 10µs | 10µs | CORE:ftsize (opcode) | DynaLoader::
1 | 1 | 1 | 9µs | 20µs | BEGIN@21 | DynaLoader::
3 | 1 | 1 | 8µs | 8µs | CORE:ftfile (opcode) | DynaLoader::
3 | 1 | 1 | 6µs | 6µs | dl_find_symbol (xsub) | DynaLoader::
3 | 1 | 1 | 4µs | 4µs | dl_load_flags | DynaLoader::
3 | 1 | 1 | 3µs | 3µs | dl_undef_symbols (xsub) | 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 | ||||
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 10µs within DynaLoader::BEGIN@17 which was called:
# once (10µs+0s) by base::import at line 19 | ||||
18 | 1 | 6µs | $VERSION = '1.18'; | ||
19 | 1 | 24µs | 1 | 10µs | } # spent 10µs making 1 call to DynaLoader::BEGIN@17 |
20 | |||||
21 | 2 | 1.59ms | 2 | 31µs | # spent 20µs (9+11) within DynaLoader::BEGIN@21 which was called:
# once (9µs+11µs) by base::import at line 21 # spent 20µs making 1 call to DynaLoader::BEGIN@21
# spent 11µs making 1 call to Config::import |
22 | |||||
23 | # enable debug/trace messages from DynaLoader perl code | ||||
24 | 1 | 2µ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 | # | ||||
32 | # This is called as a class method $module->dl_load_flags. The | ||||
33 | # definition here will be inherited and result on "default" loading | ||||
34 | # behaviour unless a sub-class of DynaLoader defines its own version. | ||||
35 | # | ||||
36 | |||||
37 | 3 | 8µs | # spent 4µs within DynaLoader::dl_load_flags which was called 3 times, avg 1µs/call:
# 3 times (4µs+0s) by DynaLoader::bootstrap at line 184, avg 1µs/call | ||
38 | |||||
39 | 1 | 12µs | 3 | 6µs | ($dl_dlext, $dl_so, $dlsrc) = @Config::Config{qw(dlext so dlsrc)}; # spent 6µs making 3 calls to Config::FETCH, avg 2µs/call |
40 | |||||
41 | 1 | 200ns | $do_expand = 0; | ||
42 | |||||
43 | 1 | 600ns | @dl_require_symbols = (); # names of symbols we need | ||
44 | 1 | 200ns | @dl_resolve_using = (); # names of files to link with | ||
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 | # This is a fix to support DLD's unfortunate desire to relink -lc | ||||
53 | 1 | 300ns | @dl_resolve_using = dl_findfile('-lc') if $dlsrc eq "dl_dld.xs"; | ||
54 | |||||
55 | # Initialise @dl_library_path with the 'standard' library path | ||||
56 | # for this platform as determined by Configure. | ||||
57 | |||||
58 | 1 | 5µs | 1 | 2µs | push(@dl_library_path, split(' ', $Config::Config{libpth})); # spent 2µs making 1 call to Config::FETCH |
59 | |||||
60 | 1 | 3µs | 1 | 2µs | my $ldlibpthname = $Config::Config{ldlibpthname}; # spent 2µs making 1 call to Config::FETCH |
61 | 1 | 3µs | 1 | 2µs | my $ldlibpthname_defined = defined $Config::Config{ldlibpthname}; # spent 2µs making 1 call to Config::FETCH |
62 | 1 | 3µs | 1 | 1µs | my $pthsep = $Config::Config{path_sep}; # spent 1µs making 1 call to Config::FETCH |
63 | |||||
64 | # Add to @dl_library_path any extra directories we can gather from environment | ||||
65 | # during runtime. | ||||
66 | |||||
67 | 1 | 600ns | if ($ldlibpthname_defined && | ||
68 | exists $ENV{$ldlibpthname}) { | ||||
69 | push(@dl_library_path, split(/$pthsep/, $ENV{$ldlibpthname})); | ||||
70 | } | ||||
71 | |||||
72 | # E.g. HP-UX supports both its native SHLIB_PATH *and* LD_LIBRARY_PATH. | ||||
73 | |||||
74 | 1 | 200ns | if ($ldlibpthname_defined && | ||
75 | $ldlibpthname ne 'LD_LIBRARY_PATH' && | ||||
76 | exists $ENV{LD_LIBRARY_PATH}) { | ||||
77 | push(@dl_library_path, split(/$pthsep/, $ENV{LD_LIBRARY_PATH})); | ||||
78 | } | ||||
79 | |||||
80 | # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here. | ||||
81 | # NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB | ||||
82 | 1 | 600ns | boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) && | ||
83 | !defined(&dl_error); | ||||
84 | |||||
85 | 1 | 100ns | if ($dl_debug) { | ||
86 | print STDERR "DynaLoader.pm loaded (@INC, @dl_library_path)\n"; | ||||
87 | print STDERR "DynaLoader not linked into this perl\n" | ||||
88 | unless defined(&boot_DynaLoader); | ||||
89 | } | ||||
90 | |||||
91 | 1 | 16µs | 1; # End of main code | ||
92 | |||||
93 | sub croak { require Carp; Carp::croak(@_) } | ||||
94 | |||||
95 | sub bootstrap_inherit { | ||||
96 | my $module = $_[0]; | ||||
97 | local *isa = *{"$module\::ISA"}; | ||||
98 | local @isa = (@isa, 'DynaLoader'); | ||||
99 | # Cannot goto due to delocalization. Will report errors on a wrong line? | ||||
100 | bootstrap(@_); | ||||
101 | } | ||||
102 | |||||
103 | # spent 606µs (212+394) within DynaLoader::bootstrap which was called 3 times, avg 202µs/call:
# once (68µs+149µs) by InfluxDB::LineProtocol::BEGIN@10 at line 66 of Time/HiRes.pm
# once (87µs+115µs) by Try::Tiny::BEGIN@1 at line 55 of Sub/Name.pm
# once (56µs+130µs) by Data::OptList::BEGIN@7 at line 88 of /opt/flows/lib/lib/perl5/x86_64-linux-gnu-thread-multi/Params/Util.pm | ||||
104 | # use local vars to enable $module.bs script to edit values | ||||
105 | 3 | 4µs | local(@args) = @_; | ||
106 | 3 | 2µs | local($module) = $args[0]; | ||
107 | 3 | 1µs | local(@dirs, $file); | ||
108 | |||||
109 | 3 | 700ns | unless ($module) { | ||
110 | require Carp; | ||||
111 | Carp::confess("Usage: DynaLoader::bootstrap(module)"); | ||||
112 | } | ||||
113 | |||||
114 | # A common error on platforms which don't support dynamic loading. | ||||
115 | # Since it's fatal and potentially confusing we give a detailed message. | ||||
116 | 3 | 2µs | croak("Can't load module $module, dynamic loading not available in this perl.\n". | ||
117 | " (You may need to build a new perl executable which either supports\n". | ||||
118 | " dynamic loading or has the $module module statically linked into it.)\n") | ||||
119 | unless defined(&dl_load_file); | ||||
120 | |||||
121 | |||||
122 | 3 | 6µs | my @modparts = split(/::/,$module); | ||
123 | 3 | 2µs | my $modfname = $modparts[-1]; | ||
124 | |||||
125 | # Some systems have restrictions on files names for DLL's etc. | ||||
126 | # mod2fname returns appropriate file base name (typically truncated) | ||||
127 | # It may also edit @modparts if required. | ||||
128 | 3 | 900ns | $modfname = &mod2fname(\@modparts) if defined &mod2fname; | ||
129 | |||||
130 | |||||
131 | |||||
132 | 3 | 3µs | my $modpname = join('/',@modparts); | ||
133 | |||||
134 | 3 | 600ns | print STDERR "DynaLoader::bootstrap for $module ", | ||
135 | "(auto/$modpname/$modfname.$dl_dlext)\n" | ||||
136 | if $dl_debug; | ||||
137 | |||||
138 | 3 | 4µs | foreach (@INC) { | ||
139 | |||||
140 | 15 | 7µs | my $dir = "$_/auto/$modpname"; | ||
141 | |||||
142 | 15 | 78µs | 15 | 42µs | next unless -d $dir; # skip over uninteresting directories # spent 42µs making 15 calls to DynaLoader::CORE:ftdir, avg 3µs/call |
143 | |||||
144 | # check for common cases to avoid autoload of dl_findfile | ||||
145 | 3 | 4µs | my $try = "$dir/$modfname.$dl_dlext"; | ||
146 | 3 | 20µs | 3 | 8µs | last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && $try); # spent 8µs making 3 calls to DynaLoader::CORE:ftfile, avg 3µs/call |
147 | |||||
148 | # no luck here, save dir for possible later dl_findfile search | ||||
149 | push @dirs, $dir; | ||||
150 | } | ||||
151 | # last resort, let dl_findfile have a go in all known locations | ||||
152 | 3 | 400ns | $file = dl_findfile(map("-L$_",@dirs,@INC), $modfname) unless $file; | ||
153 | |||||
154 | 3 | 300ns | croak("Can't locate loadable object for module $module in \@INC (\@INC contains: @INC)") | ||
155 | unless $file; # wording similar to error from 'require' | ||||
156 | |||||
157 | |||||
158 | 3 | 2µs | my $bootname = "boot_$module"; | ||
159 | 3 | 17µs | 3 | 9µs | $bootname =~ s/\W/_/g; # spent 9µs making 3 calls to DynaLoader::CORE:subst, avg 3µs/call |
160 | 3 | 3µs | @dl_require_symbols = ($bootname); | ||
161 | |||||
162 | # Execute optional '.bootstrap' perl script for this module. | ||||
163 | # The .bs file can be used to configure @dl_resolve_using etc to | ||||
164 | # match the needs of the individual module on this architecture. | ||||
165 | 3 | 800ns | my $bs = $file; | ||
166 | 3 | 59µs | 3 | 52µs | $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library # spent 52µs making 3 calls to DynaLoader::CORE:subst, avg 17µs/call |
167 | 3 | 17µs | 3 | 10µs | if (-s $bs) { # only read file if it's not empty # spent 10µs making 3 calls to DynaLoader::CORE:ftsize, avg 3µs/call |
168 | print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug; | ||||
169 | eval { do $bs; }; | ||||
170 | warn "$bs: $@\n" if $@; | ||||
171 | } | ||||
172 | |||||
173 | 3 | 500ns | my $boot_symbol_ref; | ||
174 | |||||
175 | |||||
176 | |||||
177 | # Many dynamic extension loading problems will appear to come from | ||||
178 | # this section of code: XYZ failed at line 123 of DynaLoader.pm. | ||||
179 | # Often these errors are actually occurring in the initialisation | ||||
180 | # C code of the extension XS file. Perl reports the error as being | ||||
181 | # in this perl code simply because this was the last perl code | ||||
182 | # it executed. | ||||
183 | |||||
184 | 3 | 178µs | 6 | 150µs | my $libref = dl_load_file($file, $module->dl_load_flags) or # spent 146µs making 3 calls to DynaLoader::dl_load_file, avg 49µs/call
# spent 4µs making 3 calls to DynaLoader::dl_load_flags, avg 1µs/call |
185 | croak("Can't load '$file' for module $module: ".dl_error()); | ||||
186 | |||||
187 | 3 | 2µs | push(@dl_librefs,$libref); # record loaded object | ||
188 | |||||
189 | 3 | 12µs | 3 | 3µs | my @unresolved = dl_undef_symbols(); # spent 3µs making 3 calls to DynaLoader::dl_undef_symbols, avg 1µs/call |
190 | 3 | 900ns | if (@unresolved) { | ||
191 | require Carp; | ||||
192 | Carp::carp("Undefined symbols present after loading $file: @unresolved\n"); | ||||
193 | } | ||||
194 | |||||
195 | 3 | 14µs | 3 | 6µs | $boot_symbol_ref = dl_find_symbol($libref, $bootname) or # spent 6µs making 3 calls to DynaLoader::dl_find_symbol, avg 2µs/call |
196 | croak("Can't find '$bootname' symbol in $file\n"); | ||||
197 | |||||
198 | 3 | 2µs | push(@dl_modules, $module); # record loaded module | ||
199 | |||||
200 | 3 | 26µs | 3 | 16µs | boot: # spent 16µs making 3 calls to DynaLoader::dl_install_xsub, avg 5µs/call |
201 | my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file); | ||||
202 | |||||
203 | # See comment block above | ||||
204 | |||||
205 | 3 | 1µs | push(@dl_shared_objects, $file); # record files loaded | ||
206 | |||||
207 | 3 | 130µs | 3 | 99µs | &$xs(@args); # spent 48µs making 1 call to Time::HiRes::bootstrap
# spent 30µs making 1 call to Params::Util::bootstrap
# spent 22µs making 1 call to Sub::Name::bootstrap |
208 | } | ||||
209 | |||||
210 | sub dl_findfile { | ||||
211 | # Read ext/DynaLoader/DynaLoader.doc for detailed information. | ||||
212 | # This function does not automatically consider the architecture | ||||
213 | # or the perl library auto directories. | ||||
214 | my (@args) = @_; | ||||
215 | my (@dirs, $dir); # which directories to search | ||||
216 | my (@found); # full paths to real files we have found | ||||
217 | #my $dl_ext= 'so'; # $Config::Config{'dlext'} suffix for perl extensions | ||||
218 | #my $dl_so = 'so'; # $Config::Config{'so'} suffix for shared libraries | ||||
219 | |||||
220 | print STDERR "dl_findfile(@args)\n" if $dl_debug; | ||||
221 | |||||
222 | # accumulate directories but process files as they appear | ||||
223 | arg: foreach(@args) { | ||||
224 | # Special fast case: full filepath requires no search | ||||
225 | |||||
226 | |||||
227 | if (m:/: && -f $_) { | ||||
228 | push(@found,$_); | ||||
229 | last arg unless wantarray; | ||||
230 | next; | ||||
231 | } | ||||
232 | |||||
233 | |||||
234 | # Deal with directories first: | ||||
235 | # Using a -L prefix is the preferred option (faster and more robust) | ||||
236 | if (m:^-L:) { s/^-L//; push(@dirs, $_); next; } | ||||
237 | |||||
238 | # Otherwise we try to try to spot directories by a heuristic | ||||
239 | # (this is a more complicated issue than it first appears) | ||||
240 | if (m:/: && -d $_) { push(@dirs, $_); next; } | ||||
241 | |||||
242 | |||||
243 | |||||
244 | # Only files should get this far... | ||||
245 | my(@names, $name); # what filenames to look for | ||||
246 | if (m:-l: ) { # convert -lname to appropriate library name | ||||
247 | s/-l//; | ||||
248 | push(@names,"lib$_.$dl_so"); | ||||
249 | push(@names,"lib$_.a"); | ||||
250 | } else { # Umm, a bare name. Try various alternatives: | ||||
251 | # these should be ordered with the most likely first | ||||
252 | push(@names,"$_.$dl_dlext") unless m/\.$dl_dlext$/o; | ||||
253 | push(@names,"$_.$dl_so") unless m/\.$dl_so$/o; | ||||
254 | |||||
255 | push(@names,"lib$_.$dl_so") unless m:/:; | ||||
256 | push(@names,"$_.a") if !m/\.a$/ and $dlsrc eq "dl_dld.xs"; | ||||
257 | push(@names, $_); | ||||
258 | } | ||||
259 | my $dirsep = '/'; | ||||
260 | |||||
261 | foreach $dir (@dirs, @dl_library_path) { | ||||
262 | next unless -d $dir; | ||||
263 | |||||
264 | foreach $name (@names) { | ||||
265 | my($file) = "$dir$dirsep$name"; | ||||
266 | print STDERR " checking in $dir for $name\n" if $dl_debug; | ||||
267 | $file = ($do_expand) ? dl_expandspec($file) : (-f $file && $file); | ||||
268 | #$file = _check_file($file); | ||||
269 | if ($file) { | ||||
270 | push(@found, $file); | ||||
271 | next arg; # no need to look any further | ||||
272 | } | ||||
273 | } | ||||
274 | } | ||||
275 | } | ||||
276 | if ($dl_debug) { | ||||
277 | foreach(@dirs) { | ||||
278 | print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_; | ||||
279 | } | ||||
280 | print STDERR "dl_findfile found: @found\n"; | ||||
281 | } | ||||
282 | return $found[0] unless wantarray; | ||||
283 | @found; | ||||
284 | } | ||||
285 | |||||
286 | sub dl_expandspec { | ||||
287 | my($spec) = @_; | ||||
288 | # Optional function invoked if DynaLoader.pm sets $do_expand. | ||||
289 | # Most systems do not require or use this function. | ||||
290 | # Some systems may implement it in the dl_*.xs file in which case | ||||
291 | # this Perl version should be excluded at build time. | ||||
292 | |||||
293 | # This function is designed to deal with systems which treat some | ||||
294 | # 'filenames' in a special way. For example VMS 'Logical Names' | ||||
295 | # (something like unix environment variables - but different). | ||||
296 | # This function should recognise such names and expand them into | ||||
297 | # full file paths. | ||||
298 | # Must return undef if $spec is invalid or file does not exist. | ||||
299 | |||||
300 | my $file = $spec; # default output to input | ||||
301 | |||||
302 | return undef unless -f $file; | ||||
303 | print STDERR "dl_expandspec($spec) => $file\n" if $dl_debug; | ||||
304 | $file; | ||||
305 | } | ||||
306 | |||||
307 | sub dl_find_symbol_anywhere | ||||
308 | { | ||||
309 | my $sym = shift; | ||||
310 | my $libref; | ||||
311 | foreach $libref (@dl_librefs) { | ||||
312 | my $symref = dl_find_symbol($libref,$sym); | ||||
313 | return $symref if $symref; | ||||
314 | } | ||||
315 | return undef; | ||||
316 | } | ||||
317 | |||||
318 | __END__ | ||||
# spent 42µs within DynaLoader::CORE:ftdir which was called 15 times, avg 3µs/call:
# 15 times (42µs+0s) by DynaLoader::bootstrap at line 142, avg 3µs/call | |||||
# spent 8µs within DynaLoader::CORE:ftfile which was called 3 times, avg 3µs/call:
# 3 times (8µs+0s) by DynaLoader::bootstrap at line 146, avg 3µs/call | |||||
# spent 10µs within DynaLoader::CORE:ftsize which was called 3 times, avg 3µs/call:
# 3 times (10µs+0s) by DynaLoader::bootstrap at line 167, avg 3µs/call | |||||
sub DynaLoader::CORE:subst; # opcode | |||||
# spent 6µs within DynaLoader::dl_find_symbol which was called 3 times, avg 2µs/call:
# 3 times (6µs+0s) by DynaLoader::bootstrap at line 195, avg 2µs/call | |||||
# spent 16µs within DynaLoader::dl_install_xsub which was called 3 times, avg 5µs/call:
# 3 times (16µs+0s) by DynaLoader::bootstrap at line 200, avg 5µs/call | |||||
# spent 146µs within DynaLoader::dl_load_file which was called 3 times, avg 49µs/call:
# 3 times (146µs+0s) by DynaLoader::bootstrap at line 184, avg 49µs/call | |||||
# spent 3µs within DynaLoader::dl_undef_symbols which was called 3 times, avg 1µs/call:
# 3 times (3µs+0s) by DynaLoader::bootstrap at line 189, avg 1µs/call |