Merge remote-tracking branch 'siana/master'

This commit is contained in:
Latif Khalifa
2013-04-23 12:19:09 +02:00
6 changed files with 26 additions and 28 deletions

View File

@@ -333,4 +333,6 @@ MARK_AS_ADVANCED(
CMAKE_SHARED_LINKER_FLAGS_RELEASE CMAKE_SHARED_LINKER_FLAGS_RELEASE
) )
include(GooglePerfTools)
endif(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED) endif(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED)

View File

@@ -1,4 +1,5 @@
# -*- cmake -*- # -*- cmake -*-
include(Prebuilt) include(Prebuilt)
if(WORD_SIZE EQUAL 64) if(WORD_SIZE EQUAL 64)
@@ -47,9 +48,14 @@ else (USE_GOOGLE_PERFTOOLS)
endif (USE_GOOGLE_PERFTOOLS) endif (USE_GOOGLE_PERFTOOLS)
if (NOT(DISABLE_TCMALLOC OR USE_GOOGLE_PERFTOOLS OR STANDALONE)) if (NOT(DISABLE_TCMALLOC OR USE_GOOGLE_PERFTOOLS OR STANDALONE))
message(STATUS "Building with Google TCMalloc") if (NOT STATUS_Building_with_Google_TCMalloc)
set(TCMALLOC_FLAG -DLL_USE_TCMALLOC=1) message(STATUS "Building with Google TCMalloc")
include_directories(${GOOGLE_PERFTOOLS_INCLUDE_DIR}) set(STATUS_Building_with_Google_TCMalloc true PARENT_SCOPE)
set(GOOGLE_PERFTOOLS_LIBRARIES ${TCMALLOC_LIBRARIES}) 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}) set(GOOGLE_PERFTOOLS_LINKER_FLAGS ${TCMALLOC_LINKER_FLAGS})
endif() endif()
add_definitions(${TCMALLOC_FLAG})

View File

@@ -57,13 +57,12 @@ inline void ll_aligned_free( void* ptr )
free( ((void**)ptr)[-1] ); 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(). inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed with ll_aligned_free_16().
{ {
#if defined(LL_WINDOWS) #if (LL_DARWIN || LL_USE_TCMALLOC)
return _aligned_malloc(size, 16);
#elif defined(LL_DARWIN)
return malloc(size); // default osx malloc is 16 byte aligned. return malloc(size); // default osx malloc is 16 byte aligned.
#elif LL_WINDOWS
return _aligned_malloc(size, 16);
#else #else
void *rtn; void *rtn;
if (LL_LIKELY(0 == posix_memalign(&rtn, 16, size))) 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) 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); _aligned_free(p);
#elif defined(LL_DARWIN)
return free(p);
#else #else
free(p); // posix_memalign() is compatible with heap deallocator free(p); // posix_memalign() is compatible with heap deallocator
#endif #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(). 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) #if (LL_DARWIN || LL_USE_TCMALLOC)
return _aligned_realloc(ptr, size, 16);
#elif defined(LL_DARWIN)
return realloc(ptr,size); // default osx malloc is 16 byte aligned. return realloc(ptr,size); // default osx malloc is 16 byte aligned.
#elif LL_WINDOWS
return _aligned_realloc(ptr, size, 16);
#else #else
//FIXME: memcpy is SLOW //FIXME: memcpy is SLOW
void* ret = ll_aligned_malloc_16(size); 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 #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(). 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); return _aligned_malloc(size, 32);
#elif defined(LL_DARWIN) #elif LL_DARWIN
return ll_aligned_malloc( size, 32 ); return ll_aligned_malloc( size, 32 );
#else #else
void *rtn; 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) inline void ll_aligned_free_32(void *p)
{ {
#if defined(LL_WINDOWS) #if LL_WINDOWS
_aligned_free(p); _aligned_free(p);
#elif defined(LL_DARWIN) #elif LL_DARWIN
ll_aligned_free( p ); ll_aligned_free( p );
#else #else
free(p); // posix_memalign() is compatible with heap deallocator free(p); // posix_memalign() is compatible with heap deallocator

View File

@@ -6,7 +6,6 @@ include(LLPlugin)
include(Linking) include(Linking)
include(PluginAPI) include(PluginAPI)
include(LLMessage) include(LLMessage)
include(GooglePerfTools)
include_directories( include_directories(
${LLPLUGIN_INCLUDE_DIRS} ${LLPLUGIN_INCLUDE_DIRS}

View File

@@ -38,7 +38,6 @@ include(LLXML)
#include(LScript) #include(LScript)
include(Linking) include(Linking)
include(NDOF) include(NDOF)
include(GooglePerfTools)
include(StateMachine) include(StateMachine)
include(TemplateCheck) include(TemplateCheck)
include(UI) include(UI)

View File

@@ -18,7 +18,7 @@
#include "llviewerprecompiledheaders.h" #include "llviewerprecompiledheaders.h"
#include "sgmemstat.h" #include "sgmemstat.h"
#if (!(LL_LINUX || LL_USE_TCMALLOC)) #if (!LL_LINUX && !LL_USE_TCMALLOC)
bool SGMemStat::haveStat() { bool SGMemStat::haveStat() {
return false; return false;
} }