Imported Upstream version 0.79
gregor herrmann
11 years ago
0 | 0 | Revision history for Perl extension Devel::Size. |
1 | 1 | |
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 | |
3 | 19 | [no changes] |
4 | 20 | |
5 | 21 | 0.77_51 2012-07-17 nicholas |
3 | 3 | "unknown" |
4 | 4 | ], |
5 | 5 | "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", | |
7 | 7 | "license" : [ |
8 | 8 | "perl_5" |
9 | 9 | ], |
38 | 38 | } |
39 | 39 | }, |
40 | 40 | "release_status" : "stable", |
41 | "version" : "0.78" | |
41 | "version" : "0.79" | |
42 | 42 | } |
6 | 6 | configure_requires: |
7 | 7 | ExtUtils::MakeMaker: 0 |
8 | 8 | 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' | |
10 | 10 | license: perl |
11 | 11 | meta-spec: |
12 | 12 | url: http://module-build.sourceforge.net/META-spec-v1.4.html |
20 | 20 | Test::More: 0 |
21 | 21 | XSLoader: 0 |
22 | 22 | perl: 5.005 |
23 | version: 0.78 | |
23 | version: 0.79 |
517 | 517 | #endif |
518 | 518 | #ifdef USE_ITHREADS |
519 | 519 | 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. */ | |
520 | 522 | check_new_and_strlen(st, basecop->cop_stashpv); |
521 | 523 | #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 | |
523 | 530 | sv_size(aTHX_ st, (SV *)basecop->cop_filegv, SOME_RECURSION); |
524 | 531 | #endif |
525 | 532 | |
659 | 666 | #endif |
660 | 667 | }; |
661 | 668 | |
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 | ||
662 | 693 | static void |
663 | 694 | sv_size(pTHX_ struct state *const st, const SV * const orig_thing, |
664 | 695 | const int recurse) { |
784 | 815 | |
785 | 816 | |
786 | 817 | case SVt_PVFM: TAG; |
787 | sv_size(aTHX_ st, (SV *)CvPADLIST(thing), SOME_RECURSION); | |
818 | padlist_size(aTHX_ st, CvPADLIST(thing), SOME_RECURSION); | |
788 | 819 | sv_size(aTHX_ st, (SV *)CvOUTSIDE(thing), recurse); |
789 | 820 | |
790 | 821 | if (st->go_yell && !st->fm_whine) { |
797 | 828 | sv_size(aTHX_ st, (SV *)CvSTASH(thing), SOME_RECURSION); |
798 | 829 | sv_size(aTHX_ st, (SV *)SvSTASH(thing), SOME_RECURSION); |
799 | 830 | 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); | |
801 | 832 | sv_size(aTHX_ st, (SV *)CvOUTSIDE(thing), recurse); |
802 | 833 | if (CvISXSUB(thing)) { |
803 | 834 | sv_size(aTHX_ st, cv_const_sv((CV *)thing), recurse); |
804 | } else { | |
835 | } else if (CvROOT(thing)) { | |
805 | 836 | op_size(aTHX_ CvSTART(thing), st); |
806 | 837 | op_size(aTHX_ CvROOT(thing), st); |
807 | 838 | } |
13 | 13 | # This allows declaration use Devel::Size ':all'; |
14 | 14 | %EXPORT_TAGS = ( 'all' => \@EXPORT_OK ); |
15 | 15 | |
16 | $VERSION = '0.78'; | |
16 | $VERSION = '0.79'; | |
17 | 17 | |
18 | 18 | XSLoader::load( __PACKAGE__); |
19 | 19 | |
186 | 186 | Since version 0.72, Devel::Size uses a new pointer tracking mechanism |
187 | 187 | that consumes far less memory than was previously the case. It does this |
188 | 188 | 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 | |
190 | 190 | that bit vector and only allocates each chunk when an address is seen within |
191 | 191 | that chunk. Since version 0.73, chunks are allocated in blocks of 2**16 bits |
192 | 192 | (ie 8K), accessed via a 256-way tree. The tree is 2 levels deep on a 32 bit |
9 | 9 | /); |
10 | 10 | |
11 | 11 | 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'); | |
13 | 13 | |
14 | 14 | ############################################################################# |
15 | 15 | # some basic checks: |
0 | 0 | #!/usr/bin/perl -w |
1 | 1 | |
2 | 2 | use strict; |
3 | use Test::More tests => 12; | |
3 | use Test::More tests => 14; | |
4 | 4 | use Devel::Size ':all'; |
5 | 5 | |
6 | 6 | sub zwapp; |
14 | 14 | my $crunch_size = total_size(\&crunch); |
15 | 15 | |
16 | 16 | 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 | } | |
19 | 24 | cmp_ok(length prototype \&swoosh, '>', 0, 'prototype has a length'); |
20 | 25 | cmp_ok($swoosh_size, '>', $zwapp_size + length prototype \&swoosh, |
21 | 26 | 'prototypes add to the size'); |
47 | 52 | my $long_pvop = total_size(sub {goto KREEK_KREEK_CLANK_CLANK}); |
48 | 53 | cmp_ok($short_pvop, '>', $anon_size, 'OPc_PVOP can be measured'); |
49 | 54 | 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 | } |