mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2026-01-23 03:39:26 +00:00
Organize public and internal parts of memory management (#1539)
* Introduced new 'jmem.h' for public part. * Removed obsolete headers JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
parent
f88d1a4863
commit
976c8aee80
@ -18,7 +18,7 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-lcache.h"
|
||||
#include "jrt.h"
|
||||
#include "jmem-poolman.h"
|
||||
#include "jmem.h"
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_property_value_t) == sizeof (ecma_value_t),
|
||||
size_of_ecma_property_value_t_must_be_equal_to_size_of_ecma_value_t);
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
#define ECMA_GC_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "jmem-allocator.h"
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "config.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-magic-strings.h"
|
||||
#include "jmem-allocator.h"
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@ -38,7 +38,11 @@
|
||||
* The offset is shifted right by JMEM_ALIGNMENT_LOG.
|
||||
* Least significant JMEM_ALIGNMENT_LOG bits of non-shifted offset are zeroes.
|
||||
*/
|
||||
#define ECMA_POINTER_FIELD_WIDTH JMEM_CP_WIDTH
|
||||
#ifdef JERRY_CPOINTER_32_BIT
|
||||
#define ECMA_POINTER_FIELD_WIDTH 32
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
#define ECMA_POINTER_FIELD_WIDTH 16
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
|
||||
/**
|
||||
* The NULL value for compressed pointers
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
#define ECMA_HELPERS_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "jmem-allocator.h"
|
||||
#include "jmem.h"
|
||||
#include "lit-strings.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#include "ecma-lcache.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
#include "jmem-allocator.h"
|
||||
#include "jmem.h"
|
||||
#include "jcontext.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
#define ECMA_LIT_STORAGE_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "jmem-allocator.h"
|
||||
#include "jmem.h"
|
||||
#include "lit-globals.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -20,8 +20,7 @@
|
||||
#define JCONTEXT_H
|
||||
|
||||
#include "ecma-builtins.h"
|
||||
#include "jmem-allocator.h"
|
||||
#include "jmem-config.h"
|
||||
#include "jmem.h"
|
||||
#include "re-bytecode.h"
|
||||
#include "vm-defines.h"
|
||||
|
||||
|
||||
@ -24,9 +24,33 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef JMEM_STATS
|
||||
void jmem_heap_get_stats (jmem_heap_stats_t *);
|
||||
void jmem_heap_stats_reset_peak (void);
|
||||
void jmem_heap_stats_print (void);
|
||||
#endif /* JMEM_STATS */
|
||||
|
||||
void jmem_heap_init (void);
|
||||
void jmem_heap_finalize (void);
|
||||
bool jmem_is_heap_pointer (const void *pointer);
|
||||
|
||||
void jmem_run_free_unused_memory_callbacks (jmem_free_unused_memory_severity_t severity);
|
||||
|
||||
/**
|
||||
* \addtogroup poolman Memory pool manager
|
||||
* @{
|
||||
*/
|
||||
#ifdef JMEM_STATS
|
||||
void jmem_pools_get_stats (jmem_pools_stats_t *);
|
||||
void jmem_pools_stats_reset_peak (void);
|
||||
void jmem_pools_stats_print (void);
|
||||
#endif /* JMEM_STATS */
|
||||
|
||||
void jmem_pools_finalize (void);
|
||||
void jmem_pools_collect_empty (void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
@ -18,9 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jmem-allocator.h"
|
||||
#include "jmem-heap.h"
|
||||
#include "jmem-poolman.h"
|
||||
#include "jmem.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
#define JMEM_ALLOCATOR_INTERNAL
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef JMEM_CONFIG_H
|
||||
#define JMEM_CONFIG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* Size of heap
|
||||
*/
|
||||
#define JMEM_HEAP_SIZE ((size_t) (CONFIG_MEM_HEAP_AREA_SIZE))
|
||||
|
||||
/**
|
||||
* Logarithm of required alignment for allocated units/blocks
|
||||
*/
|
||||
#define JMEM_ALIGNMENT_LOG 3
|
||||
|
||||
#endif /* !JMEM_CONFIG_H */
|
||||
@ -18,9 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jmem-allocator.h"
|
||||
#include "jmem-config.h"
|
||||
#include "jmem-heap.h"
|
||||
#include "jmem.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
@ -51,15 +49,12 @@
|
||||
#endif /* JERRY_VALGRIND */
|
||||
|
||||
#ifdef JERRY_VALGRIND_FREYA
|
||||
# include "memcheck.h"
|
||||
|
||||
/**
|
||||
* Called by pool manager before a heap allocation or free.
|
||||
*/
|
||||
void jmem_heap_valgrind_freya_mempool_request (void)
|
||||
{
|
||||
JERRY_CONTEXT (valgrind_freya_mempool_request) = true;
|
||||
} /* jmem_heap_valgrind_freya_mempool_request */
|
||||
#ifdef JERRY_VALGRIND
|
||||
#error Valgrind and valgrind-freya modes are not compatible.
|
||||
#endif /* JERRY_VALGRIND */
|
||||
|
||||
#include "memcheck.h"
|
||||
|
||||
# define VALGRIND_FREYA_CHECK_MEMPOOL_REQUEST \
|
||||
bool mempool_request = JERRY_CONTEXT (valgrind_freya_mempool_request); \
|
||||
|
||||
@ -1,121 +0,0 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Heap allocator interface
|
||||
*/
|
||||
#ifndef JMEM_HEAP_H
|
||||
#define JMEM_HEAP_H
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
/** \addtogroup mem Memory allocation
|
||||
* @{
|
||||
*
|
||||
* \addtogroup heap Heap
|
||||
* @{
|
||||
*/
|
||||
|
||||
void jmem_heap_init (void);
|
||||
void jmem_heap_finalize (void);
|
||||
void *jmem_heap_alloc_block (const size_t size);
|
||||
void *jmem_heap_alloc_block_null_on_error (const size_t size);
|
||||
void jmem_heap_free_block (void *ptr, const size_t size);
|
||||
bool jmem_is_heap_pointer (const void *pointer);
|
||||
|
||||
#ifdef JMEM_STATS
|
||||
/**
|
||||
* Heap memory usage statistics
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
size_t size; /**< size */
|
||||
|
||||
size_t allocated_bytes; /**< currently allocated bytes */
|
||||
size_t peak_allocated_bytes; /**< peak allocated bytes */
|
||||
size_t global_peak_allocated_bytes; /**< non-resettable peak allocated bytes */
|
||||
|
||||
size_t waste_bytes; /**< bytes waste due to blocks filled partially
|
||||
and due to block headers */
|
||||
size_t peak_waste_bytes; /**< peak bytes waste */
|
||||
size_t global_peak_waste_bytes; /**< non-resettable peak bytes waste */
|
||||
|
||||
size_t skip_count;
|
||||
size_t nonskip_count;
|
||||
|
||||
size_t alloc_count;
|
||||
size_t alloc_iter_count;
|
||||
|
||||
size_t free_count;
|
||||
size_t free_iter_count;
|
||||
} jmem_heap_stats_t;
|
||||
|
||||
void jmem_heap_get_stats (jmem_heap_stats_t *);
|
||||
void jmem_heap_stats_reset_peak (void);
|
||||
void jmem_heap_stats_print (void);
|
||||
#endif /* JMEM_STATS */
|
||||
|
||||
#ifdef JERRY_VALGRIND_FREYA
|
||||
|
||||
#ifdef JERRY_VALGRIND
|
||||
#error Valgrind and valgrind-freya modes are not compatible.
|
||||
#endif /* JERRY_VALGRIND */
|
||||
|
||||
void jmem_heap_valgrind_freya_mempool_request (void);
|
||||
|
||||
#define JMEM_HEAP_VALGRIND_FREYA_MEMPOOL_REQUEST() jmem_heap_valgrind_freya_mempool_request ()
|
||||
|
||||
#else /* !JERRY_VALGRIND_FREYA */
|
||||
|
||||
#define JMEM_HEAP_VALGRIND_FREYA_MEMPOOL_REQUEST()
|
||||
|
||||
#endif /* JERRY_VALGRIND_FREYA */
|
||||
|
||||
/**
|
||||
* Define a local array variable and allocate memory for the array on the heap.
|
||||
*
|
||||
* If requested number of elements is zero, assign NULL to the variable.
|
||||
*
|
||||
* Warning:
|
||||
* if there is not enough memory on the heap, shutdown engine with ERR_OUT_OF_MEMORY.
|
||||
*/
|
||||
#define JMEM_DEFINE_LOCAL_ARRAY(var_name, number, type) \
|
||||
{ \
|
||||
size_t var_name ## ___size = (size_t) (number) * sizeof (type); \
|
||||
type *var_name = (type *) (jmem_heap_alloc_block (var_name ## ___size));
|
||||
|
||||
/**
|
||||
* Free the previously defined local array variable, freeing corresponding block on the heap,
|
||||
* if it was allocated (i.e. if the array's size was non-zero).
|
||||
*/
|
||||
#define JMEM_FINALIZE_LOCAL_ARRAY(var_name) \
|
||||
if (var_name != NULL) \
|
||||
{ \
|
||||
JERRY_ASSERT (var_name ## ___size != 0); \
|
||||
\
|
||||
jmem_heap_free_block (var_name, var_name ## ___size); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
JERRY_ASSERT (var_name ## ___size == 0); \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !JMEM_HEAP_H */
|
||||
@ -18,9 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jmem-allocator.h"
|
||||
#include "jmem-heap.h"
|
||||
#include "jmem-poolman.h"
|
||||
#include "jmem.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
#define JMEM_ALLOCATOR_INTERNAL
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pool manager interface
|
||||
*/
|
||||
#ifndef JMEM_POOLMAN_H
|
||||
#define JMEM_POOLMAN_H
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
/** \addtogroup mem Memory allocation
|
||||
* @{
|
||||
*
|
||||
* \addtogroup poolman Memory pool manager
|
||||
* @{
|
||||
*/
|
||||
|
||||
void jmem_pools_finalize (void);
|
||||
void *jmem_pools_alloc (size_t size);
|
||||
void jmem_pools_free (void *chunk_p, size_t size);
|
||||
void jmem_pools_collect_empty (void);
|
||||
|
||||
#ifdef JMEM_STATS
|
||||
/**
|
||||
* Pools' memory usage statistics
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/** pools' count */
|
||||
size_t pools_count;
|
||||
|
||||
/** peak pools' count */
|
||||
size_t peak_pools_count;
|
||||
|
||||
/** non-resettable peak pools' count */
|
||||
size_t global_peak_pools_count;
|
||||
|
||||
/** free chunks count */
|
||||
size_t free_chunks;
|
||||
|
||||
/* Number of newly allocated pool chunks */
|
||||
size_t new_alloc_count;
|
||||
|
||||
/* Number of reused pool chunks */
|
||||
size_t reused_count;
|
||||
} jmem_pools_stats_t;
|
||||
|
||||
void jmem_pools_get_stats (jmem_pools_stats_t *);
|
||||
void jmem_pools_stats_reset_peak (void);
|
||||
void jmem_pools_stats_print (void);
|
||||
#endif /* JMEM_STATS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !JMEM_POOLMAN_H */
|
||||
@ -13,21 +13,36 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allocator interface
|
||||
*/
|
||||
#ifndef JMEM_ALLOCATOR_H
|
||||
#define JMEM_ALLOCATOR_H
|
||||
|
||||
#include "jrt.h"
|
||||
#include "jmem-config.h"
|
||||
#include "jmem-heap.h"
|
||||
#include "jmem-poolman.h"
|
||||
#ifndef JMEM_H
|
||||
#define JMEM_H
|
||||
|
||||
/** \addtogroup mem Memory allocation
|
||||
* @{
|
||||
*
|
||||
* \addtogroup heap Heap
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Size of heap
|
||||
*/
|
||||
#define JMEM_HEAP_SIZE ((size_t) (CONFIG_MEM_HEAP_AREA_SIZE))
|
||||
|
||||
/**
|
||||
* Logarithm of required alignment for allocated units/blocks
|
||||
*/
|
||||
#define JMEM_ALIGNMENT_LOG 3
|
||||
|
||||
/**
|
||||
* Representation of NULL value for compressed pointers
|
||||
*/
|
||||
#define JMEM_CP_NULL ((jmem_cpointer_t) 0)
|
||||
|
||||
/**
|
||||
* Required alignment for allocated units/blocks
|
||||
*/
|
||||
#define JMEM_ALIGNMENT (1u << JMEM_ALIGNMENT_LOG)
|
||||
|
||||
/**
|
||||
* Compressed pointer representations
|
||||
*
|
||||
@ -57,25 +72,6 @@ typedef uint32_t jmem_cpointer_t;
|
||||
typedef uint16_t jmem_cpointer_t;
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
|
||||
/**
|
||||
* Width of compressed memory pointer
|
||||
*/
|
||||
#ifdef JERRY_CPOINTER_32_BIT
|
||||
#define JMEM_CP_WIDTH 32
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
#define JMEM_CP_WIDTH 16
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
|
||||
/**
|
||||
* Representation of NULL value for compressed pointers
|
||||
*/
|
||||
#define JMEM_CP_NULL ((jmem_cpointer_t) 0)
|
||||
|
||||
/**
|
||||
* Required alignment for allocated units/blocks
|
||||
*/
|
||||
#define JMEM_ALIGNMENT (1u << JMEM_ALIGNMENT_LOG)
|
||||
|
||||
/**
|
||||
* Severity of a 'try give memory back' request
|
||||
*
|
||||
@ -87,32 +83,109 @@ typedef uint16_t jmem_cpointer_t;
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JMEM_FREE_UNUSED_MEMORY_SEVERITY_LOW, /* 'low' severity */
|
||||
JMEM_FREE_UNUSED_MEMORY_SEVERITY_HIGH, /* 'high' severity */
|
||||
JMEM_FREE_UNUSED_MEMORY_SEVERITY_LOW, /**< 'low' severity */
|
||||
JMEM_FREE_UNUSED_MEMORY_SEVERITY_HIGH, /**< 'high' severity */
|
||||
} jmem_free_unused_memory_severity_t;
|
||||
|
||||
/**
|
||||
* Free region node
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t next_offset; /* Offset of next region in list */
|
||||
uint32_t size; /* Size of region */
|
||||
} jmem_heap_free_t;
|
||||
|
||||
/**
|
||||
* Node for free chunk list
|
||||
*/
|
||||
typedef struct jmem_pools_chunk_t
|
||||
{
|
||||
struct jmem_pools_chunk_t *next_p; /* pointer to next pool chunk */
|
||||
struct jmem_pools_chunk_t *next_p; /**< pointer to next pool chunk */
|
||||
} jmem_pools_chunk_t;
|
||||
|
||||
/**
|
||||
* Free region node
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t next_offset; /**< Offset of next region in list */
|
||||
uint32_t size; /**< Size of region */
|
||||
} jmem_heap_free_t;
|
||||
|
||||
void jmem_init (void);
|
||||
void jmem_finalize (void);
|
||||
|
||||
void *jmem_heap_alloc_block (const size_t size);
|
||||
void *jmem_heap_alloc_block_null_on_error (const size_t size);
|
||||
void jmem_heap_free_block (void *ptr, const size_t size);
|
||||
|
||||
#ifdef JMEM_STATS
|
||||
/**
|
||||
* Heap memory usage statistics
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
size_t size; /**< size */
|
||||
|
||||
size_t allocated_bytes; /**< currently allocated bytes */
|
||||
size_t peak_allocated_bytes; /**< peak allocated bytes */
|
||||
size_t global_peak_allocated_bytes; /**< non-resettable peak allocated bytes */
|
||||
|
||||
size_t waste_bytes; /**< bytes waste due to blocks filled partially
|
||||
* and due to block headers */
|
||||
size_t peak_waste_bytes; /**< peak bytes waste */
|
||||
size_t global_peak_waste_bytes; /**< non-resettable peak bytes waste */
|
||||
|
||||
size_t skip_count; /**< Number of skip-aheads during insertion of free block */
|
||||
size_t nonskip_count; /**< Number of times we could not skip ahead during
|
||||
* free block insertion */
|
||||
|
||||
size_t alloc_count; /**< Number of allocation of new pool chunk */
|
||||
size_t alloc_iter_count; /**< Number of iterations required for allocations */
|
||||
|
||||
size_t free_count; /**< Number of freeing of pool chunk */
|
||||
size_t free_iter_count; /**< Number of iterations required for inserting free blocks */
|
||||
} jmem_heap_stats_t;
|
||||
|
||||
void jmem_stats_reset_peak (void);
|
||||
void jmem_stats_print (void);
|
||||
#endif /* JMEM_STATS */
|
||||
|
||||
jmem_cpointer_t jmem_compress_pointer (const void *pointer_p);
|
||||
void *jmem_decompress_pointer (uintptr_t compressed_pointer);
|
||||
|
||||
/**
|
||||
* A free memory callback routine type.
|
||||
*/
|
||||
typedef void (*jmem_free_unused_memory_callback_t) (jmem_free_unused_memory_severity_t);
|
||||
|
||||
void jmem_register_free_unused_memory_callback (jmem_free_unused_memory_callback_t callback);
|
||||
void jmem_unregister_free_unused_memory_callback (jmem_free_unused_memory_callback_t callback);
|
||||
|
||||
void jmem_run_free_unused_memory_callbacks (jmem_free_unused_memory_severity_t severity);
|
||||
|
||||
/**
|
||||
* Define a local array variable and allocate memory for the array on the heap.
|
||||
*
|
||||
* If requested number of elements is zero, assign NULL to the variable.
|
||||
*
|
||||
* Warning:
|
||||
* if there is not enough memory on the heap, shutdown engine with ERR_OUT_OF_MEMORY.
|
||||
*/
|
||||
#define JMEM_DEFINE_LOCAL_ARRAY(var_name, number, type) \
|
||||
{ \
|
||||
size_t var_name ## ___size = (size_t) (number) * sizeof (type); \
|
||||
type *var_name = (type *) (jmem_heap_alloc_block (var_name ## ___size));
|
||||
|
||||
/**
|
||||
* Free the previously defined local array variable, freeing corresponding block on the heap,
|
||||
* if it was allocated (i.e. if the array's size was non-zero).
|
||||
*/
|
||||
#define JMEM_FINALIZE_LOCAL_ARRAY(var_name) \
|
||||
if (var_name != NULL) \
|
||||
{ \
|
||||
JERRY_ASSERT (var_name ## ___size != 0); \
|
||||
\
|
||||
jmem_heap_free_block (var_name, var_name ## ___size); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
JERRY_ASSERT (var_name ## ___size == 0); \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value of pointer from specified non-null compressed pointer value
|
||||
*/
|
||||
@ -151,22 +224,32 @@ typedef void (*jmem_free_unused_memory_callback_t) (jmem_free_unused_memory_seve
|
||||
} \
|
||||
} while (false);
|
||||
|
||||
void jmem_init (void);
|
||||
void jmem_finalize (void);
|
||||
|
||||
jmem_cpointer_t jmem_compress_pointer (const void *pointer_p);
|
||||
void *jmem_decompress_pointer (uintptr_t compressed_pointer);
|
||||
|
||||
void jmem_register_free_unused_memory_callback (jmem_free_unused_memory_callback_t callback);
|
||||
void jmem_unregister_free_unused_memory_callback (jmem_free_unused_memory_callback_t callback);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* \addtogroup poolman Memory pool manager
|
||||
* @{
|
||||
*/
|
||||
#ifdef JMEM_STATS
|
||||
void jmem_stats_reset_peak (void);
|
||||
void jmem_stats_print (void);
|
||||
/**
|
||||
* Pools' memory usage statistics
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
size_t pools_count; /**< pools' count */
|
||||
size_t peak_pools_count; /**< peak pools' count */
|
||||
size_t global_peak_pools_count; /**< non-resettable peak pools' count */
|
||||
size_t free_chunks; /**< free chunks count */
|
||||
size_t new_alloc_count; /**< Number of newly allocated pool chunks */
|
||||
size_t reused_count; /**< Number of reused pool chunks */
|
||||
} jmem_pools_stats_t;
|
||||
#endif /* JMEM_STATS */
|
||||
|
||||
void *jmem_pools_alloc (size_t size);
|
||||
void jmem_pools_free (void *chunk_p, size_t size);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !JMEM_ALLOCATOR_H */
|
||||
#endif /* !JMEM_H */
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-regexp-object.h"
|
||||
#include "jmem-heap.h"
|
||||
#include "jmem.h"
|
||||
|
||||
/* Immediate management. */
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jcontext.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jmem-heap.h"
|
||||
#include "jmem.h"
|
||||
#include "re-bytecode.h"
|
||||
#include "re-compiler.h"
|
||||
#include "re-parser.h"
|
||||
|
||||
@ -13,7 +13,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "jmem-allocator.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "jmem.h"
|
||||
|
||||
#define JMEM_ALLOCATOR_INTERNAL
|
||||
#include "jmem-allocator-internal.h"
|
||||
|
||||
#include "test-common.h"
|
||||
|
||||
|
||||
@ -17,10 +17,14 @@
|
||||
* Unit test for pool manager.
|
||||
*/
|
||||
|
||||
#define JERRY_MEM_POOL_INTERNAL
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "jmem-allocator.h"
|
||||
#include "jmem-poolman.h"
|
||||
#include "jmem.h"
|
||||
|
||||
#define JMEM_ALLOCATOR_INTERNAL
|
||||
#include "jmem-allocator-internal.h"
|
||||
|
||||
#include "test-common.h"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user