expander: load modules on demand for recompile

This commit is contained in:
Matthew Flatt 2018-11-30 21:45:07 -07:00
parent 68e105c0ed
commit b94f84a909
4 changed files with 94 additions and 76 deletions

View File

@ -869,6 +869,7 @@ site-from-installers:
plain-site-from-installers:
rm -rf build/docs
rm -rf "build/zo`pwd`/build/docs"
$(USER_RACKET) -l- distro-build/install-for-docs build/docs $(CONFIG_MODE_q) "$(PKGS)" $(DOC_CATALOGS)
$(USER_RACKET) -l- distro-build/assemble-site $(CONFIG_MODE_q)

View File

@ -280,6 +280,7 @@
#:module-prompt? module-prompt?
#:module-use*s module-use*s
#:cross-linklet-inlining? cross-linklet-inlining?
#:load-modules? #f
#:namespace (compile-context-namespace cctx))]))
(values phase (cons linklet new-module-use*s))))
@ -396,6 +397,7 @@
#:module-prompt? module-prompt?
#:module-use*s module-use*s
#:cross-linklet-inlining? cross-linklet-inlining?
#:load-modules? load-modules?
#:namespace namespace)
(define-values (linklet new-module-use*s)
(performance-region
@ -420,6 +422,7 @@
;; to a linklet and an optional vector of keys for that linklet's
;; imports:
(make-module-use-to-linklet cross-linklet-inlining?
load-modules?
namespace
get-module-linklet-info
module-use*s))))
@ -428,7 +431,8 @@
;; ----------------------------------------
(define (make-module-use-to-linklet cross-linklet-inlining? ns get-module-linklet-info init-mu*s)
(define (make-module-use-to-linklet cross-linklet-inlining? load-modules?
ns get-module-linklet-info init-mu*s)
;; Inlining might reach the same module though different indirections;
;; use a consistent `module-use` value so that the compiler knows to
;; collapse them to a single import
@ -460,7 +464,7 @@
(values #f #f)]
[mu*-or-instance
(define mu* mu*-or-instance)
(define mod-name (module-path-index-resolve (module-use-module mu*)))
(define mod-name (module-path-index-resolve (module-use-module mu*) load-modules?))
(define mli (or (get-module-linklet-info mod-name (module-use-phase mu*))
(namespace->module-linklet-info ns
mod-name

View File

@ -178,6 +178,7 @@
#:module-prompt? #t
#:module-use*s module-use*s
#:cross-linklet-inlining? #t
#:load-modules? #t
#:namespace ns))
(values phase (cons linklet new-module-use*s))))

View File

@ -30259,11 +30259,11 @@ static const char *startup_source =
"(define-values"
"(empty-syntax-literals-instance)"
"(1/make-instance 'empty-stx #f 'constant get-syntax-literal!-id(lambda(pos_0) #f) 'get-encoded-root-expand-ctx #f))"
"(void(1/instance-describe-variable! empty-syntax-literals-instance 'get-syntax-literal!-id '(procedure/succeeds 2)))"
"(void(1/instance-describe-variable! empty-syntax-literals-instance get-syntax-literal!-id '(procedure/succeeds 2)))"
"(define-values"
"(empty-module-body-instance)"
"(let-values(((temp21_0)(lambda(name_0 val_0)(void))))(make-module-body-instance-instance18.1 temp21_0)))"
"(void(1/instance-describe-variable! empty-module-body-instance 'set-transformer!-id '(procedure/succeeds 4)))"
"(void(1/instance-describe-variable! empty-module-body-instance set-transformer!-id '(procedure/succeeds 4)))"
"(define-values"
"(empty-top-syntax-literal-instance)"
"(1/make-instance 'top-syntax-literal #f 'constant mpi-vector-id #f syntax-literals-id #f))"
@ -31837,26 +31837,26 @@ static const char *startup_source =
"(let-values()"
"(cons"
"(let-values()"
"(let-values(((header59_0)"
"(let-values(((header61_0)"
" header_0)"
"((temp60_0)"
"((temp62_0)"
"(compile-context-self"
" cctx_0))"
"((phase61_0)"
"((phase63_0)"
" phase_1)"
"((binding-sym62_0)"
"((binding-sym64_0)"
" binding-sym_0)"
"((temp63_0)"
"((temp65_0)"
" #f)"
"((temp64_0)"
"((temp66_0)"
" #t))"
"(register-required-variable-use!19.1"
" temp64_0"
" header59_0"
" temp60_0"
" phase61_0"
" binding-sym62_0"
" temp63_0)))"
" temp66_0"
" header61_0"
" temp62_0"
" phase63_0"
" binding-sym64_0"
" temp65_0)))"
" fold-var_1))))"
"(values"
" fold-var_2)))))"
@ -31878,14 +31878,14 @@ static const char *startup_source =
" cctx_0))"
"(if(compile-context?"
" the-struct_0)"
"(let-values(((phase65_0)"
"(let-values(((phase67_0)"
" phase_1)"
"((header66_0)"
"((header68_0)"
" header_0))"
"(compile-context1.1"
"(compile-context-namespace"
" the-struct_0)"
" phase65_0"
" phase67_0"
"(compile-context-self"
" the-struct_0)"
"(compile-context-module-self"
@ -31894,7 +31894,7 @@ static const char *startup_source =
" the-struct_0)"
"(compile-context-lazy-syntax-literals?"
" the-struct_0)"
" header66_0))"
" header68_0))"
"(raise-argument-error"
" 'struct-copy"
" \"compile-context?\""
@ -32001,14 +32001,14 @@ static const char *startup_source =
" cctx_0))"
"(if(compile-context?"
" the-struct_0)"
"(let-values(((phase67_0)"
"(let-values(((phase69_0)"
" phase_1)"
"((header68_0)"
"((header70_0)"
" header_0))"
"(compile-context1.1"
"(compile-context-namespace"
" the-struct_0)"
" phase67_0"
" phase69_0"
"(compile-context-self"
" the-struct_0)"
"(compile-context-module-self"
@ -32017,7 +32017,7 @@ static const char *startup_source =
" the-struct_0)"
"(compile-context-lazy-syntax-literals?"
" the-struct_0)"
" header68_0))"
" header70_0))"
"(raise-argument-error"
" 'struct-copy"
" \"compile-context?\""
@ -32097,15 +32097,15 @@ static const char *startup_source =
" cctx_0))"
"(if(compile-context?"
" the-struct_0)"
"(let-values(((phase69_0)"
"(let-values(((phase71_0)"
"(add1"
" phase_1))"
"((header70_0)"
"((header72_0)"
" next-header_0))"
"(compile-context1.1"
"(compile-context-namespace"
" the-struct_0)"
" phase69_0"
" phase71_0"
"(compile-context-self"
" the-struct_0)"
"(compile-context-module-self"
@ -32114,7 +32114,7 @@ static const char *startup_source =
" the-struct_0)"
"(compile-context-lazy-syntax-literals?"
" the-struct_0)"
" header70_0))"
" header72_0))"
"(raise-argument-error"
" 'struct-copy"
" \"compile-context?\""
@ -32237,14 +32237,14 @@ static const char *startup_source =
" cctx_0))"
"(if(compile-context?"
" the-struct_0)"
"(let-values(((phase71_0)"
"(let-values(((phase73_0)"
" phase_1)"
"((header72_0)"
"((header74_0)"
" header_0))"
"(compile-context1.1"
"(compile-context-namespace"
" the-struct_0)"
" phase71_0"
" phase73_0"
"(compile-context-self"
" the-struct_0)"
"(compile-context-module-self"
@ -32253,7 +32253,7 @@ static const char *startup_source =
" the-struct_0)"
"(compile-context-lazy-syntax-literals?"
" the-struct_0)"
" header72_0))"
" header74_0))"
"(raise-argument-error"
" 'struct-copy"
" \"compile-context?\""
@ -32292,14 +32292,14 @@ static const char *startup_source =
" cctx_0))"
"(if(compile-context?"
" the-struct_0)"
"(let-values(((phase73_0)"
"(let-values(((phase75_0)"
" phase_1)"
"((header74_0)"
"((header76_0)"
" header_0))"
"(compile-context1.1"
"(compile-context-namespace"
" the-struct_0)"
" phase73_0"
" phase75_0"
"(compile-context-self"
" the-struct_0)"
"(compile-context-module-self"
@ -32308,7 +32308,7 @@ static const char *startup_source =
" the-struct_0)"
"(compile-context-lazy-syntax-literals?"
" the-struct_0)"
" header74_0))"
" header76_0))"
"(raise-argument-error"
" 'struct-copy"
" \"compile-context?\""
@ -32334,14 +32334,14 @@ static const char *startup_source =
" cctx_0))"
"(if(compile-context?"
" the-struct_0)"
"(let-values(((phase75_0)"
"(let-values(((phase77_0)"
" phase_1)"
"((header76_0)"
"((header78_0)"
" header_0))"
"(compile-context1.1"
"(compile-context-namespace"
" the-struct_0)"
" phase75_0"
" phase77_0"
"(compile-context-self"
" the-struct_0)"
"(compile-context-module-self"
@ -32350,7 +32350,7 @@ static const char *startup_source =
" the-struct_0)"
"(compile-context-lazy-syntax-literals?"
" the-struct_0)"
" header76_0))"
" header78_0))"
"(raise-argument-error"
" 'struct-copy"
" \"compile-context?\""
@ -32409,15 +32409,15 @@ static const char *startup_source =
" #f)"
" #f)))"
"(let-values(((phases-in-order_0)"
"(let-values(((temp77_0)"
"(let-values(((temp79_0)"
"(hash-keys"
" phase-to-body_0))"
"((<78_0) <))"
"((<80_0) <))"
"(sort7.1"
" #f"
" #f"
" temp77_0"
" <78_0))))"
" temp79_0"
" <80_0))))"
"(let-values(((min-phase_0)"
"(if(pair? phases-in-order_0)"
"(car phases-in-order_0)"
@ -32626,36 +32626,39 @@ static const char *startup_source =
" 'module)"
" module-use*s_0))"
"(let-values()"
"(let-values(((body-linklet79_0)"
"(let-values(((body-linklet81_0)"
" body-linklet_0)"
"((body-imports80_0)"
"((body-imports82_0)"
" body-imports_0)"
"((body-import-instances81_0)"
"((body-import-instances83_0)"
" body-import-instances_0)"
"((get-module-linklet-info82_0)"
"((get-module-linklet-info84_0)"
" get-module-linklet-info_0)"
"((serializable?83_0)"
"((serializable?85_0)"
" serializable?_0)"
"((module-prompt?84_0)"
"((module-prompt?86_0)"
" module-prompt?_0)"
"((module-use*s85_0)"
"((module-use*s87_0)"
" module-use*s_0)"
"((cross-linklet-inlining?86_0)"
"((cross-linklet-inlining?88_0)"
" cross-linklet-inlining?_0)"
"((temp87_0)"
"((temp89_0)"
" #f)"
"((temp90_0)"
"(compile-context-namespace"
" cctx_0)))"
"(compile-module-linklet55.1"
" body-import-instances81_0"
" body-imports80_0"
"(compile-module-linklet57.1"
" body-import-instances83_0"
" body-imports82_0"
" unsafe-undefined"
" cross-linklet-inlining?86_0"
" get-module-linklet-info82_0"
" module-prompt?84_0"
" module-use*s85_0"
" temp87_0"
" serializable?83_0"
" body-linklet79_0))))))"
" cross-linklet-inlining?88_0"
" get-module-linklet-info84_0"
" temp89_0"
" module-prompt?86_0"
" module-use*s87_0"
" temp90_0"
" serializable?85_0"
" body-linklet81_0))))))"
"(values"
" phase_1"
"(cons"
@ -33029,20 +33032,21 @@ static const char *startup_source =
"(let-values(((v_0)(syntax-property$1 orig-s_0 'compiler-hint:cross-module-inline)))"
"(if v_0(correlated-property e_0 'compiler-hint:cross-module-inline v_0) e_0)))))"
"(define-values"
"(compile-module-linklet55.1)"
"(compile-module-linklet57.1)"
"(lambda(body-import-instances38_0"
" body-imports37_0"
" compile-linklet36_0"
" cross-linklet-inlining?43_0"
" get-module-linklet-info39_0"
" load-modules?44_0"
" module-prompt?41_0"
" module-use*s42_0"
" namespace44_0"
" namespace45_0"
" serializable?40_0"
" body-linklet54_0)"
" body-linklet56_0)"
"(begin"
" 'compile-module-linklet55"
"(let-values(((body-linklet_0) body-linklet54_0))"
" 'compile-module-linklet57"
"(let-values(((body-linklet_0) body-linklet56_0))"
"(let-values(((compile-linklet_0)"
"(if(eq? compile-linklet36_0 unsafe-undefined) 1/compile-linklet compile-linklet36_0)))"
"(let-values(((body-imports_0) body-imports37_0))"
@ -33052,7 +33056,8 @@ static const char *startup_source =
"(let-values(((module-prompt?_0) module-prompt?41_0))"
"(let-values(((module-use*s_0) module-use*s42_0))"
"(let-values(((cross-linklet-inlining?_0) cross-linklet-inlining?43_0))"
"(let-values(((namespace_0) namespace44_0))"
"(let-values(((load-modules?_0) load-modules?44_0))"
"(let-values(((namespace_0) namespace45_0))"
"(let-values()"
"(let-values(((linklet_0 new-module-use*s_0)"
"(begin"
@ -33075,16 +33080,19 @@ static const char *startup_source =
"(list->vector(append body-import-instances_0 module-use*s_0))"
"(make-module-use-to-linklet"
" cross-linklet-inlining?_0"
" load-modules?_0"
" namespace_0"
" get-module-linklet-info_0"
" module-use*s_0)))"
"(if log-performance?(let-values()(end-performance-region))(void))))))"
"(if log-performance?"
"(let-values()(end-performance-region))"
"(void))))))"
"(values"
" linklet_0"
"(list-tail(vector->list new-module-use*s_0)(length body-imports_0))))))))))))))))))"
"(list-tail(vector->list new-module-use*s_0)(length body-imports_0)))))))))))))))))))"
"(define-values"
"(make-module-use-to-linklet)"
"(lambda(cross-linklet-inlining?_0 ns_0 get-module-linklet-info_0 init-mu*s_0)"
"(lambda(cross-linklet-inlining?_0 load-modules?_0 ns_0 get-module-linklet-info_0 init-mu*s_0)"
"(begin"
"(let-values(((mu*-intern-table_0)(make-hash)))"
"(let-values(((intern-module-use*_0)"
@ -33132,7 +33140,8 @@ static const char *startup_source =
"(if mu*-or-instance_0"
"(let-values()"
"(let-values(((mu*_0) mu*-or-instance_0))"
"(let-values(((mod-name_0)(1/module-path-index-resolve(module-use-module mu*_0))))"
"(let-values(((mod-name_0)"
"(1/module-path-index-resolve(module-use-module mu*_0) load-modules?_0)))"
"(let-values(((mli_0)"
"(let-values(((or-part_0)"
"(get-module-linklet-info_0 mod-name_0(module-use-phase mu*_0))))"
@ -40380,17 +40389,20 @@ static const char *startup_source =
" module-use*s_0)"
"((temp11_0)"
" #t)"
"((ns12_0)"
"((temp12_0)"
" #t)"
"((ns13_0)"
" ns_0))"
"(compile-module-linklet55.1"
"(compile-module-linklet57.1"
" temp6_0"
" temp5_0"
" temp4_0"
" temp11_0"
" find-submodule7_0"
" temp12_0"
" temp9_0"
" module-use*s10_0"
" ns12_0"
" ns13_0"
" temp8_0"
" temp3_0))))"
"(values"