From 833fe991cbea2b0f64020b43408d5d30dd85f16f Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 21 Apr 2018 13:31:12 +0200 Subject: [PATCH] core: Fixes for garbage collector/jam scraper. * src/gc.c (gc_loop): Do not relocate car of TCLOSURE, TCONTINUATION. Check for TBROKEN_HEART. * src/mes.c (make_closure_): Set car to 0. (check_apply): Check for TBROKEN_HEART. Fixes reporting artificial out-of-memory error. (eval_apply): Likewise. * src/vector.c (vector_entry): Only copy TCHAR and TNUMBER. --- src/gc.c | 6 +++--- src/mes.c | 8 +++++++- src/vector.c | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gc.c b/src/gc.c index 9a78356f..e1600c4d 100644 --- a/src/gc.c +++ b/src/gc.c @@ -96,9 +96,9 @@ gc_loop (SCM scan) ///((internal)) SCM cdr; while (scan < g_free) { - if (NTYPE (scan) == TCLOSURE - || NTYPE (scan) == TCONTINUATION - || NTYPE (scan) == TFUNCTION + if (NTYPE (scan) == TBROKEN_HEART) + error (cell_symbol_system_error, cell_gc); + if (NTYPE (scan) == TFUNCTION || NTYPE (scan) == TKEYWORD || NTYPE (scan) == TMACRO || NTYPE (scan) == TPAIR diff --git a/src/mes.c b/src/mes.c index 35a0faf5..fa68ddeb 100644 --- a/src/mes.c +++ b/src/mes.c @@ -579,6 +579,8 @@ check_apply (SCM f, SCM e) ///((internal)) type = "number"; if (TYPE (f) == TSTRING) type = "string"; + if (TYPE (f) == TBROKEN_HEART) + type = "<3"; if (type) { @@ -771,7 +773,7 @@ call_lambda (SCM e, SCM x, SCM aa, SCM a) ///((internal)) SCM make_closure_ (SCM args, SCM body, SCM a) ///((internal)) { - return make_cell__ (TCLOSURE, cell_f, cons (cons (cell_circular, a), cons (args, body))); + return make_cell__ (TCLOSURE, 0, cons (cons (cell_circular, a), cons (args, body))); } SCM @@ -1256,6 +1258,10 @@ eval_apply () r1 = CDR (VARIABLE (r1)); goto vm_return; } + case TBROKEN_HEART: + { + error (cell_symbol_system_error, r1); + } default: goto vm_return; } diff --git a/src/vector.c b/src/vector.c index 701fd6de..b7dd25d9 100644 --- a/src/vector.c +++ b/src/vector.c @@ -59,7 +59,7 @@ vector_ref (SCM x, SCM i) SCM vector_entry (SCM x) { - if (TYPE (x) == TPAIR || TYPE (x) == TSPECIAL || TYPE (x) == TSTRING || TYPE (x) == TSYMBOL || TYPE (x) == TVECTOR) + if (TYPE (x) != TCHAR && TYPE (x) != TNUMBER) x = MAKE_REF (x); return x; }