summaryrefslogtreecommitdiffstats
path: root/tests/gpgscm/scheme.c
diff options
context:
space:
mode:
authorJustus Winter <justus@g10code.com>2016-11-15 11:03:30 +0100
committerJustus Winter <justus@g10code.com>2016-11-15 11:10:56 +0100
commit64a58e23c38db8658423bbe26fcd650330e24a88 (patch)
tree7caf7ab5219a706198df3907d9e2e68da474ae9c /tests/gpgscm/scheme.c
parentgpgscm: Recover more cells. (diff)
downloadgnupg2-64a58e23c38db8658423bbe26fcd650330e24a88.tar.xz
gnupg2-64a58e23c38db8658423bbe26fcd650330e24a88.zip
gpgscm: Mark cells requiring finalization.
* tests/gpgscm/scheme.c (T_FINALIZE): New macro. (mk_port): Use the new macro. (mk_foreign_object): Likewise. (mk_counted_string): Likewise. (mk_empty_string): Likewise. (gc): Only call 'finalize_cell' for cells with the new flag. -- This speeds up the sweep phase of the garbage collector considerably because most cells do not require finalization. Signed-off-by: Justus Winter <justus@g10code.com>
Diffstat (limited to '')
-rw-r--r--tests/gpgscm/scheme.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/gpgscm/scheme.c b/tests/gpgscm/scheme.c
index 3ed1a00ca..1db6456fc 100644
--- a/tests/gpgscm/scheme.c
+++ b/tests/gpgscm/scheme.c
@@ -165,6 +165,7 @@ type_to_string (enum scheme_types typ)
#define ADJ 32
#define TYPE_BITS 5
#define T_MASKTYPE 31 /* 0000000000011111 */
+#define T_FINALIZE 2048 /* 0000100000000000 */
#define T_SYNTAX 4096 /* 0001000000000000 */
#define T_IMMUTABLE 8192 /* 0010000000000000 */
#define T_ATOM 16384 /* 0100000000000000 */ /* only for gc */
@@ -1095,7 +1096,7 @@ static pointer oblist_all_symbols(scheme *sc)
static pointer mk_port(scheme *sc, port *p) {
pointer x = get_cell(sc, sc->NIL, sc->NIL);
- typeflag(x) = T_PORT|T_ATOM;
+ typeflag(x) = T_PORT|T_ATOM|T_FINALIZE;
x->_object._port=p;
return (x);
}
@@ -1111,7 +1112,7 @@ pointer mk_foreign_func(scheme *sc, foreign_func f) {
pointer mk_foreign_object(scheme *sc, const foreign_object_vtable *vtable, void *data) {
pointer x = get_cell(sc, sc->NIL, sc->NIL);
- typeflag(x) = (T_FOREIGN_OBJECT | T_ATOM);
+ typeflag(x) = (T_FOREIGN_OBJECT | T_ATOM | T_FINALIZE);
x->_object._foreign_object._vtable=vtable;
x->_object._foreign_object._data = data;
return (x);
@@ -1179,7 +1180,7 @@ INTERFACE pointer mk_string(scheme *sc, const char *str) {
INTERFACE pointer mk_counted_string(scheme *sc, const char *str, int len) {
pointer x = get_cell(sc, sc->NIL, sc->NIL);
- typeflag(x) = (T_STRING | T_ATOM);
+ typeflag(x) = (T_STRING | T_ATOM | T_FINALIZE);
strvalue(x) = store_string(sc,len,str,0);
strlength(x) = len;
return (x);
@@ -1187,7 +1188,7 @@ INTERFACE pointer mk_counted_string(scheme *sc, const char *str, int len) {
INTERFACE pointer mk_empty_string(scheme *sc, int len, char fill) {
pointer x = get_cell(sc, sc->NIL, sc->NIL);
- typeflag(x) = (T_STRING | T_ATOM);
+ typeflag(x) = (T_STRING | T_ATOM | T_FINALIZE);
strvalue(x) = store_string(sc,len,0,fill);
strlength(x) = len;
return (x);
@@ -1504,7 +1505,7 @@ static void gc(scheme *sc, pointer a, pointer b) {
clrmark(p);
} else {
/* reclaim cell */
- if (typeflag(p) != 0) {
+ if (typeflag(p) & T_FINALIZE) {
finalize_cell(sc, p);
typeflag(p) = 0;
car(p) = sc->NIL;