line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# The original notice of B::Size: |
3
|
|
|
|
|
|
|
# B::TerseSize.pm |
4
|
|
|
|
|
|
|
# Copyright (c) 1999-2000 Doug MacEachern. All rights reserved. |
5
|
|
|
|
|
|
|
# This module is free software; you can redistribute and/or modify |
6
|
|
|
|
|
|
|
# it under the same terms as Perl itself. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package B::Size2; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
184327
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
154
|
|
11
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
111
|
|
12
|
4
|
|
|
4
|
|
19
|
use XSLoader (); |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
54
|
|
13
|
4
|
|
|
4
|
|
18
|
use B (); |
|
4
|
|
|
|
|
20
|
|
|
4
|
|
|
|
|
183
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
BEGIN { |
16
|
4
|
|
|
4
|
|
11
|
our $VERSION = '2.07'; |
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
|
|
3854
|
XSLoader::load(__PACKAGE__, $VERSION); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
{ |
22
|
4
|
|
|
4
|
|
25
|
no warnings qw (redefine prototype); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
384
|
|
23
|
|
|
|
|
|
|
*B::OP::size = \&B::Sizeof::OP; |
24
|
|
|
|
|
|
|
*B::UNOP::size = \&B::Sizeof::UNOP; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
4
|
|
26
|
use constant _CHECK_SVPAD_OUR_FOR_MAGIC => $] < 5.016; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
308
|
|
28
|
|
|
|
|
|
|
|
29
|
4
|
|
|
4
|
|
19
|
use constant _SVpad_NAME => 0x40000000; # sv.h |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1602
|
|
30
|
4
|
|
|
4
|
|
107
|
use constant _SVpad_OUR => 0x00040000; # sv.h |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
9369
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _SvPAD_OUR { # see SvPAD_OUR()@sv.h |
33
|
0
|
|
|
0
|
|
0
|
my($sv) = @_; |
34
|
0
|
|
|
|
|
0
|
return ($sv->FLAGS() & _SVpad_NAME|_SVpad_OUR) == (_SVpad_NAME|_SVpad_OUR); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub B::SVOP::size { |
38
|
7080
|
|
|
7080
|
|
7818
|
my($op) = @_; |
39
|
7080
|
100
|
|
|
|
30470
|
if ($op->desc eq 'constant array element') { # aelemfast |
40
|
307
|
|
|
|
|
805
|
return B::Sizeof::SVOP; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
6773
|
|
|
|
|
27965
|
return B::Sizeof::SVOP + $op->sv->size; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub B::GVOP::size { |
48
|
0
|
|
|
0
|
|
0
|
my $op = shift; |
49
|
0
|
|
|
|
|
0
|
B::Sizeof::GVOP; #XXX more to measure? |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub B::PVOP::size { |
53
|
17
|
|
|
17
|
|
110
|
B::Sizeof::PVOP + length(shift->pv); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
*B::BINOP::size = \&B::Sizeof::BINOP; |
57
|
|
|
|
|
|
|
*B::LOGOP::size = \&B::Sizeof::LOGOP; |
58
|
|
|
|
|
|
|
*B::LISTOP::size = \&B::Sizeof::LISTOP; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub B::PMOP::size { |
61
|
228
|
|
|
228
|
|
279
|
my $op = shift; |
62
|
228
|
|
|
|
|
251
|
my $size = B::Sizeof::PMOP + B::Sizeof::REGEXP; |
63
|
228
|
|
|
|
|
893
|
$size += $op->REGEXP_size; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub B::PV::size { |
67
|
5145
|
|
|
5145
|
|
6401
|
my $sv = shift; |
68
|
5145
|
|
|
|
|
25890
|
B::Sizeof::SV + B::Sizeof::XPV + $sv->LEN; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub B::IV::size { |
72
|
1502
|
|
|
1502
|
|
5370
|
B::Sizeof::SV + B::Sizeof::XPVIV; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub B::NV::size { |
76
|
1646
|
|
|
1646
|
|
4442
|
B::Sizeof::SV + B::Sizeof::XPVNV; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub B::PVIV::size { |
80
|
17
|
|
|
17
|
|
81
|
my $sv = shift; |
81
|
17
|
|
|
|
|
62
|
B::IV::size + $sv->LEN; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub B::PVNV::size { |
85
|
1641
|
|
|
1641
|
|
1960
|
my $sv = shift; |
86
|
1641
|
|
|
|
|
4569
|
B::NV::size + $sv->LEN; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub B::PVLV::size { |
90
|
0
|
|
|
0
|
|
0
|
my $sv = shift; |
91
|
0
|
|
|
|
|
0
|
B::Sizeof::SV + B::Sizeof::XPVLV + |
92
|
|
|
|
|
|
|
B::Sizeof::MAGIC + $sv->LEN; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub B::PVMG::size { |
96
|
1238
|
|
|
1238
|
|
2954
|
my $sv = shift; |
97
|
1238
|
|
|
|
|
1453
|
my $size = B::Sizeof::SV + B::Sizeof::XPVMG; |
98
|
|
|
|
|
|
|
|
99
|
1238
|
|
|
|
|
1035
|
if (_CHECK_SVPAD_OUR_FOR_MAGIC && !_SvPAD_OUR($sv)){ |
100
|
|
|
|
|
|
|
my(@chain) = $sv->MAGIC; |
101
|
|
|
|
|
|
|
for my $mg (@chain) { |
102
|
|
|
|
|
|
|
$size += B::Sizeof::MAGIC + $mg->LENGTH; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
1238
|
100
|
|
|
|
1153
|
if (defined(my $tied = tied(${ $sv->object_2svref }))) { |
|
1238
|
|
|
|
|
4444
|
|
106
|
4
|
|
|
|
|
21
|
return $size + B::svref_2object($tied)->size; |
107
|
|
|
|
|
|
|
} |
108
|
1234
|
|
|
|
|
3723
|
$size; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub B::AV::size { |
112
|
467
|
|
|
467
|
|
2217
|
my $sv = shift; |
113
|
467
|
|
|
|
|
526
|
my $size = B::Sizeof::AV + B::Sizeof::XPVAV; |
114
|
467
|
100
|
|
|
|
478
|
if (defined(my $tied = tied(@{ $sv->object_2svref }))) { |
|
467
|
|
|
|
|
1721
|
|
115
|
2
|
|
|
|
|
11
|
return $size + B::svref_2object($tied)->size; |
116
|
|
|
|
|
|
|
} |
117
|
465
|
|
|
|
|
1439
|
my @vals = $sv->ARRAY; |
118
|
465
|
|
|
|
|
1650
|
for (my $i = 0; $i <= $sv->MAX; $i++) { |
119
|
540
|
100
|
|
|
|
1538
|
my $sizecv = $vals[$i]->can('size') if $vals[$i]; |
120
|
540
|
100
|
|
|
|
1467
|
$size += $sizecv ? $sizecv->($vals[$i]) : B::Sizeof::SV; |
121
|
|
|
|
|
|
|
} |
122
|
465
|
|
|
|
|
1311
|
$size; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub B::HV::size { |
126
|
36
|
|
|
36
|
|
2012
|
my $sv = shift; |
127
|
36
|
|
|
|
|
52
|
my $size = B::Sizeof::HV + B::Sizeof::XPVHV; |
128
|
|
|
|
|
|
|
#$size += length($sv->NAME); |
129
|
|
|
|
|
|
|
|
130
|
36
|
100
|
|
|
|
39
|
if (defined(my $tied = tied(%{ $sv->object_2svref }))) { |
|
36
|
|
|
|
|
219
|
|
131
|
3
|
|
|
|
|
20
|
return $size + B::svref_2object($tied)->size; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
33
|
|
|
|
|
114
|
$size += ($sv->MAX * (B::Sizeof::HE + B::Sizeof::HEK)); |
135
|
|
|
|
|
|
|
|
136
|
33
|
|
|
|
|
819
|
my %vals = $sv->ARRAY; |
137
|
33
|
|
|
|
|
177
|
while (my($k,$v) = each %vals) { |
138
|
339
|
|
|
|
|
660
|
$size += length($k) + $v->size; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
33
|
|
|
|
|
289
|
$size; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub B::RV::size { |
145
|
0
|
|
|
0
|
|
0
|
B::Sizeof::SV + B::Sizeof::XRV(); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub B::CV::size { |
149
|
28
|
|
|
28
|
|
573
|
B::Sizeof::SV + B::Sizeof::XPVCV + 0000; #__ANON__ |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub B::BM::size { |
153
|
0
|
|
|
0
|
|
0
|
my $sv = shift; |
154
|
0
|
|
|
|
|
0
|
B::Sizeof::SV + B::Sizeof::XPVBM() + $sv->LEN; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub B::FM::size { |
158
|
0
|
|
|
0
|
|
0
|
B::Sizeof::SV + B::Sizeof::XPVFM; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub B::IO::size { |
162
|
0
|
|
|
0
|
|
0
|
B::Sizeof::SV + B::Sizeof::XPVIO; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub B::SPECIAL::size { |
166
|
4833
|
|
|
4833
|
|
10788
|
B::Sizeof::SV + 0; #? |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub B::NULL::size { |
170
|
5464
|
|
|
5464
|
|
10565
|
B::Sizeof::SV + 0; #? |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub B::SPECIAL::PV { |
174
|
0
|
|
|
0
|
|
0
|
my $sv = shift; |
175
|
0
|
|
|
|
|
0
|
$B::specialsv_name[$$sv]; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub B::RV::sizeval { |
179
|
0
|
|
|
0
|
|
0
|
my $sv = shift; |
180
|
0
|
|
|
|
|
0
|
sprintf "0x%lx", $$sv; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub B::PV::sizeval { |
184
|
136
|
|
|
136
|
|
155
|
my $sv = shift; |
185
|
136
|
|
|
|
|
353
|
my $pv = $sv->PV; |
186
|
136
|
50
|
|
|
|
364
|
escape_html(\$pv) if $ENV{MOD_PERL}; |
187
|
136
|
|
|
|
|
755
|
$pv; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub B::AV::sizeval { |
191
|
442
|
|
|
442
|
|
3487
|
"MAX => " . shift->MAX; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub B::HV::sizeval { |
195
|
4
|
|
|
4
|
|
38
|
"MAX => " . shift->MAX; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub B::IV::sizeval { |
199
|
129
|
|
|
129
|
|
254
|
my($sv) = @_; |
200
|
129
|
100
|
|
|
|
739
|
return $sv->FLAGS & (B::SVf_IOK|B::SVp_IOK) |
201
|
|
|
|
|
|
|
? $sv->IV |
202
|
|
|
|
|
|
|
: B::NULL::sizeval($sv); |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub B::NV::sizeval { |
206
|
0
|
|
|
0
|
|
0
|
my($sv) = @_; |
207
|
0
|
0
|
|
|
|
0
|
return $sv->FLAGS & (B::SVf_NOK|B::SVp_NOK) |
208
|
|
|
|
|
|
|
? $sv->NV |
209
|
|
|
|
|
|
|
: B::NULL::sizeval($sv); |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub B::NULL::sizeval { |
213
|
5505
|
|
|
5505
|
|
6785
|
my $sv = shift; |
214
|
5505
|
|
|
|
|
36887
|
sprintf "0x%lx", $$sv; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub B::SPECIAL::sizeval { |
218
|
44
|
|
|
44
|
|
64
|
my $sv = shift; |
219
|
44
|
|
|
|
|
278
|
sprintf "0x%lx", $$sv; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub B::SPECIAL::FLAGS { |
223
|
9540
|
|
|
9540
|
|
27175
|
0; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub B::NULL::FLAGS { |
227
|
0
|
|
|
0
|
|
0
|
0; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub B::CV::is_alias { |
231
|
404
|
|
|
404
|
|
526
|
my($cv, $package) = @_; |
232
|
404
|
|
|
|
|
2971
|
my $stash = $cv->GV->STASH->NAME; |
233
|
404
|
100
|
|
|
|
1164
|
if($package ne $stash) { |
234
|
31
|
|
|
|
|
116
|
my $name = $cv->GV->NAME; |
235
|
|
|
|
|
|
|
#print "$package\::$name aliased to $stash\::$name\n"; |
236
|
31
|
|
|
|
|
129
|
return $stash; |
237
|
|
|
|
|
|
|
} |
238
|
373
|
|
|
|
|
1252
|
0; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub B::Size::SV_size { |
242
|
0
|
|
|
0
|
|
|
B::svref_2object(shift)->size; |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
#bleh |
246
|
|
|
|
|
|
|
my %esc = ( |
247
|
|
|
|
|
|
|
'&' => 'amp', |
248
|
|
|
|
|
|
|
'>' => 'gt', |
249
|
|
|
|
|
|
|
'<' => 'lt', |
250
|
|
|
|
|
|
|
'"' => 'quot', |
251
|
|
|
|
|
|
|
); |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
my $esc = join '', keys %esc; |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub escape_html { |
256
|
0
|
|
|
0
|
0
|
|
my $str = shift; |
257
|
0
|
0
|
|
|
|
|
$$str =~ s/([$esc])/&$esc{$1};/g if $$str; |
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
1; |
261
|
|
|
|
|
|
|
__END__ |