| Filename | /usr/lib/perl/5.10/DynaLoader.pm |
| Statements | Executed 156 statements in 5.09ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 3 | 1 | 1 | 1.10ms | 1.10ms | DynaLoader::dl_load_file (xsub) |
| 1 | 1 | 1 | 833µs | 965µs | DynaLoader::BEGIN@24 |
| 3 | 3 | 3 | 475µs | 3.26ms | DynaLoader::bootstrap |
| 19 | 1 | 1 | 105µs | 105µs | DynaLoader::CORE:ftdir (opcode) |
| 6 | 2 | 1 | 95µs | 95µs | DynaLoader::CORE:subst (opcode) |
| 3 | 1 | 1 | 27µs | 27µs | DynaLoader::dl_install_xsub (xsub) |
| 3 | 1 | 1 | 20µs | 20µs | DynaLoader::CORE:ftsize (opcode) |
| 3 | 1 | 1 | 19µs | 19µs | DynaLoader::CORE:ftfile (opcode) |
| 1 | 1 | 1 | 16µs | 16µs | DynaLoader::BEGIN@17 |
| 3 | 1 | 1 | 13µs | 13µs | DynaLoader::dl_find_symbol (xsub) |
| 3 | 1 | 1 | 12µs | 12µs | DynaLoader::dl_load_flags |
| 3 | 1 | 1 | 8µs | 8µs | DynaLoader::dl_undef_symbols (xsub) |
| 0 | 0 | 0 | 0s | 0s | DynaLoader::bootstrap_inherit |
| 0 | 0 | 0 | 0s | 0s | DynaLoader::croak |
| Line | State ments |
Time on line |
Calls | Time in subs |
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 | # spent 16µs within DynaLoader::BEGIN@17 which was called:
# once (16µs+0s) by XML::LibXML::BEGIN@28 at line 19 | ||||
| 18 | 1 | 8µs | $VERSION = '1.10'; | ||
| 19 | 1 | 49µs | 1 | 16µs | } # spent 16µs making 1 call to DynaLoader::BEGIN@17 |
| 20 | |||||
| 21 | 1 | 143µs | require AutoLoader; | ||
| 22 | 1 | 2µs | *AUTOLOAD = \&AutoLoader::AUTOLOAD; | ||
| 23 | |||||
| 24 | 3 | 1.51ms | 2 | 988µs | # spent 965µs (833+132) within DynaLoader::BEGIN@24 which was called:
# once (833µs+132µs) by XML::LibXML::BEGIN@28 at line 24 # spent 965µs making 1 call to DynaLoader::BEGIN@24
# spent 23µs making 1 call to Config::import |
| 25 | |||||
| 26 | # enable debug/trace messages from DynaLoader perl code | ||||
| 27 | 1 | 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 | 3 | 16µs | # spent 12µs within DynaLoader::dl_load_flags which was called 3 times, avg 4µs/call:
# 3 times (12µs+0s) by DynaLoader::bootstrap at line 192, avg 4µs/call | ||
| 41 | |||||
| 42 | 1 | 30µs | 3 | 3.33ms | ($dl_dlext, $dl_so, $dlsrc) = @Config::Config{qw(dlext so dlsrc)}; # spent 3.33ms making 3 calls to Config::FETCH, avg 1.11ms/call |
| 43 | |||||
| 44 | 1 | 1µs | $do_expand = 0; | ||
| 45 | |||||
| 46 | 1 | 2µs | @dl_require_symbols = (); # names of symbols we need | ||
| 47 | 1 | 1µs | @dl_resolve_using = (); # names of files to link with | ||
| 48 | 1 | 1µs | @dl_library_path = (); # path to look for files | ||
| 49 | |||||
| 50 | #XSLoader.pm may have added elements before we were required | ||||
| 51 | #@dl_shared_objects = (); # shared objects for symbols we have | ||||
| 52 | #@dl_librefs = (); # things we have loaded | ||||
| 53 | #@dl_modules = (); # Modules we have loaded | ||||
| 54 | |||||
| 55 | # This is a fix to support DLD's unfortunate desire to relink -lc | ||||
| 56 | 1 | 1µs | @dl_resolve_using = dl_findfile('-lc') if $dlsrc eq "dl_dld.xs"; | ||
| 57 | |||||
| 58 | # Initialise @dl_library_path with the 'standard' library path | ||||
| 59 | # for this platform as determined by Configure. | ||||
| 60 | |||||
| 61 | 1 | 13µs | 1 | 6µs | push(@dl_library_path, split(' ', $Config::Config{libpth})); # spent 6µs making 1 call to Config::FETCH |
| 62 | |||||
| 63 | 1 | 8µs | 1 | 5µs | my $ldlibpthname = $Config::Config{ldlibpthname}; # spent 5µs making 1 call to Config::FETCH |
| 64 | 1 | 8µs | 1 | 6µs | my $ldlibpthname_defined = defined $Config::Config{ldlibpthname}; # spent 6µs making 1 call to Config::FETCH |
| 65 | 1 | 6µs | 1 | 5µs | my $pthsep = $Config::Config{path_sep}; # spent 5µs making 1 call to Config::FETCH |
| 66 | |||||
| 67 | # Add to @dl_library_path any extra directories we can gather from environment | ||||
| 68 | # during runtime. | ||||
| 69 | |||||
| 70 | 1 | 2µs | if ($ldlibpthname_defined && | ||
| 71 | exists $ENV{$ldlibpthname}) { | ||||
| 72 | push(@dl_library_path, split(/$pthsep/, $ENV{$ldlibpthname})); | ||||
| 73 | } | ||||
| 74 | |||||
| 75 | # E.g. HP-UX supports both its native SHLIB_PATH *and* LD_LIBRARY_PATH. | ||||
| 76 | |||||
| 77 | 1 | 1µs | if ($ldlibpthname_defined && | ||
| 78 | $ldlibpthname ne 'LD_LIBRARY_PATH' && | ||||
| 79 | exists $ENV{LD_LIBRARY_PATH}) { | ||||
| 80 | push(@dl_library_path, split(/$pthsep/, $ENV{LD_LIBRARY_PATH})); | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here. | ||||
| 84 | # NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB | ||||
| 85 | 1 | 2µs | boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) && | ||
| 86 | !defined(&dl_error); | ||||
| 87 | |||||
| 88 | 1 | 1µs | if ($dl_debug) { | ||
| 89 | print STDERR "DynaLoader.pm loaded (@INC, @dl_library_path)\n"; | ||||
| 90 | print STDERR "DynaLoader not linked into this perl\n" | ||||
| 91 | unless defined(&boot_DynaLoader); | ||||
| 92 | } | ||||
| 93 | |||||
| 94 | 1 | 31µs | 1; # End of main code | ||
| 95 | |||||
| 96 | sub croak { require Carp; Carp::croak(@_) } | ||||
| 97 | |||||
| 98 | sub bootstrap_inherit { | ||||
| 99 | my $module = $_[0]; | ||||
| 100 | local *isa = *{"$module\::ISA"}; | ||||
| 101 | local @isa = (@isa, 'DynaLoader'); | ||||
| 102 | # Cannot goto due to delocalization. Will report errors on a wrong line? | ||||
| 103 | bootstrap(@_); | ||||
| 104 | } | ||||
| 105 | |||||
| 106 | # The bootstrap function cannot be autoloaded (without complications) | ||||
| 107 | # so we define it here: | ||||
| 108 | |||||
| 109 | # spent 3.26ms (475µs+2.78) within DynaLoader::bootstrap which was called 3 times, avg 1.09ms/call:
# once (154µs+1.81ms) by XML::LibXML::BEGIN@28 at line 147 of XML/LibXML.pm
# once (160µs+710µs) by MARC::Charset::BEGIN@10 at line 42 of Unicode/Normalize.pm
# once (161µs+263µs) by MARC::Charset::Table::BEGIN@40 at line 67 of Storable.pm | ||||
| 110 | # use local vars to enable $module.bs script to edit values | ||||
| 111 | 3 | 11µs | local(@args) = @_; | ||
| 112 | 3 | 4µs | local($module) = $args[0]; | ||
| 113 | 3 | 4µs | local(@dirs, $file); | ||
| 114 | |||||
| 115 | 3 | 4µs | unless ($module) { | ||
| 116 | require Carp; | ||||
| 117 | Carp::confess("Usage: DynaLoader::bootstrap(module)"); | ||||
| 118 | } | ||||
| 119 | |||||
| 120 | # A common error on platforms which don't support dynamic loading. | ||||
| 121 | # Since it's fatal and potentially confusing we give a detailed message. | ||||
| 122 | 3 | 5µs | croak("Can't load module $module, dynamic loading not available in this perl.\n". | ||
| 123 | " (You may need to build a new perl executable which either supports\n". | ||||
| 124 | " dynamic loading or has the $module module statically linked into it.)\n") | ||||
| 125 | unless defined(&dl_load_file); | ||||
| 126 | |||||
| 127 | |||||
| 128 | 3 | 13µs | my @modparts = split(/::/,$module); | ||
| 129 | 3 | 5µs | my $modfname = $modparts[-1]; | ||
| 130 | |||||
| 131 | # Some systems have restrictions on files names for DLL's etc. | ||||
| 132 | # mod2fname returns appropriate file base name (typically truncated) | ||||
| 133 | # It may also edit @modparts if required. | ||||
| 134 | 3 | 5µs | $modfname = &mod2fname(\@modparts) if defined &mod2fname; | ||
| 135 | |||||
| 136 | |||||
| 137 | |||||
| 138 | 3 | 9µs | my $modpname = join('/',@modparts); | ||
| 139 | |||||
| 140 | 3 | 5µs | print STDERR "DynaLoader::bootstrap for $module ", | ||
| 141 | "(auto/$modpname/$modfname.$dl_dlext)\n" | ||||
| 142 | if $dl_debug; | ||||
| 143 | |||||
| 144 | 3 | 21µs | foreach (@INC) { | ||
| 145 | |||||
| 146 | |||||
| 147 | 19 | 34µs | my $dir = "$_/auto/$modpname"; | ||
| 148 | |||||
| 149 | |||||
| 150 | 19 | 187µs | 19 | 105µs | next unless -d $dir; # skip over uninteresting directories # spent 105µs making 19 calls to DynaLoader::CORE:ftdir, avg 6µs/call |
| 151 | |||||
| 152 | # check for common cases to avoid autoload of dl_findfile | ||||
| 153 | 3 | 10µs | my $try = "$dir/$modfname.$dl_dlext"; | ||
| 154 | 3 | 39µs | 3 | 19µs | last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && $try); # spent 19µs making 3 calls to DynaLoader::CORE:ftfile, avg 6µs/call |
| 155 | |||||
| 156 | # no luck here, save dir for possible later dl_findfile search | ||||
| 157 | push @dirs, $dir; | ||||
| 158 | } | ||||
| 159 | # last resort, let dl_findfile have a go in all known locations | ||||
| 160 | 3 | 3µs | $file = dl_findfile(map("-L$_",@dirs,@INC), $modfname) unless $file; | ||
| 161 | |||||
| 162 | 3 | 4µs | croak("Can't locate loadable object for module $module in \@INC (\@INC contains: @INC)") | ||
| 163 | unless $file; # wording similar to error from 'require' | ||||
| 164 | |||||
| 165 | |||||
| 166 | 3 | 7µs | my $bootname = "boot_$module"; | ||
| 167 | 3 | 27µs | 3 | 11µs | $bootname =~ s/\W/_/g; # spent 11µs making 3 calls to DynaLoader::CORE:subst, avg 4µs/call |
| 168 | 3 | 6µs | @dl_require_symbols = ($bootname); | ||
| 169 | |||||
| 170 | # Execute optional '.bootstrap' perl script for this module. | ||||
| 171 | # The .bs file can be used to configure @dl_resolve_using etc to | ||||
| 172 | # match the needs of the individual module on this architecture. | ||||
| 173 | 3 | 3µs | my $bs = $file; | ||
| 174 | 3 | 97µs | 3 | 84µs | $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library # spent 84µs making 3 calls to DynaLoader::CORE:subst, avg 28µs/call |
| 175 | 3 | 35µs | 3 | 20µs | if (-s $bs) { # only read file if it's not empty # spent 20µs making 3 calls to DynaLoader::CORE:ftsize, avg 7µs/call |
| 176 | print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug; | ||||
| 177 | eval { do $bs; }; | ||||
| 178 | warn "$bs: $@\n" if $@; | ||||
| 179 | } | ||||
| 180 | |||||
| 181 | 3 | 3µs | my $boot_symbol_ref; | ||
| 182 | |||||
| 183 | |||||
| 184 | |||||
| 185 | # Many dynamic extension loading problems will appear to come from | ||||
| 186 | # this section of code: XYZ failed at line 123 of DynaLoader.pm. | ||||
| 187 | # Often these errors are actually occurring in the initialisation | ||||
| 188 | # C code of the extension XS file. Perl reports the error as being | ||||
| 189 | # in this perl code simply because this was the last perl code | ||||
| 190 | # it executed. | ||||
| 191 | |||||
| 192 | 3 | 1.15ms | 6 | 1.11ms | my $libref = dl_load_file($file, $module->dl_load_flags) or # spent 1.10ms making 3 calls to DynaLoader::dl_load_file, avg 367µs/call
# spent 12µs making 3 calls to DynaLoader::dl_load_flags, avg 4µs/call |
| 193 | croak("Can't load '$file' for module $module: ".dl_error()); | ||||
| 194 | |||||
| 195 | 3 | 5µs | push(@dl_librefs,$libref); # record loaded object | ||
| 196 | |||||
| 197 | 3 | 24µs | 3 | 8µs | my @unresolved = dl_undef_symbols(); # spent 8µs making 3 calls to DynaLoader::dl_undef_symbols, avg 3µs/call |
| 198 | 3 | 4µs | if (@unresolved) { | ||
| 199 | require Carp; | ||||
| 200 | Carp::carp("Undefined symbols present after loading $file: @unresolved\n"); | ||||
| 201 | } | ||||
| 202 | |||||
| 203 | 3 | 30µs | 3 | 13µs | $boot_symbol_ref = dl_find_symbol($libref, $bootname) or # spent 13µs making 3 calls to DynaLoader::dl_find_symbol, avg 4µs/call |
| 204 | croak("Can't find '$bootname' symbol in $file\n"); | ||||
| 205 | |||||
| 206 | 3 | 7µs | push(@dl_modules, $module); # record loaded module | ||
| 207 | |||||
| 208 | 3 | 46µs | 3 | 27µs | boot: # spent 27µs making 3 calls to DynaLoader::dl_install_xsub, avg 9µs/call |
| 209 | my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file); | ||||
| 210 | |||||
| 211 | # See comment block above | ||||
| 212 | |||||
| 213 | 3 | 7µs | push(@dl_shared_objects, $file); # record files loaded | ||
| 214 | |||||
| 215 | 3 | 1.44ms | 3 | 1.38ms | &$xs(@args); # spent 1.20ms making 1 call to XML::LibXML::bootstrap
# spent 106µs making 1 call to Unicode::Normalize::bootstrap
# spent 78µs making 1 call to Storable::bootstrap |
| 216 | } | ||||
| 217 | |||||
| 218 | #sub _check_file { # private utility to handle dl_expandspec vs -f tests | ||||
| 219 | # my($file) = @_; | ||||
| 220 | # return $file if (!$do_expand && -f $file); # the common case | ||||
| 221 | # return $file if ( $do_expand && ($file=dl_expandspec($file))); | ||||
| 222 | # return undef; | ||||
| 223 | #} | ||||
| 224 | |||||
| 225 | # Let autosplit and the autoloader deal with these functions: | ||||
# spent 105µs within DynaLoader::CORE:ftdir which was called 19 times, avg 6µs/call:
# 19 times (105µs+0s) by DynaLoader::bootstrap at line 150, avg 6µs/call | |||||
# spent 19µs within DynaLoader::CORE:ftfile which was called 3 times, avg 6µs/call:
# 3 times (19µs+0s) by DynaLoader::bootstrap at line 154, avg 6µs/call | |||||
# spent 20µs within DynaLoader::CORE:ftsize which was called 3 times, avg 7µs/call:
# 3 times (20µs+0s) by DynaLoader::bootstrap at line 175, avg 7µs/call | |||||
sub DynaLoader::CORE:subst; # opcode | |||||
# spent 13µs within DynaLoader::dl_find_symbol which was called 3 times, avg 4µs/call:
# 3 times (13µs+0s) by DynaLoader::bootstrap at line 203, avg 4µs/call | |||||
# spent 27µs within DynaLoader::dl_install_xsub which was called 3 times, avg 9µs/call:
# 3 times (27µs+0s) by DynaLoader::bootstrap at line 208, avg 9µs/call | |||||
# spent 1.10ms within DynaLoader::dl_load_file which was called 3 times, avg 367µs/call:
# 3 times (1.10ms+0s) by DynaLoader::bootstrap at line 192, avg 367µs/call | |||||
# spent 8µs within DynaLoader::dl_undef_symbols which was called 3 times, avg 3µs/call:
# 3 times (8µs+0s) by DynaLoader::bootstrap at line 197, avg 3µs/call |