From d6d5d5ae1b03e3c5023498be99ee2c4410df2149 Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Tue, 23 Apr 2013 11:46:44 +0200 Subject: [PATCH] Bring back memory stat! Someone is a clobbermonster. --- indra/cmake/00-Common.cmake | 2 ++ indra/cmake/GooglePerfTools.cmake | 14 ++++++++--- indra/llcommon/llmemory.h | 34 ++++++++++---------------- indra/llplugin/slplugin/CMakeLists.txt | 1 - indra/newview/CMakeLists.txt | 1 - indra/newview/sgmemstat.cpp | 2 +- 6 files changed, 26 insertions(+), 28 deletions(-) diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 5eb78b0b2..319c9c13c 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -333,4 +333,6 @@ MARK_AS_ADVANCED( CMAKE_SHARED_LINKER_FLAGS_RELEASE ) +include(GooglePerfTools) + endif(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED) diff --git a/indra/cmake/GooglePerfTools.cmake b/indra/cmake/GooglePerfTools.cmake index 3ad669c94..d92c39ded 100644 --- a/indra/cmake/GooglePerfTools.cmake +++ b/indra/cmake/GooglePerfTools.cmake @@ -1,4 +1,5 @@ # -*- cmake -*- + include(Prebuilt) if(WORD_SIZE EQUAL 64) @@ -47,9 +48,14 @@ else (USE_GOOGLE_PERFTOOLS) endif (USE_GOOGLE_PERFTOOLS) if (NOT(DISABLE_TCMALLOC OR USE_GOOGLE_PERFTOOLS OR STANDALONE)) - message(STATUS "Building with Google TCMalloc") - set(TCMALLOC_FLAG -DLL_USE_TCMALLOC=1) - include_directories(${GOOGLE_PERFTOOLS_INCLUDE_DIR}) - set(GOOGLE_PERFTOOLS_LIBRARIES ${TCMALLOC_LIBRARIES}) + if (NOT STATUS_Building_with_Google_TCMalloc) + message(STATUS "Building with Google TCMalloc") + set(STATUS_Building_with_Google_TCMalloc true PARENT_SCOPE) + endif (NOT STATUS_Building_with_Google_TCMalloc) + set(TCMALLOC_FLAG -DLL_USE_TCMALLOC=1) + include_directories(${GOOGLE_PERFTOOLS_INCLUDE_DIR}) + set(GOOGLE_PERFTOOLS_LIBRARIES ${TCMALLOC_LIBRARIES}) set(GOOGLE_PERFTOOLS_LINKER_FLAGS ${TCMALLOC_LINKER_FLAGS}) endif() + +add_definitions(${TCMALLOC_FLAG}) \ No newline at end of file diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 8a0e0e66d..0762dc3f4 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -57,13 +57,12 @@ inline void ll_aligned_free( void* ptr ) free( ((void**)ptr)[-1] ); } -#if !LL_USE_TCMALLOC inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed with ll_aligned_free_16(). { -#if defined(LL_WINDOWS) - return _aligned_malloc(size, 16); -#elif defined(LL_DARWIN) +#if (LL_DARWIN || LL_USE_TCMALLOC) return malloc(size); // default osx malloc is 16 byte aligned. +#elif LL_WINDOWS + return _aligned_malloc(size, 16); #else void *rtn; if (LL_LIKELY(0 == posix_memalign(&rtn, 16, size))) @@ -75,10 +74,10 @@ inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed wi inline void ll_aligned_free_16(void *p) { -#if defined(LL_WINDOWS) +#if (LL_DARWIN || LL_USE_TCMALLOC) + free(p); +#elif LL_WINDOWS _aligned_free(p); -#elif defined(LL_DARWIN) - return free(p); #else free(p); // posix_memalign() is compatible with heap deallocator #endif @@ -86,10 +85,10 @@ inline void ll_aligned_free_16(void *p) inline void* ll_aligned_realloc_16(void* ptr, size_t size, size_t old_size) // returned hunk MUST be freed with ll_aligned_free_16(). { -#if defined(LL_WINDOWS) - return _aligned_realloc(ptr, size, 16); -#elif defined(LL_DARWIN) +#if (LL_DARWIN || LL_USE_TCMALLOC) return realloc(ptr,size); // default osx malloc is 16 byte aligned. +#elif LL_WINDOWS + return _aligned_realloc(ptr, size, 16); #else //FIXME: memcpy is SLOW void* ret = ll_aligned_malloc_16(size); @@ -106,18 +105,11 @@ inline void* ll_aligned_realloc_16(void* ptr, size_t size, size_t old_size) // r #endif } -#else // USE_TCMALLOC -// ll_aligned_foo_16 are not needed with tcmalloc -#define ll_aligned_malloc_16 malloc -#define ll_aligned_realloc_16(a,b,c) realloc(a,b) -#define ll_aligned_free_16 free -#endif // USE_TCMALLOC - inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed with ll_aligned_free_32(). { -#if defined(LL_WINDOWS) +#if LL_WINDOWS return _aligned_malloc(size, 32); -#elif defined(LL_DARWIN) +#elif LL_DARWIN return ll_aligned_malloc( size, 32 ); #else void *rtn; @@ -130,9 +122,9 @@ inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed wi inline void ll_aligned_free_32(void *p) { -#if defined(LL_WINDOWS) +#if LL_WINDOWS _aligned_free(p); -#elif defined(LL_DARWIN) +#elif LL_DARWIN ll_aligned_free( p ); #else free(p); // posix_memalign() is compatible with heap deallocator diff --git a/indra/llplugin/slplugin/CMakeLists.txt b/indra/llplugin/slplugin/CMakeLists.txt index e377434b1..381782ed6 100644 --- a/indra/llplugin/slplugin/CMakeLists.txt +++ b/indra/llplugin/slplugin/CMakeLists.txt @@ -6,7 +6,6 @@ include(LLPlugin) include(Linking) include(PluginAPI) include(LLMessage) -include(GooglePerfTools) include_directories( ${LLPLUGIN_INCLUDE_DIRS} diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index c5dcff371..092b9c0f5 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -38,7 +38,6 @@ include(LLXML) #include(LScript) include(Linking) include(NDOF) -include(GooglePerfTools) include(StateMachine) include(TemplateCheck) include(UI) diff --git a/indra/newview/sgmemstat.cpp b/indra/newview/sgmemstat.cpp index d8c4a3f5a..ca4ce0593 100644 --- a/indra/newview/sgmemstat.cpp +++ b/indra/newview/sgmemstat.cpp @@ -18,7 +18,7 @@ #include "llviewerprecompiledheaders.h" #include "sgmemstat.h" -#if (!(LL_LINUX || LL_USE_TCMALLOC)) +#if (!LL_LINUX && !LL_USE_TCMALLOC) bool SGMemStat::haveStat() { return false; }