| Filename | /usr/share/perl/5.14/warnings.pm |
| Statements | Executed 290 statements in 496µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 3 | 1 | 1 | 106µs | 120µs | warnings::register_categories |
| 7 | 7 | 7 | 52µs | 52µs | warnings::import |
| 4 | 4 | 3 | 50µs | 50µs | warnings::unimport |
| 1 | 1 | 1 | 23µs | 23µs | warnings::CORE:regcomp (opcode) |
| 6 | 2 | 1 | 14µs | 14µs | warnings::_mkMask |
| 1 | 1 | 1 | 9µs | 9µs | warnings::CORE:match (opcode) |
| 0 | 0 | 0 | 0s | 0s | warnings::Croaker |
| 0 | 0 | 0 | 0s | 0s | warnings::__chk |
| 0 | 0 | 0 | 0s | 0s | warnings::_bits |
| 0 | 0 | 0 | 0s | 0s | warnings::_error_loc |
| 0 | 0 | 0 | 0s | 0s | warnings::bits |
| 0 | 0 | 0 | 0s | 0s | warnings::enabled |
| 0 | 0 | 0 | 0s | 0s | warnings::fatal_enabled |
| 0 | 0 | 0 | 0s | 0s | warnings::warn |
| 0 | 0 | 0 | 0s | 0s | warnings::warnif |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # -*- buffer-read-only: t -*- | ||||
| 2 | # !!!!!!! DO NOT EDIT THIS FILE !!!!!!! | ||||
| 3 | # This file is built by regen/warnings.pl. | ||||
| 4 | # Any changes made here will be lost! | ||||
| 5 | |||||
| 6 | package warnings; | ||||
| 7 | |||||
| 8 | 1 | 900ns | our $VERSION = '1.12'; | ||
| 9 | |||||
| 10 | # Verify that we're called correctly so that warnings will work. | ||||
| 11 | # see also strict.pm. | ||||
| 12 | 1 | 55µs | 2 | 32µs | unless ( __FILE__ =~ /(^|[\/\\])\Q${\__PACKAGE__}\E\.pmc?$/ ) { # spent 23µs making 1 call to warnings::CORE:regcomp
# spent 9µs making 1 call to warnings::CORE:match |
| 13 | my (undef, $f, $l) = caller; | ||||
| 14 | die("Incorrect use of pragma '${\__PACKAGE__}' at $f line $l.\n"); | ||||
| 15 | } | ||||
| 16 | |||||
| 17 | 1 | 48µs | our %Offsets = ( | ||
| 18 | |||||
| 19 | # Warnings Categories added in Perl 5.008 | ||||
| 20 | |||||
| 21 | 'all' => 0, | ||||
| 22 | 'closure' => 2, | ||||
| 23 | 'deprecated' => 4, | ||||
| 24 | 'exiting' => 6, | ||||
| 25 | 'glob' => 8, | ||||
| 26 | 'io' => 10, | ||||
| 27 | 'closed' => 12, | ||||
| 28 | 'exec' => 14, | ||||
| 29 | 'layer' => 16, | ||||
| 30 | 'newline' => 18, | ||||
| 31 | 'pipe' => 20, | ||||
| 32 | 'unopened' => 22, | ||||
| 33 | 'misc' => 24, | ||||
| 34 | 'numeric' => 26, | ||||
| 35 | 'once' => 28, | ||||
| 36 | 'overflow' => 30, | ||||
| 37 | 'pack' => 32, | ||||
| 38 | 'portable' => 34, | ||||
| 39 | 'recursion' => 36, | ||||
| 40 | 'redefine' => 38, | ||||
| 41 | 'regexp' => 40, | ||||
| 42 | 'severe' => 42, | ||||
| 43 | 'debugging' => 44, | ||||
| 44 | 'inplace' => 46, | ||||
| 45 | 'internal' => 48, | ||||
| 46 | 'malloc' => 50, | ||||
| 47 | 'signal' => 52, | ||||
| 48 | 'substr' => 54, | ||||
| 49 | 'syntax' => 56, | ||||
| 50 | 'ambiguous' => 58, | ||||
| 51 | 'bareword' => 60, | ||||
| 52 | 'digit' => 62, | ||||
| 53 | 'parenthesis' => 64, | ||||
| 54 | 'precedence' => 66, | ||||
| 55 | 'printf' => 68, | ||||
| 56 | 'prototype' => 70, | ||||
| 57 | 'qw' => 72, | ||||
| 58 | 'reserved' => 74, | ||||
| 59 | 'semicolon' => 76, | ||||
| 60 | 'taint' => 78, | ||||
| 61 | 'threads' => 80, | ||||
| 62 | 'uninitialized' => 82, | ||||
| 63 | 'unpack' => 84, | ||||
| 64 | 'untie' => 86, | ||||
| 65 | 'utf8' => 88, | ||||
| 66 | 'void' => 90, | ||||
| 67 | |||||
| 68 | # Warnings Categories added in Perl 5.011 | ||||
| 69 | |||||
| 70 | 'imprecision' => 92, | ||||
| 71 | 'illegalproto' => 94, | ||||
| 72 | |||||
| 73 | # Warnings Categories added in Perl 5.013 | ||||
| 74 | |||||
| 75 | 'non_unicode' => 96, | ||||
| 76 | 'nonchar' => 98, | ||||
| 77 | 'surrogate' => 100, | ||||
| 78 | ); | ||||
| 79 | |||||
| 80 | 1 | 21µs | our %Bits = ( | ||
| 81 | 'all' => "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15", # [0..50] | ||||
| 82 | 'ambiguous' => "\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00", # [29] | ||||
| 83 | 'bareword' => "\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00", # [30] | ||||
| 84 | 'closed' => "\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6] | ||||
| 85 | 'closure' => "\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [1] | ||||
| 86 | 'debugging' => "\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00", # [22] | ||||
| 87 | 'deprecated' => "\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [2] | ||||
| 88 | 'digit' => "\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00", # [31] | ||||
| 89 | 'exec' => "\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7] | ||||
| 90 | 'exiting' => "\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3] | ||||
| 91 | 'glob' => "\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [4] | ||||
| 92 | 'illegalproto' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00", # [47] | ||||
| 93 | 'imprecision' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00", # [46] | ||||
| 94 | 'inplace' => "\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00", # [23] | ||||
| 95 | 'internal' => "\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00", # [24] | ||||
| 96 | 'io' => "\x00\x54\x55\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [5..11] | ||||
| 97 | 'layer' => "\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [8] | ||||
| 98 | 'malloc' => "\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00", # [25] | ||||
| 99 | 'misc' => "\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [12] | ||||
| 100 | 'newline' => "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [9] | ||||
| 101 | 'non_unicode' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", # [48] | ||||
| 102 | 'nonchar' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04", # [49] | ||||
| 103 | 'numeric' => "\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [13] | ||||
| 104 | 'once' => "\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [14] | ||||
| 105 | 'overflow' => "\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [15] | ||||
| 106 | 'pack' => "\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00", # [16] | ||||
| 107 | 'parenthesis' => "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00", # [32] | ||||
| 108 | 'pipe' => "\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [10] | ||||
| 109 | 'portable' => "\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00", # [17] | ||||
| 110 | 'precedence' => "\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00", # [33] | ||||
| 111 | 'printf' => "\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00", # [34] | ||||
| 112 | 'prototype' => "\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00", # [35] | ||||
| 113 | 'qw' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00", # [36] | ||||
| 114 | 'recursion' => "\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00", # [18] | ||||
| 115 | 'redefine' => "\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00", # [19] | ||||
| 116 | 'regexp' => "\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00", # [20] | ||||
| 117 | 'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00", # [37] | ||||
| 118 | 'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00", # [38] | ||||
| 119 | 'severe' => "\x00\x00\x00\x00\x00\x54\x05\x00\x00\x00\x00\x00\x00", # [21..25] | ||||
| 120 | 'signal' => "\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00", # [26] | ||||
| 121 | 'substr' => "\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00", # [27] | ||||
| 122 | 'surrogate' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10", # [50] | ||||
| 123 | 'syntax' => "\x00\x00\x00\x00\x00\x00\x00\x55\x55\x15\x00\x40\x00", # [28..38,47] | ||||
| 124 | 'taint' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00", # [39] | ||||
| 125 | 'threads' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00", # [40] | ||||
| 126 | 'uninitialized' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00", # [41] | ||||
| 127 | 'unopened' => "\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [11] | ||||
| 128 | 'unpack' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00", # [42] | ||||
| 129 | 'untie' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00", # [43] | ||||
| 130 | 'utf8' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x15", # [44,48..50] | ||||
| 131 | 'void' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00", # [45] | ||||
| 132 | ); | ||||
| 133 | |||||
| 134 | 1 | 26µs | our %DeadBits = ( | ||
| 135 | 'all' => "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\x2a", # [0..50] | ||||
| 136 | 'ambiguous' => "\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00", # [29] | ||||
| 137 | 'bareword' => "\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00", # [30] | ||||
| 138 | 'closed' => "\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6] | ||||
| 139 | 'closure' => "\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [1] | ||||
| 140 | 'debugging' => "\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00", # [22] | ||||
| 141 | 'deprecated' => "\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [2] | ||||
| 142 | 'digit' => "\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00", # [31] | ||||
| 143 | 'exec' => "\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7] | ||||
| 144 | 'exiting' => "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3] | ||||
| 145 | 'glob' => "\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [4] | ||||
| 146 | 'illegalproto' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00", # [47] | ||||
| 147 | 'imprecision' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00", # [46] | ||||
| 148 | 'inplace' => "\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00", # [23] | ||||
| 149 | 'internal' => "\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00", # [24] | ||||
| 150 | 'io' => "\x00\xa8\xaa\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [5..11] | ||||
| 151 | 'layer' => "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [8] | ||||
| 152 | 'malloc' => "\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00", # [25] | ||||
| 153 | 'misc' => "\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [12] | ||||
| 154 | 'newline' => "\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [9] | ||||
| 155 | 'non_unicode' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02", # [48] | ||||
| 156 | 'nonchar' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08", # [49] | ||||
| 157 | 'numeric' => "\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [13] | ||||
| 158 | 'once' => "\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [14] | ||||
| 159 | 'overflow' => "\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [15] | ||||
| 160 | 'pack' => "\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00", # [16] | ||||
| 161 | 'parenthesis' => "\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00", # [32] | ||||
| 162 | 'pipe' => "\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [10] | ||||
| 163 | 'portable' => "\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00", # [17] | ||||
| 164 | 'precedence' => "\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00", # [33] | ||||
| 165 | 'printf' => "\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00", # [34] | ||||
| 166 | 'prototype' => "\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00", # [35] | ||||
| 167 | 'qw' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00", # [36] | ||||
| 168 | 'recursion' => "\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00", # [18] | ||||
| 169 | 'redefine' => "\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00", # [19] | ||||
| 170 | 'regexp' => "\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00", # [20] | ||||
| 171 | 'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00", # [37] | ||||
| 172 | 'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00", # [38] | ||||
| 173 | 'severe' => "\x00\x00\x00\x00\x00\xa8\x0a\x00\x00\x00\x00\x00\x00", # [21..25] | ||||
| 174 | 'signal' => "\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00", # [26] | ||||
| 175 | 'substr' => "\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00", # [27] | ||||
| 176 | 'surrogate' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20", # [50] | ||||
| 177 | 'syntax' => "\x00\x00\x00\x00\x00\x00\x00\xaa\xaa\x2a\x00\x80\x00", # [28..38,47] | ||||
| 178 | 'taint' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00", # [39] | ||||
| 179 | 'threads' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00", # [40] | ||||
| 180 | 'uninitialized' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00", # [41] | ||||
| 181 | 'unopened' => "\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [11] | ||||
| 182 | 'unpack' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00", # [42] | ||||
| 183 | 'untie' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00", # [43] | ||||
| 184 | 'utf8' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x2a", # [44,48..50] | ||||
| 185 | 'void' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00", # [45] | ||||
| 186 | ); | ||||
| 187 | |||||
| 188 | 1 | 400ns | $NONE = "\0\0\0\0\0\0\0\0\0\0\0\0\0"; | ||
| 189 | 1 | 200ns | $LAST_BIT = 102 ; | ||
| 190 | 1 | 200ns | $BYTES = 13 ; | ||
| 191 | |||||
| 192 | 2 | 11µs | $All = "" ; vec($All, $Offsets{'all'}, 2) = 3 ; | ||
| 193 | |||||
| 194 | sub Croaker | ||||
| 195 | { | ||||
| 196 | require Carp; # this initializes %CarpInternal | ||||
| 197 | local $Carp::CarpInternal{'warnings'}; | ||||
| 198 | delete $Carp::CarpInternal{'warnings'}; | ||||
| 199 | Carp::croak(@_); | ||||
| 200 | } | ||||
| 201 | |||||
| 202 | sub _bits { | ||||
| 203 | my $mask = shift ; | ||||
| 204 | my $catmask ; | ||||
| 205 | my $fatal = 0 ; | ||||
| 206 | my $no_fatal = 0 ; | ||||
| 207 | |||||
| 208 | foreach my $word ( @_ ) { | ||||
| 209 | if ($word eq 'FATAL') { | ||||
| 210 | $fatal = 1; | ||||
| 211 | $no_fatal = 0; | ||||
| 212 | } | ||||
| 213 | elsif ($word eq 'NONFATAL') { | ||||
| 214 | $fatal = 0; | ||||
| 215 | $no_fatal = 1; | ||||
| 216 | } | ||||
| 217 | elsif ($catmask = $Bits{$word}) { | ||||
| 218 | $mask |= $catmask ; | ||||
| 219 | $mask |= $DeadBits{$word} if $fatal ; | ||||
| 220 | $mask &= ~($DeadBits{$word}|$All) if $no_fatal ; | ||||
| 221 | } | ||||
| 222 | else | ||||
| 223 | { Croaker("Unknown warnings category '$word'")} | ||||
| 224 | } | ||||
| 225 | |||||
| 226 | return $mask ; | ||||
| 227 | } | ||||
| 228 | |||||
| 229 | sub bits | ||||
| 230 | { | ||||
| 231 | # called from B::Deparse.pm | ||||
| 232 | push @_, 'all' unless @_ ; | ||||
| 233 | return _bits(undef, @_) ; | ||||
| 234 | } | ||||
| 235 | |||||
| 236 | sub import | ||||
| 237 | # spent 52µs within warnings::import which was called 7 times, avg 7µs/call:
# once (12µs+0s) by Function::Parameters::BEGIN@5 at line 5 of Function/Parameters.pm
# once (9µs+0s) by Sorthash::BEGIN@7 at line 7 of /homes/dcw/lib/perl5/DCW/Sorthash.pm
# once (8µs+0s) by Carp::BEGIN@4 at line 4 of Carp.pm
# once (6µs+0s) by Tuple::BEGIN@4 at line 4 of /homes/dcw/lib/perl5/DCW/Tuple.pm
# once (6µs+0s) by List::BEGIN@11 at line 11 of /homes/dcw/lib/perl5/DCW/List.pm
# once (6µs+0s) by utf8::BEGIN@3 at line 3 of utf8_heavy.pl
# once (4µs+0s) by Config::BEGIN@10 at line 10 of Config.pm | ||||
| 238 | 28 | 70µs | shift; | ||
| 239 | |||||
| 240 | my $mask = ${^WARNING_BITS} ; | ||||
| 241 | |||||
| 242 | if (vec($mask, $Offsets{'all'}, 1)) { | ||||
| 243 | $mask |= $Bits{'all'} ; | ||||
| 244 | $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1); | ||||
| 245 | } | ||||
| 246 | |||||
| 247 | # Empty @_ is equivalent to @_ = 'all' ; | ||||
| 248 | ${^WARNING_BITS} = @_ ? _bits($mask, @_) : $mask | $Bits{all} ; | ||||
| 249 | } | ||||
| 250 | |||||
| 251 | sub unimport | ||||
| 252 | # spent 50µs within warnings::unimport which was called 4 times, avg 12µs/call:
# once (18µs+0s) by Carp::BEGIN@342 at line 342 of Carp.pm
# once (12µs+0s) by utf8::BEGIN@117 at line 117 of utf8_heavy.pl
# once (12µs+0s) by utf8::BEGIN@460 at line 460 of utf8_heavy.pl
# once (7µs+0s) by Exporter::Heavy::BEGIN@183 at line 183 of Exporter/Heavy.pm | ||||
| 253 | 28 | 45µs | shift; | ||
| 254 | |||||
| 255 | my $catmask ; | ||||
| 256 | my $mask = ${^WARNING_BITS} ; | ||||
| 257 | |||||
| 258 | 6 | 5µs | if (vec($mask, $Offsets{'all'}, 1)) { | ||
| 259 | $mask |= $Bits{'all'} ; | ||||
| 260 | $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1); | ||||
| 261 | } | ||||
| 262 | |||||
| 263 | push @_, 'all' unless @_; | ||||
| 264 | |||||
| 265 | foreach my $word ( @_ ) { | ||||
| 266 | 4 | 12µs | if ($word eq 'FATAL') { | ||
| 267 | next; | ||||
| 268 | } | ||||
| 269 | elsif ($catmask = $Bits{$word}) { | ||||
| 270 | $mask &= ~($catmask | $DeadBits{$word} | $All); | ||||
| 271 | } | ||||
| 272 | else | ||||
| 273 | { Croaker("Unknown warnings category '$word'")} | ||||
| 274 | } | ||||
| 275 | |||||
| 276 | ${^WARNING_BITS} = $mask ; | ||||
| 277 | } | ||||
| 278 | |||||
| 279 | 2 | 10µs | my %builtin_type; @builtin_type{qw(SCALAR ARRAY HASH CODE REF GLOB LVALUE Regexp)} = (); | ||
| 280 | |||||
| 281 | sub MESSAGE () { 4 }; | ||||
| 282 | sub FATAL () { 2 }; | ||||
| 283 | sub NORMAL () { 1 }; | ||||
| 284 | |||||
| 285 | sub __chk | ||||
| 286 | { | ||||
| 287 | my $category ; | ||||
| 288 | my $offset ; | ||||
| 289 | my $isobj = 0 ; | ||||
| 290 | my $wanted = shift; | ||||
| 291 | my $has_message = $wanted & MESSAGE; | ||||
| 292 | |||||
| 293 | unless (@_ == 1 || @_ == ($has_message ? 2 : 0)) { | ||||
| 294 | my $sub = (caller 1)[3]; | ||||
| 295 | my $syntax = $has_message ? "[category,] 'message'" : '[category]'; | ||||
| 296 | Croaker("Usage: $sub($syntax)"); | ||||
| 297 | } | ||||
| 298 | |||||
| 299 | my $message = pop if $has_message; | ||||
| 300 | |||||
| 301 | if (@_) { | ||||
| 302 | # check the category supplied. | ||||
| 303 | $category = shift ; | ||||
| 304 | if (my $type = ref $category) { | ||||
| 305 | Croaker("not an object") | ||||
| 306 | if exists $builtin_type{$type}; | ||||
| 307 | $category = $type; | ||||
| 308 | $isobj = 1 ; | ||||
| 309 | } | ||||
| 310 | $offset = $Offsets{$category}; | ||||
| 311 | Croaker("Unknown warnings category '$category'") | ||||
| 312 | unless defined $offset; | ||||
| 313 | } | ||||
| 314 | else { | ||||
| 315 | $category = (caller(1))[0] ; | ||||
| 316 | $offset = $Offsets{$category}; | ||||
| 317 | Croaker("package '$category' not registered for warnings") | ||||
| 318 | unless defined $offset ; | ||||
| 319 | } | ||||
| 320 | |||||
| 321 | my $i; | ||||
| 322 | |||||
| 323 | if ($isobj) { | ||||
| 324 | my $pkg; | ||||
| 325 | $i = 2; | ||||
| 326 | while (do { { package DB; $pkg = (caller($i++))[0] } } ) { | ||||
| 327 | last unless @DB::args && $DB::args[0] =~ /^$category=/ ; | ||||
| 328 | } | ||||
| 329 | $i -= 2 ; | ||||
| 330 | } | ||||
| 331 | else { | ||||
| 332 | $i = _error_loc(); # see where Carp will allocate the error | ||||
| 333 | } | ||||
| 334 | |||||
| 335 | # Defaulting this to 0 reduces complexity in code paths below. | ||||
| 336 | my $callers_bitmask = (caller($i))[9] || 0 ; | ||||
| 337 | |||||
| 338 | my @results; | ||||
| 339 | foreach my $type (FATAL, NORMAL) { | ||||
| 340 | next unless $wanted & $type; | ||||
| 341 | |||||
| 342 | push @results, (vec($callers_bitmask, $offset + $type - 1, 1) || | ||||
| 343 | vec($callers_bitmask, $Offsets{'all'} + $type - 1, 1)); | ||||
| 344 | } | ||||
| 345 | |||||
| 346 | # &enabled and &fatal_enabled | ||||
| 347 | return $results[0] unless $has_message; | ||||
| 348 | |||||
| 349 | # &warnif, and the category is neither enabled as warning nor as fatal | ||||
| 350 | return if $wanted == (NORMAL | FATAL | MESSAGE) | ||||
| 351 | && !($results[0] || $results[1]); | ||||
| 352 | |||||
| 353 | require Carp; | ||||
| 354 | Carp::croak($message) if $results[0]; | ||||
| 355 | # will always get here for &warn. will only get here for &warnif if the | ||||
| 356 | # category is enabled | ||||
| 357 | Carp::carp($message); | ||||
| 358 | } | ||||
| 359 | |||||
| 360 | sub _mkMask | ||||
| 361 | { | ||||
| 362 | 24 | 21µs | my ($bit) = @_; | ||
| 363 | my $mask = ""; | ||||
| 364 | |||||
| 365 | vec($mask, $bit, 1) = 1; | ||||
| 366 | return $mask; | ||||
| 367 | } | ||||
| 368 | |||||
| 369 | sub register_categories | ||||
| 370 | # spent 120µs (106+14) within warnings::register_categories which was called 3 times, avg 40µs/call:
# 3 times (106µs+14µs) by warnings::register::import at line 24 of warnings/register.pm, avg 40µs/call | ||||
| 371 | 6 | 7µs | my @names = @_; | ||
| 372 | |||||
| 373 | for my $name (@names) { | ||||
| 374 | 21 | 28µs | if (! defined $Bits{$name}) { | ||
| 375 | 3 | 8µs | $Bits{$name} = _mkMask($LAST_BIT); # spent 8µs making 3 calls to warnings::_mkMask, avg 3µs/call | ||
| 376 | vec($Bits{'all'}, $LAST_BIT, 1) = 1; | ||||
| 377 | $Offsets{$name} = $LAST_BIT ++; | ||||
| 378 | foreach my $k (keys %Bits) { | ||||
| 379 | 159 | 66µs | vec($Bits{$k}, $LAST_BIT, 1) = 0; | ||
| 380 | } | ||||
| 381 | 3 | 5µs | $DeadBits{$name} = _mkMask($LAST_BIT); # spent 5µs making 3 calls to warnings::_mkMask, avg 2µs/call | ||
| 382 | vec($DeadBits{'all'}, $LAST_BIT++, 1) = 1; | ||||
| 383 | } | ||||
| 384 | } | ||||
| 385 | } | ||||
| 386 | |||||
| 387 | sub _error_loc { | ||||
| 388 | require Carp; | ||||
| 389 | goto &Carp::short_error_loc; # don't introduce another stack frame | ||||
| 390 | } | ||||
| 391 | |||||
| 392 | sub enabled | ||||
| 393 | { | ||||
| 394 | return __chk(NORMAL, @_); | ||||
| 395 | } | ||||
| 396 | |||||
| 397 | sub fatal_enabled | ||||
| 398 | { | ||||
| 399 | return __chk(FATAL, @_); | ||||
| 400 | } | ||||
| 401 | |||||
| 402 | sub warn | ||||
| 403 | { | ||||
| 404 | return __chk(FATAL | MESSAGE, @_); | ||||
| 405 | } | ||||
| 406 | |||||
| 407 | sub warnif | ||||
| 408 | { | ||||
| 409 | return __chk(NORMAL | FATAL | MESSAGE, @_); | ||||
| 410 | } | ||||
| 411 | |||||
| 412 | # These are not part of any public interface, so we can delete them to save | ||||
| 413 | # space. | ||||
| 414 | 1 | 12µs | delete $warnings::{$_} foreach qw(NORMAL FATAL MESSAGE); | ||
| 415 | |||||
| 416 | 1 | 57µs | 1; | ||
| 417 | |||||
| 418 | # ex: set ro: | ||||
# spent 9µs within warnings::CORE:match which was called:
# once (9µs+0s) by Function::Parameters::BEGIN@5 at line 12 | |||||
# spent 23µs within warnings::CORE:regcomp which was called:
# once (23µs+0s) by Function::Parameters::BEGIN@5 at line 12 |