15#if defined(DUK_USE_MARK_AND_SWEEP) && defined(DUK_USE_VOLUNTARY_GC)
16#define DUK__VOLUNTARY_PERIODIC_GC(heap) do { \
17 (heap)->mark_and_sweep_trigger_counter--; \
18 if ((heap)->mark_and_sweep_trigger_counter <= 0) { \
19 duk__run_voluntary_gc(heap); \
25 DUK_DD(
DUK_DDPRINT(
"mark-and-sweep in progress -> skip voluntary mark-and-sweep now"));
37#define DUK__VOLUNTARY_PERIODIC_GC(heap)
44#ifdef DUK_USE_MARK_AND_SWEEP
63#ifdef DUK_USE_GC_TORTURE
73 if (res || size == 0) {
77#ifdef DUK_USE_GC_TORTURE
81 DUK_D(
DUK_DPRINT(
"first alloc attempt failed, attempt to gc and retry"));
90 DUK_D(
DUK_DPRINT(
"duk_heap_mem_alloc() failed, gc in progress (gc skipped), alloc size %ld", (
long) size));
113 DUK_D(
DUK_DPRINT(
"duk_heap_mem_alloc() succeeded after gc (pass %ld), alloc size %ld",
114 (
long) (i + 1), (
long) size));
119 DUK_D(
DUK_DPRINT(
"duk_heap_mem_alloc() failed even after gc, alloc size %ld", (
long) size));
153#ifdef DUK_USE_MARK_AND_SWEEP
173#ifdef DUK_USE_GC_TORTURE
183 if (res || newsize == 0) {
187#ifdef DUK_USE_GC_TORTURE
191 DUK_D(
DUK_DPRINT(
"first realloc attempt failed, attempt to gc and retry"));
198 DUK_D(
DUK_DPRINT(
"duk_heap_mem_realloc() failed, gc in progress (gc skipped), alloc size %ld", (
long) newsize));
220 if (res || newsize == 0) {
221 DUK_D(
DUK_DPRINT(
"duk_heap_mem_realloc() succeeded after gc (pass %ld), alloc size %ld",
222 (
long) (i + 1), (
long) newsize));
227 DUK_D(
DUK_DPRINT(
"duk_heap_mem_realloc() failed even after gc, alloc size %ld", (
long) newsize));
247#ifdef DUK_USE_MARK_AND_SWEEP
266#ifdef DUK_USE_GC_TORTURE
269 DUK_DDD(
DUK_DDDPRINT(
"gc torture enabled, pretend that first indirect realloc attempt fails"));
276 if (res || newsize == 0) {
280#ifdef DUK_USE_GC_TORTURE
284 DUK_D(
DUK_DPRINT(
"first indirect realloc attempt failed, attempt to gc and retry"));
291 DUK_D(
DUK_DPRINT(
"duk_heap_mem_realloc_indirect() failed, gc in progress (gc skipped), alloc size %ld", (
long) newsize));
304#ifdef DUK_USE_ASSERTIONS
309#ifdef DUK_USE_ASSERTIONS
310 ptr_pre = cb(heap, ud);
319#ifdef DUK_USE_ASSERTIONS
320 ptr_post = cb(heap, ud);
321 if (ptr_pre != ptr_post) {
324 (
void *) ptr_pre, (
void *) ptr_post));
333 if (res || newsize == 0) {
334 DUK_D(
DUK_DPRINT(
"duk_heap_mem_realloc_indirect() succeeded after gc (pass %ld), alloc size %ld",
335 (
long) (i + 1), (
long) newsize));
340 DUK_D(
DUK_DPRINT(
"duk_heap_mem_realloc_indirect() failed even after gc, alloc size %ld", (
long) newsize));
354#ifdef DUK_USE_MARK_AND_SWEEP
369#ifdef DUK_USE_VOLUNTARY_GC
unsigned int duk_small_uint_t
#define DUK_MEMZERO(p, n)
duk_small_int_t duk_bool_t
#define DUK_MS_FLAG_EMERGENCY
#define DUK_ALLOC(heap, size)
#define DUK_ASSERT_DISABLE(x)
DUK_INTERNAL_DECL duk_bool_t duk_heap_mark_and_sweep(duk_heap *heap, duk_small_uint_t flags)
#define DUK_HEAP_HAS_MARKANDSWEEP_RUNNING(heap)
#define DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_LIMIT
void *(* duk_mem_getptr)(duk_heap *heap, void *ud)
#define DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_EMERGENCY_LIMIT
DUK_LOCAL void duk__run_voluntary_gc(duk_heap *heap)
DUK_INTERNAL void duk_heap_mem_free(duk_heap *heap, void *ptr)
DUK_INTERNAL void * duk_heap_mem_alloc(duk_heap *heap, duk_size_t size)
DUK_INTERNAL void * duk_heap_mem_alloc_zeroed(duk_heap *heap, duk_size_t size)
DUK_INTERNAL void * duk_heap_mem_realloc_indirect(duk_heap *heap, duk_mem_getptr cb, void *ud, duk_size_t newsize)
#define DUK__VOLUNTARY_PERIODIC_GC(heap)
DUK_INTERNAL void * duk_heap_mem_realloc(duk_heap *heap, void *ptr, duk_size_t newsize)
duk_int_t mark_and_sweep_trigger_counter
duk_realloc_function realloc_func
duk_free_function free_func
duk_alloc_function alloc_func