Codebase list libdevel-size-perl / 212be1b
Imported Upstream version 0.79 gregor herrmann 11 years ago
7 changed file(s) with 103 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
00 Revision history for Perl extension Devel::Size.
11
2 0.78 2011-07-26 nicholas
2 0.79 2013-05-12 nicholas
3 [no changes]
4
5 0.78_52 2013-05-10 nicholas
6 * Fix the bug in the previous fix. Oops :-)
7
8 0.78_51 2013-05-10 nicholas
9 * v5.17.1 and later handle CopSTASH differently under ithreads
10
11 0.78_50 2013-05-10 nicholas
12 * Alternative test for CvOUTSIDE, and one for CvPADLIST
13 * v5.17 changes the type of PADLIST [CPAN #83904]
14 * stubbed subs no longer have CvOUTSIDE set [CPAN #77913]
15 * Fix for v5.17.2's OP slab allocator [CPAN #83903]
16 * Spelling fix to docs from gregor herrmann [CPAN #78766]
17
18 0.78 2012-07-26 nicholas
319 [no changes]
420
521 0.77_51 2012-07-17 nicholas
33 "unknown"
44 ],
55 "dynamic_config" : 1,
6 "generated_by" : "ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120630",
6 "generated_by" : "ExtUtils::MakeMaker version 6.6501, CPAN::Meta::Converter version 2.120921",
77 "license" : [
88 "perl_5"
99 ],
3838 }
3939 },
4040 "release_status" : "stable",
41 "version" : "0.78"
41 "version" : "0.79"
4242 }
66 configure_requires:
77 ExtUtils::MakeMaker: 0
88 dynamic_config: 1
9 generated_by: 'ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120630'
9 generated_by: 'ExtUtils::MakeMaker version 6.6501, CPAN::Meta::Converter version 2.120921'
1010 license: perl
1111 meta-spec:
1212 url: http://module-build.sourceforge.net/META-spec-v1.4.html
2020 Test::More: 0
2121 XSLoader: 0
2222 perl: 5.005
23 version: 0.78
23 version: 0.79
517517 #endif
518518 #ifdef USE_ITHREADS
519519 check_new_and_strlen(st, basecop->cop_file);
520 #if PERL_VERSION < 17 || (PERL_VERSION == 17 && PERL_SUBVERSION == 0)
521 /* This pointer is owned by the COP, and freed with it. */
520522 check_new_and_strlen(st, basecop->cop_stashpv);
521523 #else
522 sv_size(aTHX_ st, (SV *)basecop->cop_stash, SOME_RECURSION);
524 /* A per-interpreter pointer for this stash is allocated in
525 PL_stashpad. */
526 if (check_new(st, PL_stashpad + basecop->cop_stashoff))
527 st->total_size += sizeof(PL_stashpad[basecop->cop_stashoff]);
528 #endif
529 #else
523530 sv_size(aTHX_ st, (SV *)basecop->cop_filegv, SOME_RECURSION);
524531 #endif
525532
659666 #endif
660667 };
661668
669 #ifdef PadlistNAMES
670 static void
671 padlist_size(pTHX_ struct state *const st, const PADLIST * const padl,
672 const int recurse) {
673 SSize_t i;
674 if (!check_new(st, padl))
675 return;
676 /* This relies on PADNAMELIST and PAD being typedefed to AV. If that
677 ever changes, this code will need an update. */
678 st->total_size += sizeof(PADLIST);
679 sv_size(aTHX_ st, (SV*)PadlistNAMES(padl), recurse);
680 i = PadlistMAX(padl) + 1;
681 st->total_size += sizeof(PAD*) * i;
682 while (--i)
683 sv_size(aTHX_ st, (SV*)PadlistARRAY(padl)[i], recurse);
684 }
685 #else
686 static void
687 padlist_size(pTHX_ struct state *const st, const AV * const padl,
688 const int recurse) {
689 sv_size(aTHX_ st, (SV*)padl, recurse);
690 }
691 #endif
692
662693 static void
663694 sv_size(pTHX_ struct state *const st, const SV * const orig_thing,
664695 const int recurse) {
784815
785816
786817 case SVt_PVFM: TAG;
787 sv_size(aTHX_ st, (SV *)CvPADLIST(thing), SOME_RECURSION);
818 padlist_size(aTHX_ st, CvPADLIST(thing), SOME_RECURSION);
788819 sv_size(aTHX_ st, (SV *)CvOUTSIDE(thing), recurse);
789820
790821 if (st->go_yell && !st->fm_whine) {
797828 sv_size(aTHX_ st, (SV *)CvSTASH(thing), SOME_RECURSION);
798829 sv_size(aTHX_ st, (SV *)SvSTASH(thing), SOME_RECURSION);
799830 sv_size(aTHX_ st, (SV *)CvGV(thing), SOME_RECURSION);
800 sv_size(aTHX_ st, (SV *)CvPADLIST(thing), SOME_RECURSION);
831 padlist_size(aTHX_ st, CvPADLIST(thing), SOME_RECURSION);
801832 sv_size(aTHX_ st, (SV *)CvOUTSIDE(thing), recurse);
802833 if (CvISXSUB(thing)) {
803834 sv_size(aTHX_ st, cv_const_sv((CV *)thing), recurse);
804 } else {
835 } else if (CvROOT(thing)) {
805836 op_size(aTHX_ CvSTART(thing), st);
806837 op_size(aTHX_ CvROOT(thing), st);
807838 }
1313 # This allows declaration use Devel::Size ':all';
1414 %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
1515
16 $VERSION = '0.78';
16 $VERSION = '0.79';
1717
1818 XSLoader::load( __PACKAGE__);
1919
186186 Since version 0.72, Devel::Size uses a new pointer tracking mechanism
187187 that consumes far less memory than was previously the case. It does this
188188 by using a bit vector where 1 bit represents each 4- or 8-byte aligned pointer
189 (32- or 64-bit platform dependant) that could exist. Further, it segments
189 (32- or 64-bit platform dependent) that could exist. Further, it segments
190190 that bit vector and only allocates each chunk when an address is seen within
191191 that chunk. Since version 0.73, chunks are allocated in blocks of 2**16 bits
192192 (ie 8K), accessed via a 256-way tree. The tree is 2 levels deep on a 32 bit
99 /);
1010
1111 die ("Uhoh, test uses an outdated version of Devel::Size")
12 unless is ($Devel::Size::VERSION, '0.78', 'VERSION MATCHES');
12 unless is ($Devel::Size::VERSION, '0.79', 'VERSION MATCHES');
1313
1414 #############################################################################
1515 # some basic checks:
00 #!/usr/bin/perl -w
11
22 use strict;
3 use Test::More tests => 12;
3 use Test::More tests => 14;
44 use Devel::Size ':all';
55
66 sub zwapp;
1414 my $crunch_size = total_size(\&crunch);
1515
1616 cmp_ok($whack_size, '>', 0, 'CV generated at runtime has a size');
17 cmp_ok($zwapp_size, '>', $whack_size,
18 'CV stubbed at compiletime is larger (CvOUTSIDE is set and followed)');
17 if("$]" >= 5.017) {
18 cmp_ok($zwapp_size, '==', $whack_size,
19 'CV stubbed at compiletime is the same size');
20 } else {
21 cmp_ok($zwapp_size, '>', $whack_size,
22 'CV stubbed at compiletime is larger (CvOUTSIDE is set and followed)');
23 }
1924 cmp_ok(length prototype \&swoosh, '>', 0, 'prototype has a length');
2025 cmp_ok($swoosh_size, '>', $zwapp_size + length prototype \&swoosh,
2126 'prototypes add to the size');
4752 my $long_pvop = total_size(sub {goto KREEK_KREEK_CLANK_CLANK});
4853 cmp_ok($short_pvop, '>', $anon_size, 'OPc_PVOP can be measured');
4954 is($long_pvop, $short_pvop + 19, 'the only size difference is the label length');
55
56 sub bloop {
57 my $clunk = shift;
58 if (--$clunk > 0) {
59 bloop($clunk);
60 }
61 }
62
63 my $before_size = total_size(\&bloop);
64 bloop(42);
65 my $after_size = total_size(\&bloop);
66
67 cmp_ok($after_size, '>', $before_size, 'Recursion increases the PADLIST');
68
69 sub closure_with_eval {
70 my $a;
71 return sub { eval ""; $a };
72 }
73
74 sub closure_without_eval {
75 my $a;
76 return sub { require ""; $a };
77 }
78
79 if ($] > 5.017001) {
80 # Again relying too much on the core's implementation, but while that holds,
81 # this does test that CvOUTSIDE() is being followed.
82 cmp_ok(total_size(closure_with_eval()), '>',
83 total_size(closure_without_eval()) + 256,
84 'CvOUTSIDE is now NULL on cloned closures, unless they have eval');
85 } else {
86 # Seems that they differ by a few bytes on 5.8.x
87 cmp_ok(total_size(closure_with_eval()), '<=',
88 total_size(closure_without_eval()) + 256,
89 "CvOUTSIDE is set on all cloned closures, so these won't differ by much");
90 }