[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 06/06: Minor evaluator tweaks
From: |
Andy Wingo |
Subject: |
[Guile-commits] 06/06: Minor evaluator tweaks |
Date: |
Mon, 08 Dec 2014 10:50:28 +0000 |
wingo pushed a commit to branch wip-closure-conversion
in repository guile.
commit 5bfc0653d6361ab29ed2da68eeba14cce1ec8f6c
Author: Andy Wingo <address@hidden>
Date: Sun Dec 7 19:03:19 2014 +0100
Minor evaluator tweaks
* libguile/eval.c (eval): Remove unused variable.
* libguile/memoize.c (unmemoize): Fix unmemoization.
* module/ice-9/eval.scm: Attempt to speed up common box-ref cases.
---
libguile/eval.c | 2 +-
libguile/memoize.c | 13 +++++++++----
module/ice-9/eval.scm | 15 +++++++++++++--
3 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/libguile/eval.c b/libguile/eval.c
index b69b5b2..72f1531 100644
--- a/libguile/eval.c
+++ b/libguile/eval.c
@@ -413,7 +413,7 @@ eval (SCM x, SCM env)
return mx;
else
{
- SCM mod, var;
+ SCM var;
var = scm_sys_resolve_variable (mx, env_tail (env));
scm_set_cdr_x (x, var);
diff --git a/libguile/memoize.c b/libguile/memoize.c
index cefb269..88a168f 100644
--- a/libguile/memoize.c
+++ b/libguile/memoize.c
@@ -750,10 +750,15 @@ unmemoize (const SCM expr)
unmemoize (CAR (args)),
unmemoize (CDR (args)));
case SCM_M_RESOLVE:
- return (SCM_VARIABLEP (args) || scm_is_symbol (args)) ? args
- : scm_list_3 (scm_is_true (CDDR (args)) ? scm_sym_at : scm_sym_atat,
- scm_i_finite_list_copy (CAR (args)),
- CADR (args));
+ if (SCM_VARIABLEP (args))
+ return args;
+ else if (scm_is_symbol (CDR (args)))
+ return CDR (args);
+ else
+ return scm_list_3
+ (scm_is_true (CDDDR (args)) ? scm_sym_at : scm_sym_atat,
+ scm_i_finite_list_copy (CADR (args)),
+ CADDR (args));
case SCM_M_CALL_WITH_PROMPT:
return scm_list_4 (scm_from_latin1_symbol ("call-with-prompt"),
unmemoize (CAR (args)),
diff --git a/module/ice-9/eval.scm b/module/ice-9/eval.scm
index f3f0899..a1398f6 100644
--- a/module/ice-9/eval.scm
+++ b/module/ice-9/eval.scm
@@ -279,9 +279,11 @@
;; we compile `case' effectively, this situation will improve.
(define-syntax mx-match
(lambda (x)
- (syntax-case x (quote)
+ (syntax-case x (quote else)
((_ mx data tag)
#'(error "what" mx))
+ ((_ mx data tag (else body))
+ #'body)
((_ mx data tag (('type pat) body) c* ...)
#`(if (eqv? tag #,(or (memoized-typecode (syntax->datum #'type))
(error "not a typecode" #'type)))
@@ -464,7 +466,16 @@
(call eval proc nargs args env)))
(('box-ref box)
- (variable-ref (eval box env)))
+ (memoized-expression-case box
+ ;; Accelerate common cases.
+ (('resolve var-or-loc)
+ (if (variable? var-or-loc)
+ (variable-ref var-or-loc)
+ (variable-ref (eval box env))))
+ (('lexical-ref (depth . width))
+ (variable-ref (env-ref env depth width)))
+ (else
+ (variable-ref (eval box env)))))
(('resolve var-or-loc)
(if (variable? var-or-loc)
- [Guile-commits] branch wip-closure-conversion created (now 5bfc065), Andy Wingo, 2014/12/08
- [Guile-commits] 03/06: Add capture-env to evaluator, Andy Wingo, 2014/12/08
- [Guile-commits] 06/06: Minor evaluator tweaks,
Andy Wingo <=
- [Guile-commits] 04/06: Closure conversion in evaluator, Andy Wingo, 2014/12/08
- [Guile-commits] 01/06: Assignment conversion in the interpreter, Andy Wingo, 2014/12/08
- [Guile-commits] 05/06: Simplify variable resolution in the evaluator, Andy Wingo, 2014/12/08
- [Guile-commits] 02/06: Simplify the interpreter for trivial inits and no letrec, Andy Wingo, 2014/12/08