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

these VALGRIND allocator annotations never worked for me, just busted memcheck

üst 043ddca9
...@@ -922,7 +922,6 @@ try_alloc: ...@@ -922,7 +922,6 @@ try_alloc:
if (result != 0) if (result != 0)
{ {
rtl_arena_type * arena = result; rtl_arena_type * arena = result;
VALGRIND_CREATE_MEMPOOL(arena, 0, 0);
rtl_arena_constructor (arena); rtl_arena_constructor (arena);
if (!source_arena) if (!source_arena)
...@@ -945,7 +944,6 @@ try_alloc: ...@@ -945,7 +944,6 @@ try_alloc:
{ {
rtl_arena_deactivate (arena); rtl_arena_deactivate (arena);
rtl_arena_destructor (arena); rtl_arena_destructor (arena);
VALGRIND_DESTROY_MEMPOOL(arena);
rtl_arena_free (gp_arena_arena, arena, size); rtl_arena_free (gp_arena_arena, arena, size);
} }
} }
...@@ -972,7 +970,6 @@ SAL_CALL rtl_arena_destroy ( ...@@ -972,7 +970,6 @@ SAL_CALL rtl_arena_destroy (
{ {
rtl_arena_deactivate (arena); rtl_arena_deactivate (arena);
rtl_arena_destructor (arena); rtl_arena_destructor (arena);
VALGRIND_DESTROY_MEMPOOL(arena);
rtl_arena_free (gp_arena_arena, arena, sizeof(rtl_arena_type)); rtl_arena_free (gp_arena_arena, arena, sizeof(rtl_arena_type));
} }
} }
...@@ -1033,10 +1030,6 @@ SAL_CALL rtl_arena_alloc ( ...@@ -1033,10 +1030,6 @@ SAL_CALL rtl_arena_alloc (
rtl_arena_hash_insert (arena, segment); rtl_arena_hash_insert (arena, segment);
/* DEBUG ONLY: mark allocated, undefined */
OSL_DEBUG_ONLY(memset((void*)(segment->m_addr), 0x77777777, segment->m_size));
VALGRIND_MEMPOOL_ALLOC(arena, segment->m_addr, segment->m_size);
(*pSize) = segment->m_size; (*pSize) = segment->m_size;
addr = (void*)(segment->m_addr); addr = (void*)(segment->m_addr);
} }
...@@ -1086,11 +1079,6 @@ SAL_CALL rtl_arena_free ( ...@@ -1086,11 +1079,6 @@ SAL_CALL rtl_arena_free (
{ {
rtl_arena_segment_type *next, *prev; rtl_arena_segment_type *next, *prev;
/* DEBUG ONLY: mark unallocated, undefined */
VALGRIND_MEMPOOL_FREE(arena, segment->m_addr);
/* OSL_DEBUG_ONLY() */ RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_UNDEFINED(segment->m_addr, segment->m_size);
OSL_DEBUG_ONLY(memset((void*)(segment->m_addr), 0x33333333, segment->m_size));
/* coalesce w/ adjacent free segment(s) */ /* coalesce w/ adjacent free segment(s) */
rtl_arena_segment_coalesce (arena, segment); rtl_arena_segment_coalesce (arena, segment);
...@@ -1266,7 +1254,6 @@ rtl_arena_init() ...@@ -1266,7 +1254,6 @@ rtl_arena_init()
static rtl_arena_type g_machdep_arena; static rtl_arena_type g_machdep_arena;
assert(gp_machdep_arena == 0); assert(gp_machdep_arena == 0);
VALGRIND_CREATE_MEMPOOL(&g_machdep_arena, 0, 0);
rtl_arena_constructor (&g_machdep_arena); rtl_arena_constructor (&g_machdep_arena);
gp_machdep_arena = rtl_arena_activate ( gp_machdep_arena = rtl_arena_activate (
...@@ -1283,7 +1270,6 @@ rtl_arena_init() ...@@ -1283,7 +1270,6 @@ rtl_arena_init()
static rtl_arena_type g_default_arena; static rtl_arena_type g_default_arena;
assert(gp_default_arena == 0); assert(gp_default_arena == 0);
VALGRIND_CREATE_MEMPOOL(&g_default_arena, 0, 0);
rtl_arena_constructor (&g_default_arena); rtl_arena_constructor (&g_default_arena);
gp_default_arena = rtl_arena_activate ( gp_default_arena = rtl_arena_activate (
...@@ -1302,7 +1288,6 @@ rtl_arena_init() ...@@ -1302,7 +1288,6 @@ rtl_arena_init()
static rtl_arena_type g_arena_arena; static rtl_arena_type g_arena_arena;
assert(gp_arena_arena == 0); assert(gp_arena_arena == 0);
VALGRIND_CREATE_MEMPOOL(&g_arena_arena, 0, 0);
rtl_arena_constructor (&g_arena_arena); rtl_arena_constructor (&g_arena_arena);
gp_arena_arena = rtl_arena_activate ( gp_arena_arena = rtl_arena_activate (
......
...@@ -483,11 +483,6 @@ rtl_cache_slab_alloc ( ...@@ -483,11 +483,6 @@ rtl_cache_slab_alloc (
addr = (void*)rtl_cache_hash_insert (cache, bufctl); addr = (void*)rtl_cache_hash_insert (cache, bufctl);
else else
addr = bufctl; addr = bufctl;
/* DEBUG ONLY: mark allocated, undefined */
/* OSL_DEBUG_ONLY() */ RTL_VALGRIND_IGNORE_VAL 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);
} }
RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock)); RTL_MEMORY_LOCK_RELEASE(&(cache->m_slab_lock));
...@@ -510,11 +505,6 @@ rtl_cache_slab_free ( ...@@ -510,11 +505,6 @@ rtl_cache_slab_free (
RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock)); RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_slab_lock));
/* DEBUG ONLY: mark unallocated, undefined */
VALGRIND_MEMPOOL_FREE(cache, addr);
/* OSL_DEBUG_ONLY() */ RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_UNDEFINED(addr, cache->m_type_size);
OSL_DEBUG_ONLY(memset(addr, 0x33333333, cache->m_type_size));
/* determine slab from addr */ /* determine slab from addr */
if (cache->m_features & RTL_CACHE_FEATURE_HASH) if (cache->m_features & RTL_CACHE_FEATURE_HASH)
{ {
...@@ -611,13 +601,8 @@ rtl_cache_magazine_clear ( ...@@ -611,13 +601,8 @@ rtl_cache_magazine_clear (
void * obj = mag->m_objects[mag->m_mag_used - 1]; void * obj = mag->m_objects[mag->m_mag_used - 1];
mag->m_objects[mag->m_mag_used - 1] = 0; mag->m_objects[mag->m_mag_used - 1] = 0;
/* DEBUG ONLY: mark cached object allocated, undefined */
VALGRIND_MEMPOOL_ALLOC(cache, obj, cache->m_type_size);
if (cache->m_destructor != 0) if (cache->m_destructor != 0)
{ {
/* DEBUG ONLY: keep constructed object defined */
RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_DEFINED(obj, cache->m_type_size);
/* destruct object */ /* destruct object */
(cache->m_destructor)(obj, cache->m_userarg); (cache->m_destructor)(obj, cache->m_userarg);
} }
...@@ -1107,7 +1092,6 @@ try_alloc: ...@@ -1107,7 +1092,6 @@ try_alloc:
if (result != 0) if (result != 0)
{ {
rtl_cache_type * cache = result; rtl_cache_type * cache = result;
VALGRIND_CREATE_MEMPOOL(cache, 0, 0);
(void) rtl_cache_constructor (cache); (void) rtl_cache_constructor (cache);
if (!source) if (!source)
...@@ -1135,7 +1119,6 @@ try_alloc: ...@@ -1135,7 +1119,6 @@ try_alloc:
/* activation failed */ /* activation failed */
rtl_cache_deactivate (cache); rtl_cache_deactivate (cache);
rtl_cache_destructor (cache); rtl_cache_destructor (cache);
VALGRIND_DESTROY_MEMPOOL(cache);
rtl_arena_free (gp_cache_arena, cache, size); rtl_arena_free (gp_cache_arena, cache, size);
} }
} }
...@@ -1161,7 +1144,6 @@ void SAL_CALL rtl_cache_destroy ( ...@@ -1161,7 +1144,6 @@ void SAL_CALL rtl_cache_destroy (
{ {
rtl_cache_deactivate (cache); rtl_cache_deactivate (cache);
rtl_cache_destructor (cache); rtl_cache_destructor (cache);
VALGRIND_DESTROY_MEMPOOL(cache);
rtl_arena_free (gp_cache_arena, cache, sizeof(rtl_cache_type)); rtl_arena_free (gp_cache_arena, cache, sizeof(rtl_cache_type));
} }
} }
...@@ -1204,14 +1186,6 @@ SAL_CALL rtl_cache_alloc ( ...@@ -1204,14 +1186,6 @@ SAL_CALL rtl_cache_alloc (
if ((curr != 0) && (curr->m_mag_used > 0)) if ((curr != 0) && (curr->m_mag_used > 0))
{ {
obj = curr->m_objects[--curr->m_mag_used]; obj = curr->m_objects[--curr->m_mag_used];
#if defined(HAVE_VALGRIND_MEMCHECK_H)
VALGRIND_MEMPOOL_ALLOC(cache, obj, cache->m_type_size);
if (cache->m_constructor != 0)
{
/* keep constructed object defined */
RTL_VALGRIND_IGNORE_VAL VALGRIND_MAKE_MEM_DEFINED(obj, cache->m_type_size);
}
#endif /* HAVE_VALGRIND_MEMCHECK_H */
cache->m_cpu_stats.m_alloc += 1; cache->m_cpu_stats.m_alloc += 1;
RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock));
...@@ -1289,9 +1263,6 @@ SAL_CALL rtl_cache_free ( ...@@ -1289,9 +1263,6 @@ SAL_CALL rtl_cache_free (
if ((curr != 0) && (curr->m_mag_used < curr->m_mag_size)) if ((curr != 0) && (curr->m_mag_used < curr->m_mag_size))
{ {
curr->m_objects[curr->m_mag_used++] = obj; curr->m_objects[curr->m_mag_used++] = obj;
#if defined(HAVE_VALGRIND_MEMCHECK_H)
VALGRIND_MEMPOOL_FREE(cache, obj);
#endif /* HAVE_VALGRIND_MEMCHECK_H */
cache->m_cpu_stats.m_free += 1; cache->m_cpu_stats.m_free += 1;
RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock)); RTL_MEMORY_LOCK_RELEASE(&(cache->m_depot_lock));
...@@ -1604,7 +1575,6 @@ rtl_cache_init() ...@@ -1604,7 +1575,6 @@ rtl_cache_init()
static rtl_cache_type g_cache_magazine_cache; static rtl_cache_type g_cache_magazine_cache;
assert(gp_cache_magazine_cache == 0); assert(gp_cache_magazine_cache == 0);
VALGRIND_CREATE_MEMPOOL(&g_cache_magazine_cache, 0, 0);
(void) rtl_cache_constructor (&g_cache_magazine_cache); (void) rtl_cache_constructor (&g_cache_magazine_cache);
gp_cache_magazine_cache = rtl_cache_activate ( gp_cache_magazine_cache = rtl_cache_activate (
...@@ -1629,7 +1599,6 @@ rtl_cache_init() ...@@ -1629,7 +1599,6 @@ rtl_cache_init()
static rtl_cache_type g_cache_slab_cache; static rtl_cache_type g_cache_slab_cache;
assert(gp_cache_slab_cache == 0); assert(gp_cache_slab_cache == 0);
VALGRIND_CREATE_MEMPOOL(&g_cache_slab_cache, 0, 0);
(void) rtl_cache_constructor (&g_cache_slab_cache); (void) rtl_cache_constructor (&g_cache_slab_cache);
gp_cache_slab_cache = rtl_cache_activate ( gp_cache_slab_cache = rtl_cache_activate (
...@@ -1651,7 +1620,6 @@ rtl_cache_init() ...@@ -1651,7 +1620,6 @@ rtl_cache_init()
static rtl_cache_type g_cache_bufctl_cache; static rtl_cache_type g_cache_bufctl_cache;
assert(gp_cache_bufctl_cache == 0); assert(gp_cache_bufctl_cache == 0);
VALGRIND_CREATE_MEMPOOL(&g_cache_bufctl_cache, 0, 0);
(void) rtl_cache_constructor (&g_cache_bufctl_cache); (void) rtl_cache_constructor (&g_cache_bufctl_cache);
gp_cache_bufctl_cache = rtl_cache_activate ( gp_cache_bufctl_cache = rtl_cache_activate (
...@@ -1689,21 +1657,18 @@ rtl_cache_fini() ...@@ -1689,21 +1657,18 @@ rtl_cache_fini()
cache = gp_cache_bufctl_cache, gp_cache_bufctl_cache = 0; cache = gp_cache_bufctl_cache, gp_cache_bufctl_cache = 0;
rtl_cache_deactivate (cache); rtl_cache_deactivate (cache);
rtl_cache_destructor (cache); rtl_cache_destructor (cache);
VALGRIND_DESTROY_MEMPOOL(cache);
} }
if (gp_cache_slab_cache != 0) if (gp_cache_slab_cache != 0)
{ {
cache = gp_cache_slab_cache, gp_cache_slab_cache = 0; cache = gp_cache_slab_cache, gp_cache_slab_cache = 0;
rtl_cache_deactivate (cache); rtl_cache_deactivate (cache);
rtl_cache_destructor (cache); rtl_cache_destructor (cache);
VALGRIND_DESTROY_MEMPOOL(cache);
} }
if (gp_cache_magazine_cache != 0) if (gp_cache_magazine_cache != 0)
{ {
cache = gp_cache_magazine_cache, gp_cache_magazine_cache = 0; cache = gp_cache_magazine_cache, gp_cache_magazine_cache = 0;
rtl_cache_deactivate (cache); rtl_cache_deactivate (cache);
rtl_cache_destructor (cache); rtl_cache_destructor (cache);
VALGRIND_DESTROY_MEMPOOL(cache);
} }
if (gp_cache_arena != 0) if (gp_cache_arena != 0)
{ {
...@@ -1735,6 +1700,4 @@ rtl_cache_fini() ...@@ -1735,6 +1700,4 @@ rtl_cache_fini()
// SAL_INFO("sal", "rtl_cache_fini completed"); // SAL_INFO("sal", "rtl_cache_fini completed");
} }
/* ================================================================= */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -235,37 +235,6 @@ typedef CRITICAL_SECTION rtl_memory_lock_type; ...@@ -235,37 +235,6 @@ typedef CRITICAL_SECTION rtl_memory_lock_type;
#define RTL_CACHE_FLAG_NOMAGAZINE (1 << 13) /* w/o magazine layer */ #define RTL_CACHE_FLAG_NOMAGAZINE (1 << 13) /* w/o magazine layer */
#define RTL_CACHE_FLAG_QUANTUMCACHE (2 << 13) /* used as arena quantum cache */ #define RTL_CACHE_FLAG_QUANTUMCACHE (2 << 13) /* used as arena quantum cache */
/** Valgrind support macros.
*/
#if !defined(HAVE_MEMCHECK_H) || (OSL_DEBUG_LEVEL == 0)
#if !defined(NVALGRIND)
#define NVALGRIND 1
#endif /* ! NVALGRIND */
#endif /* ! HAVE_MEMCHECK_H || (OSL_DEBUG_LEVEL == 0) */
#if defined(NVALGRIND)
#define VALGRIND_MAKE_MEM_UNDEFINED(addr, size)
#define VALGRIND_MAKE_MEM_DEFINED(addr, size)
#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed)
#define VALGRIND_FREELIKE_BLOCK(addr, rzB)
#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed)
#define VALGRIND_DESTROY_MEMPOOL(pool)
#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size)
#define VALGRIND_MEMPOOL_FREE(pool, addr)
#define RTL_VALGRIND_IGNORE_VAL
#elif defined(HAVE_MEMCHECK_H)
#include <memcheck.h>
/* valgrind macros contain unused variables... */
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
#if GCC_VERSION >= 40600 && !defined __clang__
#pragma GCC diagnostic warning "-Wunused-but-set-variable"
#endif
#define RTL_VALGRIND_IGNORE_VAL (void)
#endif /* NVALGRIND || HAVE_MEMCHECK_H */
typedef enum { AMode_CUSTOM, AMode_SYSTEM, AMode_UNSET } AllocMode; typedef enum { AMode_CUSTOM, AMode_SYSTEM, AMode_UNSET } AllocMode;
extern AllocMode alloc_mode; extern AllocMode alloc_mode;
......
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