Introducing 'try to give memory back' callback for heap allocator to use upon allocation request that can not be satisfied by the allocator.

This commit is contained in:
Ruben Ayrapetyan
2014-12-18 21:20:28 +03:00
parent 8febd2bae8
commit 6bb39bb8ea
14 changed files with 308 additions and 105 deletions
+3 -19
View File
@@ -16,6 +16,7 @@
#include "ecma-alloc.h"
#include "ecma-globals.h"
#include "ecma-gc.h"
#include "ecma-lcache.h"
#include "globals.h"
#include "mem-poolman.h"
@@ -59,26 +60,9 @@ JERRY_STATIC_ASSERT (sizeof (ecma_label_descriptor_t) == sizeof (uint64_t));
{ \
ecma_ ## ecma_type ## _t *p ## ecma_type = (ecma_ ## ecma_type ## _t *) mem_pools_alloc (); \
\
if (likely (p ## ecma_type != NULL)) \
{ \
return p ## ecma_type; \
} \
JERRY_ASSERT (p ## ecma_type != NULL); \
\
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; \
gen_id < ECMA_GC_GEN_COUNT; \
gen_id++) \
{ \
ecma_gc_run (gen_id); \
\
p ## ecma_type = (ecma_ ## ecma_type ## _t *) mem_pools_alloc (); \
\
if (likely (p ## ecma_type != NULL)) \
{ \
return p ## ecma_type; \
} \
} \
\
jerry_exit (ERR_OUT_OF_MEMORY); \
return p ## ecma_type; \
}
/**