From 55a27e01a666ac59de11f7e88831ab1bdadc6df8 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 26 Feb 2018 17:18:54 -0700 Subject: [PATCH] expander: fix tracking of MPIs for cross-submodule inlining --- .../racket-test-core/tests/racket/module.rktl | 23 +++++++++++++++++++ racket/src/expander/compile/module.rkt | 2 +- racket/src/expander/eval/module.rkt | 14 +++++------ racket/src/expander/expand/module.rkt | 2 +- racket/src/racket/src/startup.inc | 3 ++- 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/pkgs/racket-test-core/tests/racket/module.rktl b/pkgs/racket-test-core/tests/racket/module.rktl index 06e4797f2a..1b9f1951e2 100644 --- a/pkgs/racket-test-core/tests/racket/module.rktl +++ b/pkgs/racket-test-core/tests/racket/module.rktl @@ -2262,6 +2262,29 @@ case of module-leve bindings; it doesn't cover local bindings. (require 'check-shadowing-in-other-phase-b) b) +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Make sure that cross-module inlinign doesn't +;; lose track of shifts for module path indices + +(module likely-inlines-across-two-submodules racket/base + (provide result) + + (module a racket/base + (provide get-x) + (define x 5) + (set! x x) + (define (get-x) x)) + + (module b racket/base + (require (submod ".." a)) + (provide get-x2) + (define (get-x2) (get-x))) + + (require 'b) + (define result (get-x2))) + +(test 5 dynamic-require ''likely-inlines-across-two-submodules 'result) + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (report-errs) diff --git a/racket/src/expander/compile/module.rkt b/racket/src/expander/compile/module.rkt index d3770b84e7..00638b9cd0 100644 --- a/racket/src/expander/compile/module.rkt +++ b/racket/src/expander/compile/module.rkt @@ -404,7 +404,7 @@ (values phase (module-linklet-info linklet (hash-ref phase-to-link-module-uses phase #f) - self + (compiled-in-memory-original-self cim) #f ; inspector is the same as the module being compiled (compiled-in-memory-compile-time-inspector cim) (and phase-to-extra-inspectorsss diff --git a/racket/src/expander/eval/module.rkt b/racket/src/expander/eval/module.rkt index f2108e3e91..6e86217bc1 100644 --- a/racket/src/expander/eval/module.rkt +++ b/racket/src/expander/eval/module.rkt @@ -172,13 +172,13 @@ (define module-uses (hash-ref phase-to-link-modules phase-level)) (define-values (import-module-instances import-instances) (for/lists (mis is) ([mu (in-list module-uses)]) - (namespace-module-use->module+linklet-instances - ns mu - #:shift-from original-self - #:shift-to self - #:phase-shift - (phase+ (phase- phase-level (module-use-phase mu)) - phase-shift)))) + (namespace-module-use->module+linklet-instances + ns mu + #:shift-from original-self + #:shift-to self + #:phase-shift + (phase+ (phase- phase-level (module-use-phase mu)) + phase-shift)))) (check-require-access phase-linklet #:skip-imports 2 module-uses import-module-instances insp diff --git a/racket/src/expander/expand/module.rkt b/racket/src/expander/expand/module.rkt index f94604d217..ffeba59676 100644 --- a/racket/src/expander/expand/module.rkt +++ b/racket/src/expander/expand/module.rkt @@ -522,7 +522,7 @@ (cond [(not (expand-context-to-parsed? init-ctx)) ;; Shift the "self" reference that we have been using for expansion - ;; to a generic and constant (for a particualr submodule path) + ;; to a generic and constant (for a particular submodule path) ;; "self", so that we can reocognize it for compilation or to shift ;; back on any future re-expansion: (define generic-self (make-generic-self-module-path-index self)) diff --git a/racket/src/racket/src/startup.inc b/racket/src/racket/src/startup.inc index e5a9d301e3..cd9895527a 100644 --- a/racket/src/racket/src/startup.inc +++ b/racket/src/racket/src/startup.inc @@ -35670,7 +35670,8 @@ static const char *startup_source = " phase-to-link-module-uses_5" " phase_93" " #f)" -" self_25" +"(compiled-in-memory-original-self" +" cim_10)" " #f" "(compiled-in-memory-compile-time-inspector" " cim_10)"