diff options
| author | 2022-10-09 10:00:52 +0200 | |
|---|---|---|
| committer | 2022-10-09 10:00:52 +0200 | |
| commit | f04e8718a3aae2a03a5df4dfff7c773f3cf19a99 (patch) | |
| tree | d1008ef0ae0350662e2f2d1c27204a520d1d90a3 /pez.c | |
| parent | d4ab29a4adf9ee1c9aa0e80539910a16a7c1a762 (diff) | |
gc erratas
Diffstat (limited to 'pez.c')
| -rw-r--r-- | pez.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -754,8 +754,10 @@ static void gc(PezContext *cx) { uint nalloc = cx->nalloc; - fprintf(stderr, "--- GC running with %d bytes allocated\n", - nalloc); + if (cx->dbg & DBGgcinfo) { + fprintf(stderr, "--- GC running with %d bytes allocated\n", + nalloc); + } for (Val *stk = cx->stack; stk != cx->stktop; ++stk) { if (isobj(*stk)) { gcmark(cx, unbox_obj(*stk)); @@ -777,12 +779,13 @@ gc(PezContext *cx) for (Obj *o = cx->heap, *next, *prev = NULL; o; o = next) { next = o->next; if (o->gc) { - fprintf(stderr, "live %p %s\n", o, typestr(box_obj(o))); + if (cx->dbg & DBGgcinfo) + fprintf(stderr, "live %p %s\n", o, typestr(box_obj(o))); prev = o; o->gc = 0; } else { - fprintf(stderr, "dead %p %s\n", o, typestr(box_obj(o))); - // fprintf(stderr, "free %p %s\n", o, typestr(box_obj(o))); + if (cx->dbg & DBGgcinfo) + fprintf(stderr, "dead %p %s\n", o, typestr(box_obj(o))); if (o == cx->heap) { cx->heap = next; } @@ -3423,6 +3426,9 @@ pez_eval_cb(PezContext *cx, const char *fname, int (*cb)(void *), void *ud) ETRY(exefn(cx, fn, 0)); cx->stktop[-2] = cx->stktop[-1]; --cx->stktop; // gc unkeep + if (cx->dbg & DBGstressgc) { + gc(cx); + } deinitcomp(&cm); cx->gccanrun = gccanrun; |