diff options
Diffstat (limited to 'sal')
-rw-r--r-- | sal/rtl/source/alloc_arena.cxx | 162 | ||||
-rw-r--r-- | sal/rtl/source/alloc_cache.cxx | 214 | ||||
-rw-r--r-- | sal/rtl/source/alloc_global.cxx | 14 |
3 files changed, 182 insertions, 208 deletions
diff --git a/sal/rtl/source/alloc_arena.cxx b/sal/rtl/source/alloc_arena.cxx index 03c7f475d10a..e10131076f8c 100644 --- a/sal/rtl/source/alloc_arena.cxx +++ b/sal/rtl/source/alloc_arena.cxx @@ -34,6 +34,7 @@ #include "sal/macros.h" #include "osl/diagnose.h" +#include <cassert> #include <string.h> #include <stdio.h> @@ -118,14 +119,11 @@ rtl_arena_segment_constructor (void * obj) static void rtl_arena_segment_destructor (void * obj) { -#if OSL_DEBUG_LEVEL == 0 - (void) obj; /* unused */ -#else /* OSL_DEBUG_LEVEL */ - rtl_arena_segment_type * segment = (rtl_arena_segment_type*)(obj); - - OSL_ASSERT(QUEUE_STARTED_NAMED(segment, s)); - OSL_ASSERT(QUEUE_STARTED_NAMED(segment, f)); -#endif /* OSL_DEBUG_LEVEL */ + rtl_arena_segment_type * segment = static_cast< rtl_arena_segment_type * >( + obj); + assert(QUEUE_STARTED_NAMED(segment, s)); + assert(QUEUE_STARTED_NAMED(segment, f)); + (void) segment; // avoid warnings } /* ================================================================= */ @@ -184,7 +182,7 @@ rtl_arena_segment_get ( { rtl_arena_segment_type * head; - OSL_ASSERT(*ppSegment == 0); + assert(*ppSegment == 0); head = &(arena->m_segment_reserve_head); if ((head->m_snext != head) || rtl_arena_segment_populate (arena)) @@ -212,13 +210,13 @@ rtl_arena_segment_put ( { rtl_arena_segment_type * head; - OSL_ASSERT(QUEUE_STARTED_NAMED((*ppSegment), s)); - OSL_ASSERT(QUEUE_STARTED_NAMED((*ppSegment), f)); + assert(QUEUE_STARTED_NAMED((*ppSegment), s)); + assert(QUEUE_STARTED_NAMED((*ppSegment), f)); (*ppSegment)->m_addr = 0; (*ppSegment)->m_size = 0; - OSL_ASSERT((*ppSegment)->m_type != RTL_ARENA_SEGMENT_TYPE_HEAD); + assert((*ppSegment)->m_type != RTL_ARENA_SEGMENT_TYPE_HEAD); (*ppSegment)->m_type = 0; /* keep as reserve */ @@ -274,7 +272,7 @@ rtl_arena_freelist_remove ( rtl_arena_segment_type * head; head = segment->m_fprev; - OSL_ASSERT(arena->m_freelist_bitmap & head->m_size); + assert(arena->m_freelist_bitmap & head->m_size); arena->m_freelist_bitmap ^= head->m_size; } QUEUE_REMOVE_NAMED(segment, f); @@ -323,16 +321,14 @@ rtl_arena_hash_rescale ( old_table = arena->m_hash_table; old_size = arena->m_hash_size; - OSL_TRACE( - "rtl_arena_hash_rescale(\"%s\"): " - "nseg: %"PRIu64" (ave: %"PRIu64"), frees: %"PRIu64" " - "[old_size: %lu, new_size: %lu]", - arena->m_name, - arena->m_stats.m_alloc - arena->m_stats.m_free, - (arena->m_stats.m_alloc - arena->m_stats.m_free) >> arena->m_hash_shift, - arena->m_stats.m_free, - old_size, new_size - ); + // SAL_INFO( + // "sal", + // "rtl_arena_hash_rescale(" << arena->m_name << "): nseg: " + // << (arena->m_stats.m_alloc - arena->m_stats.m_free) << " (ave: " + // << ((arena->m_stats.m_alloc - arena->m_stats.m_free) + // >> arena->m_hash_shift) + // << "), frees: " << arena->m_stats.m_free << " [old_size: " + // << old_size << ", new_size: " << new_size << ']'); arena->m_hash_table = new_table; arena->m_hash_size = new_size; @@ -404,10 +400,6 @@ rtl_arena_hash_remove ( rtl_arena_segment_type *segment, **segpp; sal_Size lookups = 0; -#if OSL_DEBUG_LEVEL == 0 - (void) size; /* unused */ -#endif /* OSL_DEBUG_LEVEL */ - segpp = &(arena->m_hash_table[RTL_ARENA_HASH_INDEX(arena, addr)]); while ((segment = *segpp) != 0) { @@ -422,10 +414,11 @@ rtl_arena_hash_remove ( segpp = &(segment->m_fnext); } - OSL_POSTCOND(segment != 0, "rtl_arena_hash_remove(): bad free."); + assert(segment != 0); // bad free if (segment != 0) { - OSL_POSTCOND(segment->m_size == size, "rtl_arena_hash_remove(): wrong size."); + assert(segment->m_size == size); + (void) size; // avoid warnings arena->m_stats.m_free += 1; arena->m_stats.m_mem_alloc -= segment->m_size; @@ -470,7 +463,7 @@ rtl_arena_segment_alloc ( { int index = 0; - OSL_ASSERT(*ppSegment == 0); + assert(*ppSegment == 0); if (!RTL_MEMORY_ISP2(size)) { int msb = highbit(size); @@ -504,7 +497,7 @@ rtl_arena_segment_alloc ( head = &(arena->m_freelist_head[index - 1]); (*ppSegment) = head->m_fnext; - OSL_ASSERT((*ppSegment) != head); + assert((*ppSegment) != head); } dequeue_and_leave: @@ -530,7 +523,7 @@ rtl_arena_segment_create ( rtl_arena_segment_type ** ppSegment ) { - OSL_ASSERT((*ppSegment) == 0); + assert((*ppSegment) == 0); if (arena->m_source_alloc != 0) { rtl_arena_segment_get (arena, ppSegment); @@ -587,14 +580,14 @@ rtl_arena_segment_coalesce ( rtl_arena_segment_type *next, *prev; /* mark segment free */ - OSL_ASSERT(segment->m_type == RTL_ARENA_SEGMENT_TYPE_USED); + assert(segment->m_type == RTL_ARENA_SEGMENT_TYPE_USED); segment->m_type = RTL_ARENA_SEGMENT_TYPE_FREE; /* try to merge w/ next segment */ next = segment->m_snext; if (next->m_type == RTL_ARENA_SEGMENT_TYPE_FREE) { - OSL_ASSERT(segment->m_addr + segment->m_size == next->m_addr); + assert(segment->m_addr + segment->m_size == next->m_addr); segment->m_size += next->m_size; /* remove from freelist */ @@ -611,7 +604,7 @@ rtl_arena_segment_coalesce ( prev = segment->m_sprev; if (prev->m_type == RTL_ARENA_SEGMENT_TYPE_FREE) { - OSL_ASSERT(prev->m_addr + prev->m_size == segment->m_addr); + assert(prev->m_addr + prev->m_size == segment->m_addr); segment->m_addr = prev->m_addr; segment->m_size += prev->m_size; @@ -679,35 +672,35 @@ rtl_arena_destructor (void * obj) rtl_arena_segment_type * head; size_t i; - OSL_ASSERT(QUEUE_STARTED_NAMED(arena, arena_)); + assert(QUEUE_STARTED_NAMED(arena, arena_)); RTL_MEMORY_LOCK_DESTROY(&(arena->m_lock)); head = &(arena->m_segment_reserve_span_head); - OSL_ASSERT(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); + assert(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); rtl_arena_segment_destructor (head); head = &(arena->m_segment_reserve_head); - OSL_ASSERT(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); + assert(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); rtl_arena_segment_destructor (head); head = &(arena->m_segment_head); - OSL_ASSERT(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); + assert(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); rtl_arena_segment_destructor (head); for (i = 0; i < RTL_ARENA_FREELIST_SIZE; i++) { head = &(arena->m_freelist_head[i]); - OSL_ASSERT(head->m_size == (1UL << i)); - OSL_ASSERT(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); + assert(head->m_size == (1UL << i)); + assert(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); rtl_arena_segment_destructor (head); } - OSL_ASSERT(arena->m_hash_table == arena->m_hash_table_0); - OSL_ASSERT(arena->m_hash_size == RTL_ARENA_HASH_SIZE); - OSL_ASSERT( + assert(arena->m_hash_table == arena->m_hash_table_0); + assert(arena->m_hash_size == RTL_ARENA_HASH_SIZE); + assert( arena->m_hash_shift == sal::static_int_cast< unsigned >(highbit(arena->m_hash_size) - 1)); } @@ -727,7 +720,7 @@ rtl_arena_activate ( void (SAL_CALL * source_free) (rtl_arena_type *, void *, sal_Size) ) { - OSL_ASSERT(arena != 0); + assert(arena != 0); if (arena != 0) { (void) snprintf (arena->m_name, sizeof(arena->m_name), "%s", name); @@ -810,24 +803,22 @@ rtl_arena_deactivate ( } /* check for leaked segments */ - OSL_TRACE( - "rtl_arena_deactivate(\"%s\"): " - "allocs: %"PRIu64", frees: %"PRIu64"; total: %lu, used: %lu", - arena->m_name, - arena->m_stats.m_alloc, arena->m_stats.m_free, - arena->m_stats.m_mem_total, arena->m_stats.m_mem_alloc - ); + // SAL_INFO( + // "sal", + // "rtl_arena_deactivate(" << arena->m_name << "): allocs: " + // << arena->m_stats.m_alloc << ", frees: " << arena->m_stats.m_free + // << "; total: " << arena->m_stats.m_mem_total << ", used: " + // << arena->m_stats.m_mem_alloc); if (arena->m_stats.m_alloc > arena->m_stats.m_free) { sal_Size i, n; - OSL_TRACE( - "rtl_arena_deactivate(\"%s\"): " - "cleaning up %"PRIu64" leaked segment(s) [%lu bytes]", - arena->m_name, - arena->m_stats.m_alloc - arena->m_stats.m_free, - arena->m_stats.m_mem_alloc - ); + // SAL_INFO( + // "sal", + // "rtl_arena_deactivate(" << arena->m_name << "): cleaning up " + // << (arena->m_stats.m_alloc - arena->m_stats.m_free) + // << " leaked segment(s) [" << arena->m_stats.m_mem_alloc + // << " bytes]"); /* cleanup still used segment(s) */ for (i = 0, n = arena->m_hash_size; i < n; i++) @@ -871,7 +862,7 @@ rtl_arena_deactivate ( else { /* can have only free and span segments here */ - OSL_ASSERT(segment->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN); + assert(segment->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN); } /* remove from segment list */ @@ -894,7 +885,7 @@ rtl_arena_deactivate ( for (segment = head->m_snext; segment != head; segment = head->m_snext) { /* can have only span segments here */ - OSL_ASSERT(segment->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN); + assert(segment->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN); /* remove from segment list */ QUEUE_REMOVE_NAMED(segment, s); @@ -936,7 +927,7 @@ try_alloc: if (!source_arena) { - OSL_ASSERT(gp_default_arena != 0); + assert(gp_default_arena != 0); source_arena = gp_default_arena; } @@ -1017,11 +1008,11 @@ SAL_CALL rtl_arena_alloc ( sal_Size oversize; /* mark segment used */ - OSL_ASSERT(segment->m_type == RTL_ARENA_SEGMENT_TYPE_FREE); + assert(segment->m_type == RTL_ARENA_SEGMENT_TYPE_FREE); segment->m_type = RTL_ARENA_SEGMENT_TYPE_USED; /* resize */ - OSL_ASSERT(segment->m_size >= size); + assert(segment->m_size >= size); oversize = segment->m_size - size; if (oversize >= SAL_MAX(arena->m_quantum, arena->m_qcache_max)) { @@ -1055,7 +1046,7 @@ SAL_CALL rtl_arena_alloc ( { /* allocate from quantum cache(s) */ int index = (size >> arena->m_quantum_shift) - 1; - OSL_ASSERT (arena->m_qcache_ptr[index] != 0); + assert(arena->m_qcache_ptr[index] != 0); addr = rtl_cache_alloc (arena->m_qcache_ptr[index]); if (addr != 0) @@ -1111,8 +1102,9 @@ SAL_CALL rtl_arena_free ( ((next->m_type == RTL_ARENA_SEGMENT_TYPE_SPAN) || (next->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD)) ) { - OSL_ASSERT((prev->m_addr == segment->m_addr) && - (prev->m_size == segment->m_size) ); + assert( + prev->m_addr == segment->m_addr + && prev->m_size == segment->m_size); if (arena->m_source_free) { @@ -1150,7 +1142,7 @@ SAL_CALL rtl_arena_free ( { /* free to quantum cache(s) */ int index = (size >> arena->m_quantum_shift) - 1; - OSL_ASSERT (arena->m_qcache_ptr[index] != 0); + assert(arena->m_qcache_ptr[index] != 0); rtl_cache_free (arena->m_qcache_ptr[index], addr); } @@ -1180,7 +1172,7 @@ SAL_CALL rtl_machdep_alloc ( void * addr; sal_Size size = (*pSize); - OSL_PRECOND(pArena == gp_machdep_arena, "rtl_machdep_alloc(): invalid argument"); + assert(pArena == gp_machdep_arena); #if defined(SOLARIS) && defined(SPARC) /* see @ mmap(2) man pages */ @@ -1224,7 +1216,7 @@ SAL_CALL rtl_machdep_free ( sal_Size nSize ) { - OSL_PRECOND(pArena == gp_machdep_arena, "rtl_machdep_free(): invalid argument"); + assert(pArena == gp_machdep_arena); pArena->m_stats.m_free += 1; pArena->m_stats.m_mem_total -= nSize; @@ -1273,7 +1265,7 @@ rtl_arena_init() /* machdep (pseudo) arena */ static rtl_arena_type g_machdep_arena; - OSL_ASSERT(gp_machdep_arena == 0); + assert(gp_machdep_arena == 0); VALGRIND_CREATE_MEMPOOL(&g_machdep_arena, 0, 0); rtl_arena_constructor (&g_machdep_arena); @@ -1284,13 +1276,13 @@ rtl_arena_init() 0, /* no quantum caching */ 0, 0, 0 /* no source */ ); - OSL_ASSERT(gp_machdep_arena != 0); + assert(gp_machdep_arena != 0); } { /* default arena */ static rtl_arena_type g_default_arena; - OSL_ASSERT(gp_default_arena == 0); + assert(gp_default_arena == 0); VALGRIND_CREATE_MEMPOOL(&g_default_arena, 0, 0); rtl_arena_constructor (&g_default_arena); @@ -1303,13 +1295,13 @@ rtl_arena_init() rtl_machdep_alloc, rtl_machdep_free ); - OSL_ASSERT(gp_default_arena != 0); + assert(gp_default_arena != 0); } { /* arena internal arena */ static rtl_arena_type g_arena_arena; - OSL_ASSERT(gp_arena_arena == 0); + assert(gp_arena_arena == 0); VALGRIND_CREATE_MEMPOOL(&g_arena_arena, 0, 0); rtl_arena_constructor (&g_arena_arena); @@ -1322,9 +1314,9 @@ rtl_arena_init() rtl_arena_alloc, rtl_arena_free ); - OSL_ASSERT(gp_arena_arena != 0); + assert(gp_arena_arena != 0); } - OSL_TRACE("rtl_arena_init completed"); + // SAL_INFO("sal", "rtl_arena_init completed"); } /* ================================================================= */ @@ -1341,17 +1333,17 @@ rtl_arena_fini() for (arena = head->m_arena_next; arena != head; arena = arena->m_arena_next) { - OSL_TRACE( - "rtl_arena_fini(\"%s\"): " - "allocs: %"PRIu64", frees: %"PRIu64"; total: %lu, used: %lu", - arena->m_name, - arena->m_stats.m_alloc, arena->m_stats.m_free, - arena->m_stats.m_mem_total, arena->m_stats.m_mem_alloc - ); + // SAL_INFO( + // "sal", + // "rtl_arena_fini(" << arena->m_name << "): allocs: " + // << arena->m_stats.m_alloc << ", frees: " + // << arena->m_stats.m_free << "; total: " + // << arena->m_stats.m_mem_total << ", used: " + // << arena->m_stats.m_mem_alloc); } RTL_MEMORY_LOCK_RELEASE(&(g_arena_list.m_lock)); } - OSL_TRACE("rtl_arena_fini completed"); + // SAL_INFO("sal", "rtl_arena_fini completed"); } /* ================================================================= */ diff --git a/sal/rtl/source/alloc_cache.cxx b/sal/rtl/source/alloc_cache.cxx index 0769b8e68a29..d601bdb08fe9 100644 --- a/sal/rtl/source/alloc_cache.cxx +++ b/sal/rtl/source/alloc_cache.cxx @@ -33,13 +33,9 @@ #include "sal/macros.h" #include "osl/diagnose.h" -#ifndef INCLUDED_STRING_H +#include <cassert> #include <string.h> -#endif - -#ifndef INCLUDED_STDIO_H #include <stdio.h> -#endif extern AllocMode alloc_mode; @@ -133,15 +129,15 @@ rtl_cache_hash_rescale ( old_table = cache->m_hash_table; old_size = cache->m_hash_size; - OSL_TRACE( - "rtl_cache_hash_rescale(\"%s\"): " - "nbuf: % " PRIu64 " (ave: %" PRIu64 "), frees: %" PRIu64 " " - "[old_size: %lu, new_size: %lu]", - cache->m_name, - cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free, - (cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free) >> cache->m_hash_shift, - cache->m_slab_stats.m_free, - old_size, new_size); + // SAL_INFO( + // "sal", + // "rtl_cache_hash_rescale(" << cache->m_name << "): nbuf: " + // << (cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free) + // << " (ave: " + // << ((cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free) + // >> cache->m_hash_shift) + // << "), frees: " << cache->m_slab_stats.m_free << " [old_size: " + // << old_size << ", new_size: " << new_size << ']'); cache->m_hash_table = new_table; cache->m_hash_size = new_size; @@ -222,7 +218,7 @@ rtl_cache_hash_remove ( ppHead = &(bufctl->m_next); } - OSL_ASSERT (bufctl != 0); /* bad free */ + assert(bufctl != 0); // bad free if (lookups > 1) { @@ -273,17 +269,10 @@ rtl_cache_slab_constructor (void * obj, void *) static void rtl_cache_slab_destructor (void * obj, void *) { -#if OSL_DEBUG_LEVEL == 0 - (void) obj; /* unused */ -#else /* OSL_DEBUG_LEVEL */ - rtl_cache_slab_type * slab = (rtl_cache_slab_type*)(obj); - - /* assure removed from queue(s) */ - OSL_ASSERT(QUEUE_STARTED_NAMED(slab, slab_)); - - /* assure no longer referenced */ - OSL_ASSERT(slab->m_ntypes == 0); -#endif /* OSL_DEBUG_LEVEL */ + rtl_cache_slab_type * slab = static_cast< rtl_cache_slab_type * >(obj); + assert(QUEUE_STARTED_NAMED(slab, slab_)); // assure removed from queue(s) + assert(slab->m_ntypes == 0); // assure no longer referenced + (void) slab; // avoid warnings } @@ -304,12 +293,12 @@ rtl_cache_slab_create ( addr = rtl_arena_alloc (cache->m_source, &size); if (addr != 0) { - OSL_ASSERT(size >= cache->m_slab_size); + assert(size >= cache->m_slab_size); if (cache->m_features & RTL_CACHE_FEATURE_HASH) { /* allocate slab struct from slab cache */ - OSL_ASSERT (cache != gp_cache_slab_cache); + assert(cache != gp_cache_slab_cache); slab = (rtl_cache_slab_type*)rtl_cache_alloc (gp_cache_slab_cache); } else @@ -362,7 +351,7 @@ rtl_cache_slab_destroy ( /* return bufctl struct to bufctl cache */ rtl_cache_free (gp_cache_bufctl_cache, bufctl); } - OSL_ASSERT(ntypes == 0); + assert(ntypes == 0); /* return slab struct to slab cache */ rtl_cache_free (gp_cache_slab_cache, slab); @@ -437,16 +426,16 @@ rtl_cache_slab_alloc ( rtl_cache_bufctl_type * bufctl; slab = head->m_slab_next; - OSL_ASSERT(slab->m_ntypes < cache->m_ntypes); + assert(slab->m_ntypes < cache->m_ntypes); if (slab->m_sp == 0) { /* initialize bufctl w/ current 'slab->m_bp' */ - OSL_ASSERT (slab->m_bp < slab->m_data + cache->m_ntypes * cache->m_type_size + cache->m_ncolor_max); + assert(slab->m_bp < slab->m_data + cache->m_ntypes * cache->m_type_size + cache->m_ncolor_max); if (cache->m_features & RTL_CACHE_FEATURE_HASH) { /* allocate bufctl */ - OSL_ASSERT (cache != gp_cache_bufctl_cache); + assert(cache != gp_cache_bufctl_cache); bufctl = (rtl_cache_bufctl_type*)rtl_cache_alloc (gp_cache_bufctl_cache); if (bufctl == 0) { @@ -601,17 +590,11 @@ rtl_cache_magazine_constructor (void * obj, void *) static void rtl_cache_magazine_destructor (void * obj, void *) { -#if OSL_DEBUG_LEVEL == 0 - (void) obj; /* unused */ -#else /* OSL_DEBUG_LEVEL */ - rtl_cache_magazine_type * mag = (rtl_cache_magazine_type*)(obj); - - /* assure removed from queue(s) */ - OSL_ASSERT(mag->m_mag_next == 0); - - /* assure no longer referenced */ - OSL_ASSERT(mag->m_mag_used == 0); -#endif /* OSL_DEBUG_LEVEL */ + rtl_cache_magazine_type * mag = static_cast< rtl_cache_magazine_type * >( + obj); + assert(mag->m_mag_next == 0); // assure removed from queue(s) + assert(mag->m_mag_used == 0); // assure no longer referenced + (void) mag; // avoid warnings } @@ -682,7 +665,7 @@ rtl_cache_depot_dequeue ( if (depot->m_mag_count > 0) { /* dequeue magazine */ - OSL_ASSERT(depot->m_mag_next != 0); + assert(depot->m_mag_next != 0); mag = depot->m_mag_next; depot->m_mag_next = mag->m_mag_next; @@ -712,7 +695,7 @@ rtl_cache_depot_exchange_alloc ( { rtl_cache_magazine_type * full; - OSL_ASSERT((empty == 0) || (empty->m_mag_used == 0)); + assert((empty == 0) || (empty->m_mag_used == 0)); /* dequeue full magazine */ full = rtl_cache_depot_dequeue (&(cache->m_depot_full)); @@ -722,7 +705,7 @@ rtl_cache_depot_exchange_alloc ( rtl_cache_depot_enqueue (&(cache->m_depot_empty), empty); } - OSL_ASSERT((full == 0) || (full->m_mag_used > 0)); + assert((full == 0) || (full->m_mag_used > 0)); return (full); } @@ -744,7 +727,7 @@ rtl_cache_depot_exchange_free ( { rtl_cache_magazine_type * empty; - OSL_ASSERT((full == 0) || (full->m_mag_used > 0)); + assert((full == 0) || (full->m_mag_used > 0)); /* dequeue empty magazine */ empty = rtl_cache_depot_dequeue (&(cache->m_depot_empty)); @@ -754,7 +737,7 @@ rtl_cache_depot_exchange_free ( rtl_cache_depot_enqueue (&(cache->m_depot_full), full); } - OSL_ASSERT((empty == 0) || (empty->m_mag_used == 0)); + assert((empty == 0) || (empty->m_mag_used == 0)); return (empty); } @@ -828,17 +811,17 @@ rtl_cache_destructor (void * obj) rtl_cache_type * cache = (rtl_cache_type*)(obj); /* linkage */ - OSL_ASSERT(QUEUE_STARTED_NAMED(cache, cache_)); + assert(QUEUE_STARTED_NAMED(cache, cache_)); /* slab layer */ (void)RTL_MEMORY_LOCK_DESTROY(&(cache->m_slab_lock)); - OSL_ASSERT(QUEUE_STARTED_NAMED(&(cache->m_free_head), slab_)); - OSL_ASSERT(QUEUE_STARTED_NAMED(&(cache->m_used_head), slab_)); + assert(QUEUE_STARTED_NAMED(&(cache->m_free_head), slab_)); + assert(QUEUE_STARTED_NAMED(&(cache->m_used_head), slab_)); - OSL_ASSERT(cache->m_hash_table == cache->m_hash_table_0); - OSL_ASSERT(cache->m_hash_size == RTL_CACHE_HASH_SIZE); - OSL_ASSERT(cache->m_hash_shift == (sal_Size)(highbit(cache->m_hash_size) - 1)); + assert(cache->m_hash_table == cache->m_hash_table_0); + assert(cache->m_hash_size == RTL_CACHE_HASH_SIZE); + assert(cache->m_hash_shift == (sal_Size)(highbit(cache->m_hash_size) - 1)); /* depot layer */ (void)RTL_MEMORY_LOCK_DESTROY(&(cache->m_depot_lock)); @@ -862,7 +845,7 @@ rtl_cache_activate ( int flags ) { - OSL_ASSERT(cache != 0); + assert(cache != 0); if (cache != 0) { sal_Size slabsize; @@ -885,7 +868,7 @@ rtl_cache_activate ( /* ensure minimum alignment */ objalign = SAL_MAX(objalign, RTL_MEMORY_ALIGNMENT_4); } - OSL_ASSERT(RTL_MEMORY_ISP2(objalign)); + assert(RTL_MEMORY_ISP2(objalign)); cache->m_type_size = objsize = RTL_MEMORY_P2ROUNDUP(objsize, objalign); cache->m_type_align = objalign; @@ -918,8 +901,8 @@ rtl_cache_activate ( if (cache->m_slab_size > source->m_quantum) { - OSL_ASSERT(gp_cache_slab_cache != 0); - OSL_ASSERT(gp_cache_bufctl_cache != 0); + assert(gp_cache_slab_cache != 0); + assert(gp_cache_bufctl_cache != 0); cache->m_features |= RTL_CACHE_FEATURE_HASH; cache->m_ntypes = cache->m_slab_size / cache->m_type_size; @@ -932,7 +915,7 @@ rtl_cache_activate ( cache->m_ncolor_max = (cache->m_slab_size - sizeof(rtl_cache_slab_type)) % cache->m_type_size; } - OSL_ASSERT(cache->m_ntypes > 0); + assert(cache->m_ntypes > 0); cache->m_ncolor = 0; if (flags & RTL_CACHE_FLAG_BULKDESTROY) @@ -944,7 +927,7 @@ rtl_cache_activate ( /* magazine layer */ if (!(flags & RTL_CACHE_FLAG_NOMAGAZINE)) { - OSL_ASSERT(gp_cache_magazine_cache != 0); + assert(gp_cache_magazine_cache != 0); cache->m_magazine_cache = gp_cache_magazine_cache; } @@ -971,7 +954,7 @@ rtl_cache_deactivate ( QUEUE_REMOVE_NAMED(cache, cache_); RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); - OSL_PRECOND(active, "rtl_cache_deactivate(): orphaned cache."); + assert(active); // orphaned cache (void)active; /* cleanup magazine layer */ @@ -1010,29 +993,28 @@ rtl_cache_deactivate ( } } - OSL_TRACE( - "rtl_cache_deactivate(\"%s\"): " - "[slab]: allocs: %"PRIu64", frees: %"PRIu64"; total: %lu, used: %lu; " - "[cpu]: allocs: %"PRIu64", frees: %"PRIu64"; " - "[total]: allocs: %"PRIu64", frees: %"PRIu64"", - cache->m_name, - cache->m_slab_stats.m_alloc, cache->m_slab_stats.m_free, - cache->m_slab_stats.m_mem_total, cache->m_slab_stats.m_mem_alloc, - cache->m_cpu_stats.m_alloc, cache->m_cpu_stats.m_free, - cache->m_slab_stats.m_alloc + cache->m_cpu_stats.m_alloc, - cache->m_slab_stats.m_free + cache->m_cpu_stats.m_free - ); + // SAL_INFO( + // "sal", + // "rtl_cache_deactivate(" << cache->m_name << "): [slab]: allocs: " + // << cache->m_slab_stats.m_alloc << ", frees: " + // << cache->m_slab_stats.m_free << "; total: " + // << cache->m_slab_stats.m_mem_total << ", used: " + // << cache->m_slab_stats.m_mem_alloc << "; [cpu]: allocs: " + // << cache->m_cpu_stats.m_alloc << ", frees: " + // << cache->m_cpu_stats.m_free << "; [total]: allocs: " + // << (cache->m_slab_stats.m_alloc + cache->m_cpu_stats.m_alloc) + // << ", frees: " + // << (cache->m_slab_stats.m_free + cache->m_cpu_stats.m_free)); /* cleanup slab layer */ if (cache->m_slab_stats.m_alloc > cache->m_slab_stats.m_free) { - OSL_TRACE( - "rtl_cache_deactivate(\"%s\"): " - "cleaning up %"PRIu64" leaked buffer(s) [%lu bytes] [%lu total]", - cache->m_name, - cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free, - cache->m_slab_stats.m_mem_alloc, cache->m_slab_stats.m_mem_total - ); + // SAL_INFO( + // "sal", + // "rtl_cache_deactivate(" << cache->m_name << "): cleaning up " + // << (cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free) + // << " leaked buffer(s) [" << cache->m_slab_stats.m_mem_alloc + // << " bytes] [" << cache->m_slab_stats.m_mem_total << " total]"); if (cache->m_features & RTL_CACHE_FEATURE_HASH) { @@ -1131,7 +1113,7 @@ try_alloc: if (!source) { /* use default arena */ - OSL_ASSERT(gp_default_arena != 0); + assert(gp_default_arena != 0); source = gp_default_arena; } @@ -1532,18 +1514,16 @@ rtl_cache_wsupdate ( { RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); - OSL_TRACE( - "rtl_cache_wsupdate(\"%s\") " - "[depot: count, curr_min, prev_min] " - "full: %lu, %lu, %lu; empty: %lu, %lu, %lu", - cache->m_name, - cache->m_depot_full.m_mag_count, - cache->m_depot_full.m_curr_min, - cache->m_depot_full.m_prev_min, - cache->m_depot_empty.m_mag_count, - cache->m_depot_empty.m_curr_min, - cache->m_depot_empty.m_prev_min - ); + // SAL_INFO( + // "sal", + // "rtl_cache_wsupdate(" << cache->m_name + // << ") [depot: count, curr_min, prev_min] full: " + // << cache->m_depot_full.m_mag_count << ", " + // << cache->m_depot_full.m_curr_min << ", " + // << cache->m_depot_full.m_prev_min << "; empty: " + // << cache->m_depot_empty.m_mag_count << ", " + // << cache->m_depot_empty.m_curr_min << ", " + // << cache->m_depot_empty.m_prev_min); rtl_cache_depot_wsupdate (cache, &(cache->m_depot_full)); rtl_cache_depot_wsupdate (cache, &(cache->m_depot_empty)); @@ -1603,7 +1583,7 @@ rtl_cache_init() } { /* cache: internal arena */ - OSL_ASSERT(gp_cache_arena == 0); + assert(gp_cache_arena == 0); gp_cache_arena = rtl_arena_create ( "rtl_cache_internal_arena", @@ -1614,16 +1594,16 @@ rtl_cache_init() rtl_arena_free, 0 /* flags */ ); - OSL_ASSERT(gp_cache_arena != 0); + assert(gp_cache_arena != 0); /* check 'gp_default_arena' initialization */ - OSL_ASSERT(gp_default_arena != 0); + assert(gp_default_arena != 0); } { /* cache: magazine cache */ static rtl_cache_type g_cache_magazine_cache; - OSL_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); @@ -1639,7 +1619,7 @@ rtl_cache_init() gp_default_arena, /* source */ RTL_CACHE_FLAG_NOMAGAZINE /* during bootstrap; activated below */ ); - OSL_ASSERT(gp_cache_magazine_cache != 0); + assert(gp_cache_magazine_cache != 0); /* activate magazine layer */ g_cache_magazine_cache.m_magazine_cache = gp_cache_magazine_cache; @@ -1648,7 +1628,7 @@ rtl_cache_init() /* cache: slab (struct) cache */ static rtl_cache_type g_cache_slab_cache; - OSL_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); @@ -1664,13 +1644,13 @@ rtl_cache_init() gp_default_arena, /* source */ 0 /* flags: none */ ); - OSL_ASSERT(gp_cache_slab_cache != 0); + assert(gp_cache_slab_cache != 0); } { /* cache: bufctl cache */ static rtl_cache_type g_cache_bufctl_cache; - OSL_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); @@ -1686,11 +1666,11 @@ rtl_cache_init() gp_default_arena, /* source */ 0 /* flags: none */ ); - OSL_ASSERT(gp_cache_bufctl_cache != 0); + assert(gp_cache_bufctl_cache != 0); } rtl_cache_wsupdate_init(); - OSL_TRACE("rtl_cache_init completed"); + // SAL_INFO("sal", "rtl_cache_init completed"); } /* ================================================================= */ @@ -1735,22 +1715,24 @@ rtl_cache_fini() head = &(g_cache_list.m_cache_head); for (cache = head->m_cache_next; cache != head; cache = cache->m_cache_next) { - OSL_TRACE( - "rtl_cache_fini(\"%s\") " - "[slab]: allocs: %"PRIu64", frees: %"PRIu64"; total: %lu, used: %lu; " - "[cpu]: allocs: %"PRIu64", frees: %"PRIu64"; " - "[total]: allocs: %"PRIu64", frees: %"PRIu64"", - cache->m_name, - cache->m_slab_stats.m_alloc, cache->m_slab_stats.m_free, - cache->m_slab_stats.m_mem_total, cache->m_slab_stats.m_mem_alloc, - cache->m_cpu_stats.m_alloc, cache->m_cpu_stats.m_free, - cache->m_slab_stats.m_alloc + cache->m_cpu_stats.m_alloc, - cache->m_slab_stats.m_free + cache->m_cpu_stats.m_free - ); + // SAL_INFO( + // "sal", + // "rtl_cache_fini(" << cache->m_name << ") [slab]: allocs: " + // << cache->m_slab_stats.m_alloc << ", frees: " + // << cache->m_slab_stats.m_free << "; total: " + // << cache->m_slab_stats.m_mem_total << ", used: " + // << cache->m_slab_stats.m_mem_alloc << "; [cpu]: allocs: " + // << cache->m_cpu_stats.m_alloc << ", frees: " + // << cache->m_cpu_stats.m_free << "; [total]: allocs: " + // << (cache->m_slab_stats.m_alloc + // + cache->m_cpu_stats.m_alloc) + // << ", frees: " + // << (cache->m_slab_stats.m_free + // + cache->m_cpu_stats.m_free)); } RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); } - OSL_TRACE("rtl_cache_fini completed"); + // SAL_INFO("sal", "rtl_cache_fini completed"); } /* ================================================================= */ diff --git a/sal/rtl/source/alloc_global.cxx b/sal/rtl/source/alloc_global.cxx index c0de49659754..6cf7509a9058 100644 --- a/sal/rtl/source/alloc_global.cxx +++ b/sal/rtl/source/alloc_global.cxx @@ -29,8 +29,8 @@ #include "alloc_impl.hxx" #include "rtl/alloc.h" #include <sal/macros.h> -#include <osl/diagnose.h> +#include <cassert> #include <string.h> #include <stdio.h> @@ -41,7 +41,7 @@ AllocMode alloc_mode = AMode_UNSET; #if !defined(FORCE_SYSALLOC) static void determine_alloc_mode() { - OSL_ASSERT(alloc_mode == AMode_UNSET); + assert(alloc_mode == AMode_UNSET); alloc_mode = (getenv("G_SLICE") == NULL ? AMode_CUSTOM : AMode_SYSTEM); } @@ -108,7 +108,7 @@ SAL_CALL rtl_allocateMemory_CUSTOM (sal_Size n) SAL_THROW_EXTERN_C() char * addr; sal_Size size = RTL_MEMORY_ALIGN(n + RTL_MEMALIGN, RTL_MEMALIGN); - OSL_ASSERT(RTL_MEMALIGN >= sizeof(sal_Size)); + assert(RTL_MEMALIGN >= sizeof(sal_Size)); if (n >= SAL_MAX_SIZE - (RTL_MEMALIGN + RTL_MEMALIGN - 1)) { /* requested size too large for roundup alignment */ @@ -198,7 +198,7 @@ void rtl_memory_init() #if !defined(FORCE_SYSALLOC) { /* global memory arena */ - OSL_ASSERT(gp_alloc_arena == 0); + assert(gp_alloc_arena == 0); gp_alloc_arena = rtl_arena_create ( "rtl_alloc_arena", @@ -209,7 +209,7 @@ void rtl_memory_init() rtl_arena_free, 0 /* flags */ ); - OSL_ASSERT(gp_alloc_arena != 0); + assert(gp_alloc_arena != 0); } { sal_Size size; @@ -233,7 +233,7 @@ void rtl_memory_init() } } #endif - OSL_TRACE("rtl_memory_init completed"); + // SAL_INFO("sal", "rtl_memory_init completed"); } /* ================================================================= */ @@ -263,7 +263,7 @@ void rtl_memory_fini() gp_alloc_arena = 0; } #endif - OSL_TRACE("rtl_memory_fini completed"); + // SAL_INFO("sal", "rtl_memory_fini completed"); } /* ================================================================= * |