From b02e37b0b9b26ce6a0d0e308d62d9124acb76ef5 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 28 Aug 2011 17:24:29 -0600 Subject: [PATCH] restore module cache The module cache was added in 97ce26b1 (April 16, 2011), but it was accidentally disabled in e9721058 (May 5, 2011). This time, I figured out a way to test whether the cache is working (other than to benchmark examples, which is how I discovered that it wasn't working). --- collects/tests/racket/namespac.rktl | 25 +++++++++++++++++++++++++ src/racket/src/module.c | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/collects/tests/racket/namespac.rktl b/collects/tests/racket/namespac.rktl index 6e103ae803..4488d01e81 100644 --- a/collects/tests/racket/namespac.rktl +++ b/collects/tests/racket/namespac.rktl @@ -202,6 +202,31 @@ (kill-thread th))) (test #t namespace? (make-base-empty-namespace))) +;; ---------------------------------------- +;; Check module caching by monitoring `current-eval'. +;; If the module cache works, then it turns out that +;; the `module-compiled-imports' of modules to evaluate +;; will be `eq?' the second time around to the first time +;; around. This is a fragile and imprecise check, but it's +;; the best idea we have to checking that the module cache +;; works. + +(let ([codes (make-hash)]) + (define (go-once) + (parameterize ([current-namespace (make-base-namespace)] + [current-eval + (let ([orig (current-eval)]) + (lambda (x) + (when (syntax? x) + (when (compiled-module-expression? (syntax-e x)) + (hash-set! codes (module-compiled-imports (syntax-e x)) #t))) + (orig x)))]) + (dynamic-require 'racket/string #f))) + (go-once) + (let ([pre (hash-count codes)]) + (go-once) + (test pre hash-count codes))) + ;; ---------------------------------------- (report-errs) diff --git a/src/racket/src/module.c b/src/racket/src/module.c index 54ad1054f1..e1a432fc6e 100644 --- a/src/racket/src/module.c +++ b/src/racket/src/module.c @@ -5334,7 +5334,7 @@ static Scheme_Object *do_module_execute(Scheme_Object *data, Scheme_Env *genv, i Scheme_Object *scheme_module_execute(Scheme_Object *data, Scheme_Env *genv) { - return do_module_execute(data, genv, 0); + return do_module_execute(data, genv, 1); } static Scheme_Object *rebuild_et_vec(Scheme_Object *naya, Scheme_Object *vec, Resolve_Prefix *rp)