Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] smoke-me/bulk88/w32_vmem_cleanup #15129

Closed
p5pRT opened this issue Jan 13, 2016 · 8 comments
Closed

[PATCH] smoke-me/bulk88/w32_vmem_cleanup #15129

p5pRT opened this issue Jan 13, 2016 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 13, 2016

Migrated from rt.perl.org#127260 (status was 'open')

Searchable as RT127260$

@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2016

From @bulk88

Created by @bulk88

See branch in smoke-me/bulk88/w32_vmem_cleanup The branch is a bunch of
improvements related to
http​://www.nntp.perl.org/group/perl.perl5.porters/2016/01/msg233685.html
but not actually changing the design of the memory allocator (linked
lists creating memory pools out of the singular CRT "malloc" allocator).

Perl Info

Flags:
         category=core
         severity=low

Site configuration information for perl 5.23.5:

Configured by Owner at Sun Oct 25 19:14:27 2015.

Summary of my perl5 (revision 5 version 23 subversion 5) configuration:
       Derived from: 644207b7a8ff7a2b1661c05a7f9ac2df9a5dad91
       Platform:
         osname=MSWin32, osvers=6.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 -GL 
-DWIN32 -D_CONSOLE -DNO_STRICT -D_CRT_SECURE_NO_DEPRECATE 
-D_CRT_NONSTDC_NO_DEPRECATE  -DPERL_TEXTMODE_SCRIPTS 
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS',
         optimize='-O1 -MD -Zi -DNDEBUG -GL',
         cppflags='-DWIN32'
         ccversion='18.00.31101', gccversion='', gccosandvers=''
         intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234, 
doublekind=3
         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 
-ltcg         -libpath:"c:\p523\lib\CORE"         -machine:x86 
"/manifestdependency:type='Win32' 
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' 
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' 
language='*'" -subsystem:console,"5.01"'
         libpth=\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=perl523.lib
         gnulibc_version=''
       Dynamic Linking:
         dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
         cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug 
-opt:ref,icf -ltcg         -libpath:"c:\p523\lib\CORE"  -machine:x86 
"/manifestdependency:type='Win32' 
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' 
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' 
language='*'" -subsystem:console,"5.01"'

Locally applied patches:
         uncommitted-changes


@INC for perl 5.23.5:
         C:/p523/site/lib
         C:/p523/lib
         .


Environment for perl 5.23.5:
         HOME (unset)
         LANG (unset)
         LANGUAGE (unset)
         LD_LIBRARY_PATH (unset)
         LOGDIR (unset)
         PATH=C:\p523\site\bin;C:\p523\bin;C:\Program Files\ActiveState 
Komodo Edit 
9\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program 
Files\TortoiseGit\bin;C:\Program Files\Microsoft Windows Performance 
Toolkit\;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;C:\Program 
Files\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program 
Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft 
SDKs\TypeScript\1.0\;C:\Program Files\TortoiseHg\;
         PERL_BADLANG (unset)
         SHELL (unset)






@p5pRT
Copy link
Author

p5pRT commented Jan 14, 2016

From @tonycoz

On Wed Jan 13 14​:00​:38 2016, bulk88 wrote​:

See branch in smoke-me/bulk88/w32_vmem_cleanup The branch is a bunch
of
improvements related to
http​://www.nntp.perl.org/group/perl.perl5.porters/2016/01/msg233685.html
but not actually changing the design of the memory allocator (linked
lists creating memory pools out of the singular CRT "malloc"
allocator).

That first commit should be split into 6 or 7 separate commits.

Attached your commits so people won't need to look at the (ephemeral) smoke-me branch.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jan 14, 2016

From @tonycoz

0001-VMem-refactor-part-1-Parse-mem-pool-removal.patch
From 7aec53282afad11801cbd06077ccd85b92e1fc79 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Wed, 13 Jan 2016 00:27:15 -0500
Subject: [PATCH 1/2] VMem refactor part 1+Parse mem pool removal

-Add ReleaseVoid, since void Release(void) and long Release(void) in the
 same class are illegal in C++ (error C2556). ReleaseVoid avoids saving the new refcount
 to return it later, around a function class. This removes instructions to
 save and restore nonvol registers. "long Release(void)" is optimized out
 of the perl523.dll binary by CC/LD.
-Remove "Parse" memory pool, it seems to have never been used since it was
 introduced in commit 7766f1371a in 5.00563, removing "Parse" removes
 vtables, C++ obj members, func args, machine code, runtime memory, etc
 associated with the Parse memory pool. NewWare is untestable by me.
-Add a test that "free to wrong pool" doesn't accidentally stop working.
 Future refactoring of VMem class might cause "free to wrong pool" to
 accidentally stop catching thread mixups.
-dont aquire the VMem lock twice (call EnterCriticalSection twice) if
 using _USE_MSVCRT_MEM_ALLOC, the other allocator at the bottom has no
 serialization, and therefore _USE_MSVCRT_MEM_ALLOC doesn't need it either
 while I could narrow the scope of the locks in VMem methods and remove
 the locks in CPerlHost if using _USE_MSVCRT_MEM_ALLOC, I decided against
 it since most mallocs are per-interp/per-thread, shared memory is only for
 sub optrees and hint hashes and etc, and it is rare to compile/load perl
 code compared to running perl opcode code. With removal of the locks in
 VMem the caller (PerlMemSharedMalloc) must serialize if needed, and for
 PerlMem no locks at all are needed. This supports spliting VMem into a
 shared and non-shared class in the next commit.
-remove the 2nd "FreeLock()"/LeaveCriticalSection branch in ::Malloc,
 ::Realloc, and ::Free, remove "ptr = NULL;"/load zero instruction and
 just pass through the NULL from CRT alloc
-rearrange the code for "Free to wrong pool" so nowhere is a cheap vol reg
 and that NULL isn't saved across a function call
-add NOT_REACHED since there is no recovery from a SEGV, and remove a
 scenario where no warning would be printed on a double free, if the
 memblock was not overwritten/handed back out by the time of the 2nd free()
 and kept its owner member as NULL

Size of VC2013 32b perl523.dll's .text section before, 0xE182B bytes of
machine code, after 0xE1625 bytes.
---
 NetWare/interface.cpp               |   1 -
 NetWare/nwperlhost.h                |  69 +-----------------------
 NetWare/nwperlsys.c                 |   4 +-
 NetWare/perllib.cpp                 |  11 +---
 embed.fnc                           |   2 -
 embedvar.h                          |   1 -
 ext/XS-APItest/APItest.xs           |   8 +++
 ext/XS-APItest/t/clone-with-stack.t |  15 +++++-
 intrpvar.h                          |   1 -
 iperlsys.h                          |  26 ---------
 makedef.pl                          |   1 -
 perl.c                              |   3 +-
 proto.h                             |   8 +--
 sv.c                                |   4 +-
 win32/perlhost.h                    | 104 ++----------------------------------
 win32/perllib.c                     |  12 +----
 win32/vmem.h                        |  57 ++++++++++++--------
 17 files changed, 74 insertions(+), 253 deletions(-)

diff --git a/NetWare/interface.cpp b/NetWare/interface.cpp
index aef71f9..41643bb 100644
--- a/NetWare/interface.cpp
+++ b/NetWare/interface.cpp
@@ -151,7 +151,6 @@ int RunPerl(int argc, char **argv, char **env)
 					new_perl = perl_clone_using(my_perl, 1,
 										h->m_pHostperlMem,
 										h->m_pHostperlMemShared,
-										h->m_pHostperlMemParse,
 										h->m_pHostperlEnv,
 										h->m_pHostperlStdIO,
 										h->m_pHostperlLIO,
diff --git a/NetWare/nwperlhost.h b/NetWare/nwperlhost.h
index c69e554..1cfab2e 100644
--- a/NetWare/nwperlhost.h
+++ b/NetWare/nwperlhost.h
@@ -52,7 +52,7 @@ class CPerlHost
 public:
     CPerlHost(void);
     CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
-		 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
+		 struct IPerlEnv** ppEnv,
 		 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
 		 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
 		 struct IPerlProc** ppProc);
@@ -61,7 +61,6 @@ public:
 
     static CPerlHost* IPerlMem2Host(struct IPerlMem* piPerl);
     static CPerlHost* IPerlMemShared2Host(struct IPerlMem* piPerl);
-    static CPerlHost* IPerlMemParse2Host(struct IPerlMem* piPerl);
     static CPerlHost* IPerlEnv2Host(struct IPerlEnv* piPerl);
     static CPerlHost* IPerlStdIO2Host(struct IPerlStdIO* piPerl);
     static CPerlHost* IPerlLIO2Host(struct IPerlLIO* piPerl);
@@ -90,18 +89,6 @@ public:
 	return lpVoid;
     };
 
-/* IPerlMemParse */
-    inline void* MallocParse(size_t size) { return m_pVMemParse->Malloc(size); };
-    inline void* ReallocParse(void* ptr, size_t size) { return m_pVMemParse->Realloc(ptr, size); };
-    inline void FreeParse(void* ptr) { m_pVMemParse->Free(ptr); };
-    inline void* CallocParse(size_t num, size_t size)
-    {
-	size_t count = num*size;
-	void* lpVoid = MallocParse(count);
-
-	return lpVoid;
-    };
-
 /* IPerlEnv */
     char *Getenv(const char *varname);
     int Putenv(const char *envstring);
