develooper Front page | perl.perl5.porters | Postings from September 2014

[perl #122861] [PATCH] for storage of NVs, use "IV in sv_u in head no-body trick" where possible

Thread Previous | Thread Next
From:
bulk88
Date:
September 28, 2014 05:50
Subject:
[perl #122861] [PATCH] for storage of NVs, use "IV in sv_u in head no-body trick" where possible
Message ID:
rt-4.0.18-25578-1411883438-899.122861-75-0@perl.org
# New Ticket Created by  bulk88 
# Please include the string:  [perl #122861]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=122861 >


This is a bug report for perl from bulk88@hotmail.com,
generated with the help of perlbug 1.40 running under perl 5.21.4.


-----------------------------------------------------------------
[Please describe your issue here]

See attached patch. I am surprised Nicholas didn't do this in the 
original "IV is now bodyless" patch, and nobody else thought of it for 9 
years. I had heap corruption (a bodyless NV had free() called on it) and 
in DEBUGGING failed an existing assert on 1st try of this patch but it 
was fixed.

---------------------------------
     /* if this is zero, this is a body-less SVt_NULL, SVt_IV/SVt_RV,
        and sometimes SVt_NV */
     if (old_type_details->body_size) {
#ifdef PURIFY
	safefree(old_body);
#else
	/* Note that there is an assumption that all bodies of types that
	   can be upgraded came from arenas. Only the more complex non-
	   upgradable types are allowed to be directly malloc()ed.  */
	assert(old_type_details->arena);<<<<<<<<<<<<<<<<<<<<<FAILED
	del_body((void*)((char*)old_body + old_type_details->offset),
		 &PL_body_roots[old_type]);
#endif
     }
---------------------------------

so that lead to revision of this area of code.

Also I discovered the large amount of padding in the struct 
body_details. Since on everything but Win32/Win64 body_details will be 
12 bytes long since only Mingw GCC and VC actively use non-int bitfields.

Now struct body_details is 8 bytes long each, and instead of sv_upgrade 
using struct body_details *s for vars "const struct body_details 
*new_type_details" and "const struct body_details *old_type_details", I 
would just COPY the struct to a C auto with type "struct body_details" 
not type "struct body_details *" since its just 1 (Win64) or 2 (Win32) 
machine words after my changes, but only on Windows. So I wont optimize 
that.

This is from perl.h, and everything but win32.h platforms will fall back 
to this type for bitfields

---------------------------------
/* macros to define bit-fields in structs. */
#ifndef PERL_BITFIELD8
#  define PERL_BITFIELD8 unsigned
#endif
#ifndef PERL_BITFIELD16
#  define PERL_BITFIELD16 unsigned
#endif
#ifndef PERL_BITFIELD32
#  define PERL_BITFIELD32 unsigned
#endif
-----------------------------------

Since I really dont like to use Unix CC unless I have to (due to Tux, I 
can't say I dont have access to a Unix CC, thanks Tux), bitfields 
smaller than type int remains unoptimized in everything but Win32/64.

Also in theory a 32 bit Perl with 32 bit NVs (type float) will do this 
optimization but I dont think anyone has ever tried to build a Perl with 
32 bit NVs. Also it won't work on __float128 and 80 bit "long double" 
platforms for obvious reasons.

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

Configured by Owner at Thu Sep 18 12:08:58 2014.

Summary of my perl5 (revision 5 version 21 subversion 4) configuration:
        Derived from: 7d2b2edb94ab56333b9049a3e26d15ea18445512
        Ancestor: 19be3be6968e2337bcdfe480693fff795ecd1304
        Platform:
          osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
          uname=''
          config_args='undef'
          hint=recommended, useposix=true, d_sigaction=undef
          useithreads=define, usemultiplicity=define
          use64bitint=undef, use64bitall=undef, uselongdouble=undef
          usemymalloc=n, bincompat5005=undef
        Compiler:
          cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -DWIN32
-D_CONSOLE -DNO_STRICT  -DPERL_TEXTMODE_SCRIPTS
-DPERL_HASH_FUNC_ONE_AT_A_TIME -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T',
          optimize='-O1 -MD -Zi -DNDEBUG',
          cppflags='-DWIN32'
          ccversion='12.00.8168', gccversion='', gccosandvers=''
          intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
          d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8,
longdblkind=0
          ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='__int64',
lseeksize=8
          alignbytes=8, prototype=define
        Linker and Libraries:
          ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf
-libpath:"c:\perl521\lib\CORE"  -machine:x86'
          libpth=C:\PROGRA~1\MIAF9D~1\VC98\lib
          libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
          perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
          libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl521.lib
          gnulibc_version=''
        Dynamic Linking:
          dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
          cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt:ref,icf  -libpath:"c:\perl521\lib\CORE"  -machine:x86'

Locally applied patches:
          uncommitted-changes
          a0fe7a7e75de29e59f1da0d6822dc06e5be658fe
          a261faffee83d0145642ab5d1d046c9f813bc497
          6506ab86ad1602a9ca720fcd30446dce1461d23d
          7d2b2edb94ab56333b9049a3e26d15ea18445512

---
@INC for perl 5.21.4:
          lib
          C:/perl521/srcnew/lib
          .

---
Environment for perl 5.21.4:
          HOME (unset)
          LANG (unset)
          LANGUAGE (unset)
          LD_LIBRARY_PATH (unset)
          LOGDIR (unset)
          PATH=
          PERL_BADLANG (unset)
          PERL_JSON_BACKEND=Cpanel::JSON::XS
          PERL_YAML_BACKEND=YAML
          SHELL (unset)









Thread Previous | Thread Next


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