develooper Front page | perl.perl5.porters | Postings from June 2015

GvFILE and GvLINE origin of globs differ on threaded vs unthreadedperl

From:
bulk88
Date:
June 30, 2015 23:23
Subject:
GvFILE and GvLINE origin of globs differ on threaded vs unthreadedperl
Message ID:
BLU436-SMTP111A5147B3C456D6142C321DFA90@phx.gbl
FILE, and LINE in the *{"_<$filename"} perl debuggger PVGV differ on 
whether perl was compiled with or without threads.

I dont believe there is any way make this difference in the 
*{"_<$filename"} globs visible in pure perl. GvFILE/GvLINE's ***sole*** 
purpose is to report
-----------------------------------------------------------------
Name "%s::%s" used only once: possible typo

(W once) Typographical errors often show up as unique variable names. If 
you had a good reason for having a unique name, then just mention it 
again somehow to suppress the message. The our declaration is also 
provided for this purpose.

NOTE: This warning detects package symbols that have been used only 
once. This means lexical variables will never trigger this warning. It 
also means that all of the package variables $c, @c, %c, as well as *c, 
&c, sub c{}, c(), and c (the filehandle or format) are considered the 
same; if a program uses $c only once but also uses any of the others it 
will not trigger this warning. Symbols beginning with an underscore and 
symbols using special identifiers (q.v. perldata) are exempt from this 
warning.
------------------------------------------------------------------
and that will never warn for "_" prefixed globs.

Unthreaded is more accurate by quoting the "require" line of the caller. 
  Threaded might be faster (1 less hash lookup per .pm loaded)/less 
memory since I have a patch which sets the filename SCALAR part of the 
glob to be a COW of the GP's FILE HEK. On unthreaded, currently the GP 
FILE HEK will never be filename scalar in the glob's SCALAR slice.

So what is the correct behavior?


----------------------------------------------------------------
BEGIN{$^P = $^P | 0x2;}
use Devel::Peek 'Dump';
use Data::Dumper;
$Data::Dumper::Sortkeys =1;
#print Dumper(\%main::);
my $xsl;
foreach(keys %main::){
     if(/XSLoader\.pm/){
         $xsl = $_;
         last;
     }
}
die "no xsl" unless $xsl;
Dump(*{$xsl});
Dump(*{$xsl}{SCALAR});
----------------------------------------------------------------
THREADED
----------------------------------------------------------------
C:\perl521\srcnewb4opt>perl -Ilib gvfile.pl
SV = PVGV(0x904408) at 0x90dc58
   REFCNT = 1
   FLAGS = (MULTI)
   NAME = "_<lib/XSLoader.pm"
   NAMELEN = 17
   GvSTASH = 0x368000    "main"
   FLAGS = 0x2
   GP = 0x905e20
     SV = 0x90dca8
     REFCNT = 1
     IO = 0x0
     FORM = 0x0
     AV = 0x90dd28
     HV = 0x91cf80
     CV = 0x0
     CVGEN = 0x0
     GPFLAGS = 0x0 ()
     LINE = 1
     FILE = "lib/XSLoader.pm"
     EGV = 0x90dc58      "_<lib/XSLoader.pm"
SV = IV(0x3681bc) at 0x3681c0
   REFCNT = 1
   FLAGS = (TEMP,ROK)
   RV = 0x90dca8
   SV = PV(0x369148) at 0x90dca8
     REFCNT = 2
     FLAGS = (POK,IsCOW,pPOK)
     PV = 0x905e6c "lib/XSLoader.pm"
     CUR = 15
     LEN = 0