@@ -132,7 +119,6 @@ public:
 
     struct IPerlMem	    m_hostperlMem;
     struct IPerlMem	    m_hostperlMemShared;
-    struct IPerlMem	    m_hostperlMemParse;
     struct IPerlEnv	    m_hostperlEnv;
     struct IPerlStdIO	    m_hostperlStdIO;
     struct IPerlLIO	    m_hostperlLIO;
@@ -142,7 +128,6 @@ public:
 
     struct IPerlMem*	    m_pHostperlMem;
     struct IPerlMem*	    m_pHostperlMemShared;
-    struct IPerlMem*	    m_pHostperlMemParse;
     struct IPerlEnv*	    m_pHostperlEnv;
     struct IPerlStdIO*	    m_pHostperlStdIO;
     struct IPerlLIO*	    m_pHostperlLIO;
@@ -154,7 +139,6 @@ protected:
 
     VMem*   m_pVMem;
     VMem*   m_pVMemShared;
-    VMem*   m_pVMemParse;
 };
 
 
@@ -170,11 +154,6 @@ inline CPerlHost* IPerlMemShared2Host(struct IPerlMem* piPerl)
     return STRUCT2PTR(piPerl, m_hostperlMemShared);
 }
 
-inline CPerlHost* IPerlMemParse2Host(struct IPerlMem* piPerl)
-{
-    return STRUCT2PTR(piPerl, m_hostperlMemParse);
-}
-
 inline CPerlHost* IPerlEnv2Host(struct IPerlEnv* piPerl)
 {
     return STRUCT2PTR(piPerl, m_hostperlEnv);
@@ -276,41 +255,6 @@ struct IPerlMem perlMemShared =
 };
 
 #undef IPERL2HOST
-#define IPERL2HOST(x) IPerlMemParse2Host(x)
-
-/* IPerlMemParse */
-void*
-PerlMemParseMalloc(struct IPerlMem* piPerl, size_t size)
-{
-    return IPERL2HOST(piPerl)->MallocParse(size);
-}
-void*
-PerlMemParseRealloc(struct IPerlMem* piPerl, void* ptr, size_t size)
-{
-    return IPERL2HOST(piPerl)->ReallocParse(ptr, size);
-}
-void
-PerlMemParseFree(struct IPerlMem* piPerl, void* ptr)
-{
-    IPERL2HOST(piPerl)->FreeParse(ptr);
-}
-void*
-PerlMemParseCalloc(struct IPerlMem* piPerl, size_t num, size_t size)
-{
-    return IPERL2HOST(piPerl)->CallocParse(num, size);
-}
-
-
-struct IPerlMem perlMemParse =
-{
-    PerlMemParseMalloc,
-    PerlMemParseRealloc,
-    PerlMemParseFree,
-    PerlMemParseCalloc,
-};
-
-
-#undef IPERL2HOST
 #define IPERL2HOST(x) IPerlEnv2Host(x)
 
 /* IPerlEnv */
@@ -1580,11 +1524,9 @@ CPerlHost::CPerlHost(void)
 {
     m_pVMem = new VMem();
     m_pVMemShared = new VMem();
-    m_pVMemParse =  new VMem();
 
 	memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem));
 	memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
-    memcpy(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse));
     memcpy(&m_hostperlEnv, &perlEnv, sizeof(perlEnv));
     memcpy(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO));
     memcpy(&m_hostperlLIO, &perlLIO, sizeof(perlLIO));
@@ -1594,7 +1536,6 @@ CPerlHost::CPerlHost(void)
 
     m_pHostperlMem	    = &m_hostperlMem;
     m_pHostperlMemShared    = &m_hostperlMemShared;
-    m_pHostperlMemParse	    = &m_hostperlMemParse;
     m_pHostperlEnv	    = &m_hostperlEnv;
     m_pHostperlStdIO	    = &m_hostperlStdIO;
     m_pHostperlLIO	    = &m_hostperlLIO;
@@ -1615,18 +1556,16 @@ CPerlHost::CPerlHost(void)
     } STMT_END
 
 CPerlHost::CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
-		 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
+		 struct IPerlEnv** ppEnv,
 		 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
 		 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
 		 struct IPerlProc** ppProc)
 {
     m_pVMem = new VMem();
     m_pVMemShared = new VMem();
-    m_pVMemParse =  new VMem();
 
 	memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem));
     memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
-    memcpy(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse));
     memcpy(&m_hostperlEnv, &perlEnv, sizeof(perlEnv));
     memcpy(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO));
     memcpy(&m_hostperlLIO, &perlLIO, sizeof(perlLIO));
@@ -1636,7 +1575,6 @@ CPerlHost::CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
 
     SETUPEXCHANGE(ppMem,	m_pHostperlMem,		m_hostperlMem);
     SETUPEXCHANGE(ppMemShared,	m_pHostperlMemShared,	m_hostperlMemShared);
-    SETUPEXCHANGE(ppMemParse,	m_pHostperlMemParse,	m_hostperlMemParse);
     SETUPEXCHANGE(ppEnv,	m_pHostperlEnv,		m_hostperlEnv);
     SETUPEXCHANGE(ppStdIO,	m_pHostperlStdIO,	m_hostperlStdIO);
     SETUPEXCHANGE(ppLIO,	m_pHostperlLIO,		m_hostperlLIO);
@@ -1650,7 +1588,6 @@ CPerlHost::CPerlHost(const CPerlHost& host)
 {
 	memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem));
     memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
-    memcpy(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse));
     memcpy(&m_hostperlEnv, &perlEnv, sizeof(perlEnv));
     memcpy(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO));
     memcpy(&m_hostperlLIO, &perlLIO, sizeof(perlLIO));
@@ -1660,7 +1597,6 @@ CPerlHost::CPerlHost(const CPerlHost& host)
 
     m_pHostperlMem	    = &m_hostperlMem;
     m_pHostperlMemShared    = &m_hostperlMemShared;
-    m_pHostperlMemParse	    = &m_hostperlMemParse;
     m_pHostperlEnv	    = &m_hostperlEnv;
     m_pHostperlStdIO	    = &m_hostperlStdIO;
     m_pHostperlLIO	    = &m_hostperlLIO;
@@ -1672,7 +1608,6 @@ CPerlHost::CPerlHost(const CPerlHost& host)
 
 CPerlHost::~CPerlHost(void)
 {
-	if ( m_pVMemParse ) delete m_pVMemParse;
 	if ( m_pVMemShared ) delete m_pVMemShared;
 	if ( m_pVMem ) delete m_pVMem;
 }
diff --git a/NetWare/nwperlsys.c b/NetWare/nwperlsys.c
index 32c15cb..b73a79c 100644
--- a/NetWare/nwperlsys.c
+++ b/NetWare/nwperlsys.c
@@ -89,7 +89,6 @@ perl_alloc(void)
 	fnInsertHashListAddrs(m_allocList, FALSE);
  	my_perl = perl_alloc_using(&perlMem,
 				   &perlMem,
-				   NULL,
 				   &perlEnv,
 				   &perlStdIO,
 				   &perlLIO,
@@ -115,7 +114,7 @@ perl_alloc(void)
 ==============================================================================================*/
 EXTERN_C PerlInterpreter*
 perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
-		 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
+		 struct IPerlEnv** ppEnv,
 		 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
 		 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
 		 struct IPerlProc** ppProc)
