← Index
NYTProf Performance Profile   « line view »
For Makefile.PL
  Run on Sun Mar 1 16:04:44 2015
Reported on Sun Mar 1 16:09:02 2015

FilenameC:/tmp64ng/perl/lib/XSLoader.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sXSLoader::::bootstrap_inheritXSLoader::bootstrap_inherit
7770s0sXSLoader::::loadXSLoader::load
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# Generated from XSLoader.pm.PL (resolved %Config::Config value)
2
3package XSLoader;
4
5$VERSION = "0.17";
6
7#use strict;
8
9package DynaLoader;
10
11# No prizes for guessing why we don't say 'bootstrap DynaLoader;' here.
12# NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB
13boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) &&
14 !defined(&dl_error);
15package XSLoader;
16
17
# spent 0s within XSLoader::load which was called 7 times, avg 0s/call: # once (0s+0s) by File::Path::BEGIN@6 at line 249 of Cwd.pm # once (0s+0s) by ExtUtils::MakeMaker::Locale::BEGIN@13 at line 10 of Encode.pm # once (0s+0s) by PerlIO::import at line 14 of PerlIO/encoding.pm # once (0s+0s) by Encode::getEncoding at line 8 of Encode/Byte.pm # once (0s+0s) by Win32::API::BEGIN@36 at line 22 of List/Util.pm # once (0s+0s) by version::BEGIN@1 at line 14 of version/vxs.pm # once (0s+0s) by B::BEGIN@17 at line 27 of B.pm
sub load {
18 package DynaLoader;
19
20 my ($module, $modlibname) = caller();
21
22 if (@_) {
23 $module = $_[0];
24 } else {
25 $_[0] = $module;
26 }
27
28 # work with static linking too
29 my $boots = "$module\::bootstrap";
30 goto &$boots if defined &$boots;
31
32 goto \&XSLoader::bootstrap_inherit unless $module and defined &dl_load_file;
33
34 my @modparts = split(/::/,$module);
35 my $modfname = $modparts[-1];
36
37 my $modpname = join('/',@modparts);
38 my $c = @modparts;
39 $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename
40 my $file = "$modlibname/auto/$modpname/$modfname.xs\.dll";
41
42# print STDERR "XSLoader::load for $module ($file)\n" if $dl_debug;
43
44 my $bs = $file;
45 $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library
46
47 if (-s $bs) { # only read file if it's not empty
48# print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug;
49 eval { do $bs; };
50 warn "$bs: $@\n" if $@;
51 }
52
53 goto \&XSLoader::bootstrap_inherit if not -f $file or -s $bs;
54
55 my $bootname = "boot_$module";
56 $bootname =~ s/\W/_/g;
57 @DynaLoader::dl_require_symbols = ($bootname);
58
59 my $boot_symbol_ref;
60
61 # Many dynamic extension loading problems will appear to come from
62 # this section of code: XYZ failed at line 123 of DynaLoader.pm.
63 # Often these errors are actually occurring in the initialisation
64 # C code of the extension XS file. Perl reports the error as being
65 # in this perl code simply because this was the last perl code
66 # it executed.
67
68 my $libref = dl_load_file($file, 0) or do {
69 require Carp;
70 Carp::croak("Can't load '$file' for module $module: " . dl_error());
71 };
72 push(@DynaLoader::dl_librefs,$libref); # record loaded object
73
74 my @unresolved = dl_undef_symbols();
75 if (@unresolved) {
76 require Carp;
77 Carp::carp("Undefined symbols present after loading $file: @unresolved\n");
78 }
79
80 $boot_symbol_ref = dl_find_symbol($libref, $bootname) or do {
81 require Carp;
82 Carp::croak("Can't find '$bootname' symbol in $file\n");
83 };
84
85 push(@DynaLoader::dl_modules, $module); # record loaded module
86
87 boot:
88 my $xs = dl_install_xsub($boots, $boot_symbol_ref, $file);
89
90 # See comment block above
91 push(@DynaLoader::dl_shared_objects, $file); # record files loaded
9210s700s return &$xs(@_);
# spent 0s making 1 call to Encode::PERLQQ # spent 0s making 69 calls to Encode::define_encoding, avg 0s/call
93}
94
95sub bootstrap_inherit {
96 require DynaLoader;
97 goto \&DynaLoader::bootstrap_inherit;
98}
99
1001;
101
102
103__END__
104
105=head1 NAME
106
107XSLoader - Dynamically load C libraries into Perl code
108
109=head1 VERSION
110
111Version 0.17
112
113=head1 SYNOPSIS
114
115 package YourPackage;
116 require XSLoader;
117
118 XSLoader::load();
119
120=head1 DESCRIPTION
121
122This module defines a standard I<simplified> interface to the dynamic
123linking mechanisms available on many platforms. Its primary purpose is
124to implement cheap automatic dynamic loading of Perl modules.
125
126For a more complicated interface, see L<DynaLoader>. Many (most)
127features of C<DynaLoader> are not implemented in C<XSLoader>, like for
128example the C<dl_load_flags>, not honored by C<XSLoader>.
129
130=head2 Migration from C<DynaLoader>
131
132A typical module using L<DynaLoader|DynaLoader> starts like this:
133
134 package YourPackage;
135 require DynaLoader;
136
137 our @ISA = qw( OnePackage OtherPackage DynaLoader );
138 our $VERSION = '0.01';
139 bootstrap YourPackage $VERSION;
140
141Change this to
142
143 package YourPackage;
144 use XSLoader;
145
146 our @ISA = qw( OnePackage OtherPackage );
147 our $VERSION = '0.01';
148 XSLoader::load 'YourPackage', $VERSION;
149
150In other words: replace C<require DynaLoader> by C<use XSLoader>, remove
151C<DynaLoader> from C<@ISA>, change C<bootstrap> by C<XSLoader::load>. Do not
152forget to quote the name of your package on the C<XSLoader::load> line,
153and add comma (C<,>) before the arguments (C<$VERSION> above).
154
155Of course, if C<@ISA> contained only C<DynaLoader>, there is no need to have
156the C<@ISA> assignment at all; moreover, if instead of C<our> one uses the
157more backward-compatible
158
159 use vars qw($VERSION @ISA);
160
161one can remove this reference to C<@ISA> together with the C<@ISA> assignment.
162
163If no C<$VERSION> was specified on the C<bootstrap> line, the last line becomes
164
165 XSLoader::load 'YourPackage';
166
167If the call to C<load> is from C<YourPackage>, then that can be further
168simplified to
169
170 XSLoader::load();
171
172as C<load> will use C<caller> to determine the package.
173
174=head2 Backward compatible boilerplate
175
176If you want to have your cake and eat it too, you need a more complicated
177boilerplate.
178
179 package YourPackage;
180 use vars qw($VERSION @ISA);
181
182 @ISA = qw( OnePackage OtherPackage );
183 $VERSION = '0.01';
184 eval {
185 require XSLoader;
186 XSLoader::load('YourPackage', $VERSION);
187 1;
188 } or do {
189 require DynaLoader;
190 push @ISA, 'DynaLoader';
191 bootstrap YourPackage $VERSION;
192 };
193
194The parentheses about C<XSLoader::load()> arguments are needed since we replaced
195C<use XSLoader> by C<require>, so the compiler does not know that a function
196C<XSLoader::load()> is present.
197
198This boilerplate uses the low-overhead C<XSLoader> if present; if used with
199an antique Perl which has no C<XSLoader>, it falls back to using C<DynaLoader>.
200
201=head1 Order of initialization: early load()
202
203I<Skip this section if the XSUB functions are supposed to be called from other
204modules only; read it only if you call your XSUBs from the code in your module,
205or have a C<BOOT:> section in your XS file (see L<perlxs/"The BOOT: Keyword">).
206What is described here is equally applicable to the L<DynaLoader|DynaLoader>
207interface.>
208
209A sufficiently complicated module using XS would have both Perl code (defined
210in F<YourPackage.pm>) and XS code (defined in F<YourPackage.xs>). If this
211Perl code makes calls into this XS code, and/or this XS code makes calls to
212the Perl code, one should be careful with the order of initialization.
213
214The call to C<XSLoader::load()> (or C<bootstrap()>) calls the module's
215bootstrap code. For modules build by F<xsubpp> (nearly all modules) this
216has three side effects:
217
218=over
219
220=item *
221
222A sanity check is done to ensure that the versions of the F<.pm> and the
223(compiled) F<.xs> parts are compatible. If C<$VERSION> was specified, this
224is used for the check. If not specified, it defaults to
225C<$XS_VERSION // $VERSION> (in the module's namespace)
226
227=item *
228
229the XSUBs are made accessible from Perl
230
231=item *
232
233if a C<BOOT:> section was present in the F<.xs> file, the code there is called.
234
235=back
236
237Consequently, if the code in the F<.pm> file makes calls to these XSUBs, it is
238convenient to have XSUBs installed before the Perl code is defined; for
239example, this makes prototypes for XSUBs visible to this Perl code.
240Alternatively, if the C<BOOT:> section makes calls to Perl functions (or
241uses Perl variables) defined in the F<.pm> file, they must be defined prior to
242the call to C<XSLoader::load()> (or C<bootstrap()>).
243
244The first situation being much more frequent, it makes sense to rewrite the
245boilerplate as
246
247 package YourPackage;
248 use XSLoader;
249 use vars qw($VERSION @ISA);
250
251 BEGIN {
252 @ISA = qw( OnePackage OtherPackage );
253 $VERSION = '0.01';
254
255 # Put Perl code used in the BOOT: section here
256
257 XSLoader::load 'YourPackage', $VERSION;
258 }
259
260 # Put Perl code making calls into XSUBs here
261
262=head2 The most hairy case
263
264If the interdependence of your C<BOOT:> section and Perl code is
265more complicated than this (e.g., the C<BOOT:> section makes calls to Perl
266functions which make calls to XSUBs with prototypes), get rid of the C<BOOT:>
267section altogether. Replace it with a function C<onBOOT()>, and call it like
268this:
269
270 package YourPackage;
271 use XSLoader;
272 use vars qw($VERSION @ISA);
273
274 BEGIN {
275 @ISA = qw( OnePackage OtherPackage );
276 $VERSION = '0.01';
277 XSLoader::load 'YourPackage', $VERSION;
278 }
279
280 # Put Perl code used in onBOOT() function here; calls to XSUBs are
281 # prototype-checked.
282
283 onBOOT;
284
285 # Put Perl initialization code assuming that XS is initialized here
286
287
288=head1 DIAGNOSTICS
289
290=over
291
292=item C<Can't find '%s' symbol in %s>
293
294B<(F)> The bootstrap symbol could not be found in the extension module.
295
296=item C<Can't load '%s' for module %s: %s>
297
298B<(F)> The loading or initialisation of the extension module failed.
299The detailed error follows.
300
301=item C<Undefined symbols present after loading %s: %s>
302
303B<(W)> As the message says, some symbols stay undefined although the
304extension module was correctly loaded and initialised. The list of undefined
305symbols follows.
306
307=back
308
309=head1 LIMITATIONS
310
311To reduce the overhead as much as possible, only one possible location
312is checked to find the extension DLL (this location is where C<make install>
313would put the DLL). If not found, the search for the DLL is transparently
314delegated to C<DynaLoader>, which looks for the DLL along the C<@INC> list.
315
316In particular, this is applicable to the structure of C<@INC> used for testing
317not-yet-installed extensions. This means that running uninstalled extensions
318may have much more overhead than running the same extensions after
319C<make install>.
320
321
322=head1 KNOWN BUGS
323
324The new simpler way to call C<XSLoader::load()> with no arguments at all
325does not work on Perl 5.8.4 and 5.8.5.
326
327
328=head1 BUGS
329
330Please report any bugs or feature requests via the perlbug(1) utility.
331
332
333=head1 SEE ALSO
334
335L<DynaLoader>
336
337
338=head1 AUTHORS
339
340Ilya Zakharevich originally extracted C<XSLoader> from C<DynaLoader>.
341
342CPAN version is currently maintained by SE<eacute>bastien Aperghis-Tramoni
343E<lt>sebastien@aperghis.netE<gt>.
344
345Previous maintainer was Michael G Schwern <schwern@pobox.com>.
346
347
348=head1 COPYRIGHT & LICENSE
349
350Copyright (C) 1990-2011 by Larry Wall and others.
351
352This program is free software; you can redistribute it and/or modify
353it under the same terms as Perl itself.
354
355=cut