C:\perl521\srcnewb4opt>
----------------------------------------------------------------
~$/opt/perl64/bin/perl5.22.0 gvfile.pl
SV = PVGV(0x8000000100036990) at 0x8000000100063c30
   REFCNT = 1
   FLAGS = (MULTI)
   NAME = "_</opt/perl64/lib/5.22.0/XSLoader.pm"
   NAMELEN = 36
   GvSTASH = 0x8000000100018c30  "main"
   FLAGS = 0x2
   GP = 0x8000000100042f90
     SV = 0x8000000100063ca8
     REFCNT = 1
     IO = 0x0
     FORM = 0x0
     AV = 0x8000000100073488
     HV = 0x8000000100063d68
     CV = 0x0
     CVGEN = 0x0
     GPFLAGS = 0x0 ()
     LINE = 1
     FILE = "/opt/perl64/lib/5.22.0/XSLoader.pm"
     EGV = 0x8000000100063c30    "_</opt/perl64/lib/5.22.0/XSLoader.pm"
SV = IV(0x8000000100018f20) at 0x8000000100018f30
   REFCNT = 1
   FLAGS = (TEMP,ROK)
   RV = 0x8000000100063ca8
   SV = PV(0x800000010001a0a8) at 0x8000000100063ca8
     REFCNT = 2
     FLAGS = (POK,pPOK)
     PV = 0x8000000100042d50 "/opt/perl64/lib/5.22.0/XSLoader.pm"\0
     CUR = 34
     LEN = 36
~$
----------------------------------------------------------------
UNTHREADED
----------------------------------------------------------------
C:\perl521\srcnewb4opt>perl gvfile.pl
SV = PVGV(0x902918) at 0x919be8
   REFCNT = 44
   FLAGS = (MULTI)
   NAME = "_<C:/perl521/srcnewb4opt/lib/XSLoader.pm"
   NAMELEN = 40
   GvSTASH = 0x366b90    "main"
   FLAGS = 0x2
   GP = 0x906148
     SV = 0x90c930
     REFCNT = 1
     IO = 0x0
     FORM = 0x0
     AV = 0x90cf90
     HV = 0x90d030
     CV = 0x0
     CVGEN = 0x0
     GPFLAGS = 0x0 ()
     LINE = 11
     FILE = "C:/perl521/srcnewb4opt/lib/Devel/Peek.pm"
     EGV = 0x919be8      "_<C:/perl521/srcnewb4opt/lib/XSLoader.pm"
SV = IV(0x366d3c) at 0x366d40
   REFCNT = 1
   FLAGS = (TEMP,ROK)
   RV = 0x90c930
   SV = PV(0x367c10) at 0x90c930
     REFCNT = 2
     FLAGS = (POK,pPOK)
     PV = 0x906180 "C:/perl521/srcnewb4opt/lib/XSLoader.pm"\0
     CUR = 38
     LEN = 40

C:\perl521\srcnewb4opt>
----------------------------------------------------------------
/opt/perl32/bin/perl5.22.0 gvfile.pl
SV = PVGV(0x4006a238) at 0x40069a98
   REFCNT = 44
   FLAGS = (MULTI)
   NAME = "_</opt/perl32/lib/5.22.0/XSLoader.pm"
   NAMELEN = 36
   GvSTASH = 0x40040850  "main"
   FLAGS = 0x2
   GP = 0x4005e370
     SV = 0x40069188
     REFCNT = 1
     IO = 0x0
     FORM = 0x0
     AV = 0x40069688
     HV = 0x40069678
     CV = 0x0
     CVGEN = 0x0
     GPFLAGS = 0x0 ()
     LINE = 11
     FILE = "/opt/perl32/lib/5.22.0/PA-RISC2.0/Devel/Peek.pm"
     EGV = 0x40069a98    "_</opt/perl32/lib/5.22.0/XSLoader.pm"
SV = IV(0x40040a6c) at 0x40040a70
   REFCNT = 1
   FLAGS = (TEMP,ROK)
   RV = 0x40069188
   SV = PV(0x40041948) at 0x40069188
     REFCNT = 2
     FLAGS = (POK,pPOK)
     PV = 0x4005e3b0 "/opt/perl32/lib/5.22.0/XSLoader.pm"\0
     CUR = 34
     LEN = 36
~$
----------------------------------------------------------------






nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About