Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/5.13.5/x86_64-linux/DynaLoader.pm |
Statements | Executed 191 statements in 3.39ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
5 | 1 | 1 | 568µs | 568µs | dl_load_file (xsub) | DynaLoader::
5 | 5 | 5 | 560µs | 2.31ms | bootstrap | DynaLoader::
10 | 2 | 1 | 209µs | 209µs | CORE:subst (opcode) | DynaLoader::
5 | 1 | 1 | 104µs | 104µs | CORE:ftdir (opcode) | DynaLoader::
5 | 1 | 1 | 69µs | 69µs | CORE:ftsize (opcode) | DynaLoader::
5 | 1 | 1 | 64µs | 64µs | CORE:ftfile (opcode) | DynaLoader::
5 | 1 | 1 | 37µs | 37µs | dl_install_xsub (xsub) | DynaLoader::
5 | 1 | 1 | 19µs | 19µs | dl_load_flags | DynaLoader::
1 | 1 | 1 | 18µs | 18µs | BEGIN@18 | DynaLoader::
5 | 1 | 1 | 17µs | 17µs | dl_find_symbol (xsub) | DynaLoader::
1 | 1 | 1 | 12µs | 34µs | BEGIN@25 | DynaLoader::
5 | 1 | 1 | 12µs | 12µs | dl_undef_symbols (xsub) | DynaLoader::
0 | 0 | 0 | 0s | 0s | bootstrap_inherit | DynaLoader::
0 | 0 | 0 | 0s | 0s | croak | DynaLoader::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | # Generated from DynaLoader_pm.PL | ||||
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 | # Tim.Bunce@ig.co.uk, August 1994 | ||||
17 | |||||
18 | # spent 18µs within DynaLoader::BEGIN@18 which was called:
# once (18µs+0s) by base::import at line 20 | ||||
19 | 1 | 6µs | $VERSION = '1.10'; | ||
20 | 1 | 36µs | 1 | 18µs | } # spent 18µs making 1 call to DynaLoader::BEGIN@18 |
21 | |||||
22 | 1 | 131µs | require AutoLoader; | ||
23 | 1 | 2µs | *AUTOLOAD = \&AutoLoader::AUTOLOAD; | ||
24 | |||||
25 | 2 | 823µs | 2 | 55µs | # spent 34µs (12+21) within DynaLoader::BEGIN@25 which was called:
# once (12µs+21µs) by base::import at line 25 # spent 34µs making 1 call to DynaLoader::BEGIN@25
# spent 21µs making 1 call to Config::import |
26 | |||||
27 | # enable debug/trace messages from DynaLoader perl code | ||||
28 | 1 | 2µs | $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug; | ||
29 | |||||
30 | # | ||||
31 | # Flags to alter dl_load_file behaviour. Assigned bits: | ||||
32 | # 0x01 make symbols available for linking later dl_load_file's. | ||||
33 | # (only known to work on Solaris 2 using dlopen(RTLD_GLOBAL)) | ||||
34 | # (ignored under VMS; effect is built-in to image linking) | ||||
35 | # | ||||
36 | # This is called as a class method $module->dl_load_flags. The | ||||
37 | # definition here will be inherited and result on "default" loading | ||||
38 | # behaviour unless a sub-class of DynaLoader defines its own version. | ||||
39 | # | ||||
40 | |||||
41 | 5 | 24µs | # spent 19µs within DynaLoader::dl_load_flags which was called 5 times, avg 4µs/call:
# 5 times (19µs+0s) by DynaLoader::bootstrap at line 196, avg 4µs/call | ||
42 | |||||
43 | 1 | 19µs | 3 | 145µs | ($dl_dlext, $dl_so, $dlsrc) = @Config::Config{qw(dlext so dlsrc)}; # spent 145µs making 3 calls to Config::FETCH, avg 48µs/call |
44 | |||||
45 | |||||
46 | 1 | 1µs | $do_expand = 0; | ||
47 | |||||
48 | 1 | 1µs | @dl_require_symbols = (); # names of symbols we need | ||
49 | 1 | 1µs | @dl_resolve_using = (); # names of files to link with | ||
50 | 1 | 1µs | @dl_library_path = (); # path to look for files | ||
51 | |||||
52 | #XSLoader.pm may have added elements before we were required | ||||
53 | #@dl_shared_objects = (); # shared objects for symbols we have | ||||
54 | #@dl_librefs = (); # things we have loaded | ||||
55 | #@dl_modules = (); # Modules we have loaded | ||||
56 | |||||
57 | # This is a fix to support DLD's unfortunate desire to relink -lc | ||||
58 | 1 | 1µs | @dl_resolve_using = dl_findfile('-lc') if $dlsrc eq "dl_dld.xs"; | ||
59 | |||||
60 | # Initialise @dl_library_path with the 'standard' library path | ||||
61 | # for this platform as determined by Configure. | ||||
62 | |||||
63 | 1 | 9µs | 1 | 5µs | push(@dl_library_path, split(' ', $Config::Config{libpth})); # spent 5µs making 1 call to Config::FETCH |
64 | |||||
65 | |||||
66 | 1 | 6µs | 1 | 4µs | my $ldlibpthname = $Config::Config{ldlibpthname}; # spent 4µs making 1 call to Config::FETCH |
67 | 1 | 6µs | 1 | 4µs | my $ldlibpthname_defined = defined $Config::Config{ldlibpthname}; # spent 4µs making 1 call to Config::FETCH |
68 | 1 | 5µs | 1 | 4µs | my $pthsep = $Config::Config{path_sep}; # spent 4µs making 1 call to Config::FETCH |
69 | |||||
70 | # Add to @dl_library_path any extra directories we can gather from environment | ||||
71 | # during runtime. | ||||
72 | |||||
73 | 1 | 2µs | if ($ldlibpthname_defined && | ||
74 | exists $ENV{$ldlibpthname}) { | ||||
75 | push(@dl_library_path, split(/$pthsep/, $ENV{$ldlibpthname})); | ||||
76 | } | ||||
77 | |||||
78 | # E.g. HP-UX supports both its native SHLIB_PATH *and* LD_LIBRARY_PATH. | ||||
79 | |||||
80 | 1 | 1µs | if ($ldlibpthname_defined && | ||
81 | $ldlibpthname ne 'LD_LIBRARY_PATH' && | ||||
82 | exists $ENV{LD_LIBRARY_PATH}) { | ||||
83 | push(@dl_library_path, split(/$pthsep/, $ENV{LD_LIBRARY_PATH})); | ||||
84 | } | ||||
85 | |||||
86 | |||||
87 | # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here. | ||||
88 | # NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB | ||||
89 | 1 | 2µs | boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) && | ||
90 | !defined(&dl_error); | ||||
91 | |||||
92 | 1 | 1µs | if ($dl_debug) { | ||
93 | print STDERR "DynaLoader.pm loaded (@INC, @dl_library_path)\n"; | ||||
94 | print STDERR "DynaLoader not linked into this perl\n" | ||||
95 | unless defined(&boot_DynaLoader); | ||||
96 | } | ||||
97 | |||||
98 | 1 | 19µs | 1; # End of main code | ||
99 | |||||
100 | |||||
101 | sub croak { require Carp; Carp::croak(@_) } | ||||
102 | |||||
103 | sub bootstrap_inherit { | ||||
104 | my $module = $_[0]; | ||||
105 | local *isa = *{"$module\::ISA"}; | ||||
106 | local @isa = (@isa, 'DynaLoader'); | ||||
107 | # Cannot goto due to delocalization. Will report errors on a wrong line? | ||||
108 | bootstrap(@_); | ||||
109 | } | ||||
110 | |||||
111 | # The bootstrap function cannot be autoloaded (without complications) | ||||
112 | # so we define it here: | ||||
113 | |||||
114 | # spent 2.31ms (560µs+1.75) within DynaLoader::bootstrap which was called 5 times, avg 462µs/call:
# once (111µs+496µs) by DBI::install_driver at line 27 of DBD/SQLite.pm
# once (105µs+467µs) by DBI::BEGIN@163 at line 261 of DBI.pm
# once (140µs+404µs) by Hailo::Engine::Default::BEGIN@12 at line 24 of List/MoreUtils.pm
# once (107µs+198µs) by namespace::clean::BEGIN@14 at line 55 of Sub/Name.pm
# once (98µs+186µs) by Data::OptList::BEGIN@7 at line 88 of Params/Util.pm | ||||
115 | # use local vars to enable $module.bs script to edit values | ||||
116 | 5 | 14µs | local(@args) = @_; | ||
117 | 5 | 7µs | local($module) = $args[0]; | ||
118 | 5 | 7µs | local(@dirs, $file); | ||
119 | |||||
120 | 5 | 6µs | unless ($module) { | ||
121 | require Carp; | ||||
122 | Carp::confess("Usage: DynaLoader::bootstrap(module)"); | ||||
123 | } | ||||
124 | |||||
125 | # A common error on platforms which don't support dynamic loading. | ||||
126 | # Since it's fatal and potentially confusing we give a detailed message. | ||||
127 | 5 | 9µs | croak("Can't load module $module, dynamic loading not available in this perl.\n". | ||
128 | " (You may need to build a new perl executable which either supports\n". | ||||
129 | " dynamic loading or has the $module module statically linked into it.)\n") | ||||
130 | unless defined(&dl_load_file); | ||||
131 | |||||
- - | |||||
134 | 5 | 19µs | my @modparts = split(/::/,$module); | ||
135 | 5 | 8µs | my $modfname = $modparts[-1]; | ||
136 | |||||
137 | # Some systems have restrictions on files names for DLL's etc. | ||||
138 | # mod2fname returns appropriate file base name (typically truncated) | ||||
139 | # It may also edit @modparts if required. | ||||
140 | 5 | 7µs | $modfname = &mod2fname(\@modparts) if defined &mod2fname; | ||
141 | |||||
142 | |||||
143 | |||||
144 | 5 | 12µs | my $modpname = join('/',@modparts); | ||
145 | |||||
146 | 5 | 7µs | print STDERR "DynaLoader::bootstrap for $module ", | ||
147 | "(auto/$modpname/$modfname.$dl_dlext)\n" | ||||
148 | if $dl_debug; | ||||
149 | |||||
150 | 5 | 9µs | foreach (@INC) { | ||
151 | |||||
152 | 5 | 11µs | my $dir = "$_/auto/$modpname"; | ||
153 | |||||
154 | 5 | 138µs | 5 | 104µs | next unless -d $dir; # skip over uninteresting directories # spent 104µs making 5 calls to DynaLoader::CORE:ftdir, avg 21µs/call |
155 | |||||
156 | # check for common cases to avoid autoload of dl_findfile | ||||
157 | 5 | 14µs | my $try = "$dir/$modfname.$dl_dlext"; | ||
158 | 5 | 99µs | 5 | 64µs | last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && $try); # spent 64µs making 5 calls to DynaLoader::CORE:ftfile, avg 13µs/call |
159 | |||||
160 | # no luck here, save dir for possible later dl_findfile search | ||||
161 | push @dirs, $dir; | ||||
162 | } | ||||
163 | # last resort, let dl_findfile have a go in all known locations | ||||
164 | 5 | 6µs | $file = dl_findfile(map("-L$_",@dirs,@INC), $modfname) unless $file; | ||
165 | |||||
166 | 5 | 5µs | croak("Can't locate loadable object for module $module in \@INC (\@INC contains: @INC)") | ||
167 | unless $file; # wording similar to error from 'require' | ||||
168 | |||||
169 | |||||
170 | 5 | 10µs | my $bootname = "boot_$module"; | ||
171 | 5 | 42µs | 5 | 19µs | $bootname =~ s/\W/_/g; # spent 19µs making 5 calls to DynaLoader::CORE:subst, avg 4µs/call |
172 | 5 | 12µs | @dl_require_symbols = ($bootname); | ||
173 | |||||
174 | # Execute optional '.bootstrap' perl script for this module. | ||||
175 | # The .bs file can be used to configure @dl_resolve_using etc to | ||||
176 | # match the needs of the individual module on this architecture. | ||||
177 | 5 | 9µs | my $bs = $file; | ||
178 | 5 | 210µs | 5 | 190µs | $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library # spent 190µs making 5 calls to DynaLoader::CORE:subst, avg 38µs/call |
179 | 5 | 94µs | 5 | 69µs | if (-s $bs) { # only read file if it's not empty # spent 69µs making 5 calls to DynaLoader::CORE:ftsize, avg 14µs/call |
180 | print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug; | ||||
181 | eval { do $bs; }; | ||||
182 | warn "$bs: $@\n" if $@; | ||||
183 | } | ||||
184 | |||||
185 | 5 | 6µs | my $boot_symbol_ref; | ||
186 | |||||
187 | |||||
188 | |||||
189 | # Many dynamic extension loading problems will appear to come from | ||||
190 | # this section of code: XYZ failed at line 123 of DynaLoader.pm. | ||||
191 | # Often these errors are actually occurring in the initialisation | ||||
192 | # C code of the extension XS file. Perl reports the error as being | ||||
193 | # in this perl code simply because this was the last perl code | ||||
194 | # it executed. | ||||
195 | |||||
196 | 5 | 638µs | 10 | 588µs | my $libref = dl_load_file($file, $module->dl_load_flags) or # spent 568µs making 5 calls to DynaLoader::dl_load_file, avg 114µs/call
# spent 19µs making 5 calls to DynaLoader::dl_load_flags, avg 4µs/call |
197 | croak("Can't load '$file' for module $module: ".dl_error()); | ||||
198 | |||||
199 | 5 | 10µs | push(@dl_librefs,$libref); # record loaded object | ||
200 | |||||
201 | 5 | 35µs | 5 | 12µs | my @unresolved = dl_undef_symbols(); # spent 12µs making 5 calls to DynaLoader::dl_undef_symbols, avg 2µs/call |
202 | 5 | 6µs | if (@unresolved) { | ||
203 | require Carp; | ||||
204 | Carp::carp("Undefined symbols present after loading $file: @unresolved\n"); | ||||
205 | } | ||||
206 | |||||
207 | 5 | 38µs | 5 | 17µs | $boot_symbol_ref = dl_find_symbol($libref, $bootname) or # spent 17µs making 5 calls to DynaLoader::dl_find_symbol, avg 3µs/call |
208 | croak("Can't find '$bootname' symbol in $file\n"); | ||||
209 | |||||
210 | 5 | 9µs | push(@dl_modules, $module); # record loaded module | ||
211 | |||||
212 | 5 | 67µs | 5 | 37µs | boot: # spent 37µs making 5 calls to DynaLoader::dl_install_xsub, avg 7µs/call |
213 | my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file); | ||||
214 | |||||
215 | # See comment block above | ||||
216 | |||||
217 | 5 | 8µs | push(@dl_shared_objects, $file); # record files loaded | ||
218 | |||||
219 | 5 | 720µs | 5 | 653µs | &$xs(@args); # spent 273µs making 1 call to DBI::bootstrap
# spent 210µs making 1 call to DBD::SQLite::bootstrap
# spent 114µs making 1 call to List::MoreUtils::bootstrap
# spent 32µs making 1 call to Params::Util::bootstrap
# spent 23µs making 1 call to Sub::Name::bootstrap |
220 | } | ||||
221 | |||||
222 | |||||
223 | #sub _check_file { # private utility to handle dl_expandspec vs -f tests | ||||
224 | # my($file) = @_; | ||||
225 | # return $file if (!$do_expand && -f $file); # the common case | ||||
226 | # return $file if ( $do_expand && ($file=dl_expandspec($file))); | ||||
227 | # return undef; | ||||
228 | #} | ||||
229 | |||||
230 | |||||
231 | # Let autosplit and the autoloader deal with these functions: | ||||
232 | __END__ | ||||
# spent 104µs within DynaLoader::CORE:ftdir which was called 5 times, avg 21µs/call:
# 5 times (104µs+0s) by DynaLoader::bootstrap at line 154, avg 21µs/call | |||||
# spent 64µs within DynaLoader::CORE:ftfile which was called 5 times, avg 13µs/call:
# 5 times (64µs+0s) by DynaLoader::bootstrap at line 158, avg 13µs/call | |||||
# spent 69µs within DynaLoader::CORE:ftsize which was called 5 times, avg 14µs/call:
# 5 times (69µs+0s) by DynaLoader::bootstrap at line 179, avg 14µs/call | |||||
sub DynaLoader::CORE:subst; # opcode | |||||
# spent 17µs within DynaLoader::dl_find_symbol which was called 5 times, avg 3µs/call:
# 5 times (17µs+0s) by DynaLoader::bootstrap at line 207, avg 3µs/call | |||||
# spent 37µs within DynaLoader::dl_install_xsub which was called 5 times, avg 7µs/call:
# 5 times (37µs+0s) by DynaLoader::bootstrap at line 212, avg 7µs/call | |||||
# spent 568µs within DynaLoader::dl_load_file which was called 5 times, avg 114µs/call:
# 5 times (568µs+0s) by DynaLoader::bootstrap at line 196, avg 114µs/call | |||||
# spent 12µs within DynaLoader::dl_undef_symbols which was called 5 times, avg 2µs/call:
# 5 times (12µs+0s) by DynaLoader::bootstrap at line 201, avg 2µs/call |