fix submodule loading when a ".zo" file is referenced directly

The default load/use-compiled handler was not consistent with the
default load handler in the treatment of submodules from module files.

Closes #2363
This commit is contained in:
Matthew Flatt 2021-04-29 09:59:59 -06:00
parent ed115af6b2
commit 5ae19c56e1
5 changed files with 129 additions and 81 deletions

View File

@ -4188,7 +4188,7 @@ static const char *startup_source =
"(if i_0"
"(let-values(((k_0 vals_0)(hash-iterate-key+value ht_0 i_0)))"
"(let-values(((table_1)"
"(let-values(((new-vals_0)"
"(let-values(((id*_0)"
"(reverse$1"
"(let-values(((lst_0) vals_0))"
"(begin"
@ -4241,7 +4241,8 @@ static const char *startup_source =
"(lambda(table_1)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((new-vals_0)"
" id*_0))"
"(let-values(((table_2)"
"(let-values(((table_2)"
" table_1))"
@ -7431,7 +7432,7 @@ static const char *startup_source =
"(let-values(((sym_0 bindings-for-sym_0)"
"(unsafe-immutable-hash-iterate-key+value ht_0 i_0)))"
"(let-values(((table_1)"
"(let-values(((new-bindings-for-sym_0)"
"(let-values(((id*_0)"
"(let-values(((ht_1)"
" bindings-for-sym_0))"
"(begin"
@ -7496,7 +7497,8 @@ static const char *startup_source =
"(lambda(table_1)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((new-bindings-for-sym_0)"
" id*_0))"
"(let-values(((table_2)"
"(let-values(((table_2)"
" table_1))"
@ -10457,7 +10459,7 @@ static const char *startup_source =
" ht_0"
" i_0)))"
"(let-values(((table_1)"
"(let-values(((new-sms_0)"
"(let-values(((id*_0)"
"(shift-multi-scope"
" sms_0"
" phase_0)))"
@ -10467,7 +10469,8 @@ static const char *startup_source =
"(lambda(table_1)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((new-sms_0)"
" id*_0))"
"(let-values(((table_2)"
"(let-values(((table_2)"
" table_1))"
@ -26112,7 +26115,7 @@ static const char *startup_source =
"(let-values(((r_0)(if(pair? lst_1)(car lst_1) lst_1))"
"((rest_0)(if(pair? lst_1)(cdr lst_1) null)))"
"(let-values(((fold-var_1)"
"(let-values(((r_1)"
"(let-values(((id*_0)"
"(normalize-required r_0 mpi_0 nominal-phase_0 sym_0)))"
"(begin"
" #t"
@ -26120,7 +26123,7 @@ static const char *startup_source =
"(lambda(fold-var_1)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((r_1) id*_0))"
"(let-values(((fold-var_2)"
"(let-values(((fold-var_2)"
" fold-var_1))"
@ -26573,7 +26576,7 @@ static const char *startup_source =
"(let-values(((fold-var_1) fold-var_0))"
"(if(eq? mod-name_1 self_0)"
" fold-var_1"
"(let-values(((phase-to-requireds_0)"
"(let-values(((id*_0)"
"(hash-ref"
" requires_0"
" mod-name_1"
@ -26584,7 +26587,8 @@ static const char *startup_source =
"(lambda(fold-var_2)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((phase-to-requireds_0)"
" id*_0))"
"(let-values(((fold-var_3)"
"(let-values(((lst_2)"
"(if(eq?"
@ -31703,7 +31707,7 @@ static const char *startup_source =
" mu_0"
"(variable-use-module-use"
" vu_0))"
"(let-values(((var-sym_0)"
"(let-values(((id*_0)"
"(hash-ref"
"(header-require-var-to-import-sym"
" header_0)"
@ -31714,9 +31718,10 @@ static const char *startup_source =
"(lambda(table_2)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((var-sym_0)"
" id*_0))"
"(let-values(((table_3)"
"(let-values(((extra-inspectors_0)"
"(let-values(((id*_1)"
"(hash-ref"
"(header-import-sym-to-extra-inspectors"
" header_0)"
@ -31728,7 +31733,8 @@ static const char *startup_source =
"(lambda(table_3)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((extra-inspectors_0)"
" id*_1))"
"(let-values(((table_4)"
"(let-values(((table_4)"
" table_3))"
@ -34428,7 +34434,7 @@ static const char *startup_source =
" ht_0"
" i_0)))"
"(let-values(((table_1)"
"(let-values(((extra-inspectorsss_0)"
"(let-values(((id*_0)"
"(module-uses-extract-extra-inspectorsss"
"(cdr"
" l+mu*s_0)"
@ -34446,7 +34452,8 @@ static const char *startup_source =
"(lambda(table_1)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((extra-inspectorsss_0)"
" id*_0))"
"(let-values(((table_2)"
"(let-values(((table_2)"
" table_1))"
@ -35185,7 +35192,7 @@ static const char *startup_source =
"(if(< pos_0 end_0)"
"(let-values(((i_0) pos_0))"
"(let-values(((fold-var_1)"
"(let-values(((top_0)"
"(let-values(((id*_0)"
"(hash-ref"
" ht_0"
"(string->symbol(number->string i_0))"
@ -35196,7 +35203,7 @@ static const char *startup_source =
"(lambda(fold-var_1)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((top_0) id*_0))"
"(let-values(((fold-var_2)"
"(let-values(((fold-var_2)"
" fold-var_1))"
@ -39326,7 +39333,7 @@ static const char *startup_source =
"(let-values(((phase-level_0)"
" pos_0))"
"(let-values(((table_1)"
"(let-values(((v_0)"
"(let-values(((id*_0)"
"(hash-ref"
" h_0"
" phase-level_0"
@ -39337,7 +39344,8 @@ static const char *startup_source =
"(lambda(table_1)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((v_0)"
" id*_0))"
"(let-values(((table_2)"
"(let-values(((table_2)"
" table_1))"
@ -40152,7 +40160,7 @@ static const char *startup_source =
"(let-values(((phase_0 at-phase_0)"
"(hash-iterate-key+value ht_0 i_0)))"
"(let-values(((fold-var_1)"
"(let-values(((l_0)"
"(let-values(((id*_0)"
"(reverse$1"
"(let-values(((ht_1)"
" at-phase_0))"
@ -40293,7 +40301,8 @@ static const char *startup_source =
"(lambda(fold-var_1)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((l_0)"
" id*_0))"
"(let-values(((fold-var_2)"
"(let-values(((fold-var_2)"
" fold-var_1))"
@ -40358,7 +40367,7 @@ static const char *startup_source =
"(let-values(((phase_0 vars_0)(hash-iterate-key+value ht_0 i_0)))"
"(let-values(((fold-var_1)"
"(let-values(((fold-var_1) fold-var_0))"
"(let-values(((l_0)"
"(let-values(((id*_0)"
"(let-values(((syms_0)"
"(hash-ref"
" provides_0"
@ -40419,7 +40428,7 @@ static const char *startup_source =
"(lambda(fold-var_2)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((l_0) id*_0))"
"(let-values(((fold-var_3)"
"(let-values(((fold-var_3)"
" fold-var_2))"
@ -66501,7 +66510,7 @@ static const char *startup_source =
"((rest_0)"
"(unsafe-cdr lst_1)))"
"(let-values(((table_1)"
"(let-values(((m_0)"
"(let-values(((id*_0)"
"(namespace->module"
" ns_0"
"(1/module-path-index-resolve"
@ -66512,7 +66521,8 @@ static const char *startup_source =
"(lambda(table_1)"
"(begin"
" 'for-loop"
"(let-values()"
"(let-values(((m_0)"
" id*_0))"
"(let-values(((table_2)"
"(let-values(((ht_0)"
"(hash-ref"
@ -67753,7 +67763,15 @@ static const char *startup_source =
" expect-module_0))))"
"(if or-part_0"
" or-part_0"
"(car expect-module_0)))"
"(let-values(((or-part_1)"
"(car"
" expect-module_0)))"
"(if or-part_1"
" or-part_1"
"(is-compiled-file?"
"(if try-main?_0"
" path_1"
" alt-path_0))))))"
"(let-values()"
"(let-values(((p_0)"
"(if try-main?_0"
@ -67788,6 +67806,14 @@ static const char *startup_source =
"(register-zo-path)"
"(lambda(name_0 ns-hts_0 path_0 src-path_0 base_0)"
"(begin(if ns-hts_0(let-values()(hash-set!(cdr ns-hts_0) name_0(list path_0 src-path_0 base_0)))(void)))))"
"(define-values"
"(is-compiled-file?)"
"(lambda(p_0)"
"(begin"
"(if(file-exists? p_0)"
"(let-values(((p1_0) p_0)((linklet-directory-start2_0) linklet-directory-start))"
"(call-with-input-file*.1 'binary p1_0 linklet-directory-start2_0))"
" #f))))"
"(define-values(default-reader-guard)(lambda(path_0)(begin path_0)))"
"(define-values(cell.1)(unsafe-make-place-local(make-weak-hasheq)))"
"(define-values"

