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)