From e44f8e16614283698f648186302ea9d8cadd3066 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 27 Mar 2014 19:00:49 -0700 Subject: More generational GC fixes. One GC fix. * combi.c (perm_init_common, comb_gen_fun_common, rcomb_gen_fun_common): Use set macro instead of plain assignment. * hash.c (hash_grow, copy_hash, hash_update_1): Use set macro instead of plain assignment. * lib.c (nreverse, lazy_appendv_func, lazy_appendv, vec_push, refset): Use set macro instead of plain assignment. (make_package): Assign all fields of the newly created PKG object before calling a function which can trigger GC. * parser.y (rlset): Use set macro. --- ChangeLog | 17 +++++++++++++++++ combi.c | 16 ++++++++-------- hash.c | 8 ++++---- lib.c | 15 ++++++++------- parser.y | 2 +- 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 39a7a296..2737654c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2014-03-27 Kaz Kylheku + + More generational GC fixes. One GC fix. + + * combi.c (perm_init_common, comb_gen_fun_common, + rcomb_gen_fun_common): Use set macro instead of plain assignment. + + * hash.c (hash_grow, copy_hash, hash_update_1): Use set macro + instead of plain assignment. + + * lib.c (nreverse, lazy_appendv_func, lazy_appendv, + vec_push, refset): Use set macro instead of plain assignment. + (make_package): Assign all fields of the newly created PKG + object before calling a function which can trigger GC. + + * parser.y (rlset): Use set macro. + 2014-03-27 Kaz Kylheku Fix generational GC regression caused by fixes diff --git a/combi.c b/combi.c index 68664b5c..24061b2a 100644 --- a/combi.c +++ b/combi.c @@ -105,9 +105,9 @@ static val perm_init_common(val p, val k_null) } else { val state = vector(three, nil); val c = vector(k, zero); - *vecref_l(state, zero) = p; - *vecref_l(state, one) = k; - *vecref_l(state, two) = c; + set(*vecref_l(state, zero), p); + set(*vecref_l(state, one), k); + set(*vecref_l(state, two), c); *vecref_l(c, negone) = negone; return state; } @@ -355,7 +355,7 @@ static void comb_gen_fun_common(val state) val curr = first(iter); val curr_rest = rest(curr); if (curr_rest != prev && consp(curr_rest)) { - *car_l(iter) = curr_rest; + set(*car_l(iter), curr_rest); return; } else if (rest(iter)) { val next = second(iter); @@ -363,7 +363,7 @@ static void comb_gen_fun_common(val state) val next_rest_rest = rest(next_rest); prev = curr; if (next_rest != curr && consp(next_rest_rest)) - prev = *car_l(iter) = next_rest_rest; + prev = set(*car_l(iter), next_rest_rest); } } @@ -516,13 +516,13 @@ static void rcomb_gen_fun_common(val state) if (consp(curr_rest)) { val jter; for (jter = state; jter != next; jter = cdr(jter)) - *car_l(jter) = curr_rest; + set(*car_l(jter), curr_rest); return; } else if (next) { val next = second(iter); if (curr != next) - *car_l(iter) = rest(next); - } + set(*car_l(iter), rest(next)); + } } *car_l(state) = nil; diff --git a/hash.c b/hash.c index 96a4f802..c5fdf335 100644 --- a/hash.c +++ b/hash.c @@ -439,7 +439,7 @@ static void hash_grow(struct hash *h) val key = car(entry); val *pchain = vecref_l(new_table, num_fast(h->hash_fun(key) % new_modulus)); - *cdr_l(conses) = *pchain; + set(*cdr_l(conses), *pchain); *pchain = conses; conses = next; } @@ -518,7 +518,7 @@ val copy_hash(val existing) h->acons_new_c_fun = ex->acons_new_c_fun; for (iter = zero; lt(iter, mod); iter = plus(iter, one)) - *vecref_l(h->table, iter) = copy_alist(vecref(ex->table, iter)); + set(*vecref_l(h->table, iter), copy_alist(vecref(ex->table, iter))); return hash; } @@ -1027,9 +1027,9 @@ val hash_update_1(val hash, val key, val fun, val init) val new_p; val *place = gethash_l(hash, key, &new_p); if (new_p) - *place = funcall1(fun, init); + set(*place, funcall1(fun, init)); else - *place = funcall1(fun, *place); + set(*place, funcall1(fun, *place)); return *place; } } diff --git a/lib.c b/lib.c index a493d875..afcf1689 100644 --- a/lib.c +++ b/lib.c @@ -595,7 +595,7 @@ val nreverse(val in) while (in) { val temp = cdr(in); - *cdr_l(in) = rev; + set(*cdr_l(in), rev); rev = in; in = temp; } @@ -782,7 +782,7 @@ static val lazy_appendv_func(val env, val lcons) { val *ptail = ltail(&nonempty); rplaca(env, car(*ptail)); - *ptail = make_lazy_cons(lcons_fun(lcons)); + set(*ptail, make_lazy_cons(lcons_fun(lcons))); rplacd(lcons, nonempty); } return nil; @@ -803,8 +803,8 @@ val lazy_appendv(val lists) { val *ptail = ltail(&nonempty); - *ptail = make_lazy_cons(func_f1(cons(car(*ptail), lists), - lazy_appendv_func)); + set(*ptail, make_lazy_cons(func_f1(cons(car(*ptail), lists), + lazy_appendv_func))); return nonempty; } } @@ -2746,6 +2746,7 @@ val make_package(val name) val obj = make_obj(); obj->pk.type = PKG; obj->pk.name = name; + obj->pk.symhash = nil; /* make_hash call below could trigger gc! */ obj->pk.symhash = make_hash(nil, nil, lit("t")); /* don't have t yet! */ push(cons(name, obj), &packages); @@ -3977,7 +3978,7 @@ val vec_push(val vec, val item) { val length = length_vec(vec); vec_set_length(vec, plus(length, one)); - *vecref_l(vec, length) = item; + set(*vecref_l(vec, length), item); return length; } @@ -5041,12 +5042,12 @@ val refset(val seq, val ind, val newval) case NIL: case CONS: case LCONS: - return *listref_l(seq, ind) = newval; + return set(*listref_l(seq, ind), newval); case LIT: case STR: return chr_str_set(seq, ind, newval); case VEC: - return *vecref_l(seq, ind) = newval; + return set(*vecref_l(seq, ind), newval); default: type_mismatch(lit("ref: ~s is not a sequence"), cons, nao); } diff --git a/parser.y b/parser.y index ff3ff944..2909944f 100644 --- a/parser.y +++ b/parser.y @@ -1237,7 +1237,7 @@ val rlset(val form, val info) val cell = gethash_c(form_to_ln_hash, form, 0); val *place = cdr_l(cell); if (nilp(*place)) - *place = info; + set(*place, info); return form; } -- cgit v1.2.3