[Pkg-gnupg-commit] [gnupg2] 234/292: gpgscm: Recover cells used to maintain interpreter state.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Mon Nov 21 06:31:46 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit e0cbd3389e2dd6ec19ee3a4c7bad81fa0f1907f5
Author: Justus Winter <justus at g10code.com>
Date: Thu Nov 10 14:02:11 2016 +0100
gpgscm: Recover cells used to maintain interpreter state.
* tests/gpgscm/scheme.c (free_cell): New function.
(free_cons): Likewise.
(_s_return): Use the new function to recover cells used to save the
state of the interpreter in 's_save'. This reduces the need to do a
garbage collection considerably.
Signed-off-by: Justus Winter <justus at g10code.com>
---
tests/gpgscm/scheme.c | 39 +++++++++++++++++++++++++++++++--------
1 file changed, 31 insertions(+), 8 deletions(-)
diff --git a/tests/gpgscm/scheme.c b/tests/gpgscm/scheme.c
index 90cb8fd..105d2a1 100644
--- a/tests/gpgscm/scheme.c
+++ b/tests/gpgscm/scheme.c
@@ -773,6 +773,26 @@ static pointer find_consecutive_cells(scheme *sc, int n) {
return sc->NIL;
}
+/* Free a cell. This is dangerous. Only free cells that are not
+ * referenced. */
+static INLINE void
+free_cell(scheme *sc, pointer a)
+{
+ cdr(a) = sc->free_cell;
+ sc->free_cell = a;
+ sc->fcells += 1;
+}
+
+/* Free a cell and retrieve its content. This is dangerous. Only
+ * free cells that are not referenced. */
+static INLINE void
+free_cons(scheme *sc, pointer a, pointer *r_car, pointer *r_cdr)
+{
+ *r_car = car(a);
+ *r_cdr = cdr(a);
+ free_cell(sc, a);
+}
+
/* To retain recent allocs before interpreter knows about them -
Tehom */
@@ -2481,14 +2501,17 @@ static void dump_stack_free(scheme *sc)
}
static pointer _s_return(scheme *sc, pointer a) {
- sc->value = (a);
- if(sc->dump==sc->NIL) return sc->NIL;
- sc->op = ivalue(car(sc->dump));
- sc->args = cadr(sc->dump);
- sc->envir = caddr(sc->dump);
- sc->code = cadddr(sc->dump);
- sc->dump = cddddr(sc->dump);
- return sc->T;
+ pointer dump = sc->dump;
+ pointer op;
+ sc->value = (a);
+ if (dump == sc->NIL)
+ return sc->NIL;
+ free_cons(sc, dump, &op, &dump);
+ sc->op = ivalue(op);
+ free_cons(sc, dump, &sc->args, &dump);
+ free_cons(sc, dump, &sc->envir, &dump);
+ free_cons(sc, dump, &sc->code, &sc->dump);
+ return sc->T;
}
static void s_save(scheme *sc, enum scheme_opcodes op, pointer args, pointer code) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list