From 9b5cc28e76265848464f451f54fcd4d77d560097 Mon Sep 17 00:00:00 2001 From: Nicky Date: Sun, 27 Jan 2013 18:53:56 +0100 Subject: [PATCH 1/3] Refactor code. All nd*.cpp/h files are now in their own subdirectory. --- indra/llcharacter/llkeyframemotion.cpp | 2 +- indra/llcommon/CMakeLists.txt | 5 +++-- indra/llcommon/llapr.h | 2 +- indra/llcommon/llmemory.cpp | 2 +- indra/llcommon/llmemory.h | 2 +- indra/llcommon/llrefcount.h | 2 +- indra/llcommon/llsys.cpp | 2 +- indra/llcommon/{ => nd}/ndallocators.cpp | 0 indra/llcommon/{ => nd}/ndallocators.h | 0 indra/llcommon/{ => nd}/ndcallstack.h | 0 indra/llcommon/{ => nd}/ndexceptions.cpp | 0 indra/llcommon/{ => nd}/ndexceptions.h | 0 indra/llcommon/{ => nd}/ndfile.cpp | 0 indra/llcommon/{ => nd}/ndfile.h | 0 indra/llcommon/{ => nd}/ndintrin.cpp | 0 indra/llcommon/{ => nd}/ndintrin.h | 0 indra/llcommon/{ => nd}/ndlocks.h | 0 indra/llcommon/{ => nd}/ndmallocstats.cpp | 0 indra/llcommon/{ => nd}/ndmallocstats.h | 0 indra/llcommon/{ => nd}/ndmemory.h | 0 indra/llcommon/{ => nd}/ndmemorypool.cpp | 0 indra/llcommon/{ => nd}/ndmemorypool.h | 0 indra/llcommon/{ => nd}/ndobjectpool.h | 0 indra/llcommon/{ => nd}/ndpooldefines.h | 0 indra/llcommon/{ => nd}/ndstackwalk.h | 0 indra/llcommon/{ => nd}/ndstlallocator.h | 0 indra/llmessage/lldatapacker.h | 2 +- indra/llmessage/lliopipe.h | 2 +- indra/llmessage/llmessagetemplate.h | 2 +- indra/llmessage/lltemplatemessagedispatcher.cpp | 2 +- indra/llmessage/lltemplatemessagereader.cpp | 2 +- indra/llmessage/message.cpp | 2 +- indra/newview/llappviewer.cpp | 4 ++-- indra/newview/llspatialpartition.cpp | 4 ++-- indra/newview/llviewerpartsim.cpp | 4 ++-- 35 files changed, 21 insertions(+), 20 deletions(-) rename indra/llcommon/{ => nd}/ndallocators.cpp (100%) rename indra/llcommon/{ => nd}/ndallocators.h (100%) rename indra/llcommon/{ => nd}/ndcallstack.h (100%) rename indra/llcommon/{ => nd}/ndexceptions.cpp (100%) rename indra/llcommon/{ => nd}/ndexceptions.h (100%) rename indra/llcommon/{ => nd}/ndfile.cpp (100%) rename indra/llcommon/{ => nd}/ndfile.h (100%) rename indra/llcommon/{ => nd}/ndintrin.cpp (100%) rename indra/llcommon/{ => nd}/ndintrin.h (100%) rename indra/llcommon/{ => nd}/ndlocks.h (100%) rename indra/llcommon/{ => nd}/ndmallocstats.cpp (100%) rename indra/llcommon/{ => nd}/ndmallocstats.h (100%) rename indra/llcommon/{ => nd}/ndmemory.h (100%) rename indra/llcommon/{ => nd}/ndmemorypool.cpp (100%) rename indra/llcommon/{ => nd}/ndmemorypool.h (100%) rename indra/llcommon/{ => nd}/ndobjectpool.h (100%) rename indra/llcommon/{ => nd}/ndpooldefines.h (100%) rename indra/llcommon/{ => nd}/ndstackwalk.h (100%) rename indra/llcommon/{ => nd}/ndstlallocator.h (100%) diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index cc27b9e8d2..01217925a3 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -44,7 +44,7 @@ #include "message.h" #include "lltimer.h" -#include // For nd::exceptions::xran +#include "nd/ndexceptions.h" // For nd::exceptions::xran //----------------------------------------------------------------------------- // Static Definitions diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index b736ad1b0d..f04e952b34 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -269,8 +269,9 @@ set(llcommon_HEADER_FILES ) # Add all nd* files. memory pool, intrinsics, ... -set(llcommon_ND_SOURCE_FILES ndallocators.cpp ndintrin.cpp ndmemorypool.cpp ndexceptions.cpp ndmallocstats.cpp ndfile.cpp ) -set(llcommon_ND_HEADER_FILES ndintrin.h ndlocks.h ndmemory.h ndmemorypool.h ndpooldefines.h ndexceptions.h ndmallocstats.h ndstackwalk.h ndcallstack.h ndobjectpool.h ndstlallocator.h ndfile.h ) + +FILE( GLOB llcommon_ND_SOURCE_FILES nd/nd*.cpp ) +FILE( GLOB llcommon_ND_HEADER_FILES nd/nd*.h ) SOURCE_GROUP( nd FILES ${llcommon_ND_SOURCE_FILES} ${llcommon_ND_HEADER_FILES} ) diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 24d416f7ce..f628419bf5 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -275,7 +275,7 @@ void LL_COMMON_API ll_apr_assert_status(apr_status_t status, apr_dso_handle_t* h extern "C" LL_COMMON_API apr_pool_t* gAPRPoolp; // Global APR memory pool -#include "ndfile.h" +#include "nd/ndfile.h" typedef ll::apr::LLAPRFile LLAPRFile; //typedef nd::apr::ndFile LLAPRFile; diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index b452796e46..1ca6be78c2 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -47,7 +47,7 @@ #include "llsys.h" #include "llframetimer.h" -#include "ndmemorypool.h" // tcmalloc replacement +#include "nd/ndmemorypool.h" // tcmalloc replacement //---------------------------------------------------------------------------- diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index a30286d227..3fbc6e022c 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -36,7 +36,7 @@ // No tcmalloc #ifdef ND_NO_TCMALLOC -#include "ndmemory.h" +#include "nd/ndmemory.h" #else inline void* ll_aligned_malloc( size_t size, int align ) diff --git a/indra/llcommon/llrefcount.h b/indra/llcommon/llrefcount.h index 6ba4802918..053347804b 100644 --- a/indra/llcommon/llrefcount.h +++ b/indra/llcommon/llrefcount.h @@ -28,7 +28,7 @@ #include -#include "ndintrin.h" // For FAA/FAD +#include "nd/ndintrin.h" // For FAA/FAD #define LL_REF_COUNT_DEBUG 0 #if LL_REF_COUNT_DEBUG diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 4bc9171ba8..63da8484eb 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -93,7 +93,7 @@ const char MEMINFO_FILE[] = "/proc/meminfo"; extern int errno; #endif -#include "ndmemorypool.h" // tcmalloc replacement +#include "nd/ndmemorypool.h" // tcmalloc replacement static const S32 CPUINFO_BUFFER_SIZE = 16383; LLCPUInfo gSysCPU; diff --git a/indra/llcommon/ndallocators.cpp b/indra/llcommon/nd/ndallocators.cpp similarity index 100% rename from indra/llcommon/ndallocators.cpp rename to indra/llcommon/nd/ndallocators.cpp diff --git a/indra/llcommon/ndallocators.h b/indra/llcommon/nd/ndallocators.h similarity index 100% rename from indra/llcommon/ndallocators.h rename to indra/llcommon/nd/ndallocators.h diff --git a/indra/llcommon/ndcallstack.h b/indra/llcommon/nd/ndcallstack.h similarity index 100% rename from indra/llcommon/ndcallstack.h rename to indra/llcommon/nd/ndcallstack.h diff --git a/indra/llcommon/ndexceptions.cpp b/indra/llcommon/nd/ndexceptions.cpp similarity index 100% rename from indra/llcommon/ndexceptions.cpp rename to indra/llcommon/nd/ndexceptions.cpp diff --git a/indra/llcommon/ndexceptions.h b/indra/llcommon/nd/ndexceptions.h similarity index 100% rename from indra/llcommon/ndexceptions.h rename to indra/llcommon/nd/ndexceptions.h diff --git a/indra/llcommon/ndfile.cpp b/indra/llcommon/nd/ndfile.cpp similarity index 100% rename from indra/llcommon/ndfile.cpp rename to indra/llcommon/nd/ndfile.cpp diff --git a/indra/llcommon/ndfile.h b/indra/llcommon/nd/ndfile.h similarity index 100% rename from indra/llcommon/ndfile.h rename to indra/llcommon/nd/ndfile.h diff --git a/indra/llcommon/ndintrin.cpp b/indra/llcommon/nd/ndintrin.cpp similarity index 100% rename from indra/llcommon/ndintrin.cpp rename to indra/llcommon/nd/ndintrin.cpp diff --git a/indra/llcommon/ndintrin.h b/indra/llcommon/nd/ndintrin.h similarity index 100% rename from indra/llcommon/ndintrin.h rename to indra/llcommon/nd/ndintrin.h diff --git a/indra/llcommon/ndlocks.h b/indra/llcommon/nd/ndlocks.h similarity index 100% rename from indra/llcommon/ndlocks.h rename to indra/llcommon/nd/ndlocks.h diff --git a/indra/llcommon/ndmallocstats.cpp b/indra/llcommon/nd/ndmallocstats.cpp similarity index 100% rename from indra/llcommon/ndmallocstats.cpp rename to indra/llcommon/nd/ndmallocstats.cpp diff --git a/indra/llcommon/ndmallocstats.h b/indra/llcommon/nd/ndmallocstats.h similarity index 100% rename from indra/llcommon/ndmallocstats.h rename to indra/llcommon/nd/ndmallocstats.h diff --git a/indra/llcommon/ndmemory.h b/indra/llcommon/nd/ndmemory.h similarity index 100% rename from indra/llcommon/ndmemory.h rename to indra/llcommon/nd/ndmemory.h diff --git a/indra/llcommon/ndmemorypool.cpp b/indra/llcommon/nd/ndmemorypool.cpp similarity index 100% rename from indra/llcommon/ndmemorypool.cpp rename to indra/llcommon/nd/ndmemorypool.cpp diff --git a/indra/llcommon/ndmemorypool.h b/indra/llcommon/nd/ndmemorypool.h similarity index 100% rename from indra/llcommon/ndmemorypool.h rename to indra/llcommon/nd/ndmemorypool.h diff --git a/indra/llcommon/ndobjectpool.h b/indra/llcommon/nd/ndobjectpool.h similarity index 100% rename from indra/llcommon/ndobjectpool.h rename to indra/llcommon/nd/ndobjectpool.h diff --git a/indra/llcommon/ndpooldefines.h b/indra/llcommon/nd/ndpooldefines.h similarity index 100% rename from indra/llcommon/ndpooldefines.h rename to indra/llcommon/nd/ndpooldefines.h diff --git a/indra/llcommon/ndstackwalk.h b/indra/llcommon/nd/ndstackwalk.h similarity index 100% rename from indra/llcommon/ndstackwalk.h rename to indra/llcommon/nd/ndstackwalk.h diff --git a/indra/llcommon/ndstlallocator.h b/indra/llcommon/nd/ndstlallocator.h similarity index 100% rename from indra/llcommon/ndstlallocator.h rename to indra/llcommon/nd/ndstlallocator.h diff --git a/indra/llmessage/lldatapacker.h b/indra/llmessage/lldatapacker.h index 525e400ef4..b2ee3e1ee2 100644 --- a/indra/llmessage/lldatapacker.h +++ b/indra/llmessage/lldatapacker.h @@ -27,7 +27,7 @@ #ifndef LL_LLDATAPACKER_H #define LL_LLDATAPACKER_H -#include "ndexceptions.h" // For ndxran +#include "nd/ndexceptions.h" // For ndxran class LLColor4; class LLColor4U; diff --git a/indra/llmessage/lliopipe.h b/indra/llmessage/lliopipe.h index 04ac853547..3f458a8549 100644 --- a/indra/llmessage/lliopipe.h +++ b/indra/llmessage/lliopipe.h @@ -35,7 +35,7 @@ #include "llsd.h" -#include "ndintrin.h" +#include "nd/ndintrin.h" class LLIOPipe; class LLPumpIO; diff --git a/indra/llmessage/llmessagetemplate.h b/indra/llmessage/llmessagetemplate.h index 675163b4bc..83c87671f9 100644 --- a/indra/llmessage/llmessagetemplate.h +++ b/indra/llmessage/llmessagetemplate.h @@ -32,7 +32,7 @@ #include "llstat.h" #include "llstl.h" -#include "ndexceptions.h" // For ndxran +#include "nd/ndexceptions.h" // For ndxran class LLMsgVarData { diff --git a/indra/llmessage/lltemplatemessagedispatcher.cpp b/indra/llmessage/lltemplatemessagedispatcher.cpp index 0849dc5d23..4e1d52f3f0 100644 --- a/indra/llmessage/lltemplatemessagedispatcher.cpp +++ b/indra/llmessage/lltemplatemessagedispatcher.cpp @@ -33,7 +33,7 @@ #include "llsd.h" #include "lltemplatemessagereader.h" -#include "ndexceptions.h" // For ndxran +#include "nd/ndexceptions.h" // For ndxran LLTemplateMessageDispatcher::LLTemplateMessageDispatcher(LLTemplateMessageReader &template_message_reader) : mTemplateMessageReader(template_message_reader) diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp index fbc0018c0b..0d876d2704 100644 --- a/indra/llmessage/lltemplatemessagereader.cpp +++ b/indra/llmessage/lltemplatemessagereader.cpp @@ -38,7 +38,7 @@ #include "v3math.h" #include "v4math.h" -#include "ndexceptions.h" // For ndxran +#include "nd/ndexceptions.h" // For ndxran LLTemplateMessageReader::LLTemplateMessageReader(message_template_number_map_t& number_template_map) : diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index 388e7c2a7a..de53d98a72 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -82,7 +82,7 @@ #include "lltransfertargetvfile.h" #include "llmemtype.h" -#include "ndexceptions.h" // For ndxran +#include "nd/ndexceptions.h" // For ndxran // Constants //const char* MESSAGE_LOG_FILENAME = "message.log"; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 594a225fd9..290a893501 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -242,8 +242,8 @@ // define a self-registering event API object #include "llappviewerlistener.h" -#include "ndmemorypool.h" // tcmalloc replacement -#include "ndmallocstats.h" // collect stats about memory allocations +#include "nd/ndmemorypool.h" // tcmalloc replacement +#include "nd/ndmallocstats.h" // collect stats about memory allocations #if (LL_LINUX || LL_SOLARIS) && LL_GTK diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index c8174ba415..ac3ea6a82c 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -54,7 +54,7 @@ #include "llglslshader.h" #include "llviewershadermgr.h" -#include "ndobjectpool.h" // For operator new/delete +#include "nd/ndobjectpool.h" // For operator new/delete static LLFastTimer::DeclareTimer FTM_FRUSTUM_CULL("Frustum Culling"); static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound"); @@ -5122,4 +5122,4 @@ void LLDrawInfo::operator delete(void* ptr) sDrawinfoPool.freeMemoryOfObject( ptr ); } -// \ No newline at end of file +// diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index 565cbdf2ca..f90bb65748 100644 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -41,7 +41,7 @@ #include "llspatialpartition.h" #include "llvovolume.h" -#include "ndobjectpool.h" // For operator new/delete +#include "nd/ndobjectpool.h" // For operator new/delete const F32 PART_SIM_BOX_SIDE = 16.f; const F32 PART_SIM_BOX_OFFSET = 0.5f*PART_SIM_BOX_SIDE; @@ -880,4 +880,4 @@ void LLViewerPart::operator delete(void* ptr) sViewerpartPool.freeMemoryOfObject( ptr ); } -// \ No newline at end of file +// From f5790d8937faee3ab35e9879e55ce78772b429bc Mon Sep 17 00:00:00 2001 From: Tonya Souther Date: Sun, 27 Jan 2013 13:50:42 -0600 Subject: [PATCH 2/3] Credits for Skills Hak and Name Short. --- indra/newview/skins/default/xui/en/floater_about.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml index 53fd2de034..55decc3fcb 100644 --- a/indra/newview/skins/default/xui/en/floater_about.xml +++ b/indra/newview/skins/default/xui/en/floater_about.xml @@ -261,7 +261,7 @@ Additional code generously contributed to Firestorm by: top_pad="10" width="435" word_wrap="true"> -Albatroz Hird, Alexie Birman, Andromeda Rage, Armin Weatherwax, Casper Warden, Chalice Yao, Cron Stardust, Damian Zhaoying, Dawa Gurbux, Felyza Wishbringer, f0rbidden, Fractured Crystal, Hitomi Tiponi, Katharine Berry, Kittin Ninetails, Kool Koolhoven, Lance Corrimal, Magne Metaverse LLC, Magus Freston, MartinRJ Fayray, Melancholy Lemon, Miguael Liamano, Mimika Oh, Mister Acacia, Mysty Saunders, Nagi Michinaga, nhede Core, NiranV Dean, Nogardrevlis Lectar, paperwork, Peyton Menges, programmtest, Qwerty Venom, Revolution Smythe, Sahkolihaa Contepomi, sal Kaligawa, Satomi Ahn, Shin Wasp, Shyotl Kuhr, Sione Lomu, Sunset Faulkes, Thickbrick Sleaford, Vaalith Jinn, Whirly Fizzle, Zwagoth Klaar and others. +Albatroz Hird, Alexie Birman, Andromeda Rage, Armin Weatherwax, Casper Warden, Chalice Yao, Cron Stardust, Damian Zhaoying, Dawa Gurbux, Felyza Wishbringer, f0rbidden, Fractured Crystal, Hitomi Tiponi, Katharine Berry, Kittin Ninetails, Kool Koolhoven, Lance Corrimal, Magne Metaverse LLC, Magus Freston, MartinRJ Fayray, Melancholy Lemon, Miguael Liamano, Mimika Oh, Mister Acacia, Mysty Saunders, Nagi Michinaga, Name Short, nhede Core, NiranV Dean, Nogardrevlis Lectar, paperwork, Peyton Menges, programmtest, Qwerty Venom, Revolution Smythe, Sahkolihaa Contepomi, sal Kaligawa, Satomi Ahn, Shin Wasp, Shyotl Kuhr, Sione Lomu, Skills Hak, Sunset Faulkes, Thickbrick Sleaford, Vaalith Jinn, Whirly Fizzle, Zwagoth Klaar and others. Date: Mon, 28 Jan 2013 00:31:48 +0100 Subject: [PATCH 3/3] New flag to control if operator new/delete should be globally changed or not. --- indra/llcommon/nd/ndallocators.cpp | 4 +++- indra/llcommon/nd/ndpooldefines.h | 35 +++++++++++++++++------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/indra/llcommon/nd/ndallocators.cpp b/indra/llcommon/nd/ndallocators.cpp index 6cc6490a62..fcd6497985 100644 --- a/indra/llcommon/nd/ndallocators.cpp +++ b/indra/llcommon/nd/ndallocators.cpp @@ -29,7 +29,7 @@ #include "ndpooldefines.h" #include "ndmemorypool.h" -#ifdef ND_NO_TCMALLOC +#if defined(ND_NO_TCMALLOC) namespace nd { namespace allocators @@ -56,6 +56,7 @@ namespace nd } } +#ifdef ND_OVERRIDE_NEW void *operator new(size_t nSize ) { return nd::allocators::malloc( nSize, 16 ); @@ -75,6 +76,7 @@ void operator delete[]( void *pMem ) { nd::allocators::free( pMem ); } +#endif #else namespace nd diff --git a/indra/llcommon/nd/ndpooldefines.h b/indra/llcommon/nd/ndpooldefines.h index 1c6d1e8c26..c5a92a39d6 100644 --- a/indra/llcommon/nd/ndpooldefines.h +++ b/indra/llcommon/nd/ndpooldefines.h @@ -32,25 +32,30 @@ #define BITS_PER_U8 (8) #define BITS_PER_U32 ( sizeof(U32) * BITS_PER_U8 ) +#define ND_OVERRIDE_NEW 0 + +// Define those to log the stacktrace for allocations with certain size. You better know what you do when enabing this, ND_OVERRIDE_NEW is best set to 1 +#if 0 + #undef ND_USE_MEMORY_POOL + #define ND_USE_MEMORY_POOL 1 + + #define LOG_ALLOCATION_STACKS + #define MIN_ALLOC_SIZE_FOR_LOG_STACK 32 + #define MAX_ALLOC_SIZE_FOR_LOG_STACK 1024 + #define LOG_STACKSIZE 16 + #define TOP_STACKS_TO_DUMP 10 +#endif + #ifdef ND_NO_TCMALLOC - #define MAX_PAGES (150) - #define POOL_CHUNK_SIZE (64) - #define POOL_CHUNK_ALIGNMENT (16) - #define PAGE_SIZE (FROM_MB(1) ) - #define BITMAP_SIZE ( PAGE_SIZE / BITS_PER_U8 / POOL_CHUNK_SIZE ) + #define MAX_PAGES (150) + #define POOL_CHUNK_SIZE (64) + #define POOL_CHUNK_ALIGNMENT (16) + #define PAGE_SIZE (FROM_MB(1) ) + #define BITMAP_SIZE ( PAGE_SIZE / BITS_PER_U8 / POOL_CHUNK_SIZE ) #else - #define MAX_PAGES (0) + #define MAX_PAGES (0) #endif #define STATS_FREQ ( 15 ) -// Define those to log the stacktrace for allocations with certain size. You better know what you do when enabing this -#if 0 - #define LOG_ALLOCATION_STACKS - #define MIN_ALLOC_SIZE_FOR_LOG_STACK 32 - #define MAX_ALLOC_SIZE_FOR_LOG_STACK 1024 - #define LOG_STACKSIZE 16 - #define TOP_STACKS_TO_DUMP 10 -#endif - #endif