diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-04-03 08:40:31 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-04-03 08:40:31 -0700 |
commit | 06ced4e18fd69399e7419a59dbe477e9a92c23e1 (patch) | |
tree | bf267f92a132acdd5d15df0b0ef7e2bb29c27fd6 /lib.c | |
parent | 6c4da3e5e1cb02f4d4e522626579cbded546059a (diff) | |
download | txr-06ced4e18fd69399e7419a59dbe477e9a92c23e1.tar.gz txr-06ced4e18fd69399e7419a59dbe477e9a92c23e1.tar.bz2 txr-06ced4e18fd69399e7419a59dbe477e9a92c23e1.zip |
* configure: Support a gen-gc configuration variable which
causes CONFIG_GEN_GC to be defined as 1 in config.h.
* eval.c (op_defvar, dwim_loc, op_modplace, transform_op): Handle
mutating assignments via set macro.
(op_dohash): Inform gc about mutated variables. TODO here.
* filter.c (trie_add, trie_compress): Handle mutating assignments
via set macro.
* gc.c (BACKPTR_VEC_SIZE, FULL_GC_INTERVAL): New preprocessor symbols.
(backptr, backptr_idx, partial_gc_count, full): New static variables.
(make_obj): Initialize generation to zero.
(gc): Added logic for deciding between full and partial gc.
(gc_set, gc_mutated): New functions.
* gc.h (gc_set, gc_mutated): Declared.
* hash.c (hash_mark): Changed useless use of vecref_l to vecref.
(gethash_f): Use set when assigning through *found since it
is a possible mutation.
* lib.c (car_l, cdr_l, vecref_l): Got rid of loc macro uses. Using the
value properly is going to be the caller's responsibility.
(push): push may be a mutation, so use set.
(intern): Uset set to mutate a hash entry.
(acons_new_l, aconsq_new_l): Use set when replacing *list.
* lib.h (PTR_BIT): New preprocessor symbol.
(obj_common): New macro for defining common object fields.
type_t is split into two bitfields, half a pointer wide,
allowing for generation to be represented.
(struct any, struct cons, struct string, struct sym, struct package,
struct func, struct vec, struct lazy_cons, struct cobj, struct env,
struct bignum, struct flonum): Use obj_common macro to defined
common fields.
(loc): Macro removed.
(set, mut): Macros conditionally defined for real functionality.
(list_collect, list_collect_nconc, list_collect_append): Replace
mutating operations with set.
* match.c (dest_set, v_cat, v_output, v_filter): Replace
mutating operations with set.
* stream.c (string_in_get_line, string_in_get_char,
strlist_out_put_string, strlist_out_put_char): Replace mutating
operations with set.
* unwind.c (uw_register_subtype): Replace mutating operation with set.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -249,13 +249,13 @@ val *car_l(val cons) { switch (type(cons)) { case CONS: - return loc(cons->c.car); + return &cons->c.car; case LCONS: if (cons->lc.func) { funcall1(cons->lc.func, cons); cons->lc.func = nil; } - return loc(cons->lc.car); + return &cons->lc.car; default: type_mismatch(lit("~s is not a cons"), cons, nao); } @@ -265,13 +265,13 @@ val *cdr_l(val cons) { switch (type(cons)) { case CONS: - return loc(cons->c.cdr); + return &cons->c.cdr; case LCONS: if (cons->lc.func) { funcall1(cons->lc.func, cons); cons->lc.func = nil; } - return loc(cons->lc.cdr); + return &cons->lc.cdr; default: type_mismatch(lit("~s is not a cons"), cons, nao); } @@ -361,7 +361,9 @@ val pop(val *plist) val push(val value, val *plist) { - return *plist = cons(value, *plist); + /* TODO: doing set here is suboptimal since + it is often used for just a local var. */ + return set(*plist, cons(value, *plist)); } val copy_list(val list) @@ -2249,7 +2251,7 @@ val intern(val str, val package) } else { val newsym = make_sym(str); newsym->s.package = package; - return *place = newsym; + return set(*place, newsym); } } @@ -3096,7 +3098,7 @@ val *vecref_l(val vec, val ind) cnum index = c_num(ind); cnum len = c_num(length_vec(vec)); range_bug_unless (index >= 0 && index < len); - return loc(vec->v.vec[index]); + return vec->v.vec + index; } val vec_push(val vec, val item) @@ -3618,7 +3620,7 @@ val *acons_new_l(val key, val *new_p, val *list) return cdr_l(existing); } else { val nc = cons(key, nil); - *list = cons(nc, *list); + set(*list, cons(nc, *list)); if (new_p) *new_p = t; return cdr_l(nc); @@ -3647,7 +3649,7 @@ val *aconsq_new_l(val key, val *new_p, val *list) return cdr_l(existing); } else { val nc = cons(key, nil); - *list = cons(nc, *list); + set(*list, cons(nc, *list)); if (new_p) *new_p = t; return cdr_l(nc); |