← Index
NYTProf Performance Profile   « block view • line view • sub view »
For C:/lo/libo-master/solenv/bin/make_installer.pl
  Run on Mon Sep 24 00:52:54 2012
Reported on Mon Sep 24 07:34:46 2012

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