raco exe: enable on-demand parsing of embedded bytecode

Creating a stand-alone executable could slow down a program,
because bytecode embedded in an executable was not treated
in the same way as bytecode loaded from files. The difference
was in on-demand parsing of bytecode --- and now it's enabled
for embedded bytecode, too.
This commit is contained in:
Matthew Flatt 2013-05-08 11:52:38 -04:00
parent e85b9d523f
commit eb46eacad9
6 changed files with 104 additions and 91 deletions

View File

@ -274,7 +274,7 @@ adjusts the parsing of S-expression input, where @racket[#f] implies the
default behavior. See @secref["readtables"] for more information.}
@defparam[read-on-demand-source path (or/c #f (and/c path? complete-path?))]{
@defparam[read-on-demand-source mode (or/c #f #t (and/c path? complete-path?))]{
A @tech{parameter} that enables lazy parsing of compiled code, so that
closure bodies and syntax objects are extracted (and validated) from
@ -282,12 +282,17 @@ marshaled compiled code on demand. Normally, this parameter is set by
the default @tech{load handler} when @racket[load-on-demand-enabled]
is @racket[#t].
Even when parsing is delayed, compiled code is loaded into memory. If
the @as-index{@envvar{PLT_DELAY_FROM_ZO}} environment variable is set
(to any value) on start-up, however, even loading from disk is
delayed. If the file at @tech{path} changes before the delayed code or
syntax object is demanded, the read-on-demand most likely will
encounter garbage, leading to an exception.}
A @racket[#f] value for @racket[read-on-demand-source] disables lazy
parsing of compiled code. A @racket[#t] value enables lazy parsing. A
@tech{path} value furthers enable lazy retrieval from disk---instead
of keeping unparsed compiled code in memory---when the
@as-index{@envvar{PLT_DELAY_FROM_ZO}} environment variable is set (to
any value) on start-up.
If the file at @racket[mode] as a @tech{path} changes before the
delayed code is parsed when lazy retrieval from disk is enabled, then
the on-demand parse most likely will encounter garbage, leading to an
exception.}
@defproc*[([(port-read-handler [in input-port?]) (case->

View File

@ -1,5 +1,6 @@
Version 5.3.4.10
Move explode-path from racket/path to racket/base
Changed read-on-demand-source to support #t
Version 5.3.4.9
racket/place: allow keywords as place messages

View File

@ -114,8 +114,8 @@
231,20,247,20,173,22,201,22,210,22,28,24,46,24,60,24,81,24,97,24,145,
24,154,24,172,24,227,24,240,24,108,27,19,28,178,28,192,28,87,31,215,33,
228,33,117,35,54,36,56,36,81,36,94,36,17,38,210,38,225,38,234,38,241,
38,110,39,235,39,86,41,177,41,14,42,109,42,44,43,76,43,206,43,0,0,
199,48,0,0,67,35,37,117,116,105,108,115,72,112,97,116,104,45,115,116,114,
38,110,39,235,39,86,41,177,41,14,42,109,42,59,43,91,43,221,43,0,0,
214,48,0,0,67,35,37,117,116,105,108,115,72,112,97,116,104,45,115,116,114,
105,110,103,63,64,98,115,98,115,76,110,111,114,109,97,108,45,99,97,115,101,
45,112,97,116,104,71,114,101,114,111,111,116,45,112,97,116,104,1,20,102,105,
110,100,45,101,120,101,99,117,116,97,98,108,101,45,112,97,116,104,1,27,112,
@ -632,85 +632,86 @@
2,56,28,192,249,22,159,8,194,7,63,2,50,2,50,27,28,23,196,1,250,
22,170,15,248,22,129,16,2,57,247,22,165,8,2,58,11,27,248,80,159,42,
8,33,39,250,22,93,23,203,1,248,22,89,248,22,129,16,2,46,23,204,1,
28,193,249,22,79,195,194,192,27,20,13,159,80,159,37,53,37,254,80,159,44,
54,37,249,22,33,11,80,159,46,53,37,22,190,14,10,22,133,15,10,22,134,
15,10,248,22,142,6,23,196,2,28,248,22,142,7,23,194,2,12,86,94,248,
22,170,9,23,194,1,27,20,13,159,80,159,38,53,37,254,80,159,45,54,37,
249,22,33,11,80,159,47,53,37,22,190,14,10,22,133,15,10,22,134,15,10,
248,22,142,6,23,197,2,28,248,22,142,7,23,194,2,12,86,94,248,22,170,
9,23,194,1,27,20,13,159,80,159,39,53,37,254,80,159,46,54,37,249,22,
33,11,80,159,48,53,37,22,190,14,10,22,133,15,10,22,134,15,10,248,22,
142,6,23,198,2,28,248,22,142,7,23,194,2,12,86,94,248,22,170,9,23,
194,1,248,80,159,40,8,34,39,197,86,94,249,22,133,7,247,22,170,5,23,
196,2,248,22,157,6,249,22,136,4,36,249,22,184,3,23,198,1,23,199,1,
27,28,23,197,2,86,95,23,196,1,23,195,1,23,197,1,86,94,23,197,1,
27,248,22,129,16,2,47,27,250,80,159,42,40,39,23,197,1,11,11,27,248,
22,139,4,23,199,1,27,28,23,194,2,23,194,1,86,94,23,194,1,36,27,
248,22,139,4,23,202,1,27,28,23,194,2,23,194,1,86,94,23,194,1,36,
249,22,137,6,23,199,1,20,20,95,88,163,8,36,36,48,11,9,224,4,2,
33,136,2,23,195,1,23,197,1,27,248,22,186,5,23,195,1,248,80,159,39,
8,34,39,193,159,36,20,114,159,36,16,1,11,16,0,20,26,145,9,2,1,
2,1,29,11,11,11,11,9,9,11,11,11,10,43,80,158,36,36,20,114,159,
40,16,31,2,2,2,3,2,4,2,5,2,6,2,7,2,8,2,9,2,10,
2,11,2,12,2,13,2,14,2,15,2,16,2,17,30,2,20,76,102,105,110,
100,45,108,105,110,107,115,45,112,97,116,104,33,11,4,30,2,21,1,20,112,
97,114,97,109,101,116,101,114,105,122,97,116,105,111,110,45,107,101,121,11,6,
30,2,21,1,23,101,120,116,101,110,100,45,112,97,114,97,109,101,116,101,114,
105,122,97,116,105,111,110,11,3,2,22,2,23,2,24,30,2,20,1,21,101,
120,99,101,112,116,105,111,110,45,104,97,110,100,108,101,114,45,107,101,121,11,
2,2,25,2,26,2,27,2,28,2,29,2,30,2,31,2,32,16,0,37,39,
36,16,0,36,16,14,2,9,2,10,2,8,2,3,2,26,2,24,2,22,2,
17,2,23,2,25,2,27,2,15,2,14,2,16,50,11,11,11,16,13,2,13,
2,11,2,32,2,12,2,6,2,31,2,30,2,4,2,29,2,7,2,28,2,
2,2,5,16,13,11,11,11,11,11,11,11,11,11,11,11,11,11,16,13,2,
13,2,11,2,32,2,12,2,6,2,31,2,30,2,4,2,29,2,7,2,28,
2,2,2,5,49,49,37,12,11,11,16,0,16,0,16,0,36,36,11,12,11,
11,16,0,16,0,16,0,36,36,16,31,20,15,16,2,32,0,88,163,36,37,
45,11,2,2,222,33,59,80,159,36,36,37,20,15,16,2,249,22,149,7,7,
92,7,92,80,159,36,37,37,20,15,16,2,88,163,36,37,54,38,2,4,223,
0,33,64,80,159,36,38,37,20,15,16,2,88,163,36,38,58,38,2,5,223,
0,33,66,80,159,36,39,37,20,15,16,2,20,25,96,2,6,88,163,8,36,
39,8,25,8,32,9,223,0,33,73,88,163,36,38,47,52,9,223,0,33,74,
88,163,36,37,46,52,9,223,0,33,75,80,159,36,40,37,20,15,16,2,27,
248,22,138,16,248,22,161,8,27,28,249,22,162,9,247,22,174,8,2,35,6,
1,1,59,6,1,1,58,250,22,131,8,6,14,14,40,91,94,126,97,93,42,
41,126,97,40,46,42,41,23,196,2,23,196,1,88,163,8,36,38,48,11,2,
7,223,0,33,79,80,159,36,41,37,20,15,16,2,32,0,88,163,8,36,38,
47,11,2,8,222,33,80,80,159,36,42,37,20,15,16,2,32,0,88,163,8,
36,39,48,11,2,9,222,33,82,80,159,36,43,37,20,15,16,2,32,0,88,
163,8,36,38,46,11,2,10,222,33,83,80,159,36,44,37,20,15,16,2,88,
163,45,39,49,8,128,16,2,11,223,0,33,85,80,159,36,45,37,20,15,16,
2,88,163,45,40,50,8,128,16,2,13,223,0,33,87,80,159,36,47,37,20,
15,16,2,248,22,129,16,70,108,105,110,107,115,45,102,105,108,101,80,159,36,
48,37,20,15,16,2,247,22,140,2,80,158,36,49,20,15,16,2,2,88,80,
158,36,50,20,15,16,2,248,80,159,37,52,37,88,163,36,36,49,8,240,16,
0,6,0,9,223,1,33,89,80,159,36,51,37,20,15,16,2,247,22,140,2,
80,158,36,55,20,15,16,2,2,88,80,158,36,56,20,15,16,2,88,163,36,
37,44,8,240,0,240,94,0,2,24,223,0,33,100,80,159,36,57,37,20,15,
16,2,88,163,36,38,56,8,240,0,0,128,0,2,25,223,0,33,102,80,159,
36,59,37,20,15,16,2,88,163,36,40,59,8,240,0,128,160,0,2,12,223,
0,33,113,80,159,36,46,37,20,15,16,2,32,0,88,163,36,39,50,11,2,
26,222,33,114,80,159,36,8,24,37,20,15,16,2,32,0,88,163,36,41,8,
27,11,2,27,222,33,117,80,159,36,8,25,37,20,15,16,2,20,27,158,32,
0,88,163,36,38,52,11,2,28,222,33,120,88,163,36,38,49,8,240,0,0,
0,2,2,28,223,0,33,122,80,159,36,8,26,37,20,15,16,2,20,27,158,
32,0,88,163,36,38,52,11,2,29,222,33,125,88,163,36,38,49,8,240,0,
0,0,2,2,29,223,0,33,126,80,159,36,8,27,37,20,15,16,2,20,27,
158,32,0,88,163,36,37,44,11,2,30,222,33,127,32,0,88,163,36,37,44,
11,2,30,222,33,128,2,80,159,36,8,28,37,20,15,16,2,88,163,8,36,
37,51,16,2,52,8,240,0,128,0,0,2,42,223,0,33,129,2,80,159,36,
8,31,39,20,15,16,2,88,163,8,36,37,51,16,4,52,36,37,36,2,42,
223,0,33,130,2,80,159,36,8,32,39,20,15,16,2,88,163,8,36,37,56,
16,4,52,36,38,36,2,42,223,0,33,131,2,80,159,36,8,33,39,20,15,
16,2,20,25,96,2,31,88,163,36,36,53,16,2,8,32,8,240,0,128,0,
0,9,223,0,33,132,2,88,163,36,37,54,16,4,8,32,36,37,36,9,223,
0,33,133,2,88,163,36,38,55,16,4,8,32,36,38,36,9,223,0,33,134,
2,80,159,36,8,29,37,20,15,16,2,88,163,8,36,37,55,16,4,36,42,
40,36,2,42,223,0,33,135,2,80,159,36,8,34,39,20,15,16,2,88,163,
8,36,39,54,16,4,52,36,40,36,2,32,223,0,33,137,2,80,159,36,8,
30,37,95,29,94,2,18,68,35,37,107,101,114,110,101,108,11,29,94,2,18,
69,35,37,109,105,110,45,115,116,120,11,2,20,9,9,9,36,0};
EVAL_ONE_SIZED_STR((char *)expr, 12806);
28,193,249,22,79,195,194,192,27,20,13,159,80,159,37,53,37,26,9,80,159,
46,54,37,249,22,33,11,80,159,48,53,37,22,190,14,10,22,133,15,10,22,
134,15,10,22,135,15,10,248,22,142,6,23,196,2,28,248,22,142,7,23,194,
2,12,86,94,248,22,170,9,23,194,1,27,20,13,159,80,159,38,53,37,26,
9,80,159,47,54,37,249,22,33,11,80,159,49,53,37,22,190,14,10,22,133,
15,10,22,134,15,10,22,135,15,10,248,22,142,6,23,197,2,28,248,22,142,
7,23,194,2,12,86,94,248,22,170,9,23,194,1,27,20,13,159,80,159,39,
53,37,26,9,80,159,48,54,37,249,22,33,11,80,159,50,53,37,22,190,14,
10,22,133,15,10,22,134,15,10,22,135,15,10,248,22,142,6,23,198,2,28,
248,22,142,7,23,194,2,12,86,94,248,22,170,9,23,194,1,248,80,159,40,
8,34,39,197,86,94,249,22,133,7,247,22,170,5,23,196,2,248,22,157,6,
249,22,136,4,36,249,22,184,3,23,198,1,23,199,1,27,28,23,197,2,86,
95,23,196,1,23,195,1,23,197,1,86,94,23,197,1,27,248,22,129,16,2,
47,27,250,80,159,42,40,39,23,197,1,11,11,27,248,22,139,4,23,199,1,
27,28,23,194,2,23,194,1,86,94,23,194,1,36,27,248,22,139,4,23,202,
1,27,28,23,194,2,23,194,1,86,94,23,194,1,36,249,22,137,6,23,199,
1,20,20,95,88,163,8,36,36,48,11,9,224,4,2,33,136,2,23,195,1,
23,197,1,27,248,22,186,5,23,195,1,248,80,159,39,8,34,39,193,159,36,
20,114,159,36,16,1,11,16,0,20,26,145,9,2,1,2,1,29,11,11,11,
11,9,9,11,11,11,10,43,80,158,36,36,20,114,159,40,16,31,2,2,2,
3,2,4,2,5,2,6,2,7,2,8,2,9,2,10,2,11,2,12,2,13,
2,14,2,15,2,16,2,17,30,2,20,76,102,105,110,100,45,108,105,110,107,
115,45,112,97,116,104,33,11,4,30,2,21,1,20,112,97,114,97,109,101,116,
101,114,105,122,97,116,105,111,110,45,107,101,121,11,6,30,2,21,1,23,101,
120,116,101,110,100,45,112,97,114,97,109,101,116,101,114,105,122,97,116,105,111,
110,11,3,2,22,2,23,2,24,30,2,20,1,21,101,120,99,101,112,116,105,
111,110,45,104,97,110,100,108,101,114,45,107,101,121,11,2,2,25,2,26,2,
27,2,28,2,29,2,30,2,31,2,32,16,0,37,39,36,16,0,36,16,14,
2,9,2,10,2,8,2,3,2,26,2,24,2,22,2,17,2,23,2,25,2,
27,2,15,2,14,2,16,50,11,11,11,16,13,2,13,2,11,2,32,2,12,
2,6,2,31,2,30,2,4,2,29,2,7,2,28,2,2,2,5,16,13,11,
11,11,11,11,11,11,11,11,11,11,11,11,16,13,2,13,2,11,2,32,2,
12,2,6,2,31,2,30,2,4,2,29,2,7,2,28,2,2,2,5,49,49,
37,12,11,11,16,0,16,0,16,0,36,36,11,12,11,11,16,0,16,0,16,
0,36,36,16,31,20,15,16,2,32,0,88,163,36,37,45,11,2,2,222,33,
59,80,159,36,36,37,20,15,16,2,249,22,149,7,7,92,7,92,80,159,36,
37,37,20,15,16,2,88,163,36,37,54,38,2,4,223,0,33,64,80,159,36,
38,37,20,15,16,2,88,163,36,38,58,38,2,5,223,0,33,66,80,159,36,
39,37,20,15,16,2,20,25,96,2,6,88,163,8,36,39,8,25,8,32,9,
223,0,33,73,88,163,36,38,47,52,9,223,0,33,74,88,163,36,37,46,52,
9,223,0,33,75,80,159,36,40,37,20,15,16,2,27,248,22,138,16,248,22,
161,8,27,28,249,22,162,9,247,22,174,8,2,35,6,1,1,59,6,1,1,
58,250,22,131,8,6,14,14,40,91,94,126,97,93,42,41,126,97,40,46,42,
41,23,196,2,23,196,1,88,163,8,36,38,48,11,2,7,223,0,33,79,80,
159,36,41,37,20,15,16,2,32,0,88,163,8,36,38,47,11,2,8,222,33,
80,80,159,36,42,37,20,15,16,2,32,0,88,163,8,36,39,48,11,2,9,
222,33,82,80,159,36,43,37,20,15,16,2,32,0,88,163,8,36,38,46,11,
2,10,222,33,83,80,159,36,44,37,20,15,16,2,88,163,45,39,49,8,128,
16,2,11,223,0,33,85,80,159,36,45,37,20,15,16,2,88,163,45,40,50,
8,128,16,2,13,223,0,33,87,80,159,36,47,37,20,15,16,2,248,22,129,
16,70,108,105,110,107,115,45,102,105,108,101,80,159,36,48,37,20,15,16,2,
247,22,140,2,80,158,36,49,20,15,16,2,2,88,80,158,36,50,20,15,16,
2,248,80,159,37,52,37,88,163,36,36,49,8,240,16,0,6,0,9,223,1,
33,89,80,159,36,51,37,20,15,16,2,247,22,140,2,80,158,36,55,20,15,
16,2,2,88,80,158,36,56,20,15,16,2,88,163,36,37,44,8,240,0,240,
94,0,2,24,223,0,33,100,80,159,36,57,37,20,15,16,2,88,163,36,38,
56,8,240,0,0,128,0,2,25,223,0,33,102,80,159,36,59,37,20,15,16,
2,88,163,36,40,59,8,240,0,128,160,0,2,12,223,0,33,113,80,159,36,
46,37,20,15,16,2,32,0,88,163,36,39,50,11,2,26,222,33,114,80,159,
36,8,24,37,20,15,16,2,32,0,88,163,36,41,8,27,11,2,27,222,33,
117,80,159,36,8,25,37,20,15,16,2,20,27,158,32,0,88,163,36,38,52,
11,2,28,222,33,120,88,163,36,38,49,8,240,0,0,0,2,2,28,223,0,
33,122,80,159,36,8,26,37,20,15,16,2,20,27,158,32,0,88,163,36,38,
52,11,2,29,222,33,125,88,163,36,38,49,8,240,0,0,0,2,2,29,223,
0,33,126,80,159,36,8,27,37,20,15,16,2,20,27,158,32,0,88,163,36,
37,44,11,2,30,222,33,127,32,0,88,163,36,37,44,11,2,30,222,33,128,
2,80,159,36,8,28,37,20,15,16,2,88,163,8,36,37,51,16,2,52,8,
240,0,128,0,0,2,42,223,0,33,129,2,80,159,36,8,31,39,20,15,16,
2,88,163,8,36,37,51,16,4,52,36,37,36,2,42,223,0,33,130,2,80,
159,36,8,32,39,20,15,16,2,88,163,8,36,37,56,16,4,52,36,38,36,
2,42,223,0,33,131,2,80,159,36,8,33,39,20,15,16,2,20,25,96,2,
31,88,163,36,36,53,16,2,8,32,8,240,0,128,0,0,9,223,0,33,132,
2,88,163,36,37,54,16,4,8,32,36,37,36,9,223,0,33,133,2,88,163,
36,38,55,16,4,8,32,36,38,36,9,223,0,33,134,2,80,159,36,8,29,
37,20,15,16,2,88,163,8,36,37,57,16,4,36,42,40,36,2,42,223,0,
33,135,2,80,159,36,8,34,39,20,15,16,2,88,163,8,36,39,54,16,4,
52,36,40,36,2,32,223,0,33,137,2,80,159,36,8,30,37,95,29,94,2,
18,68,35,37,107,101,114,110,101,108,11,29,94,2,18,69,35,37,109,105,110,
45,115,116,120,11,2,20,9,9,9,36,0};
EVAL_ONE_SIZED_STR((char *)expr, 12821);
}
{
SHARED_OK static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,8,53,46,51,46,52,46,49,48,84,0,0,0,0,0,0,0,0,0,

View File

@ -800,6 +800,7 @@ static Scheme_Object *rdl_check(int argc, Scheme_Object **argv)
Scheme_Object *s = argv[0];
return ((SCHEME_FALSEP(s)
|| SAME_OBJ(scheme_true, s)
|| (SCHEME_PATHP(s)
&& scheme_is_complete_path(SCHEME_PATH_VAL(s),
SCHEME_PATH_LEN(s),
@ -814,7 +815,7 @@ read_delay_load(int argc, Scheme_Object *argv[])
scheme_make_integer(MZCONFIG_DELAY_LOAD_INFO),
argc, argv,
-1, rdl_check,
"(or/c #f (and/c path? complete-path?))",
"(or/c #f #t (and/c path? complete-path?))",
0);
}
@ -5543,6 +5544,9 @@ static Scheme_Object *read_compiled(Scheme_Object *port,
delay_info->shared_offsets = rp->shared_offsets;
delay_info->relto = rp->relto;
if (SAME_OBJ(delay_info->path, scheme_true))
perma_cache = 1;
if (perma_cache) {
unsigned char *cache;
cache = (unsigned char *)scheme_malloc_atomic(shared_size);

View File

@ -684,7 +684,8 @@
"(let loop()"
"(let((e(parameterize((read-accept-compiled #t)"
"(read-accept-reader #t)"
"(read-accept-lang #t))"
"(read-accept-lang #t)"
"(read-on-demand-source #t))"
"(read p))))"
"(unless(eof-object? e)"
"(eval e)"

View File

@ -782,7 +782,8 @@
(let loop ()
(let ([e (parameterize ([read-accept-compiled #t]
[read-accept-reader #t]
[read-accept-lang #t])
[read-accept-lang #t]
[read-on-demand-source #t])
(read p))])
(unless (eof-object? e)
(eval e)