summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorWilliam Todd Stinson <stinson@lindenlab.com>2012-09-10 10:37:02 -0700
committerWilliam Todd Stinson <stinson@lindenlab.com>2012-09-10 10:37:02 -0700
commita766e26db46c7c054bae1021470dbe365f2a3cb3 (patch)
tree93ffd22d902bef8d44e81b6989dcb2966beba2fc /indra/llcommon
parentdab915c1d2a2d08363944de8ac4362fbe162bea0 (diff)
Backing out the changes contributing to DRTVWR-167 and DRTVWR-179 from the repository.
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llallocator.cpp2
-rw-r--r--indra/llcommon/llmemory.cpp12
-rw-r--r--indra/llcommon/llmemory.h45
3 files changed, 15 insertions, 44 deletions
diff --git a/indra/llcommon/llallocator.cpp b/indra/llcommon/llallocator.cpp
index 87654b5b97..6f6abefc67 100644
--- a/indra/llcommon/llallocator.cpp
+++ b/indra/llcommon/llallocator.cpp
@@ -27,7 +27,7 @@
#include "linden_common.h"
#include "llallocator.h"
-#if (LL_USE_TCMALLOC && LL_USE_HEAP_PROFILER)
+#if LL_USE_TCMALLOC
#include "google/heap-profiler.h"
#include "google/commandlineflags_public.h"
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index afaf366668..3b9758f996 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -61,18 +61,6 @@ BOOL LLMemory::sEnableMemoryFailurePrevention = FALSE;
LLPrivateMemoryPoolManager::mem_allocation_info_t LLPrivateMemoryPoolManager::sMemAllocationTracker;
#endif
-void ll_assert_aligned_func(uintptr_t ptr,U32 alignment)
-{
-#ifdef SHOW_ASSERT
- // Redundant, place to set breakpoints.
- if (ptr%alignment!=0)
- {
- llwarns << "alignment check failed" << llendl;
- }
- llassert(ptr%alignment==0);
-#endif
-}
-
//static
void LLMemory::initClass()
{
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 9dd776ff57..bbbdaa6497 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -27,6 +27,7 @@
#define LLMEMORY_H
#include "llmemtype.h"
+#if LL_DEBUG
inline void* ll_aligned_malloc( size_t size, int align )
{
void* mem = malloc( size + (align - 1) + sizeof(void*) );
@@ -42,11 +43,10 @@ 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);
+ return _mm_malloc(size, 16);
#elif defined(LL_DARWIN)
return malloc(size); // default osx malloc is 16 byte aligned.
#else
@@ -58,38 +58,21 @@ inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed wi
#endif
}
-inline void* ll_aligned_realloc_16(void* ptr, size_t 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)
- return realloc(ptr,size); // default osx malloc is 16 byte aligned.
-#else
- return realloc(ptr,size); // FIXME not guaranteed to be aligned.
-#endif
-}
-
inline void ll_aligned_free_16(void *p)
{
#if defined(LL_WINDOWS)
- _aligned_free(p);
+ _mm_free(p);
#elif defined(LL_DARWIN)
return free(p);
#else
free(p); // posix_memalign() is compatible with heap deallocator
#endif
}
-#else // USE_TCMALLOC
-// ll_aligned_foo_16 are not needed with tcmalloc
-#define ll_aligned_malloc_16 malloc
-#define ll_aligned_realloc_16 realloc
-#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)
- return _aligned_malloc(size, 32);
+ return _mm_malloc(size, 32);
#elif defined(LL_DARWIN)
return ll_aligned_malloc( size, 32 );
#else
@@ -104,13 +87,22 @@ 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)
- _aligned_free(p);
+ _mm_free(p);
#elif defined(LL_DARWIN)
ll_aligned_free( p );
#else
free(p); // posix_memalign() is compatible with heap deallocator
#endif
}
+#else // LL_DEBUG
+// ll_aligned_foo are noops now that we use tcmalloc everywhere (tcmalloc aligns automatically at appropriate intervals)
+#define ll_aligned_malloc( size, align ) malloc(size)
+#define ll_aligned_free( ptr ) free(ptr)
+#define ll_aligned_malloc_16 malloc
+#define ll_aligned_free_16 free
+#define ll_aligned_malloc_32 malloc
+#define ll_aligned_free_32 free
+#endif // LL_DEBUG
#ifndef __DEBUG_PRIVATE_MEM__
#define __DEBUG_PRIVATE_MEM__ 0
@@ -520,13 +512,4 @@ void LLPrivateMemoryPoolTester::operator delete[](void* addr)
// LLSingleton moved to llsingleton.h
-LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment);
-
-#ifdef SHOW_ASSERT
-#define ll_assert_aligned(ptr,alignment) ll_assert_aligned_func(reinterpret_cast<uintptr_t>(ptr),((U32)alignment))
-#else
-#define ll_assert_aligned(ptr,alignment)
-#endif
-
-
#endif