go reuses frames
This commit is contained in:
@@ -1492,6 +1492,10 @@ void gc_scan_object (JSContext *ctx, void *ptr, uint8_t *from_base, uint8_t *fro
|
||||
allow_grow: if true, grow heap when recovery is poor
|
||||
alloc_size: the allocation that triggered GC — used to size the new block */
|
||||
int ctx_gc (JSContext *ctx, int allow_grow, size_t alloc_size) {
|
||||
#ifdef DUMP_GC_TIMING
|
||||
struct timespec gc_t0, gc_t1;
|
||||
clock_gettime(CLOCK_MONOTONIC, &gc_t0);
|
||||
#endif
|
||||
JSRuntime *rt = ctx->rt;
|
||||
size_t old_used = ctx->heap_free - ctx->heap_base;
|
||||
size_t old_heap_size = ctx->current_block_size;
|
||||
@@ -1692,6 +1696,16 @@ int ctx_gc (JSContext *ctx, int allow_grow, size_t alloc_size) {
|
||||
ctx->gc_bytes_copied += new_used;
|
||||
size_t recovered = old_used > new_used ? old_used - new_used : 0;
|
||||
|
||||
#ifdef DUMP_GC_TIMING
|
||||
clock_gettime(CLOCK_MONOTONIC, &gc_t1);
|
||||
double gc_ms = (gc_t1.tv_sec - gc_t0.tv_sec) * 1000.0 +
|
||||
(gc_t1.tv_nsec - gc_t0.tv_nsec) / 1e6;
|
||||
fprintf(stderr, "GC #%u: %.2f ms | copied %zu KB | old %zu KB -> new %zu KB | recovered %zu KB (%.0f%%)\n",
|
||||
ctx->gc_count, gc_ms,
|
||||
new_used / 1024, old_used / 1024, new_size / 1024,
|
||||
recovered / 1024,
|
||||
old_used > 0 ? (100.0 * recovered / old_used) : 0.0);
|
||||
#endif
|
||||
|
||||
ctx->heap_base = to_base;
|
||||
ctx->heap_free = to_free;
|
||||
|
||||
Reference in New Issue
Block a user