1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Add StompAlloc workspace alloc option

This commit is contained in:
Brian Fiete 2022-06-02 07:03:42 -07:00
parent 949bc209d3
commit a77a95b71b
7 changed files with 40 additions and 13 deletions

View file

@ -582,7 +582,7 @@
</PrecompiledHeader> </PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;BF_STOMP_EXPORT;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
<DisableSpecificWarnings> <DisableSpecificWarnings>
</DisableSpecificWarnings> </DisableSpecificWarnings>
@ -607,7 +607,7 @@
</PrecompiledHeader> </PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BFRTDBG;BP_DISABLED;BF_NO_BFAPP;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BF_STOMP_EXPORT;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
<DisableSpecificWarnings> <DisableSpecificWarnings>
</DisableSpecificWarnings> </DisableSpecificWarnings>
@ -633,7 +633,7 @@
</PrecompiledHeader> </PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BFRTDBG;BP_DISABLED;BF_NO_BFAPP;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BF_STOMP_EXPORT;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
<DisableSpecificWarnings> <DisableSpecificWarnings>
</DisableSpecificWarnings> </DisableSpecificWarnings>
@ -720,7 +720,7 @@
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BFRT_DYNAMIC;;BF_STOMP_EXPORT;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@ -742,7 +742,7 @@
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>BFRTDBG;BP_DISABLED;BF_NO_BFAPP;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BF_STOMP_EXPORT;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@ -764,7 +764,7 @@
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>BFRTDBG;BP_DISABLED;BF_NO_BFAPP;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BFRTDBG;BP_DISABLED;BF_NO_BFAPP;BF_STOMP_EXPORT;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>

View file

@ -1,4 +1,4 @@
#ifdef BF_USE_STOMP_ALLOC #if defined BF_USE_STOMP_ALLOC || defined BF_STOMP_EXPORT
#include "BeefySysLib/Common.h" #include "BeefySysLib/Common.h"
@ -166,7 +166,11 @@ public:
static std::list<SA_AllocRange> gAllocRanges; static std::list<SA_AllocRange> gAllocRanges;
static CritSect gSA_CritSect; static CritSect gSA_CritSect;
extern "C" void* StompAlloc(intptr size) extern "C"
#ifdef BF_STOMP_EXPORT
__declspec(dllexport)
#endif
void* StompAlloc(intptr size)
{ {
AutoCrit autoCrit(gSA_CritSect); AutoCrit autoCrit(gSA_CritSect);
@ -184,7 +188,11 @@ extern "C" void* StompAlloc(intptr size)
} }
} }
extern "C" void StompFree(void* addr) extern "C"
#ifdef BF_STOMP_EXPORT
__declspec(dllexport)
#endif
void StompFree(void* addr)
{ {
AutoCrit autoCrit(gSA_CritSect); AutoCrit autoCrit(gSA_CritSect);

View file

@ -1,4 +1,13 @@
#pragma once #pragma once
extern "C" void* StompAlloc(intptr size); extern "C"
extern "C" void StompFree(void* addr); #ifdef BF_STOMP_EXPORT
__declspec(dllexport)
#endif
void* StompAlloc(intptr size);
extern "C"
#ifdef BF_STOMP_EXPORT
__declspec(dllexport)
#endif
void StompFree(void* addr);

View file

@ -740,7 +740,7 @@ namespace IDE
outRt.Append(dynName ? ".dll" : ".lib"); outRt.Append(dynName ? ".dll" : ".lib");
} }
if ((workspaceOptions.mEnableObjectDebugFlags) || (workspaceOptions.mAllocType == .Debug)) if ((workspaceOptions.mEnableObjectDebugFlags) || (workspaceOptions.mAllocType == .Debug) || (workspaceOptions.mAllocType == .Stomp))
{ {
outDbg.Append("Beef", IDEApp.sRTVersionStr, "Dbg"); outDbg.Append("Beef", IDEApp.sRTVersionStr, "Dbg");
outDbg.Append((Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName) == 4) ? "32" : "64"); outDbg.Append((Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName) == 4) ? "32" : "64");

View file

@ -745,6 +745,9 @@ namespace IDE.Compiler
optionFlags |= .DebugAlloc; optionFlags |= .DebugAlloc;
mallocLinkName = ""; mallocLinkName = "";
freeLinkName = ""; freeLinkName = "";
case .Stomp:
mallocLinkName = "StompAlloc";
freeLinkName = "StompFree";
case .CRT: case .CRT:
mallocLinkName = "malloc"; mallocLinkName = "malloc";
freeLinkName = "free"; freeLinkName = "free";

View file

@ -215,6 +215,7 @@ namespace IDE
public enum AllocType public enum AllocType
{ {
Debug, Debug,
Stomp,
CRT, CRT,
JEMalloc, JEMalloc,
TCMalloc, TCMalloc,

View file

@ -733,7 +733,8 @@ namespace IDE.ui
AddPropertiesItem(category, "Preprocessor Macros", "mPreprocessorMacros"); AddPropertiesItem(category, "Preprocessor Macros", "mPreprocessorMacros");
AddPropertiesItem(category, "Incremental Build", "mIncrementalBuild"); AddPropertiesItem(category, "Incremental Build", "mIncrementalBuild");
AddPropertiesItem(category, "Intermediate Type", "mIntermediateType"); AddPropertiesItem(category, "Intermediate Type", "mIntermediateType");
var (allocCategory, allocPropEntry) = AddPropertiesItem(category, "Memory Allocator", "mAllocType"); var (allocCategory, allocPropEntry) = AddPropertiesItem(category, "Memory Allocator", "mAllocType",
scope String[] ("Debug", "Stomp (Debug)", "CRT", "JEMalloc", "TCMalloc"));
var (mallocItem, mallocPropEntry) = AddPropertiesItem(allocCategory, "Malloc", "mAllocMalloc"); var (mallocItem, mallocPropEntry) = AddPropertiesItem(allocCategory, "Malloc", "mAllocMalloc");
var (freeItem, freePropEntry) = AddPropertiesItem(allocCategory, "Free", "mAllocFree"); var (freeItem, freePropEntry) = AddPropertiesItem(allocCategory, "Free", "mAllocFree");
allocPropEntry.mOnUpdate.Add(new () => allocPropEntry.mOnUpdate.Add(new () =>
@ -758,6 +759,11 @@ namespace IDE.ui
mallocSubItem.Label = ""; mallocSubItem.Label = "";
freeSubItem.Label = ""; freeSubItem.Label = "";
} }
else if (allocType == .Stomp)
{
mallocSubItem.Label = "StompAlloc";
freeSubItem.Label = "StompFree";
}
else if (allocType == .CRT) else if (allocType == .CRT)
{ {
mallocSubItem.Label = "malloc"; mallocSubItem.Label = "malloc";