@@ -170,7 +169,6 @@ perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
 		lpProc=*ppProc;
 	my_perl = perl_alloc_using(lpMem,
 				   lpMem,
-				   NULL,
 				   lpEnv,
 				   lpStdio,
 				   lpLIO,
diff --git a/NetWare/perllib.cpp b/NetWare/perllib.cpp
index 32f8ed2..04f76b3 100644
--- a/NetWare/perllib.cpp
+++ b/NetWare/perllib.cpp
@@ -51,7 +51,6 @@
 EXTERN_C void
 perl_get_host_info(struct IPerlMemInfo* perlMemInfo,
 		   struct IPerlMemInfo* perlMemSharedInfo,
-		   struct IPerlMemInfo* perlMemParseInfo,
 		   struct IPerlEnvInfo* perlEnvInfo,
 		   struct IPerlStdIOInfo* perlStdIOInfo,
 		   struct IPerlLIOInfo* perlLIOInfo,
@@ -67,10 +66,6 @@ perl_get_host_info(struct IPerlMemInfo* perlMemInfo,
 	Copy(&perlMem, &perlMemSharedInfo->perlMemList, perlMemSharedInfo->nCount, void*);
 	perlMemSharedInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
     }
-    if (perlMemParseInfo) {
-	Copy(&perlMem, &perlMemParseInfo->perlMemList, perlMemParseInfo->nCount, void*);
-	perlMemParseInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
-    }
     if (perlEnvInfo) {
 	Copy(&perlEnv, &perlEnvInfo->perlEnvList, perlEnvInfo->nCount, void*);
 	perlEnvInfo->nCount = (sizeof(struct IPerlEnv)/sizeof(void*));
@@ -99,19 +94,18 @@ perl_get_host_info(struct IPerlMemInfo* perlMemInfo,
 
 EXTERN_C PerlInterpreter*
 perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
-		 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
+		 struct IPerlEnv** ppEnv,
 		 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
 		 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
 		 struct IPerlProc** ppProc)
 {
     PerlInterpreter *my_perl = NULL;
-    CPerlHost* pHost = new CPerlHost(ppMem, ppMemShared, ppMemParse, ppEnv,
+    CPerlHost* pHost = new CPerlHost(ppMem, ppMemShared, ppEnv,
 				     ppStdIO, ppLIO, ppDir, ppSock, ppProc);
 
     if (pHost) {
 	my_perl = perl_alloc_using(pHost->m_pHostperlMem,
 				   pHost->m_pHostperlMemShared,
-				   pHost->m_pHostperlMemParse,
 				   pHost->m_pHostperlEnv,
 				   pHost->m_pHostperlStdIO,
 				   pHost->m_pHostperlLIO,
@@ -136,7 +130,6 @@ perl_alloc(void)
     if (pHost) {
 	my_perl = perl_alloc_using(pHost->m_pHostperlMem,
 				   pHost->m_pHostperlMemShared,
-				   pHost->m_pHostperlMemParse,
 				   pHost->m_pHostperlEnv,
 				   pHost->m_pHostperlStdIO,
 				   pHost->m_pHostperlLIO,
diff --git a/embed.fnc b/embed.fnc
index 178892e..0a81417 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -150,7 +150,6 @@
 Ano	|PerlInterpreter*|perl_alloc_using \
 				|NN struct IPerlMem *ipM \
 				|NN struct IPerlMem *ipMS \
-				|NN struct IPerlMem *ipMP \
 				|NN struct IPerlEnv *ipE \
 				|NN struct IPerlStdIO *ipStd \
 				|NN struct IPerlLIO *ipLIO \
@@ -174,7 +173,6 @@ Ano	|PerlInterpreter*|perl_clone_using \
 				|UV flags \
 				|NN struct IPerlMem* ipM \
 				|NN struct IPerlMem* ipMS \
-				|NN struct IPerlMem* ipMP \
 				|NN struct IPerlEnv* ipE \
 				|NN struct IPerlStdIO* ipStd \
 				|NN struct IPerlLIO* ipLIO \
diff --git a/embedvar.h b/embedvar.h
index c6213c0..5d03480 100644
--- a/embedvar.h
+++ b/embedvar.h
@@ -59,7 +59,6 @@
 #define PL_LIO			(vTHX->ILIO)
 #define PL_Latin1		(vTHX->ILatin1)
 #define PL_Mem			(vTHX->IMem)
-#define PL_MemParse		(vTHX->IMemParse)
 #define PL_MemShared		(vTHX->IMemShared)
 #define PL_NonL1NonFinalFold	(vTHX->INonL1NonFinalFold)
 #define PL_Posix_ptrs		(vTHX->IPosix_ptrs)
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
index 77a38c5..efbb555 100644
--- a/ext/XS-APItest/APItest.xs
+++ b/ext/XS-APItest/APItest.xs
@@ -4185,6 +4185,14 @@ test_sv_catpvf(SV *fmtsv)
         sv = sv_2mortal(newSVpvn("", 0));
         sv_catpvf(sv, fmt, 5, 6, 7, 8);
 
+# Make sure this warning/crash doesn't accidentally stop working.
+# Whether the warning can be removed one day, this test has no opinion on that.
+
+void
+test_wrong_pool()
+    CODE:
+        PerlMem_free(PerlMemShared_malloc(1));
+
 MODULE = XS::APItest PACKAGE = XS::APItest::AUTOLOADtest
 
 int
diff --git a/ext/XS-APItest/t/clone-with-stack.t b/ext/XS-APItest/t/clone-with-stack.t
index 179fba0..a2c3226 100644
--- a/ext/XS-APItest/t/clone-with-stack.t
+++ b/ext/XS-APItest/t/clone-with-stack.t
@@ -17,7 +17,7 @@ if (not $Config{'useithreads'}) {
     skip_all("clone_with_stack requires threads");
 }
 
-plan(6);
+plan(7);
 
 fresh_perl_is( <<'----', <<'====', undef, "minimal clone_with_stack" );
 use XS::APItest;
@@ -101,3 +101,16 @@ hsh: hale
 ====
 
 }
+
+{
+    my $name = 'Freeing mem block with wrong allocator results in warning';
+    fresh_perl_like ( <<'----', qr/wrong pool/, {stderr => 1}, $name);
+use XS::APItest;
+if($^O eq q|MSWin32|) {
+    require Win32API::File;
+    Win32API::File::SetErrorMode(Win32API::File::SEM_NOGPFAULTERRORBOX());
+}
+XS::APItest::test_wrong_pool();
+----
+
+}
diff --git a/intrpvar.h b/intrpvar.h
index d44f1f2..504e94a 100644
--- a/intrpvar.h
+++ b/intrpvar.h
@@ -653,7 +653,6 @@ PERLVAR(I, psig_name,	SV **)
 #if defined(PERL_IMPLICIT_SYS)
 PERLVAR(I, Mem,		struct IPerlMem *)
 PERLVAR(I, MemShared,	struct IPerlMem *)
-PERLVAR(I, MemParse,	struct IPerlMem *)
 PERLVAR(I, Env,		struct IPerlEnv *)
 PERLVAR(I, StdIO,	struct IPerlStdIO *)
 PERLVAR(I, LIO,		struct IPerlLIO *)
diff --git a/iperlsys.h b/iperlsys.h
index 86ab687..f1ca297 100644
--- a/iperlsys.h
+++ b/iperlsys.h
@@ -861,23 +861,6 @@ struct IPerlMemInfo
 
 #endif
 
-/* Parse tree memory macros */
-#define PerlMemParse_malloc(size)			    \
-	(*PL_MemParse->pMalloc)(PL_MemParse, (size))
-#define PerlMemParse_realloc(buf, size)			    \
-	(*PL_MemParse->pRealloc)(PL_MemParse, (buf), (size))
-#define PerlMemParse_free(buf)				    \
-	(*PL_MemParse->pFree)(PL_MemParse, (buf))
-#define PerlMemParse_calloc(num, size)			    \
-	(*PL_MemParse->pCalloc)(PL_MemParse, (num), (size))
-#define PerlMemParse_get_lock()				    \
-	(*PL_MemParse->pGetLock)(PL_MemParse)
-#define PerlMemParse_free_lock()			    \
-	(*PL_MemParse->pFreeLock)(PL_MemParse)
-#define PerlMemParse_is_locked()			    \
-	(*PL_MemParse->pIsLocked)(PL_MemParse)
-
-
 #else	/* PERL_IMPLICIT_SYS */
 
 /* Interpreter specific memory macros */
@@ -898,15 +881,6 @@ struct IPerlMemInfo
 #define PerlMemShared_free_lock()
 #define PerlMemShared_is_locked()		0
 
-/* Parse tree memory macros */
-#define PerlMemParse_malloc(size)	malloc((size))
-#define PerlMemParse_realloc(buf, size)	realloc((buf), (size))
-#define PerlMemParse_free(buf)		free((buf))
-#define PerlMemParse_calloc(num, size)	calloc((num), (size))
-#define PerlMemParse_get_lock()		
-#define PerlMemParse_free_lock()
-#define PerlMemParse_is_locked()	0
-
 #endif	/* PERL_IMPLICIT_SYS */
 
 /*
diff --git a/makedef.pl b/makedef.pl
index 05252cf..f6e3f85 100644
--- a/makedef.pl
+++ b/makedef.pl
@@ -274,7 +274,6 @@ else {
     ++$skip{$_} foreach qw(
 		    PL_Mem
 		    PL_MemShared
-		    PL_MemParse
 		    PL_Env
 		    PL_StdIO
 		    PL_LIO
diff --git a/perl.c b/perl.c
index b8d98ff..4df3254 100644
--- a/perl.c
+++ b/perl.c
@@ -148,7 +148,7 @@ Perl_sys_term(void)
 #ifdef PERL_IMPLICIT_SYS
 PerlInterpreter *
 perl_alloc_using(struct IPerlMem* ipM, struct IPerlMem* ipMS,
-		 struct IPerlMem* ipMP, struct IPerlEnv* ipE,
+		 struct IPerlEnv* ipE,
 		 struct IPerlStdIO* ipStd, struct IPerlLIO* ipLIO,
 		 struct IPerlDir* ipD, struct IPerlSock* ipS,
 		 struct IPerlProc* ipP)
@@ -163,7 +163,6 @@ perl_alloc_using(struct IPerlMem* ipM, struct IPerlMem* ipMS,
     Zero(my_perl, 1, PerlInterpreter);
     PL_Mem = ipM;
     PL_MemShared = ipMS;
-    PL_MemParse = ipMP;
     PL_Env = ipE;
     PL_StdIO = ipStd;
     PL_LIO = ipLIO;
diff --git a/proto.h b/proto.h
index 0128cc9..0f6ca1b 100644
--- a/proto.h
+++ b/proto.h
@@ -4051,13 +4051,13 @@ PERL_CALLCONV void	Perl_warner_nocontext(U32 err, const char* pat, ...)
 
 #endif
 #if defined(PERL_IMPLICIT_SYS)
-PERL_CALLCONV PerlInterpreter*	perl_alloc_using(struct IPerlMem *ipM, struct IPerlMem *ipMS, struct IPerlMem *ipMP, struct IPerlEnv *ipE, struct IPerlStdIO *ipStd, struct IPerlLIO *ipLIO, struct IPerlDir *ipD, struct IPerlSock *ipS, struct IPerlProc *ipP);
+PERL_CALLCONV PerlInterpreter*	perl_alloc_using(struct IPerlMem *ipM, struct IPerlMem *ipMS, struct IPerlEnv *ipE, struct IPerlStdIO *ipStd, struct IPerlLIO *ipLIO, struct IPerlDir *ipD, struct IPerlSock *ipS, struct IPerlProc *ipP);
 #define PERL_ARGS_ASSERT_PERL_ALLOC_USING	\
-	assert(ipM); assert(ipMS); assert(ipMP); assert(ipE); assert(ipStd); assert(ipLIO); assert(ipD); assert(ipS); assert(ipP)
+	assert(ipM); assert(ipMS); assert(ipE); assert(ipStd); assert(ipLIO); assert(ipD); assert(ipS); assert(ipP)
 #  if defined(USE_ITHREADS)
-PERL_CALLCONV PerlInterpreter*	perl_clone_using(PerlInterpreter *proto_perl, UV flags, struct IPerlMem* ipM, struct IPerlMem* ipMS, struct IPerlMem* ipMP, struct IPerlEnv* ipE, struct IPerlStdIO* ipStd, struct IPerlLIO* ipLIO, struct IPerlDir* ipD, struct IPerlSock* ipS, struct IPerlProc* ipP);
+PERL_CALLCONV PerlInterpreter*	perl_clone_using(PerlInterpreter *proto_perl, UV flags, struct IPerlMem* ipM, struct IPerlMem* ipMS, struct IPerlEnv* ipE, struct IPerlStdIO* ipStd, struct IPerlLIO* ipLIO, struct IPerlDir* ipD, struct IPerlSock* ipS, struct IPerlProc* ipP);
 #define PERL_ARGS_ASSERT_PERL_CLONE_USING	\
-	assert(proto_perl); assert(ipM); assert(ipMS); assert(ipMP); assert(ipE); assert(ipStd); assert(ipLIO); assert(ipD); assert(ipS); assert(ipP)
+	assert(proto_perl); assert(ipM); assert(ipMS); assert(ipE); assert(ipStd); assert(ipLIO); assert(ipD); assert(ipS); assert(ipP)
 #  endif
 #endif
 #if defined(PERL_IN_AV_C)
diff --git a/sv.c b/sv.c
index f36a724..a808c85 100644
--- a/sv.c
+++ b/sv.c
@@ -14457,7 +14457,6 @@ perl_clone(PerlInterpreter *proto_perl, UV flags)
    return perl_clone_using(proto_perl, flags,
 			    proto_perl->IMem,
 			    proto_perl->IMemShared,
-			    proto_perl->IMemParse,
 			    proto_perl->IEnv,
 			    proto_perl->IStdIO,
 			    proto_perl->ILIO,
@@ -14469,7 +14468,7 @@ perl_clone(PerlInterpreter *proto_perl, UV flags)
 PerlInterpreter *
 perl_clone_using(PerlInterpreter *proto_perl, UV flags,
 		 struct IPerlMem* ipM, struct IPerlMem* ipMS,
-		 struct IPerlMem* ipMP, struct IPerlEnv* ipE,
+		 struct IPerlEnv* ipE,
 		 struct IPerlStdIO* ipStd, struct IPerlLIO* ipLIO,
 		 struct IPerlDir* ipD, struct IPerlSock* ipS,
 		 struct IPerlProc* ipP)
@@ -14528,7 +14527,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
     /* host pointers */
     PL_Mem		= ipM;
     PL_MemShared	= ipMS;
-    PL_MemParse		= ipMP;
     PL_Env		= ipE;
     PL_StdIO		= ipStd;
     PL_LIO		= ipLIO;
diff --git a/win32/perlhost.h b/win32/perlhost.h
index 9963319..21b9da5 100644
--- a/win32/perlhost.h
+++ b/win32/perlhost.h
@@ -35,7 +35,7 @@ public:
     /* Constructors */
     CPerlHost(void);
     CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
-		 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
+		 struct IPerlEnv** ppEnv,
 		 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
 		 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
 		 struct IPerlProc** ppProc);
@@ -44,7 +44,6 @@ public:
 
     static CPerlHost* IPerlMem2Host(struct IPerlMem* piPerl);
     static CPerlHost* IPerlMemShared2Host(struct IPerlMem* piPerl);
-    static CPerlHost* IPerlMemParse2Host(struct IPerlMem* piPerl);
     static CPerlHost* IPerlEnv2Host(struct IPerlEnv* piPerl);
     static CPerlHost* IPerlStdIO2Host(struct IPerlStdIO* piPerl);
     static CPerlHost* IPerlLIO2Host(struct IPerlLIO* piPerl);
@@ -79,6 +78,7 @@ public:
     inline void GetLockShared(void) { m_pVMemShared->GetLock(); };
     inline void FreeLockShared(void) { m_pVMemShared->FreeLock(); };
     inline int IsLockedShared(void) { return m_pVMemShared->IsLocked(); };
+
     inline void* MallocShared(size_t size)
     {
 	void *result;
@@ -110,25 +110,6 @@ public:
 	return lpVoid;
     };
 
-/* IPerlMemParse */
-    /* Assume something else is using locks to mangaging serialize
-       on a batch basis
-     */
-    inline void GetLockParse(void) { m_pVMemParse->GetLock(); };
-    inline void FreeLockParse(void) { m_pVMemParse->FreeLock(); };
-    inline int IsLockedParse(void) { return m_pVMemParse->IsLocked(); };
-    inline void* MallocParse(size_t size) { return m_pVMemParse->Malloc(size); };
-    inline void* ReallocParse(void* ptr, size_t size) { return m_pVMemParse->Realloc(ptr, size); };
-    inline void FreeParse(void* ptr) { m_pVMemParse->Free(ptr); };
-    inline void* CallocParse(size_t num, size_t size)
-    {
-	size_t count = num*size;
-	void* lpVoid = MallocParse(count);
-	if (lpVoid)
-	    ZeroMemory(lpVoid, count);
-	return lpVoid;
-    };
-
 /* IPerlEnv */
     char *Getenv(const char *varname);
     int Putenv(const char *envstring);
@@ -180,14 +161,12 @@ public:
     int Execvp(const char *cmdname, const char *const *argv);
 
     inline VMem* GetMemShared(void) { m_pVMemShared->AddRef(); return m_pVMemShared; };
-    inline VMem* GetMemParse(void) { m_pVMemParse->AddRef(); return m_pVMemParse; };
     inline VDir* GetDir(void) { return m_pvDir; };
 
 public:
 
     struct IPerlMem	    m_hostperlMem;
     struct IPerlMem	    m_hostperlMemShared;
-    struct IPerlMem	    m_hostperlMemParse;
     struct IPerlEnv	    m_hostperlEnv;
     struct IPerlStdIO	    m_hostperlStdIO;
     struct IPerlLIO	    m_hostperlLIO;
@@ -197,7 +176,6 @@ public:
 
     struct IPerlMem*	    m_pHostperlMem;
     struct IPerlMem*	    m_pHostperlMemShared;
-    struct IPerlMem*	    m_pHostperlMemParse;
     struct IPerlEnv*	    m_pHostperlEnv;
     struct IPerlStdIO*	    m_pHostperlStdIO;
     struct IPerlLIO*	    m_pHostperlLIO;
@@ -212,7 +190,6 @@ protected:
     VDir*   m_pvDir;
     VMem*   m_pVMem;
     VMem*   m_pVMemShared;
-    VMem*   m_pVMemParse;
 
     DWORD   m_dwEnvCount;
     LPSTR*  m_lppEnvList;
@@ -249,11 +226,6 @@ inline CPerlHost* IPerlMemShared2Host(struct IPerlMem* piPerl)
     return STRUCT2RAWPTR(piPerl, m_hostperlMemShared);
 }
 
-inline CPerlHost* IPerlMemParse2Host(struct IPerlMem* piPerl)
-{
-    return STRUCT2RAWPTR(piPerl, m_hostperlMemParse);
-}
-
 inline CPerlHost* IPerlEnv2Host(struct IPerlEnv* piPerl)
 {
     return STRUCT2PTR(piPerl, m_hostperlEnv);
@@ -395,61 +367,6 @@ const struct IPerlMem perlMemShared =
 };
 
 #undef IPERL2HOST
-#define IPERL2HOST(x) IPerlMemParse2Host(x)
-
-/* IPerlMemParse */
-void*
-PerlMemParseMalloc(struct IPerlMem* piPerl, size_t size)
-{
-    return IPERL2HOST(piPerl)->MallocParse(size);
-}
-void*
-PerlMemParseRealloc(struct IPerlMem* piPerl, void* ptr, size_t size)
-{
-    return IPERL2HOST(piPerl)->ReallocParse(ptr, size);
-}
-void
-PerlMemParseFree(struct IPerlMem* piPerl, void* ptr)
-{
-    IPERL2HOST(piPerl)->FreeParse(ptr);
-}
-void*
-PerlMemParseCalloc(struct IPerlMem* piPerl, size_t num, size_t size)
-{
-    return IPERL2HOST(piPerl)->CallocParse(num, size);
-}
-
-void
-PerlMemParseGetLock(struct IPerlMem* piPerl)
-{
-    IPERL2HOST(piPerl)->GetLockParse();
-}
-
-void
-PerlMemParseFreeLock(struct IPerlMem* piPerl)
-{
-    IPERL2HOST(piPerl)->FreeLockParse();
-}
-
-int
-PerlMemParseIsLocked(struct IPerlMem* piPerl)
-{
-    return IPERL2HOST(piPerl)->IsLockedParse();
-}
-
-const struct IPerlMem perlMemParse =
-{
-    PerlMemParseMalloc,
-    PerlMemParseRealloc,
-    PerlMemParseFree,
-    PerlMemParseCalloc,
-    PerlMemParseGetLock,
-    PerlMemParseFreeLock,
-    PerlMemParseIsLocked,
-};
-
-
-#undef IPERL2HOST
 #define IPERL2HOST(x) IPerlEnv2Host(x)
 
 /* IPerlEnv */
@@ -1821,7 +1738,6 @@ PerlProcFork(struct IPerlProc* piPerl)
 						 CLONEf_COPY_STACKS,
 						 h->m_pHostperlMem,
 						 h->m_pHostperlMemShared,
-						 h->m_pHostperlMemParse,
 						 h->m_pHostperlEnv,
 						 h->m_pHostperlStdIO,
 						 h->m_pHostperlLIO,
@@ -1947,7 +1863,6 @@ CPerlHost::CPerlHost(void)
     m_pvDir = new VDir();
     m_pVMem = new VMem();
     m_pVMemShared = new VMem();
-    m_pVMemParse =  new VMem();
 
     m_pvDir->Init(NULL, m_pVMem);
 
@@ -1957,7 +1872,6 @@ CPerlHost::CPerlHost(void)
 
     CopyMemory(&m_hostperlMem, &perlMem, sizeof(perlMem));
     CopyMemory(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
-    CopyMemory(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse));
     CopyMemory(&m_hostperlEnv, &perlEnv, sizeof(perlEnv));
     CopyMemory(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO));
     CopyMemory(&m_hostperlLIO, &perlLIO, sizeof(perlLIO));
@@ -1967,7 +1881,6 @@ CPerlHost::CPerlHost(void)
 
     m_pHostperlMem	    = &m_hostperlMem;
     m_pHostperlMemShared    = &m_hostperlMemShared;
-    m_pHostperlMemParse	    = &m_hostperlMemParse;
     m_pHostperlEnv	    = &m_hostperlEnv;
     m_pHostperlStdIO	    = &m_hostperlStdIO;
     m_pHostperlLIO	    = &m_hostperlLIO;
@@ -1988,7 +1901,7 @@ CPerlHost::CPerlHost(void)
     } STMT_END
 
 CPerlHost::CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
-		 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
+		 struct IPerlEnv** ppEnv,
 		 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
 		 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
 		 struct IPerlProc** ppProc)
@@ -1997,7 +1910,6 @@ CPerlHost::CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
     m_pvDir = new VDir(0);
     m_pVMem = new VMem();
     m_pVMemShared = new VMem();
-    m_pVMemParse =  new VMem();
 
     m_pvDir->Init(NULL, m_pVMem);
 
@@ -2007,7 +1919,6 @@ CPerlHost::CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
 
     CopyMemory(&m_hostperlMem, &perlMem, sizeof(perlMem));
     CopyMemory(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
-    CopyMemory(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse));
     CopyMemory(&m_hostperlEnv, &perlEnv, sizeof(perlEnv));
     CopyMemory(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO));
     CopyMemory(&m_hostperlLIO, &perlLIO, sizeof(perlLIO));
@@ -2017,7 +1928,6 @@ CPerlHost::CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
 
     SETUPEXCHANGE(ppMem,	m_pHostperlMem,		m_hostperlMem);
     SETUPEXCHANGE(ppMemShared,	m_pHostperlMemShared,	m_hostperlMemShared);
-    SETUPEXCHANGE(ppMemParse,	m_pHostperlMemParse,	m_hostperlMemParse);
     SETUPEXCHANGE(ppEnv,	m_pHostperlEnv,		m_hostperlEnv);
     SETUPEXCHANGE(ppStdIO,	m_pHostperlStdIO,	m_hostperlStdIO);
     SETUPEXCHANGE(ppLIO,	m_pHostperlLIO,		m_hostperlLIO);
@@ -2033,7 +1943,6 @@ CPerlHost::CPerlHost(CPerlHost& host)
     InterlockedIncrement(&num_hosts);
     m_pVMem = new VMem();
     m_pVMemShared = host.GetMemShared();
-    m_pVMemParse =  host.GetMemParse();
 
     /* duplicate directory info */
     m_pvDir = new VDir(0);
@@ -2041,7 +1950,6 @@ CPerlHost::CPerlHost(CPerlHost& host)
 
     CopyMemory(&m_hostperlMem, &perlMem, sizeof(perlMem));
     CopyMemory(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
-    CopyMemory(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse));
     CopyMemory(&m_hostperlEnv, &perlEnv, sizeof(perlEnv));
     CopyMemory(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO));
     CopyMemory(&m_hostperlLIO, &perlLIO, sizeof(perlLIO));
@@ -2050,7 +1958,6 @@ CPerlHost::CPerlHost(CPerlHost& host)
     CopyMemory(&m_hostperlProc, &perlProc, sizeof(perlProc));
     m_pHostperlMem	    = &m_hostperlMem;
     m_pHostperlMemShared    = &m_hostperlMemShared;
-    m_pHostperlMemParse	    = &m_hostperlMemParse;
     m_pHostperlEnv	    = &m_hostperlEnv;
     m_pHostperlStdIO	    = &m_hostperlStdIO;
     m_pHostperlLIO	    = &m_hostperlLIO;
@@ -2074,9 +1981,8 @@ CPerlHost::~CPerlHost(void)
     Reset();
     InterlockedDecrement(&num_hosts);
     delete m_pvDir;
-    m_pVMemParse->Release();
-    m_pVMemShared->Release();
-    m_pVMem->Release();
+    m_pVMemShared->ReleaseVoid();
+    m_pVMem->ReleaseVoid();
 }
 
 LPSTR
