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:
@@ -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; \
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user