File | /usr/lib/perl/5.10/DynaLoader.pm |
Statements Executed | 400 |
Total Time | 0.0060106 seconds |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
10 | 1 | 2 | 1.75ms | 1.75ms | dl_load_file(xsub) | DynaLoader::
9 | 9 | 9 | 1.14ms | 4.58ms | bootstrap | DynaLoader::
10 | 1 | 2 | 106µs | 106µs | dl_install_xsub(xsub) | DynaLoader::
10 | 1 | 2 | 56µs | 56µs | dl_find_symbol(xsub) | DynaLoader::
9 | 1 | 1 | 54µs | 54µs | dl_load_flags | DynaLoader::
10 | 1 | 2 | 33µs | 33µs | dl_undef_symbols(xsub) | DynaLoader::
0 | 0 | 0 | 0s | 0s | BEGIN | DynaLoader::
0 | 0 | 0 | 0s | 0s | bootstrap_inherit | DynaLoader::
0 | 0 | 0 | 0s | 0s | croak | DynaLoader::
Line | Stmts. | Exclusive Time | Avg. | 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 | BEGIN { | |||
18 | 1 | 1µs | 1µs | $VERSION = '1.08'; |
19 | 1 | 47µs | 47µs | } |
20 | ||||
21 | 1 | 85µs | 85µs | require AutoLoader; |
22 | 1 | 4µs | 4µs | *AUTOLOAD = \&AutoLoader::AUTOLOAD; |
23 | ||||
24 | 3 | 1.23ms | 409µs | use Config; # spent 27µs making 1 call to Config::import |
25 | ||||
26 | # enable debug/trace messages from DynaLoader perl code | |||
27 | 1 | 2µs | 2µs | $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug; |
28 | ||||
29 | # | |||
30 | # Flags to alter dl_load_file behaviour. Assigned bits: | |||
31 | # 0x01 make symbols available for linking later dl_load_file's. | |||
32 | # (only known to work on Solaris 2 using dlopen(RTLD_GLOBAL)) | |||
33 | # (ignored under VMS; effect is built-in to image linking) | |||
34 | # | |||
35 | # This is called as a class method $module->dl_load_flags. The | |||
36 | # definition here will be inherited and result on "default" loading | |||
37 | # behaviour unless a sub-class of DynaLoader defines its own version. | |||
38 | # | |||
39 | ||||
40 | 9 | 15µs | 2µs | # spent 54µs within DynaLoader::dl_load_flags which was called 9 times, avg 6µs/call:
# 9 times (54µs+0s) by DynaLoader::bootstrap at line 196, avg 6µs/call |
41 | ||||
42 | # ($dl_dlext, $dlsrc) | |||
43 | # = @Config::Config{'dlext', 'dlsrc'}; | |||
44 | 1 | 2µs | 2µs | ($dl_dlext, $dlsrc) = ('so', 'dl_dlopen.xs') |
45 | ; | |||
46 | ||||
47 | 1 | 400ns | 400ns | $do_expand = 0; |
48 | ||||
49 | 1 | 700ns | 700ns | @dl_require_symbols = (); # names of symbols we need |
50 | 1 | 400ns | 400ns | @dl_resolve_using = (); # names of files to link with |
51 | 1 | 400ns | 400ns | @dl_library_path = (); # path to look for files |
52 | ||||
53 | #XSLoader.pm may have added elements before we were required | |||
54 | #@dl_shared_objects = (); # shared objects for symbols we have | |||
55 | #@dl_librefs = (); # things we have loaded | |||
56 | #@dl_modules = (); # Modules we have loaded | |||
57 | ||||
58 | # This is a fix to support DLD's unfortunate desire to relink -lc | |||
59 | 1 | 500ns | 500ns | @dl_resolve_using = dl_findfile('-lc') if $dlsrc eq "dl_dld.xs"; |
60 | ||||
61 | # Initialise @dl_library_path with the 'standard' library path | |||
62 | # for this platform as determined by Configure. | |||
63 | ||||
64 | 1 | 24µs | 24µs | push(@dl_library_path, split(' ', $Config::Config{libpth})); # spent 9µs making 1 call to Config::FETCH |
65 | ||||
66 | 1 | 10µs | 10µs | my $ldlibpthname = $Config::Config{ldlibpthname}; # spent 9µs making 1 call to Config::FETCH |
67 | 1 | 11µs | 11µs | my $ldlibpthname_defined = defined $Config::Config{ldlibpthname}; # spent 6µs making 1 call to Config::FETCH |
68 | 1 | 6µs | 6µs | my $pthsep = $Config::Config{path_sep}; # spent 5µ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 | 9µs | 9µ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 | 600ns | 600ns | 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 | # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here. | |||
87 | # NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB | |||
88 | 1 | 1µs | 1µs | boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) && |
89 | !defined(&dl_error); | |||
90 | ||||
91 | 1 | 300ns | 300ns | if ($dl_debug) { |
92 | print STDERR "DynaLoader.pm loaded (@INC, @dl_library_path)\n"; | |||
93 | print STDERR "DynaLoader not linked into this perl\n" | |||
94 | unless defined(&boot_DynaLoader); | |||
95 | } | |||
96 | ||||
97 | 1 | 25µs | 25µs | 1; # End of main code |
98 | ||||
99 | sub croak { require Carp; Carp::croak(@_) } | |||
100 | ||||
101 | sub bootstrap_inherit { | |||
102 | 4 | 29µs | 7µs | my $module = $_[0]; |
103 | local *isa = *{"$module\::ISA"}; | |||
104 | local @isa = (@isa, 'DynaLoader'); | |||
105 | # Cannot goto due to delocalization. Will report errors on a wrong line? | |||
106 | bootstrap(@_); # spent 266µs making 1 call to DynaLoader::bootstrap | |||
107 | } | |||
108 | ||||
109 | # The bootstrap function cannot be autoloaded (without complications) | |||
110 | # so we define it here: | |||
111 | ||||
112 | # spent 4.58ms (1.14+3.44) within DynaLoader::bootstrap which was called 9 times, avg 509µs/call:
# once (112µs+1.14ms) by XML::LibXML::BEGIN at line 113 of /usr/lib/perl5/XML/LibXML.pm
# once (164µs+771µs) at line 42 of /usr/lib/perl/5.10/Unicode/Normalize.pm
# once (134µs+412µs) at line 19 of /usr/lib/perl5/XML/LibXML/Common.pm
# once (151µs+216µs) at line 65 of /usr/lib/perl/5.10/Time/HiRes.pm
# once (119µs+213µs) at line 24 of /usr/lib/perl5/List/MoreUtils.pm
# once (121µs+209µs) at line 67 of /usr/local/lib/perl/5.10.0/Storable.pm
# once (124µs+183µs) at line 88 of /usr/local/lib/perl/5.10.0/Params/Util.pm
# once (102µs+164µs) by DynaLoader::bootstrap_inherit at line 106
# once (112µs+131µs) at line 55 of /usr/local/lib/perl/5.10.0/Sub/Name.pm | |||
113 | # use local vars to enable $module.bs script to edit values | |||
114 | 261 | 4.21ms | 16µs | local(@args) = @_; |
115 | local($module) = $args[0]; | |||
116 | local(@dirs, $file); | |||
117 | ||||
118 | unless ($module) { | |||
119 | require Carp; | |||
120 | Carp::confess("Usage: DynaLoader::bootstrap(module)"); | |||
121 | } | |||
122 | ||||
123 | # A common error on platforms which don't support dynamic loading. | |||
124 | # Since it's fatal and potentially confusing we give a detailed message. | |||
125 | croak("Can't load module $module, dynamic loading not available in this perl.\n". | |||
126 | " (You may need to build a new perl executable which either supports\n". | |||
127 | " dynamic loading or has the $module module statically linked into it.)\n") | |||
128 | unless defined(&dl_load_file); | |||
129 | ||||
130 | ||||
131 | my @modparts = split(/::/,$module); | |||
132 | my $modfname = $modparts[-1]; | |||
133 | ||||
134 | # Some systems have restrictions on files names for DLL's etc. | |||
135 | # mod2fname returns appropriate file base name (typically truncated) | |||
136 | # It may also edit @modparts if required. | |||
137 | $modfname = &mod2fname(\@modparts) if defined &mod2fname; | |||
138 | ||||
139 | ||||
140 | ||||
141 | my $modpname = join('/',@modparts); | |||
142 | ||||
143 | print STDERR "DynaLoader::bootstrap for $module ", | |||
144 | "(auto/$modpname/$modfname.so)\n" | |||
145 | if $dl_debug; | |||
146 | ||||
147 | foreach (@INC) { | |||
148 | ||||
149 | ||||
150 | 103 | 305µs | 3µs | my $dir = "$_/auto/$modpname"; |
151 | ||||
152 | ||||
153 | next unless -d $dir; # skip over uninteresting directories | |||
154 | ||||
155 | # check for common cases to avoid autoload of dl_findfile | |||
156 | my $try = "$dir/$modfname.so"; | |||
157 | last if $file = (-f $try) && $try; | |||
158 | ||||
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 | $file = dl_findfile(map("-L$_",@dirs,@INC), $modfname) unless $file; | |||
165 | ||||
166 | 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 | my $bootname = "boot_$module"; | |||
171 | $bootname =~ s/\W/_/g; | |||
172 | @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 | my $bs = $file; | |||
178 | $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library | |||
179 | if (-s $bs) { # only read file if it's not empty | |||
180 | print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug; | |||
181 | eval { do $bs; }; | |||
182 | warn "$bs: $@\n" if $@; | |||
183 | } | |||
184 | ||||
185 | 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 | my $libref = dl_load_file($file, $module->dl_load_flags) or # spent 1.75ms making 9 calls to DynaLoader::dl_load_file, avg 194µs/call
# spent 54µs making 9 calls to DynaLoader::dl_load_flags, avg 6µs/call | |||
197 | croak("Can't load '$file' for module $module: ".dl_error()); | |||
198 | ||||
199 | push(@dl_librefs,$libref); # record loaded object | |||
200 | ||||
201 | my @unresolved = dl_undef_symbols(); # spent 33µs making 9 calls to DynaLoader::dl_undef_symbols, avg 4µs/call | |||
202 | if (@unresolved) { | |||
203 | require Carp; | |||
204 | Carp::carp("Undefined symbols present after loading $file: @unresolved\n"); | |||
205 | } | |||
206 | ||||
207 | $boot_symbol_ref = dl_find_symbol($libref, $bootname) or # spent 56µs making 9 calls to DynaLoader::dl_find_symbol, avg 6µs/call | |||
208 | croak("Can't find '$bootname' symbol in $file\n"); | |||
209 | ||||
210 | push(@dl_modules, $module); # record loaded module | |||
211 | ||||
212 | boot: # spent 106µs making 9 calls to DynaLoader::dl_install_xsub, avg 12µs/call | |||
213 | my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file); | |||
214 | ||||
215 | # See comment block above | |||
216 | ||||
217 | push(@dl_shared_objects, $file); # record files loaded | |||
218 | ||||
219 | &$xs(@args); # spent 896µs making 1 call to XML::LibXML::bootstrap
# spent 114µs making 1 call to Unicode::Normalize::bootstrap
# spent 99µs making 1 call to List::MoreUtils::bootstrap
# spent 93µs making 1 call to Storable::bootstrap
# spent 81µs making 1 call to Time::HiRes::bootstrap
# spent 48µs making 1 call to XML::LibXML::Common::bootstrap
# spent 45µs making 1 call to Params::Util::bootstrap
# spent 36µs making 1 call to Moose::bootstrap
# spent 33µs making 1 call to Sub::Name::bootstrap | |||
220 | } | |||
221 | ||||
222 | #sub _check_file { # private utility to handle dl_expandspec vs -f tests | |||
223 | # my($file) = @_; | |||
224 | # return $file if (!$do_expand && -f $file); # the common case | |||
225 | # return $file if ( $do_expand && ($file=dl_expandspec($file))); | |||
226 | # return undef; | |||
227 | #} | |||
228 | ||||
229 | # Let autosplit and the autoloader deal with these functions: | |||
# spent 56µs within DynaLoader::dl_find_symbol which was called 9 times, avg 6µs/call:
# 9 times (56µs+0s) by DynaLoader::bootstrap at line 207 of /usr/lib/perl/5.10/DynaLoader.pm, avg 6µs/call | ||||
# spent 106µs within DynaLoader::dl_install_xsub which was called 9 times, avg 12µs/call:
# 9 times (106µs+0s) by DynaLoader::bootstrap at line 212 of /usr/lib/perl/5.10/DynaLoader.pm, avg 12µs/call | ||||
# spent 1.75ms within DynaLoader::dl_load_file which was called 9 times, avg 194µs/call:
# 9 times (1.75ms+0s) by DynaLoader::bootstrap at line 196 of /usr/lib/perl/5.10/DynaLoader.pm, avg 194µs/call | ||||
# spent 33µs within DynaLoader::dl_undef_symbols which was called 9 times, avg 4µs/call:
# 9 times (33µs+0s) by DynaLoader::bootstrap at line 201 of /usr/lib/perl/5.10/DynaLoader.pm, avg 4µs/call |