This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Tweak Peek.t
authorFather Chrysostomos <sprout@cpan.org>
Sat, 6 Sep 2014 23:22:53 +0000 (16:22 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 15 Sep 2014 13:19:33 +0000 (06:19 -0700)
commit02bd0dfcaf2882e9b8d96975db16fb4bdcdcbacf
treefad361a738cbd0f9561e4b39bf29d2b339e1afab
parent7a11f5c382a3ea35768e2f50d7dbeaed6adc2398
Tweak Peek.t

beab08741 introduced XSUB constants, but the code it added to
newATTRSUB does not set CvSTASH if there is already a CV stub.  It
does set it if there is no sub there at all (because it goes through
newCONSTSUB).

Recent changes have made constant declarations like ‘sub foo(){}’
put just a constant reference in the stash if possible, the way con-
stant.pm does.  When this gets upgraded to a typeglob, the CV is rei-
fied via newCONSTSUB, so it gets a CvSTASH pointer.

CvSTASH on a constant sub really makes no difference in practice.
It’s mostly cosmetic.

This exercises the two code paths with the oldest perl installa-
tion I have:

$ /opt/bin/perl5.8.8 -MDevel::Peek -e 'BEGIN{\&foo} sub foo(){3} Dump \&foo'
SV = RV(0x9baa18) at 0x98d580
  REFCNT = 1
  FLAGS = (TEMP,ROK)
  RV = 0x9b7398
  SV = PVCV(0x9b4810) at 0x9b7398
    REFCNT = 2
    FLAGS = (POK,pPOK,CONST)
    IV = 0
    NV = 0
    PROTOTYPE = ""
    COMP_STASH = 0x98d4a8 "main" <----------
    ROOT = 0x0
    XSUB = 0x5bb44
    XSUBANY = 10018864
    GVGV::GV = 0x98df7c "main" :: "foo"
    FILE = "-e"
    DEPTH = 0
    FLAGS = 0x200
    OUTSIDE_SEQ = 96
    PADLIST = 0x98e228
    PADNAME = 0x98e24c(0x0) PAD = 0x98e264(0x22d560)
    OUTSIDE = 0x98df34 (UNIQUE)
$ /opt/bin/perl5.8.8 -MDevel::Peek -e 'sub foo(){3} Dump \&foo'
SV = RV(0xc11018) at 0xbe3b80
  REFCNT = 1
  FLAGS = (TEMP,ROK)
  RV = 0xbe4570
  SV = PVCV(0xc0ae10) at 0xbe4570
    REFCNT = 2
    FLAGS = (POK,pPOK,CONST)
    IV = 0
    NV = 0
    PROTOTYPE = ""
    COMP_STASH = 0x0 <--------------------------
    ROOT = 0x0
    XSUB = 0x5bb44
    XSUBANY = 12469628
    GVGV::GV = 0xbe3c40 "main" :: "foo"
    FILE = "-e"
    DEPTH = 0
    FLAGS = 0x200
    OUTSIDE_SEQ = 0
    PADLIST = 0x0
    OUTSIDE = 0x0 (null)
ext/Devel-Peek/t/Peek.t