| Filename | /usr/share/perl/5.28/XSLoader.pm |
| Statements | Executed 0 statements in 0s |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 12 | 12 | 12 | 2.54ms | 2.54ms | XSLoader::load |
| 0 | 0 | 0 | 0s | 0s | XSLoader::bootstrap_inherit |
| 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 | package XSLoader; | ||||
| 5 | |||||
| 6 | $VERSION = "0.30"; # remember to update version in POD! | ||||
| 7 | |||||
| 8 | #use strict; | ||||
| 9 | |||||
| 10 | package DynaLoader; | ||||
| 11 | |||||
| 12 | # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here. | ||||
| 13 | # NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB | ||||
| 14 | boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) && | ||||
| 15 | !defined(&dl_error); | ||||
| 16 | package XSLoader; | ||||
| 17 | |||||
| 18 | # spent 2.54ms within XSLoader::load which was called 12 times, avg 212µs/call:
# once (308µs+0s) by File::Copy::BEGIN@1 at line 94 of Time/HiRes.pm
# once (258µs+0s) by RBM::BEGIN@21 at line 244 of Digest/SHA.pm
# once (239µs+0s) by YAML::XS::BEGIN@20 at line 7 of YAML/XS/LibYAML.pm
# once (238µs+0s) by Unicode::UTF8::BEGIN@6 at line 14 of Unicode/UTF8.pm
# once (221µs+0s) by Storable::BEGIN@72 at line 11 of Fcntl.pm
# once (212µs+0s) by IO::Handle::BEGIN@8 at line 11 of IO.pm
# once (206µs+0s) by Encode::BEGIN@9 at line 12 of Encode.pm
# once (197µs+0s) by File::Spec::Unix::BEGIN@4 at line 80 of Cwd.pm
# once (172µs+0s) by Encode::BEGIN@55 at line 98 of Storable.pm
# once (169µs+0s) by RBM::BEGIN@53 at line 68 of File/Glob.pm
# once (168µs+0s) by YAML::XS::BEGIN@21 at line 23 of List/Util.pm
# once (154µs+0s) by RBM::BEGIN@22 at line 24 of Digest/MD5.pm | ||||
| 19 | package DynaLoader; | ||||
| 20 | |||||
| 21 | my ($caller, $modlibname) = caller(); | ||||
| 22 | my $module = $caller; | ||||
| 23 | |||||
| 24 | if (@_) { | ||||
| 25 | $module = $_[0]; | ||||
| 26 | } else { | ||||
| 27 | $_[0] = $module; | ||||
| 28 | } | ||||
| 29 | |||||
| 30 | # work with static linking too | ||||
| 31 | my $boots = "$module\::bootstrap"; | ||||
| 32 | goto &$boots if defined &$boots; | ||||
| 33 | |||||
| 34 | goto \&XSLoader::bootstrap_inherit unless $module and defined &dl_load_file; | ||||
| 35 | |||||
| 36 | my @modparts = split(/::/,$module); | ||||
| 37 | my $modfname = $modparts[-1]; | ||||
| 38 | my $modfname_orig = $modfname; # For .bs file search | ||||
| 39 | |||||
| 40 | my $modpname = join('/',@modparts); | ||||
| 41 | my $c = () = split(/::/,$caller,-1); | ||||
| 42 | $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename | ||||
| 43 | # Does this look like a relative path? | ||||
| 44 | if ($modlibname !~ m{^/}) { | ||||
| 45 | # Someone may have a #line directive that changes the file name, or | ||||
| 46 | # may be calling XSLoader::load from inside a string eval. We cer- | ||||
| 47 | # tainly do not want to go loading some code that is not in @INC, | ||||
| 48 | # as it could be untrusted. | ||||
| 49 | # | ||||
| 50 | # We could just fall back to DynaLoader here, but then the rest of | ||||
| 51 | # this function would go untested in the perl core, since all @INC | ||||
| 52 | # paths are relative during testing. That would be a time bomb | ||||
| 53 | # waiting to happen, since bugs could be introduced into the code. | ||||
| 54 | # | ||||
| 55 | # So look through @INC to see if $modlibname is in it. A rela- | ||||
| 56 | # tive $modlibname is not a common occurrence, so this block is | ||||
| 57 | # not hot code. | ||||
| 58 | FOUND: { | ||||
| 59 | for (@INC) { | ||||
| 60 | if ($_ eq $modlibname) { | ||||
| 61 | last FOUND; | ||||
| 62 | } | ||||
| 63 | } | ||||
| 64 | # Not found. Fall back to DynaLoader. | ||||
| 65 | goto \&XSLoader::bootstrap_inherit; | ||||
| 66 | } | ||||
| 67 | } | ||||
| 68 | my $file = "$modlibname/auto/$modpname/$modfname.so"; | ||||
| 69 | |||||
| 70 | # print STDERR "XSLoader::load for $module ($file)\n" if $dl_debug; | ||||
| 71 | |||||
| 72 | # N.B. The .bs file does not following the naming convention used | ||||
| 73 | # by mod2fname, so use the unedited version of the name. | ||||
| 74 | |||||
| 75 | my $bs = "$modlibname/auto/$modpname/$modfname_orig.bs"; | ||||
| 76 | |||||
| 77 | # This calls DynaLoader::bootstrap, which will load the .bs file if present | ||||
| 78 | goto \&XSLoader::bootstrap_inherit if not -f $file or -s $bs; | ||||
| 79 | |||||
| 80 | my $bootname = "boot_$module"; | ||||
| 81 | $bootname =~ s/\W/_/g; | ||||
| 82 | @DynaLoader::dl_require_symbols = ($bootname); | ||||
| 83 | |||||
| 84 | my $boot_symbol_ref; | ||||
| 85 | |||||
| 86 | # Many dynamic extension loading problems will appear to come from | ||||
| 87 | # this section of code: XYZ failed at line 123 of DynaLoader.pm. | ||||
| 88 | # Often these errors are actually occurring in the initialisation | ||||
| 89 | # C code of the extension XS file. Perl reports the error as being | ||||
| 90 | # in this perl code simply because this was the last perl code | ||||
| 91 | # it executed. | ||||
| 92 | |||||
| 93 | my $libref = dl_load_file($file, 0) or do { | ||||
| 94 | require Carp; | ||||
| 95 | Carp::croak("Can't load '$file' for module $module: " . dl_error()); | ||||
| 96 | }; | ||||
| 97 | push(@DynaLoader::dl_librefs,$libref); # record loaded object | ||||
| 98 | |||||
| 99 | $boot_symbol_ref = dl_find_symbol($libref, $bootname) or do { | ||||
| 100 | require Carp; | ||||
| 101 | Carp::croak("Can't find '$bootname' symbol in $file\n"); | ||||
| 102 | }; | ||||
| 103 | |||||
| 104 | push(@DynaLoader::dl_modules, $module); # record loaded module | ||||
| 105 | |||||
| 106 | boot: | ||||
| 107 | my $xs = dl_install_xsub($boots, $boot_symbol_ref, $file); | ||||
| 108 | |||||
| 109 | # See comment block above | ||||
| 110 | push(@DynaLoader::dl_shared_objects, $file); # record files loaded | ||||
| 111 | return &$xs(@_); | ||||
| 112 | } | ||||
| 113 | |||||
| 114 | sub bootstrap_inherit { | ||||
| 115 | require DynaLoader; | ||||
| 116 | goto \&DynaLoader::bootstrap_inherit; | ||||
| 117 | } | ||||
| 118 | |||||
| 119 | 1; | ||||
| 120 | |||||
| 121 | __END__ | ||||
| 122 |