diff --git a/win32/perllib.c b/win32/perllib.c
index cf7bf56..fd78bc5 100644
--- a/win32/perllib.c
+++ b/win32/perllib.c
@@ -97,7 +97,6 @@ int xcegeteuid(){ return 0;}
 EXTERN_C void
 perl_get_host_info(struct IPerlMemInfo* perlMemInfo,
 		   struct IPerlMemInfo* perlMemSharedInfo,
-		   struct IPerlMemInfo* perlMemParseInfo,
 		   struct IPerlEnvInfo* perlEnvInfo,
 		   struct IPerlStdIOInfo* perlStdIOInfo,
 		   struct IPerlLIOInfo* perlLIOInfo,
@@ -113,10 +112,6 @@ perl_get_host_info(struct IPerlMemInfo* perlMemInfo,
 	Copy(&perlMem, &perlMemSharedInfo->perlMemList, perlMemSharedInfo->nCount, void*);
 	perlMemSharedInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
     }
-    if (perlMemParseInfo) {
-	Copy(&perlMem, &perlMemParseInfo->perlMemList, perlMemParseInfo->nCount, void*);
-	perlMemParseInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
-    }
     if (perlEnvInfo) {
 	Copy(&perlEnv, &perlEnvInfo->perlEnvList, perlEnvInfo->nCount, void*);
 	perlEnvInfo->nCount = (sizeof(struct IPerlEnv)/sizeof(void*));
@@ -145,19 +140,18 @@ perl_get_host_info(struct IPerlMemInfo* perlMemInfo,
 
 EXTERN_C PerlInterpreter*
 perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
-		 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
+		 struct IPerlEnv** ppEnv,
 		 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
 		 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
 		 struct IPerlProc** ppProc)
 {
     PerlInterpreter *my_perl = NULL;
-    CPerlHost* pHost = new CPerlHost(ppMem, ppMemShared, ppMemParse, ppEnv,
+    CPerlHost* pHost = new CPerlHost(ppMem, ppMemShared, ppEnv,
 				     ppStdIO, ppLIO, ppDir, ppSock, ppProc);
 
     if (pHost) {
 	my_perl = perl_alloc_using(pHost->m_pHostperlMem,
 				   pHost->m_pHostperlMemShared,
-				   pHost->m_pHostperlMemParse,
 				   pHost->m_pHostperlEnv,
 				   pHost->m_pHostperlStdIO,
 				   pHost->m_pHostperlLIO,
@@ -180,7 +174,6 @@ perl_alloc(void)
     if (pHost) {
 	my_perl = perl_alloc_using(pHost->m_pHostperlMem,
 				   pHost->m_pHostperlMemShared,
-				   pHost->m_pHostperlMemParse,
 				   pHost->m_pHostperlEnv,
 				   pHost->m_pHostperlStdIO,
 				   pHost->m_pHostperlLIO,
@@ -337,7 +330,6 @@ perl_clone_host(PerlInterpreter* proto_perl, UV flags) {
     proto_perl = perl_clone_using(proto_perl, flags,
                         h->m_pHostperlMem,
                         h->m_pHostperlMemShared,
-                        h->m_pHostperlMemParse,
                         h->m_pHostperlEnv,
                         h->m_pHostperlStdIO,
                         h->m_pHostperlLIO,
diff --git a/win32/vmem.h b/win32/vmem.h
index c662887..957196a 100644
--- a/win32/vmem.h
+++ b/win32/vmem.h
@@ -91,6 +91,7 @@ public:
     void FreeLock(void);
     int IsLocked(void);
     long Release(void);
+    void ReleaseVoid(void);
     long AddRef(void);
 
     inline BOOL CreateOk(void)
@@ -147,15 +148,12 @@ VMem::~VMem(void)
 void* VMem::Malloc(size_t size)
 {
 #ifdef _USE_LINKED_LIST
-    GetLock();
     PMEMORY_BLOCK_HEADER ptr = (PMEMORY_BLOCK_HEADER)malloc(size+sizeof(MEMORY_BLOCK_HEADER));
-    if (!ptr) {
-	FreeLock();
-	return NULL;
+    if (ptr) {
+	LinkBlock(ptr);
+	ptr += 1;
     }
-    LinkBlock(ptr);
-    FreeLock();
-    return (ptr+1);
+    return ptr;
 #else
     return malloc(size);
 #endif
@@ -172,18 +170,14 @@ void* VMem::Realloc(void* pMem, size_t size)
 	return NULL;
     }
 
-    GetLock();
     PMEMORY_BLOCK_HEADER ptr = (PMEMORY_BLOCK_HEADER)(((char*)pMem)-sizeof(MEMORY_BLOCK_HEADER));
     UnlinkBlock(ptr);
     ptr = (PMEMORY_BLOCK_HEADER)realloc(ptr, size+sizeof(MEMORY_BLOCK_HEADER));
-    if (!ptr) {
-	FreeLock();
-	return NULL;
+    if (ptr) {
+	LinkBlock(ptr);
+	ptr += 1;
     }
-    LinkBlock(ptr);
-    FreeLock();
-
-    return (ptr+1);
+    return ptr;
 #else
     return realloc(pMem, size);
 #endif
@@ -195,23 +189,23 @@ void VMem::Free(void* pMem)
     if (pMem) {
 	PMEMORY_BLOCK_HEADER ptr = (PMEMORY_BLOCK_HEADER)(((char*)pMem)-sizeof(MEMORY_BLOCK_HEADER));
         if (ptr->owner != this) {
-	    if (ptr->owner) {
 #if 1
-	    	int *nowhere = NULL;
-	    	Perl_warn_nocontext("Free to wrong pool %p not %p",this,ptr->owner);
-            	*nowhere = 0; /* this segfault is deliberate, 
-            	                 so you can see the stack trace */
+	    Perl_warn_nocontext("Free to wrong pool %p not %p",this,ptr->owner);
+	    int *nowhere = NULL;
+	    *nowhere = 0; /* this segfault is deliberate,
+			     so you can see the stack trace */
+	    NOT_REACHED;
 #else
+	    if (ptr->owner) {
                 ptr->owner->Free(pMem);	
-#endif
 	    }
+	    /* else a double free that is ignored ??? */
 	    return;
+#endif
         }
-	GetLock();
 	UnlinkBlock(ptr);
 	ptr->owner = NULL;
 	free(ptr);
-	FreeLock();
     }
 #else /*_USE_LINKED_LIST*/
     free(pMem);
@@ -257,6 +251,14 @@ long VMem::Release(void)
     return lCount;
 }
 
+void VMem::ReleaseVoid(void)
+{
+    long lCount = InterlockedDecrement(&m_lRefCount);
+    if(!lCount)
+	delete this;
+    return;
+}
+
 long VMem::AddRef(void)
 {
     long lCount = InterlockedIncrement(&m_lRefCount);
@@ -408,6 +410,7 @@ public:
     void FreeLock(void);
     int IsLocked(void);
     long Release(void);
+    void ReleaseVoid(void);
     long AddRef(void);
 
     inline BOOL CreateOk(void)
@@ -903,6 +906,14 @@ long VMem::Release(void)
     return lCount;
 }
 
+void VMem::ReleaseVoid(void)
+{
+    long lCount = InterlockedDecrement(&m_lRefCount);
+    if(!lCount)
+	delete this;
+    return;
+}
+
 long VMem::AddRef(void)
 {
     long lCount = InterlockedIncrement(&m_lRefCount);
-- 
2.1.4

@p5pRT
Copy link
Author

p5pRT commented Jan 14, 2016

From @tonycoz

0002-VMem-refactor-part-2-split-the-class-and-inline-stor.patch
From 1b3b80d1d7773ae195cf4a72c59bf7566d19b8e8 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Wed, 13 Jan 2016 11:57:58 -0500
Subject: [PATCH 2/2] VMem refactor part 2, split the class and inline storage
 it

-Split VMem Class into a possibly serialized and refcounted child class
 that can be shared that inherits from the non-multithread compatible
 actual allocator
-Convert m_pVMem (non-shared VMem) from being a heap allocated object
 (new/malloc) to an inline object stored directly in CPerlHost. This saves
 the memory that would otherwise be used for a full VMem heap object,
 a malloc header (8 bytes on 32b), CRITICAL_SECTION	m_cs, long m_lRefCount
 and pointer slot VMem* m_pVMem are saved. Also 1 memory read instruction
 "mov ecx, [ecx+2F8h];call ?Malloc@VMem@@QAEPAXI@Z;" in PerlMemMalloc
 becomes "lea ecx, [ecx+2F8h]; call ?Malloc@VMemBasic@@QAEPAXI@Z" which is
 just addition of a constant to a register, no memory read.
-make VMem ctor non-exception throwing, the only func inside it is
 a plain C InitializeCriticalSection, this saves machine code+unwind table
 space in setting up and tearing down the exception frame
---
 win32/perlhost.h |  25 ++++--------
 win32/vdir.h     |   6 +--
 win32/vmem.h     | 116 ++++++++++++++++++++++++++++++++++++-------------------
 3 files changed, 87 insertions(+), 60 deletions(-)

diff --git a/win32/perlhost.h b/win32/perlhost.h
index 21b9da5..c135a38 100644
--- a/win32/perlhost.h
+++ b/win32/perlhost.h
@@ -58,9 +58,9 @@ public:
 
 /* IPerlMem */
     /* Locks provided but should be unnecessary as this is private pool */
-    inline void* Malloc(size_t size) { return m_pVMem->Malloc(size); };
-    inline void* Realloc(void* ptr, size_t size) { return m_pVMem->Realloc(ptr, size); };
-    inline void Free(void* ptr) { m_pVMem->Free(ptr); };
+    inline void* Malloc(size_t size) { return m_VMem.Malloc(size); };
+    inline void* Realloc(void* ptr, size_t size) { return m_VMem.Realloc(ptr, size); };
+    inline void Free(void* ptr) { m_VMem.Free(ptr); };
     inline void* Calloc(size_t num, size_t size)
     {
 	size_t count = num*size;
@@ -69,9 +69,6 @@ public:
 	    ZeroMemory(lpVoid, count);
 	return lpVoid;
     };
-    inline void GetLock(void) { m_pVMem->GetLock(); };
-    inline void FreeLock(void) { m_pVMem->FreeLock(); };
-    inline int IsLocked(void) { return m_pVMem->IsLocked(); };
 
 /* IPerlMemShared */
     /* Locks used to serialize access to the pool */
@@ -188,7 +185,7 @@ public:
 protected:
 
     VDir*   m_pvDir;
-    VMem*   m_pVMem;
+    VMemBasic   m_VMem;
     VMem*   m_pVMemShared;
 
     DWORD   m_dwEnvCount;
@@ -286,19 +283,17 @@ PerlMemCalloc(struct IPerlMem* piPerl, size_t num, size_t size)
 void
 PerlMemGetLock(struct IPerlMem* piPerl)
 {
-    IPERL2HOST(piPerl)->GetLock();
 }
 
 void
 PerlMemFreeLock(struct IPerlMem* piPerl)
 {
-    IPERL2HOST(piPerl)->FreeLock();
 }
 
 int
 PerlMemIsLocked(struct IPerlMem* piPerl)
 {
-    return IPERL2HOST(piPerl)->IsLocked();
+    return 0;
 }
 
 const struct IPerlMem perlMem =
@@ -1861,10 +1856,9 @@ CPerlHost::CPerlHost(void)
     /* Construct a host from scratch */
     InterlockedIncrement(&num_hosts);
     m_pvDir = new VDir();
-    m_pVMem = new VMem();
     m_pVMemShared = new VMem();
 
-    m_pvDir->Init(NULL, m_pVMem);
+    m_pvDir->Init(NULL, &m_VMem);
 
     m_dwEnvCount = 0;
     m_lppEnvList = NULL;
@@ -1908,10 +1902,9 @@ CPerlHost::CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
 {
     InterlockedIncrement(&num_hosts);
     m_pvDir = new VDir(0);
-    m_pVMem = new VMem();
     m_pVMemShared = new VMem();
 
-    m_pvDir->Init(NULL, m_pVMem);
+    m_pvDir->Init(NULL, &m_VMem);
 
     m_dwEnvCount = 0;
     m_lppEnvList = NULL;
@@ -1941,12 +1934,11 @@ CPerlHost::CPerlHost(CPerlHost& host)
 {
     /* Construct a host from another host */
     InterlockedIncrement(&num_hosts);
-    m_pVMem = new VMem();
     m_pVMemShared = host.GetMemShared();
 
     /* duplicate directory info */
     m_pvDir = new VDir(0);
-    m_pvDir->Init(host.GetDir(), m_pVMem);
+    m_pvDir->Init(host.GetDir(), &m_VMem);
 
     CopyMemory(&m_hostperlMem, &perlMem, sizeof(perlMem));
     CopyMemory(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
@@ -1982,7 +1974,6 @@ CPerlHost::~CPerlHost(void)
     InterlockedDecrement(&num_hosts);
     delete m_pvDir;
     m_pVMemShared->ReleaseVoid();
-    m_pVMem->ReleaseVoid();
 }
 
 LPSTR
diff --git a/win32/vdir.h b/win32/vdir.h
index 42c306b..fcc4455 100644
--- a/win32/vdir.h
+++ b/win32/vdir.h
@@ -22,7 +22,7 @@ public:
     VDir(int bManageDir = 1);
     ~VDir() {};
 
-    void Init(VDir* pDir, VMem *pMem);
+    void Init(VDir* pDir, VMemBasic *pMem);
     void SetDefaultA(char const *pDefault);
     void SetDefaultW(WCHAR const *pDefault);
     char* MapPathA(const char *pInName);
@@ -115,7 +115,7 @@ protected:
 	return (chr | 0x20)-'a';
     };
 
-    VMem *pMem;
+    VMemBasic *pMem;
     int nDefault, bManageDirectory;
     char *dirTableA[driveCount];
     char szLocalBufferA[MAX_PATH+1];
@@ -132,7 +132,7 @@ VDir::VDir(int bManageDir /* = 1 */)
     memset(dirTableW, 0, sizeof(dirTableW));
 }
 
-void VDir::Init(VDir* pDir, VMem *p)
+void VDir::Init(VDir* pDir, VMemBasic *p)
 {
     int index;
 
diff --git a/win32/vmem.h b/win32/vmem.h
index 957196a..de68ebd 100644
--- a/win32/vmem.h
+++ b/win32/vmem.h
@@ -70,29 +70,23 @@ inline void MEMODSlx(char *str, long x)
  */
 
 #ifdef _USE_LINKED_LIST
-class VMem;
+class VMemBasic;
 typedef struct _MemoryBlockHeader* PMEMORY_BLOCK_HEADER;
 typedef struct _MemoryBlockHeader {
     PMEMORY_BLOCK_HEADER    pNext;
     PMEMORY_BLOCK_HEADER    pPrev;
-    VMem *owner;
+    VMemBasic *owner;
 } MEMORY_BLOCK_HEADER, *PMEMORY_BLOCK_HEADER;
 #endif
 
-class VMem
+class VMemBasic
 {
 public:
-    VMem();
-    ~VMem();
+    VMemBasic();
+    ~VMemBasic();
     void* Malloc(size_t size);
     void* Realloc(void* pMem, size_t size);
     void Free(void* pMem);
-    void GetLock(void);
-    void FreeLock(void);
-    int IsLocked(void);
-    long Release(void);
-    void ReleaseVoid(void);
-    long AddRef(void);
 
     inline BOOL CreateOk(void)
     {
@@ -119,9 +113,22 @@ protected:
     }
 
     MEMORY_BLOCK_HEADER	m_Dummy;
-    CRITICAL_SECTION	m_cs;		// access lock
 #endif
+};
 
+class VMem: public VMemBasic
+{
+public:
+    VMem() throw();
+    ~VMem();
+    void GetLock(void);
+    void FreeLock(void);
+    int IsLocked(void);
+    long Release(void);
+    void ReleaseVoid(void);
+    long AddRef(void);
+protected:
+    CRITICAL_SECTION	m_cs;		// access lock
     long		m_lRefCount;	// number of current users
 };
 
@@ -130,22 +137,34 @@ VMem::VMem()
     m_lRefCount = 1;
 #ifdef _USE_LINKED_LIST
     InitializeCriticalSection(&m_cs);
+#endif
+}
+
+VMemBasic::VMemBasic()
+{
+#ifdef _USE_LINKED_LIST
     m_Dummy.pNext = m_Dummy.pPrev =  &m_Dummy;
     m_Dummy.owner = this;
 #endif
 }
 
-VMem::~VMem(void)
+VMemBasic::~VMemBasic(void)
 {
 #ifdef _USE_LINKED_LIST
     while (m_Dummy.pNext != &m_Dummy) {
 	Free(m_Dummy.pNext+1);
     }
+#endif
+}
+
+VMem::~VMem(void)
+{
+#ifdef _USE_LINKED_LIST
     DeleteCriticalSection(&m_cs);
 #endif
 }
 
-void* VMem::Malloc(size_t size)
+void* VMemBasic::Malloc(size_t size)
 {
 #ifdef _USE_LINKED_LIST
     PMEMORY_BLOCK_HEADER ptr = (PMEMORY_BLOCK_HEADER)malloc(size+sizeof(MEMORY_BLOCK_HEADER));
@@ -159,7 +178,7 @@ void* VMem::Malloc(size_t size)
 #endif
 }
 
-void* VMem::Realloc(void* pMem, size_t size)
+void* VMemBasic::Realloc(void* pMem, size_t size)
 {
 #ifdef _USE_LINKED_LIST
     if (!pMem)
@@ -183,7 +202,7 @@ void* VMem::Realloc(void* pMem, size_t size)
 #endif
 }
 
-void VMem::Free(void* pMem)
+void VMemBasic::Free(void* pMem)
 {
 #ifdef _USE_LINKED_LIST
     if (pMem) {
@@ -398,20 +417,14 @@ typedef struct _HeapRec
 #endif
 } HeapRec;
 
-class VMem
+class VMemBasic
 {
 public:
-    VMem();
-    ~VMem();
+    VMemBasic();
+    ~VMemBasic();
     void* Malloc(size_t size);
     void* Realloc(void* pMem, size_t size);
     void Free(void* pMem);
-    void GetLock(void);
-    void FreeLock(void);
-    int IsLocked(void);
-    long Release(void);
-    void ReleaseVoid(void);
-    long AddRef(void);
 
     inline BOOL CreateOk(void)
     {
@@ -481,8 +494,7 @@ protected:
     HeapRec		m_heaps[maxHeaps];	    // list of all non-contiguous heap areas 
     int			m_nHeaps;		    // no. of heaps in m_heaps 
     long		m_lAllocSize;		    // current alloc size
-    long		m_lRefCount;		    // number of current users
-    CRITICAL_SECTION	m_cs;			    // access lock
+
 
 #ifdef _DEBUG_MEM
     void WalkHeap(int complete);
@@ -491,9 +503,30 @@ protected:
 #endif
 };
 
+class VMem: public VMemBasic
+{
+public:
+    VMem() throw();
+    ~VMem();
+    void GetLock(void);
+    void FreeLock(void);
+    int IsLocked(void);
+    long Release(void);
+    void ReleaseVoid(void);
+    long AddRef(void);
+protected:
+    long		m_lRefCount;		    // number of current users
+    CRITICAL_SECTION	m_cs;			    // access lock
+};
+
 VMem::VMem()
 {
     m_lRefCount = 1;
+    InitializeCriticalSection(&m_cs);
+}
+
+VMemBasic::VMemBasic()
+{
 #ifndef _USE_BUDDY_BLOCKS
     BOOL bRet = (NULL != (m_hHeap = HeapCreate(HEAP_NO_SERIALIZE,
 				lAllocStart,	/* initial size of heap */
@@ -501,7 +534,6 @@ VMem::VMem()
     ASSERT(bRet);
 #endif
 
-    InitializeCriticalSection(&m_cs);
 #ifdef _DEBUG_MEM
     m_pLog = 0;
 #endif
@@ -509,14 +541,13 @@ VMem::VMem()
     Init();
 }
 
-VMem::~VMem(void)
+VMemBasic::~VMemBasic(void)
 {
 #ifndef _USE_BUDDY_BLOCKS
     ASSERT(HeapValidate(m_hHeap, HEAP_NO_SERIALIZE, NULL));
 #endif
     WALKHEAPTRACE();
 
-    DeleteCriticalSection(&m_cs);
 #ifdef _USE_BUDDY_BLOCKS
     for(int index = 0; index < m_nHeaps; ++index) {
 	VirtualFree(m_heaps[index].base, 0, MEM_RELEASE);
@@ -534,7 +565,12 @@ VMem::~VMem(void)
 #endif /* _USE_BUDDY_BLOCKS */
 }
 
-void VMem::ReInit(void)
+VMem::~VMem(void)
+{
+    DeleteCriticalSection(&m_cs);
+}
+
+void VMemBasic::ReInit(void)
 {
     for(int index = 0; index < m_nHeaps; ++index) {
 #ifdef _USE_BUDDY_BLOCKS
@@ -553,7 +589,7 @@ void VMem::ReInit(void)
     Init();
 }
 
-void VMem::Init(void)
+void VMemBasic::Init(void)
 {
 #ifdef _USE_BUDDY_BLOCKS
     PBLOCK pFreeList;
@@ -586,7 +622,7 @@ void VMem::Init(void)
     m_lAllocSize = lAllocStart;
 }
 
-void* VMem::Malloc(size_t size)
+void* VMemBasic::Malloc(size_t size)
 {
     WALKHEAP();
 
@@ -732,7 +768,7 @@ void* VMem::Malloc(size_t size)
     }
 }
 
-void* VMem::Realloc(void* block, size_t size)
+void* VMemBasic::Realloc(void* block, size_t size)
 {
     WALKHEAP();
 
@@ -809,7 +845,7 @@ void* VMem::Realloc(void* block, size_t size)
     return ((void *)ptr);
 }
 
-void VMem::Free(void* p)
+void VMemBasic::Free(void* p)
 {
     WALKHEAP();
 
@@ -921,7 +957,7 @@ long VMem::AddRef(void)
 }
 
 
-int VMem::Getmem(size_t requestSize)
+int VMemBasic::Getmem(size_t requestSize)
 {   /* returns -1 is successful 0 if not */
 #ifdef USE_BIGBLOCK_ALLOC
     BOOL bBigBlock;
@@ -1018,7 +1054,7 @@ Restart:
     return -1;
 }
 
-int VMem::HeapAdd(void* p, size_t size
+int VMemBasic::HeapAdd(void* p, size_t size
 #ifdef USE_BIGBLOCK_ALLOC
     , BOOL bBigBlock
 #endif
@@ -1097,7 +1133,7 @@ int VMem::HeapAdd(void* p, size_t size
 }
 
 
-void* VMem::Expand(void* block, size_t size)
+void* VMemBasic::Expand(void* block, size_t size)
 {
     /*
      * Disallow negative or zero sizes.
@@ -1181,7 +1217,7 @@ void* VMem::Expand(void* block, size_t size)
 #ifdef _DEBUG_MEM
 #define LOG_FILENAME ".\\MemLog.txt"
 
-void VMem::MemoryUsageMessage(char *str, long x, long y, int c)
+void VMemBasic::MemoryUsageMessage(char *str, long x, long y, int c)
 {
     char szBuffer[512];
     if(str) {
@@ -1199,7 +1235,7 @@ void VMem::MemoryUsageMessage(char *str, long x, long y, int c)
     }
 }
 
-void VMem::WalkHeap(int complete)
+void VMemBasic::WalkHeap(int complete)
 {
     if(complete) {
 	MemoryUsageMessage(NULL, 0, 0, 0);
-- 
2.1.4

@p5pRT
Copy link
Author

p5pRT commented Jan 14, 2016

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jan 14, 2016

From @bulk88

On Wed Jan 13 16​:07​:10 2016, tonyc wrote​:

That first commit should be split into 6 or 7 separate commits.

If I split part 1, half of the commits would be less than 5 lines, and a waste of space in the git log. Part 2 was so large/drastic API changes I knew had to be another commit, otherwise I wouldn't understand it or be able to mentally connect the diff hunks to the commit message body. I can connect the diff hunks in part 1 to the correct "-".

Also the 7 commits from splitting up part 1 would add nicely to the "top committer for 2016 contest". Currently I am #12 in 12 month commits https​://www.openhub.net/p/perl/contributors?query=&time_span=12+months&sort=twelve_month_commits and #23 in all time commits https://www.openhub.net/p/perl/contributors?page=1&query=&sort=commits&time_span=12+months , if I turn each "-" commit section into a separate commit, this branch will be 10 commits, which will make me tie ALH for the #10 spot. On hindsight if I split up http​://perl5.git.perl.org/perl.git/commit/3bdc51af3f9be1ab22a176fefca16c329755b094 http​://perl5.git.perl.org/perl.git/commit/d89ea36076afa0a17a3faa7cb33a1c9c215a26eb http​://perl5.git.perl.org/perl.git/commit/d67e180c79c65d7f57c566e833b50b24b5de336d and http​://perl5.git.perl.org/perl.git/commit/c2c7bda0885d19e01f0d998f22d2248d7663e957 , 4 commits would've been 40, FORTY, commits on one branch. With a couple other branches/patches in the queue (on RT) to be applied, I will easily jump over bingos and get the #8 spot in the next month. If I really up my gameplan, I see myself winning #2 in 2016 but the code freeze will put that on hold till June. KHW just can't be beaten since I dont have enough hours to dedicate to winning the P5P commit game. I am happy to settle for #2 spot.

Okay, I'll stop being silly now, many of the changes are small, and it is easier for me to record the machine code size difference and put it in the commit because many of the changes in part 1 were about deleting functions and simplifying machine code generation. The ~512 bytes in part 1 I saved wouldn't be that impressive if each commit had to have a separate before/after number. Also titling each micro commit would've been hard, "dont acquire lock twice", "remove NULL assignment" and "var liveness tweak" as titles are very vauge as to where they are, whether they are Perl or C code, and what files/functions they are changing when looking at the root git log. "VMem refactor" explains what part is being changed, and most people will never open that commit since it has nothing to do with Unix Perl/what they are interested in, "dont acquire lock twice" and "remove NULL assignment" can be anywhere in the perl source code.

Here are my estimates of number of lines changes in if I split part 1 into separate commits.

-Add ReleaseVoid, since void Release(void) and long Release(void) in the
same class are illegal in C++ (error C2556). ReleaseVoid avoids saving the new refcount
to return it later, around a function class. This removes instructions to
save and restore nonvol registers. "long Release(void)" is optimized out
of the perl523.dll binary by CC/LD.

17 lines

-Remove "Parse" memory pool, it seems to have never been used since it was
introduced in commit 7766f13 in 5.00563, removing "Parse" removes
vtables, C++ obj members, func args, machine code, runtime memory, etc
associated with the Parse memory pool. NewWare is untestable by me.

too many lines to count

-Add a test that "free to wrong pool" doesn't accidentally stop working.
Future refactoring of VMem class might cause "free to wrong pool" to
accidentally stop catching thread mixups.

23 lines

-dont aquire the VMem lock twice (call EnterCriticalSection twice) if
using _USE_MSVCRT_MEM_ALLOC, the other allocator at the bottom has no
serialization, and therefore _USE_MSVCRT_MEM_ALLOC doesn't need it either
while I could narrow the scope of the locks in VMem methods and remove
the locks in CPerlHost if using _USE_MSVCRT_MEM_ALLOC, I decided against
it since most mallocs are per-interp/per-thread, shared memory is only for
sub optrees and hint hashes and etc, and it is rare to compile/load perl
code compared to running perl opcode code. With removal of the locks in
VMem the caller (PerlMemSharedMalloc) must serialize if needed, and for
PerlMem no locks at all are needed. This supports spliting VMem into a
shared and non-shared class in the next commit.

4 lines

-remove the 2nd "FreeLock()"/LeaveCriticalSection branch in :​:Malloc,
:​:Realloc, and :​:Free, remove "ptr = NULL;"/load zero instruction and
just pass through the NULL from CRT alloc

2-4 lines

-rearrange the code for "Free to wrong pool" so nowhere is a cheap vol reg
and that NULL isn't saved across a function call

2 lines

-add NOT_REACHED since there is no recovery from a SEGV, and remove a
scenario where no warning would be printed on a double free, if the
memblock was not overwritten/handed back out by the time of the 2nd free()
and kept its owner member as NULL

2-3 lines

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Feb 10, 2016

From @tonycoz

On Wed Jan 13 17​:31​:10 2016, bulk88 wrote​:

Here are my estimates of number of lines changes in if I split part 1
into separate commits.

Several small patches are fine, we're not going to run out of commit ids any time soon.

Keeping patches small helps anyone looking back at git history understand what the change is doing, and in this case you really are making separable changes.

I did consider asking you to split up the parallel build makefile changes, but makefiles are such a pain to deal with that I didn't want to torture you with splitting them up.

In this case the changes look much simpler to separate, so I'm asking for separate patches.

Tony

@toddr
Copy link
Member

toddr commented Feb 13, 2020

@bulk88 please submit pull requests if you would like to pursue this further. Thanks!

@toddr toddr closed this as completed Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants