klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 55ec7ab33e1f1f512c7913965b9e3d11343a1131
parent 9b4983c0ff03dfb6f205462c2a6f10581fdde7b8
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Wed, 20 Apr 2011 10:59:09 -0300

GC Bugfix: in add_binding, an intermediate pair wasn't being rooted (Thanks Valgrind!).

Diffstat:
Msrc/kenvironment.c | 2++
Msrc/klispconf.h | 5+++--
Msrc/kstate.c | 3++-
3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/kenvironment.c b/src/kenvironment.c @@ -124,7 +124,9 @@ void kadd_binding(klisp_State *K, TValue env, TValue sym, TValue val) if (ttisnil(oldb)) { TValue new_pair = kcons(K, sym, val); + krooted_tvs_push(K, new_pair); kenv_bindings(K, env) = kcons(K, new_pair, bindings); + krooted_tvs_pop(K); } else { kset_cdr(oldb, val); } diff --git a/src/klispconf.h b/src/klispconf.h @@ -16,7 +16,7 @@ /* XXX: disable the gc till the bug is removed (throws a weird error after running (load "tests/test-all.k") twice */ /* temp defines till gc is stabilized */ -/* #define KUSE_GC 1 */ +#define KUSE_GC 1 /* Print msgs when starting and ending gc */ #define KDEBUG_GC 1 @@ -39,7 +39,8 @@ /* In lua that has incremental gc this is setted to 200, in klisp as we don't yet have incremental gc, we set it to 400 */ -#define KLISPI_GCPAUSE 400 /* 400% (wait memory to quadruple before next GC) */ +//#define KLISPI_GCPAUSE 400 /* 400% (wait memory to quadruple before next GC) */ +#define KLISPI_GCPAUSE 125 /* diff --git a/src/kstate.c b/src/kstate.c @@ -187,7 +187,8 @@ klisp_State *klisp_newstate (klisp_Alloc f, void *ud) { kinit_ground_env(K); /* set the threshold for gc start now that we have allocated all mem */ - K->GCthreshold = 4*K->totalbytes; +// K->GCthreshold = 4*K->totalbytes; + K->GCthreshold = K->totalbytes + K->totalbytes / 4; return K; }