Filename | /usr/lib/x86_64-linux-gnu/perl-base/XSLoader.pm |
Statements | Executed 4 statements in 111µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
17 | 17 | 17 | 2.81ms | 3.41ms | load (recurses: max depth 1, inclusive time 102µs) | XSLoader::
0 | 0 | 0 | 0s | 0s | BEGIN | Devel::NYTProf::Core::
0 | 0 | 0 | 0s | 0s | bootstrap_inherit | XSLoader::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # Generated from XSLoader_pm.PL (resolved %Config::Config value) | ||||
2 | # This file is unique for every OS | ||||
3 | |||||
4 | use strict; | ||||
5 | no strict 'refs'; | ||||
6 | |||||
7 | package XSLoader; | ||||
8 | |||||
9 | our $VERSION = "0.31"; # remember to update version in POD! | ||||
10 | |||||
11 | package DynaLoader; | ||||
12 | |||||
13 | # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here. | ||||
14 | # NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB | ||||
15 | boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) && | ||||
16 | !defined(&dl_error); | ||||
17 | package XSLoader; | ||||
18 | |||||
19 | # spent 3.41ms (2.81+597µs) within XSLoader::load which was called 17 times, avg 201µs/call:
# once (185µs+694µs) by JSON::BEGIN@2 at line 1821 of JSON/XS.pm
# once (347µs+0s) by File::Slurp::BEGIN@16 at line 24 of POSIX.pm
# once (285µs+0s) by File::Temp::BEGIN@150 at line 9 of Fcntl.pm
# once (227µs+0s) by IPC::Cmd::BEGIN@5 at line 885 of Socket.pm
# once (170µs+4µs) by Text::CSV::BEGIN@1 at line 31 of Text/CSV_XS.pm
# once (156µs+0s) by Encode::BEGIN@9 at line 12 of Encode.pm
# once (154µs+0s) by File::Temp::BEGIN@153 at line 24 of List/Util.pm
# once (143µs+0s) by ExtUtils::MakeMaker::Locale::_init at line 75 of I18N/Langinfo.pm
# once (141µs+0s) by IO::Handle::BEGIN@268 at line 11 of IO.pm
# once (136µs+0s) by File::Slurp::BEGIN@128 at line 95 of re.pm
# once (136µs+0s) by Storable::BEGIN@109 at line 109 of Storable.pm
# once (131µs+0s) by Capture::Tiny::BEGIN@1 at line 94 of Time/HiRes.pm
# once (129µs+1µs) by PerlIO::import at line 14 of PerlIO/encoding.pm
# once (127µs+0s) by IO::Prompter::BEGIN@334 at line 64 of File/Glob.pm
# once (124µs+0s) by YAML::XS::BEGIN@29 at line 7 of YAML/XS/LibYAML.pm
# once (123µs+0s) by main::BEGIN@14 at line 82 of Cwd.pm
# once (102µs+-102µs) by DynaLoader::BEGIN@112.2 at line 114 of attributes.pm | ||||
20 | package DynaLoader; | ||||
21 | |||||
22 | my ($caller, $modlibname) = caller(); | ||||
23 | my $module = $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 | my $modfname_orig = $modfname; # For .bs file search | ||||
40 | |||||
41 | my $modpname = join('/',@modparts); | ||||
42 | my $c = () = split(/::/,$caller,-1); | ||||
43 | $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename | ||||
44 | # Does this look like a relative path? | ||||
45 | if ($modlibname !~ m{^/}) { | ||||
46 | # Someone may have a #line directive that changes the file name, or | ||||
47 | # may be calling XSLoader::load from inside a string eval. We cer- | ||||
48 | # tainly do not want to go loading some code that is not in @INC, | ||||
49 | # as it could be untrusted. | ||||
50 | # | ||||
51 | # We could just fall back to DynaLoader here, but then the rest of | ||||
52 | # this function would go untested in the perl core, since all @INC | ||||
53 | # paths are relative during testing. That would be a time bomb | ||||
54 | # waiting to happen, since bugs could be introduced into the code. | ||||
55 | # | ||||
56 | # So look through @INC to see if $modlibname is in it. A rela- | ||||
57 | # tive $modlibname is not a common occurrence, so this block is | ||||
58 | # not hot code. | ||||
59 | FOUND: { | ||||
60 | for (@INC) { | ||||
61 | if ($_ eq $modlibname) { | ||||
62 | last FOUND; | ||||
63 | } | ||||
64 | } | ||||
65 | # Not found. Fall back to DynaLoader. | ||||
66 | goto \&XSLoader::bootstrap_inherit; | ||||
67 | } | ||||
68 | } | ||||
69 | my $file = "$modlibname/auto/$modpname/$modfname.so"; | ||||
70 | |||||
71 | # print STDERR "XSLoader::load for $module ($file)\n" if $dl_debug; | ||||
72 | |||||
73 | # N.B. The .bs file does not following the naming convention used | ||||
74 | # by mod2fname, so use the unedited version of the name. | ||||
75 | |||||
76 | my $bs = "$modlibname/auto/$modpname/$modfname_orig.bs"; | ||||
77 | |||||
78 | # This calls DynaLoader::bootstrap, which will load the .bs file if present | ||||
79 | goto \&XSLoader::bootstrap_inherit if not -f $file or -s $bs; | ||||
80 | |||||
81 | my $bootname = "boot_$module"; | ||||
82 | $bootname =~ s/\W/_/g; | ||||
83 | @DynaLoader::dl_require_symbols = ($bootname); | ||||
84 | |||||
85 | my $boot_symbol_ref; | ||||
86 | |||||
87 | # Many dynamic extension loading problems will appear to come from | ||||
88 | # this section of code: XYZ failed at line 123 of DynaLoader.pm. | ||||
89 | # Often these errors are actually occurring in the initialisation | ||||
90 | # C code of the extension XS file. Perl reports the error as being | ||||
91 | # in this perl code simply because this was the last perl code | ||||
92 | # it executed. | ||||
93 | |||||
94 | my $libref = dl_load_file($file, 0) or do { | ||||
95 | require Carp; | ||||
96 | Carp::croak("Can't load '$file' for module $module: " . dl_error()); | ||||
97 | }; | ||||
98 | push(@DynaLoader::dl_librefs,$libref); # record loaded object | ||||
99 | |||||
100 | $boot_symbol_ref = dl_find_symbol($libref, $bootname) or do { | ||||
101 | require Carp; | ||||
102 | Carp::croak("Can't find '$bootname' symbol in $file\n"); | ||||
103 | }; | ||||
104 | |||||
105 | push(@DynaLoader::dl_modules, $module); # record loaded module | ||||
106 | |||||
107 | boot: | ||||
108 | my $xs = dl_install_xsub($boots, $boot_symbol_ref, $file); | ||||
109 | |||||
110 | # See comment block above | ||||
111 | push(@DynaLoader::dl_shared_objects, $file); # record files loaded | ||||
112 | 4 | 111µs | 3 | 20µs | return &$xs(@_); # spent 19µs making 1 call to attributes::import
# spent 800ns making 1 call to Encode::STOP_AT_PARTIAL
# spent 200ns making 1 call to Encode::LEAVE_SRC |
113 | } | ||||
114 | |||||
115 | # Can't test with DynaLoader->can('bootstrap_inherit') when building in the | ||||
116 | # core, as XSLoader gets built before DynaLoader. | ||||
117 | |||||
118 | sub bootstrap_inherit { | ||||
119 | require DynaLoader; | ||||
120 | goto \&DynaLoader::bootstrap_inherit; | ||||
121 | } | ||||
122 | |||||
123 | 1; | ||||
124 | |||||
125 | __END__ | ||||
126 |