View File

@ -5525,7 +5525,7 @@
(case-lambda
((k_0 vals_0)
(let ((table_1
(let ((new-vals_0
(let ((id*_0
(reverse$1
(begin
(letrec*
@ -5565,13 +5565,13 @@
(lambda (table_1)
(begin
(let ((table_2
(if (pair? new-vals_0)
(if (pair? id*_0)
(let ((table_2
(call-with-values
(lambda ()
(values
k_0
new-vals_0))
id*_0))
(case-lambda
((key_0 val_0)
(hash-set
@ -9173,7 +9173,7 @@
(case-lambda
((sym_0 bindings-for-sym_0)
(let ((table_1
(let ((new-bindings-for-sym_0
(let ((id*_0
(begin
(letrec*
((for-loop_1
@ -9242,13 +9242,13 @@
(let ((table_2
(if (positive?
(hash-count
new-bindings-for-sym_0))
id*_0))
(let ((table_2
(call-with-values
(lambda ()
(values
sym_0
new-bindings-for-sym_0))
id*_0))
(case-lambda
((key_0
val_0)
@ -12498,7 +12498,7 @@
smss_1
i_0)))
(let ((table_1
(let ((new-sms_0
(let ((id*_0
(shift-multi-scope
sms_0
phase_0)))
@ -12511,12 +12511,12 @@
(lambda (table_1)
(begin
(let ((table_2
(if new-sms_0
(if id*_0
(let ((table_2
(call-with-values
(lambda ()
(values
new-sms_0
id*_0
#t))
(case-lambda
((key_0
@ -30081,7 +30081,7 @@
(let ((rest_0 (if (pair? lst_0) (cdr lst_0) null)))
(let ((r_1 r_0))
(let ((fold-var_1
(let ((r_2
(let ((id*_0
(begin-unsafe
(if (bulk-required? r_1)
(bulk-required->required
@ -30101,9 +30101,10 @@
(let ((fold-var_2
(if (if (eqv?
phase_0
(required-phase r_2))
(required-phase
id*_0))
(free-identifier=?$1
(required-id r_2)
(required-id id*_0)
id_0
phase_0
phase_0)
@ -30111,7 +30112,7 @@
fold-var_1
(let ((fold-var_2
(cons
r_2
id*_0
fold-var_1)))
(values fold-var_2)))))
fold-var_2))))))
@ -30527,7 +30528,7 @@
(let ((fold-var_1
(if (eq? mod-name_1 self_0)
fold-var_0
(let ((phase-to-requireds_0
(let ((id*_0
(hash-ref
requires_0
mod-name_1
@ -30546,7 +30547,7 @@
phase_0
'all)
(hash-keys
phase-to-requireds_0)
id*_0)
(list
phase_0))))
(begin
@ -30568,7 +30569,7 @@
(let ((fold-var_3
(let ((ht_0
(hash-ref
phase-to-requireds_0
id*_0
phase_1
(lambda ()
(|#%app|
@ -36704,7 +36705,7 @@
mu_0
(variable-use-module-use
vu_0))
(let ((var-sym_0
(let ((id*_0
(hash-ref
(header-require-var-to-import-sym
header_0)
@ -36718,11 +36719,11 @@
(lambda (table_1)
(begin
(let ((table_2
(let ((extra-inspectors_0
(let ((id*_1
(hash-ref
(header-import-sym-to-extra-inspectors
header_0)
var-sym_0
id*_0
#f)))
(begin
#t
@ -36733,15 +36734,15 @@
(lambda (table_2)
(begin
(let ((table_3
(if (if extra-inspectors_0
extra-inspectors_0
(if (if id*_1
id*_1
cross-linklet-inlining?_0)
(let ((table_3
(call-with-values
(lambda ()
(values
var-sym_0
extra-inspectors_0))
id*_0
id*_1))
(case-lambda
((key_0
val_0)
@ -39442,7 +39443,7 @@
((phase_1
l+mu*s_0)
(let ((table_1
(let ((extra-inspectorsss_0
(let ((id*_0
(let ((app_0
(cdr
l+mu*s_0)))
@ -39469,13 +39470,13 @@
(lambda (table_1)
(begin
(let ((table_2
(if extra-inspectorsss_0
(if id*_0
(let ((table_2
(call-with-values
(lambda ()
(values
phase_1
extra-inspectorsss_0))
id*_0))
(case-lambda
((key_0
val_0)
@ -40243,7 +40244,7 @@
(begin
(if (< pos_0 end_0)
(let ((fold-var_1
(let ((top_0
(let ((id*_0
(hash-ref
ht_0
(string->symbol (number->string pos_0))
@ -40257,10 +40258,10 @@
(lambda (fold-var_1)
(begin
(let ((fold-var_2
(if top_0
(if id*_0
(let ((fold-var_2
(cons
top_0
id*_0
fold-var_1)))
(values fold-var_2))
fold-var_1)))
@ -44740,7 +44741,7 @@
(begin
(if (< pos_0 end_0)
(let ((table_1
(let ((v_0
(let ((id*_0
(hash-ref
h_0
pos_0
@ -44754,7 +44755,7 @@
(lambda (table_1)
(begin
(let ((table_2
(if v_0
(if id*_0
(let ((table_2
(call-with-values
(lambda ()
@ -44763,7 +44764,7 @@
(begin-unsafe
(eval-linklet
(force-compile-linklet
v_0)))))
id*_0)))))
(case-lambda
((key_0
val_0)
@ -45661,7 +45662,7 @@
(case-lambda
((phase_0 at-phase_0)
(let ((fold-var_1
(let ((l_0
(let ((id*_0
(reverse$1
(begin
(letrec*
@ -45792,7 +45793,7 @@
(begin
(let ((fold-var_2
(if (null?
l_0)
id*_0)
fold-var_1
(let ((fold-var_2
(cons
@ -45801,7 +45802,7 @@
(sort.1
#f
car
l_0
id*_0
symbol<?))
fold-var_1)))
(values
@ -45844,7 +45845,7 @@
(case-lambda
((phase_0 vars_0)
(let ((fold-var_1
(let ((l_0
(let ((id*_0
(let ((syms_0
(hash-ref
provides_0
@ -45891,7 +45892,7 @@
(lambda (fold-var_1)
(begin
(let ((fold-var_2
(if (null? l_0)
(if (null? id*_0)
fold-var_1
(let ((fold-var_2
(cons
@ -45900,7 +45901,7 @@
(sort.1
#f
#f
l_0
id*_0
symbol<?))
fold-var_1)))
(values
@ -74135,7 +74136,7 @@
(unsafe-car lst_0)))
(let ((rest_0 (unsafe-cdr lst_0)))
(let ((table_1
(let ((m_0
(let ((id*_0
(namespace->module
namespace37_0
(1/module-path-index-resolve
@ -74153,9 +74154,9 @@
(hash-ref
(shift-provides-module-path-index
(module-provides
m_0)
id*_0)
(module-self
m_0)
id*_0)
require-mpi_0)
0)))
(begin
@ -75617,8 +75618,15 @@
expect-module_0))))
(if or-part_0
or-part_0
(car
expect-module_0)))
(let ((or-part_1
(car
expect-module_0)))
(if or-part_1
or-part_1
(is-compiled-file?
(if try-main?_0
path_1
alt-path_0))))))
(let ((p_0
(if try-main?_0
path_1
@ -75670,6 +75678,11 @@
(let ((app_0 (cdr ns-hts_0)))
(hash-set! app_0 name_0 (list path_0 src-path_0 base_0)))
(void))))
(define is-compiled-file?
(lambda (p_0)
(if (file-exists? p_0)
(call-with-input-file*.1 'binary p_0 linklet-directory-start)
#f)))
(define default-reader-guard (lambda (path_0) path_0))
(define cell.1 (unsafe-make-place-local (make-weak-hasheq)))
(define registry-table-ref

View File

@ -3246,6 +3246,9 @@
(begin-unsafe (hash-ref rktio-table 'rktio_get_milliseconds)))
(define rktio_get_inexact_milliseconds
(begin-unsafe (hash-ref rktio-table 'rktio_get_inexact_milliseconds)))
(define rktio_get_inexact_monotonic_milliseconds
(begin-unsafe
(hash-ref rktio-table 'rktio_get_inexact_monotonic_milliseconds)))
(define rktio_get_process_milliseconds
(begin-unsafe (hash-ref rktio-table 'rktio_get_process_milliseconds)))
(define rktio_get_process_children_milliseconds
@ -32095,7 +32098,7 @@
(let ((b+r_0 (unsafe-car lst_1)))
(let ((rest_0 (unsafe-cdr lst_1)))
(let ((fold-var_1
(let ((lr_0 (weak-box-value (car b+r_0))))
(let ((id*_0 (weak-box-value (car b+r_0))))
(begin
#t
(letrec*
@ -32105,10 +32108,10 @@
(lambda (fold-var_1)
(begin
(let ((fold-var_2
(if lr_0
(if id*_0
(let ((fold-var_2
(cons
lr_0
id*_0
fold-var_1)))
(values fold-var_2))
fold-var_1)))
@ -34353,11 +34356,11 @@
'subprocess
"(or/c (and/c output-port? file-stream-port?) #f 'stdout)"
stderr_0))
(let ((lr1324 unsafe-undefined)
(let ((lr1325 unsafe-undefined)
(group_0 unsafe-undefined)
(command_0 unsafe-undefined)
(exact/args_0 unsafe-undefined))
(set! lr1324
(set! lr1325
(call-with-values
(lambda ()
(if (path-string? group/command_0)
@ -34412,9 +34415,9 @@
((group_1 command_1 exact/args_1)
(vector group_1 command_1 exact/args_1))
(args (raise-binding-result-arity-error 3 args)))))
(set! group_0 (unsafe-vector*-ref lr1324 0))
(set! command_0 (unsafe-vector*-ref lr1324 1))
(set! exact/args_0 (unsafe-vector*-ref lr1324 2))
(set! group_0 (unsafe-vector*-ref lr1325 0))
(set! command_0 (unsafe-vector*-ref lr1325 1))
(set! exact/args_0 (unsafe-vector*-ref lr1325 2))
(call-with-values
(lambda ()
(if (if (pair? exact/args_0)

View File

@ -162,7 +162,8 @@
(parameterize ([current-module-declare-source alt-path])
(with-dir (lambda () ((current-load) (car zo-d) expect-module)))))]
[(or (not (pair? expect-module))
(car expect-module))
(car expect-module)
(is-compiled-file? (if try-main? path alt-path)))
(let ([p (if try-main? path alt-path)])
;; "quiet" failure when asking for a submodule:
(unless (and (pair? expect-module)
@ -176,6 +177,10 @@
(when ns-hts
(hash-set! (cdr ns-hts) name (list path src-path base))))
(define (is-compiled-file? p)
(and (file-exists? p)
(call-with-input-file* p linklet-directory-start)))
(define (default-reader-guard path)
path)

View File

@ -14,7 +14,8 @@
"../read/api.rkt"
"../read/primitive-parameter.rkt")
(provide default-load-handler)
(provide default-load-handler
linklet-directory-start)
(define default-load-handler
(lambda (path expected-mod)
@ -157,7 +158,7 @@
(cond
[(module-cache-ref (make-module-cache-key (linklet-bundle-hash-code i)))
=> (lambda (declare-module)
;; The `declare-module` function has registered in the cace by
;; The `declare-module` function was registered in the cache by
;; `eval-module` in "eval/module.rkt"; we can call the function
;; instead of loading from scratch and `eval`ing;
;; FIXME: go though `current-eval`