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