Kaydet (Commit) ce906b80 authored tarafından Caolán McNamara's avatar Caolán McNamara

skip tricky allocators on G_SLICE=always-malloc

üst c2e61f08
......@@ -37,6 +37,8 @@
#include <string.h>
#include <stdio.h>
extern AllocMode alloc_mode;
/* ================================================================= *
*
* arena internals.
......@@ -999,6 +1001,9 @@ SAL_CALL rtl_arena_alloc (
if ((arena != 0) && (pSize != 0))
{
if (alloc_mode == AMode_SYSTEM)
return rtl_allocateMemory(*pSize);
sal_Size size = RTL_MEMORY_ALIGN((*pSize), arena->m_quantum);
if (size > arena->m_qcache_max)
{
......@@ -1072,6 +1077,12 @@ SAL_CALL rtl_arena_free (
{
if (arena != 0)
{
if (alloc_mode == AMode_SYSTEM)
{
rtl_freeMemory(addr);
return;
}
size = RTL_MEMORY_ALIGN(size, arena->m_quantum);
if (size > arena->m_qcache_max)
{
......
......@@ -41,6 +41,8 @@
#include <stdio.h>
#endif
extern AllocMode alloc_mode;
/* ================================================================= *
*
* cache internals.
......@@ -498,6 +500,7 @@ rtl_cache_slab_alloc (
addr = bufctl;
/* DEBUG ONLY: mark allocated, undefined */
/* OSL_DEBUG_ONLY() */ VALGRIND_MAKE_MEM_UNDEFINED(addr, cache->m_type_size);
OSL_DEBUG_ONLY(memset(addr, 0x77777777, cache->m_type_size));
VALGRIND_MEMPOOL_ALLOC(cache, addr, cache->m_type_size);
}
......@@ -1203,6 +1206,20 @@ SAL_CALL rtl_cache_alloc (
if (cache == 0)
return (0);
if (alloc_mode == AMode_SYSTEM)
{
obj = rtl_allocateMemory(cache->m_type_size);
if ((obj != 0) && (cache->m_constructor != 0))
{
if (!((cache->m_constructor)(obj, cache->m_userarg)))
{
/* construction failure */
rtl_freeMemory(obj), obj = 0;
}
}
return obj;
}
RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock));
if (cache->m_cpu_curr != 0)
{
......@@ -1278,6 +1295,17 @@ SAL_CALL rtl_cache_free (
{
if ((obj != 0) && (cache != 0))
{
if (alloc_mode == AMode_SYSTEM)
{
if (cache->m_destructor != 0)
{
/* destruct object */
(cache->m_destructor)(obj, cache->m_userarg);
}
rtl_freeMemory(obj);
return;
}
RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock));
for (;;)
......
......@@ -34,12 +34,9 @@
#include <string.h>
#include <stdio.h>
#if !defined(FORCE_SYSALLOC)
typedef enum { AMode_CUSTOM, AMode_SYSTEM, AMode_UNSET } AllocMode;
static AllocMode alloc_mode = AMode_UNSET;
AllocMode alloc_mode = AMode_UNSET;
#if !defined(FORCE_SYSALLOC)
static void determine_alloc_mode(void)
{
/* This shouldn't happen, but still ... */
......
......@@ -260,11 +260,12 @@ typedef CRITICAL_SECTION rtl_memory_lock_type;
#define VALGRIND_MEMPOOL_FREE(pool, addr)
#elif defined(HAVE_MEMCHECK_H)
#include <memcheck.h>
#if !defined(FORCE_SYSALLOC)
#define FORCE_SYSALLOC 1
#endif /* !FORCE_SYSALLOC */
#endif /* NVALGRIND || HAVE_MEMCHECK_H */
typedef enum { AMode_CUSTOM, AMode_SYSTEM, AMode_UNSET } AllocMode;
extern AllocMode alloc_mode;
#ifdef __cplusplus
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment