Compacting pool header to 8 bytes. Replaced typed pool chunks with fixed-size untyped ones. loop_arithmetics_1kk.js benchmark: 2.98517 -> 2.9443.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "globals.h"
|
||||
#include "jerry-libc.h"
|
||||
#include "mem-allocator.h"
|
||||
#include "mem-heap.h"
|
||||
#include "mem-poolman.h"
|
||||
@@ -54,6 +55,25 @@ mem_finalize( bool is_show_mem_stats) /**< show heap memory stats
|
||||
if (is_show_mem_stats)
|
||||
{
|
||||
mem_heap_print( false, false, true);
|
||||
|
||||
#ifdef MEM_STATS
|
||||
mem_pools_stats_t stats;
|
||||
mem_pools_get_stats( &stats);
|
||||
|
||||
__printf("Pools stats:\n");
|
||||
__printf(" Chunk size: %u\n"
|
||||
" Pools: %lu\n"
|
||||
" Allocated chunks: %lu\n"
|
||||
" Free chunks: %lu\n"
|
||||
" Peak pools: %lu\n"
|
||||
" Peak allocated chunks: %lu\n\n",
|
||||
MEM_POOL_CHUNK_SIZE,
|
||||
stats.pools_count,
|
||||
stats.allocated_chunks,
|
||||
stats.free_chunks,
|
||||
stats.peak_pools_count,
|
||||
stats.peak_allocated_chunks);
|
||||
#endif /* MEM_STATS */
|
||||
}
|
||||
|
||||
mem_heap_finalize();
|
||||
@@ -62,8 +82,46 @@ mem_finalize( bool is_show_mem_stats) /**< show heap memory stats
|
||||
/**
|
||||
* Get base pointer for allocation area.
|
||||
*/
|
||||
uintptr_t
|
||||
static uintptr_t
|
||||
mem_get_base_pointer( void)
|
||||
{
|
||||
return (uintptr_t) mem_heap_area;
|
||||
} /* mem_get_base_pointer */
|
||||
|
||||
/**
|
||||
* Compress pointer.
|
||||
*/
|
||||
uintptr_t
|
||||
mem_compress_pointer(void *pointer) /**< pointer to compress */
|
||||
{
|
||||
JERRY_ASSERT( pointer != NULL );
|
||||
|
||||
uintptr_t int_ptr = (uintptr_t) pointer;
|
||||
|
||||
JERRY_ASSERT(int_ptr % MEM_ALIGNMENT == 0);
|
||||
|
||||
int_ptr -= mem_get_base_pointer();
|
||||
int_ptr >>= MEM_ALIGNMENT_LOG;
|
||||
|
||||
JERRY_ASSERT((int_ptr & ~((1u << MEM_HEAP_OFFSET_LOG) - 1)) == 0);
|
||||
|
||||
JERRY_ASSERT( int_ptr != MEM_COMPRESSED_POINTER_NULL );
|
||||
|
||||
return int_ptr;
|
||||
} /* mem_compress_pointer */
|
||||
|
||||
/**
|
||||
* Decompress pointer.
|
||||
*/
|
||||
void*
|
||||
mem_decompress_pointer(uintptr_t compressed_pointer) /**< pointer to decompress */
|
||||
{
|
||||
JERRY_ASSERT( compressed_pointer != MEM_COMPRESSED_POINTER_NULL );
|
||||
|
||||
uintptr_t int_ptr = compressed_pointer;
|
||||
|
||||
int_ptr <<= MEM_ALIGNMENT_LOG;
|
||||
int_ptr += mem_get_base_pointer();
|
||||
|
||||
return (void*) int_ptr;
|
||||
} /* mem_decompress_pointer */
|
||||
|
||||
Reference in New Issue
Block a user