Improve error reporting and improve docs as suggested by Andy, and
adjust `conv` -> `conv*` to fit a naming convention.
original commit: b34817aea5d3c4862e7bb313ee9f5281472a832f
Changed the base language foregin and fcallable forms to accept a list of
conventions, which are each symbols, instead of a single convention, which was
a list of conventions, mostly to make it clear in the grammar what is going on.
base-lang.ss, cp0.ss cpcheck.ss, cpcommonize.ss, cpletrec.ss, cpnanopass.ss,
cprep.ss, cpvalid.ss, interpret.ss, syntax.ss,
Fixed a place where we were checking for eq? of two conventions, which now
should be equal? since it is a list (assuming this list will always be in a
consistent order).
cpcommonize.ss
Removed a spurious definition of convention?
np-languages.ss
original commit: dabf5a8abeaef12cdfcb36d9aac236dda9ac9158
Removed counter field from prelex, using the operand field instead to
provide the index into the fxmap. This follows other uses within the compiler
where we use the operand field as a little place for state that is used
within a single pass. This has a few advantages. First, it keeps the record a
little smaller. Second, it means that the prelex numbering can start from 0
for each compilation unit, which should help keep the numbers for the fxmap a
bit smaller in longer running sessions with multiple calls to the compiler.
Finally, it avoids adding to the burden of the tc-mutex, since within the pass
it is safe for us to set the prelexes, since only the instance of the pass
holding this block of code has a handle on it. As part of this change
prelex-counter is now defined in cptypes and the operand is cleared after the
variables go out of scope.
base-lang.ss
Fixed the highest-set-bit function in fxmap so that it will work in the 32-bit
versions of Chez Scheme. The fxsrl by 32 raises an exception, and was leading
to tests to fail in 32-bit mode.
fxmap.ss
Restructured predicate-implies? so that it uses committed choice instead of
uncommitted choice in comparing x and y. Basically, this means, instead of
doing:
(or
(and (predicate-1? x) (predicate-1? y) ---)
(and (predicate-2? x) (predicate-2? y) ---)
...)
we now do:
(cond
[(predicate-1? x) (and (predicate-1? y) ---)]
[(predicate-2? x) (and (predicate-2? y) ---)]
...)
This avoids running predicates on x that we know will fail because an earlier
predicate matches, generally getting out of the predicate faster. This did
require a little restructuring, because in some cases x was dominant and in
other cases y was dominant. This is now restructured with y dominate, after
the eq? and x 'bottom check.
Replaced let-values calls with cata-morphism syntax, including removal of maps
that built up a list of values that then needed to be separated out with
(map car ...) (map cadr ...) etc. calls. This avoid building up structures we
don't need, since the nanopass framework will generate a mutltivalued let for
these situations.
The if clause in cptypes/raw now uses types1 (the result of the recursive call
on e1) in place of the incoming types clause when processing the e2 or e3
expressions in the cases where e1 is known statically to produce either a false
or non-false value.
Fixed a bug with directly-applied variable arity lambda. The original code
marked all directly-applied variable arity lambda's as producing bottom,
because it was chacking for the interface to be equal to the number of
arguments. However, variable arity functions are represented with a negative
number. For instance, the original code would transform the expression:
(begin
((lambda (a . b) (set! t (cons* b a t))) 'a 'b 'c)
t)
to
((lambda (a . b) (set! t (cons* b a t))) 'a 'b 'c)
anticipating that the call would raise an error, however, it is a perfectly
valid (if some what unusual) expression. I tried to come up with a test for
this, however, without building something fairly complicated, it is difficult
to get past cp0 without cp0 turning it into something like:
(let ([b (list 'b 'c)])
(set! t (cons* b 'a t))
t)
Fixed make-time, time-second-set!, and time-second to indicate that second can
be an exact-integer, since it is not really restricted to the fixnum range (and
if fact we even test this fact in the mats on 32-bit machines).
primdata.ss
Changed check of prelex-was-assigned (which is not reliably on the input to any
give pass) with prelex-assigned, which should always have an accurate, if
conservative, value in it.
Added enable-type-recovery parameter to allow the type recover to be turned on
and off, and added cptype to the cp0 not run path that runs cpletrec, so that
cptypes can be run independent of cp0. This is helpful for testing and allows
us to benefit from type recovery, even in cases where we do not want cp0 to
perform any inlining.
compile.ss, front.ss, primdata.ss
Stylistic changes, mostly for consistency with other parts of the compiler,
though I'm not married to these changes if you'd really prefer to keep things
the way the are.
1. clauses of define-record type now use parenthesis instead of square brackets.
2. indented by 2 spaces where things were only indented by one space
3. define, let, define-pass, nanopass pass productions clauses, now use
parenthesis for outer markers instead of square brackets.
fxmap.ss,
original commit: 5c6c5a534ff708d4bff23f6fd48fe6726a5c4e05
Embarrassingly, I committed this change on the wrong branch initially.
Added -Wno-implicit-fallthrough flag to macOS C makefiles.
c/Mf-a6osx, c/Mf-i3osx, c/Mf-ta6osx, c/Mf-ti3osx
original commit: 8eb8336a7d2870f8e592f060bab8321703e40b48
- fixed an issue with the library system where an exception that occurs
during visit or revisit left the library in an inconsistent state that
caused it to appear that it was still in the process of running. This
manifested in it raising a cyclic dependency exception, even though
there really is not a cyclic dependency. The various library
management functions involved will now reset the part of the library
when an exception occurs. This also means that if the library visit
or revisit failed for a transient reason (such as a missing or
incorrect library version that can be fixed by updating the
library-directories) it is now possible to recover from these errors.
expand-lang.ss, syntax.ss, interpret.ss, compile.ss, cprep.ss,
8.ms
original commit: 6dbd72496fb4eaf5fb65453d0ae0a75f0ef2ad80
Also, report an error if a string type is misused as an argument (for
foreign procedures) or result (for foreign callables) with
`__collect_safe`.
original commit: cdbfa3d86cb0719bf0979b3fe0aa5c4383282b77
the signal handler could trip over the NULL jumpbuf in a CCHAIN record.
schlib.c
remade boot files
original commit: d8c270403121547101cb523cc1f80a569dbb0378
So the reduced version checks that p is a procedure
Also make the same change for #2%for-each.
cp0.ss, 4.ms
original commit: 5caa11c85bc74c0af25ac215d48b7f5f0c1d3e42
commonizatio pass and support for specifying default record
equal and hash procedures:
- more staid and consistent Mf-cross main target
Mf-cross
- cpletrec now replaces the incoming prelexes with new ones so
that it doesn't have to alter the flags on the incoming ones, since
the same expander output is passed through the compiler twice while
compiling a file with macro definitions or libraries. we were
getting away without this just by luck.
cpletrec.ss
- pure? and ivory? now return #t for a primref only if the prim is
declared to be a proc, since some non-proc prims are mutable, e.g.,
$active-threads and $collect-request-pending.
cp0.ss
- $error-handling-mode? and $eol-style? are now properly declared to
be procs rather than system state variables.
primdata.ss
- the new pass $check-prelex-flags verifies that prelex referenced,
multiply-referenced, and assigned flags are set when they
should be. (it doesn't, however, complain if a flag is set
when it need not be.) when the new system parameter
$enable-check-prelex-flags is set, $check-prelex-flags is
called after each major pass that produces Lsrc forms to verify
that the flags are set correctly in the output of the pass.
this parameter is unset by default but set when running the
mats.
cprep.ss, back.ss, compile.ss, primdata.ss,
mats/Mf-base
- removed the unnecessary set of prelex referenced flag from the
build-ref routines when we've just established that it is set.
syntax.ss, compile.ss
- equivalent-expansion? now prints differences to the current output
port to aid in debugging.
mat.ss
- the nanopass that patches calls to library globals into calls to
their local counterparts during whole-program optimization now
creates new prelexes and sets the prelex referenced, multiply
referenced, and assigned flags on the new prelexes rather than
destructively setting flags on the incoming prelexes. The
only known problems this fixes are (1) the multiply referenced
flag was not previously being set for cross-library calls when
it should have been, resulting in overly aggressive inlining
of library exports during whole-program optimization, and (2)
the referenced flag could sometimes be set for library exports
that aren't actually used in the final program, which could
prevent some unreachable code from being eliminated.
compile.ss
- added support for specifying default record-equal and
record-hash procedures.
primdata.ss, cmacros.ss, cpnanopass.ss, prims.ss, newhash.ss,
gc.c,
record.ms
- added missing call to relocate for subset-mode tc field, which
wasn't burning us because the only valid non-false value, the
symbol system, is in the static generation after the initial heap
compaction.
gc.c
- added a lambda-commonization pass that runs after the other
source optimizations, particularly inlining, and a new parameter
that controls how hard it works. the value of commonization-level
ranges from 0 through 9, with 0 disabling commonization and 9
maximizing it. The default value is 0 (disabled). At present,
for non-zero level n, the commonizer attempts to commonize
lambda expressions consisting of 2^(10-n) or more nodes.
commonization of one or more lambda expressions requires that
they have identical structure down to the leaf nodes for quote
expressions, references to unassigned variables, and primitives.
So that various downstream optimizations aren't disabled, there
are some additional restrictions, the most important of which
being that call-position expressions must be identical. The
commonizer works by abstracting the code into a helper that
takes the values of the differing leaf nodes as arguments.
the name of the helper is formed by concatenating the names of
the original procedures, separated by '&', and this is the name
that will show up in a stack trace. The source location will
be that of one of the original procedures. Profiling inhibits
commonization, because commonization requires profile source
locations to be identical.
cpcommonize.ss (new), compile.ss, interpret.ss, cprep.ss,
primdata.ss, s/Mf-base,
mats/Mf-base
- cpletrec now always produces a letrec rather than a let for
single immutable lambda bindings, even when not recursive, for
consistent expand/optimize output whether the commonizer is
run or not.
cpletrec.ss,
record.ms
- trans-make-ftype-pointer no longer generates a call to
$verify-ftype-address if the address expression is a call to
ftype-pointer-address.
ftype.ss
original commit: b6a3dcc814b64faacc9310fec4a4531fb3f18dcd