develooper Front page | perl.perl5.porters | Postings from April 2011

[perl #89188] PVBM pad constants aren't BM

From:
nick @ eris . etla . org
Date:
April 27, 2011 00:31
Subject:
[perl #89188] PVBM pad constants aren't BM
Message ID:
rt-3.6.HEAD-32285-1303677335-1440.89188-75-0@perl.org
# New Ticket Created by  nick@eris.etla.org 
# Please include the string:  [perl #89188]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=89188 >



This is a bug report for perl from nick@eris.etla.org,
generated with the help of perlbug 1.36 running under perl 5.10.0.


-----------------------------------------------------------------
[Please enter your report here]

Under ithreads:

$ ./perl -Ilib -MDevel::Peek -e 'use constant PVBM => "Foo"; my $dummy = index "Foo", PVBM; Dump(PVBM)' 
SV = PVGV(0x88cd78) at 0x84a9d0
  REFCNT = 1
  FLAGS = (PADTMP,POK,READONLY,pPOK)
  IV = 0
  NV = 0
  PV = 0x8590d8 "Foo"\0
  CUR = 3
  LEN = 8

That's very interesting, but why is it a PVGV *without* Boyer Moore data.
[That rather convoluted piece of code by Ben Morrow produces a PVBM accessible
to Perl space, something I didn't think was possible.]

At least, it does without ithreads. With ithreads, something drops the useful
part. It's an old problem:

[nicholas@dromedary perl]$ ~/Reference/5.8.0-default/bin/perl5.8.0  -MDevel::Peek -e 'use constant PVBM => "galumphing"; my $dummy = index "galumphing", PVBM; Dump(PVBM)'
SV = PVBM(0x3899800) at 0x38b9100
  REFCNT = 3
  FLAGS = (SMG,POK,READONLY,pPOK,VALID)
  UV = 0
  NV = 0
  PV = 0x3897620 "galumphing"\0
  CUR = 10
  LEN = 268
  MAGIC = 0x3861f30
    MG_VIRTUAL = &PL_vtbl_bm
    MG_TYPE = PERL_MAGIC_bm(B)
[nicholas@dromedary perl]$ ~/Reference/5.8.0-thread/bin/perl5.8.0  -MDevel::Peek -e 'use constant PVBM => "galumphing"; my $dummy = index "galumphing", PVBM; Dump(PVBM)'
SV = PVBM(0x11431430) at 0x113b4790
  REFCNT = 1
  FLAGS = (PADTMP,POK,READONLY,pPOK)
  IV = 0
  NV = 0
  PV = 0x113acb10 "galumphing"\0
  CUR = 10
  LEN = 11

Really the pad constant should either be a PV, or a PV"BM" with all the
trimmings. Using a PV"BM" that acts as plain PV is a small waste of memory.
Not using a PV"BM" is a performance loss.

Nicholas Clark

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.10.0:

Configured by nick at Sun Apr 24 21:18:40 BST 2011.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.6.35.4, archname=x86_64-linux-thread-multi
    uname='linux eris 2.6.35.4 #4 smp tue sep 21 09:54:22 bst 2010 x86_64 gnulinux '
    config_args='-des -Dusedevel -Dusethreads -Doptimize=-g -Dcc=ccache gcc -Dld=gcc -Dnoextensions=IPC/SysV Encode DB_File'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='ccache gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='4.3.2', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.7.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.7'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -g -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl 5.10.0:
    lib
    /usr/local/lib/perl5/5.10.0/x86_64-linux-thread-multi
    /usr/local/lib/perl5/5.10.0
    /usr/local/lib/perl5/site_perl/5.10.0/x86_64-linux-thread-multi
    /usr/local/lib/perl5/site_perl/5.10.0
    .

---
Environment for perl 5.10.0:
    HOME=/home/nick
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/nick/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/sbin:/sbin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash




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