Commit Graph

809 Commits

Author SHA1 Message Date
Gustavo Massaccesi
c581cd24fe cptypes: uses define-specialize handlers for special functions like eq? or list
Rewrite the handler of record? and $sealed-record? to make it easier to
understand.

Also, delay the reductions of lambdas in a sequence of arguments. This helps
to reduce for example

  (map (lambda (x) (box? b)) (unbox b))
=>
  (map (lambda (x) #t) (unbox b))

original commit: 20e478b9280c779e260f5557c2eee74946313a44
2020-02-07 21:28:49 -03:00
Gustavo Massaccesi
eb29023ed9 cptypes: add bottom-fxmap
It is a fxmap that is is full of 'bottom.

original commit: c171fca3345de3190e8d915b0cdf4c11d5ec055c
2020-02-07 21:28:48 -03:00
Matthew Flatt
baf3bba9de constrain smaller trap-check code to avoid allocation
Having the trap check allocate is questionable, since it can be
triggered during a loop that otherwise performs no allocation. Also,
on platforms where at most 1 argument is passed in a register, then
sending two arguments to the event handler could potentially need
stack space that isn't there. So, constrain the smaller trap-check
code to cases where no stack space is needed and where no allocation
happens unless the wrong number of arguments are provided.

original commit: 260a7ef5bc0bf851d9848587b0a78bdb4aab59f8
2020-02-07 15:27:07 -07:00
Matthew Flatt
d4981dd8c3 less code for trap checks
When a proceudre starts with a trap check, move the check to the very
beginning, even before checking the argument count. That way, event
detection can turn into a compact jump to an event handler, instead of
inserting a general call to `$event` in the procedure body.

original commit: 06b12d505698a2378734689370bb9e0f8eda06b9
2020-02-07 10:56:15 -07:00
Matthew Flatt
40c407e1c2 add $record-type-field-count
This is a `$` function because it is defined only for record types
that have pointer-sized fields (i.e., the normal case).

original commit: 47213a7c8450aa52bd18e8f605c02b6c1081eadf
2020-01-31 11:17:04 -07:00
Matthew Flatt
fd1745c628 improve code generation for black hole as an immediate
original commit: 2e15df8a992d1c634f04bf4e162f40026a4f0840
2020-01-31 06:43:14 -07:00
Matthew Flatt
d13e5898c8 add enable-unsafe-variable-reference
original commit: 77a0ef249b6d419dcac7c8e1c28e710b30a7aa33
2020-01-30 17:46:30 -07:00
Matthew Flatt
27e21e6e7d code inspector: improvements to reloc reporting
Fix 'reloc to avoid a crash on static-generation code, and add
'reloc+offset to report an offset for each entry.

original commit: 4d4195044377f9c619cfb46056e365044069d5bc
2020-01-29 16:22:52 -07:00
Matthew Flatt
6962aceaf0 change * to Karatsuba
original commit: 8038a1745b8d176bc97c1dd69024da76626eb775
2020-01-26 10:51:38 -07:00
Matthew Flatt
5587285fac faster bitwise-arithmetic-shift on bignum shift
Immediately produce 0, -1, or out-of-memory, instead of looping
towards one of those.

original commit: dccc7e81b2f0909ce3c7871b849b0faa83eae576
2020-01-26 08:23:37 -07:00
Matthew Flatt
16acbf1ae6 fix a test
original commit: bd0eb64e1b13e731d8378ffa2fa2bc835795d4f8
2020-01-24 19:32:57 -07:00
Matthew Flatt
26ff90e8e6 more compact return points for function calls
In the general form of a function call, the return point embeds 4
words of information: offset to the start of the enclosing function,
frame size, live-veriable mask, and multiple-value return address. In
the common case, however, the multiple-value return address is either
the same as the return address or it is a `values-error` library
function, and the frame size and live-variable mask fit into a word
with bits to spare. This patch implements a more compact return point
for that common case, which shrinks the 4 words to 2 and also avoids a
relocation (= 1 more word).

Multiple-value returns are more complex with this change (i.e.,
require more code), since they must check whether the return point is
compact or not. But multiple-value returns are far less common than
function calls, so saving function-call space is a clear win.

Overall, this change tends to reduce code size by about 10% on x86_64.

original commit: 1f53b5eabef966db01086cb32e544bbf8deacfca
2020-01-24 19:19:32 -07:00
Matthew Flatt
83f8acbfef avoid symbolic link in repo checkout
original commit: 8eb10e62d0a58d945dec67cdc38a317a8a1d88e0
2020-01-23 17:58:15 -07:00
Matthew Flatt
754bae07e3 add enable-unsafe-application
original commit: 4c0750d292999dbc476b2b0a80cad3b8beaab660
2020-01-23 15:25:22 -07:00
Matthew Flatt
5a01e2c589 make a test portable
original commit: 86b384b5ed2e1cde6c61abe50db5b606e8841cfc
2020-01-20 15:00:56 -07:00
Matthew Flatt
94fee207a1 fix missing continuation call in mp-push-mvrs
original commit: d841744b26e4b4421fc4388b6943e558014e5e70
2020-01-20 09:26:46 -07:00
Matthew Flatt
345621fc91 cp0 repair for mutated library variables
This was supposed to be part of 628d57e1bd and fixes a test
failure introduced there.

original commit: bb186c9a29acf36a7c5954356690f6648cf9348c
2020-01-20 09:25:44 -07:00
Matthew Flatt
6020b944ef improve cross-library inlining
Allow a library-defined function to be inlined when the inlined
expressions refer to other library-defined functions. Since the
library function's body may already have inlined calls, don't allow
further inlining of calls within the inlined code.

This commit also adds `$app/no-inline`, which can be used to prevent
inlining of a function. For consumers other than Racket on Chez
Scheme, probably it would make sense to provide a nicer-looking
syntactic form that expands to use the internal `$app/no-inline`
function.

original commit: 628d57e1bd2e658aad4da97a3e85bda72c38f6ab
2020-01-19 08:35:02 -07:00
Matthew Flatt
45381612b2 fix popcount support to work on Windows
Avoid RDI, since it's preserved in the Windows ABI.

original commit: 68b2f597ec67ed8752998807bd0c9fc66667c752
2020-01-11 16:41:46 -07:00
Matthew Flatt
196a9800f9 implement fxbit-count using fxpopcount
original commit: 470b088840576872fd0a7ede7bf5342f44555af0
2020-01-11 11:21:42 -07:00
Matthew Flatt
540c58bbe8 use POPCNT instruction when available on x86_64
On x86_64, a POPCNT instruction is usually available, and it can speed
up `fxpopcount` operations by a factor of 2-3.

Since POPCNT isn't always available, code using `fxpopcount` is
compiled to a call to a generic implementation. The linker substitutes
a POPCNT instruction when it determines at runtime that POPCNT is
available.

Some measurements on a 2018 MacBook Pro (2.7 GHz Core i7) using the
program below:

 popcnt = this implementation, POPCNT discovered
 nocnt  = this implementation, POPCNT considered unavailable
 optcnt = compile to use POPCNT directly (no linker work)
 cpcnt  = compile to inlined generic (no linker work, no POPCNT)

Since the generic implementation is always a 64-bit popcount, it's not
as good as an inlined version for `fxpopcount32`, but otherwise the
link-edit approach to POPCNT works well:

            fxpopcount      fxpopcount32
 popcnt:       0.098s
 nocnt:        0.284s
 optcnt        0.109s  [slower means noise?]
 cpcnt:        0.279s         0.188s

 (optimize-level 3)
 (time
  (let loop ([v #f] [i 100000000])
    (if (fx= i 0)
        v
        (loop (fxpopcount i) (fx- i 1)))))

original commit: 5f090e509f8fe5edc777ed9f0463b20c2e571336
2020-01-11 11:04:48 -07:00
Gustavo Massaccesi
f88714210b fix signature in primdata
original commit: bcb7841a33645c55bdd839c3de80bce53ce78402
2020-01-09 10:24:03 -03:00
Matthew Flatt
81ea967aea add stencil vectors and fxpopcount
original commit: ec766fca869b5e0407c4f54230b72619af73b40b
2020-01-06 05:34:28 -07:00
Matthew Flatt
27883d2749 another repair to bitwise-arithmetic-shift/ash folding
Fuzz testing exposed a problem with the example

   (bitwise-arithmetic-shift-left -1 -1)

original commit: fc6f411ffc65f436d54979dfc0455ae771f3375d
2020-01-06 05:34:28 -07:00
Sam Tobin-Hochstadt
e039b19653 Repair bitwise-arithmetic-shift/ash on bad first arguments.
Fixes 0b0777912b1aa80.

original commit: d1a82e712c9c4645c1d790162827ad4e5d8c9f1d
2020-01-03 11:42:05 -05:00
Gustavo Massaccesi
7e647535b4 don't fold ash in cp0 when the shift is too big
fix also bitwise-arithmetic-shift/-right/-left.

  primdata.ss, cp0.ss, 5_3.ms

original commit: 0b0777912b1aa80cff108dc1d34917bb80875e0b
2020-01-02 13:03:19 -03:00
Gustavo Massaccesi
8796743cbd cp0: reduce (if <boolean> #t #f)
It may help to reduce expressions like
  (and <boolean> <obviously-true>)

original commit: bf6d3134a306f0cf12768f344d647ceaf820e9fa
2020-01-02 13:03:19 -03:00
Matthew Flatt
2efa342323 speed up objlist
Instead of using `%` to compute the index into an oblist, use a power
of 2 for the oblist length and bit masking to compute an index. (Maybe
the old hashing function was bad; the current hashing function should
produce good hash-code variation at the level of bits.) Also, make the
oblist array a little sparser to reduce bucket chaining.

original commit: fb87fcb8e47902b80654789d059a25bd4a7a8def
2020-01-01 15:08:52 -07:00
Matthew Flatt
bbbda808e5 propagate $AR and $ARFLAGS to submodule builds
original commit: 652aed04f243ce4a7f5c71f18d1754952380a479
2019-12-31 07:58:12 -07:00
Matthew Flatt
69444da5a0 clear temporary bignum registers
After a bignum computation using temporary thread registers W, U, or V
is complete, clear ther register. (The X and Y registers hold only
small bignums, so clearing them doesn't matter in the same way.)

original commit: a9e11fcf9e86aee5d149764476e1fabfeee12f84
2019-12-30 07:03:19 -07:00
Matthew Flatt
7675d58fb2 avoid --exclude with git-describe
The `--exclude` flag is not supported by older-but-still-used version
of Git.

original commit: a5a594f7c3f71d17d2e55ed50463b92515de02dc
2019-12-27 04:58:56 -06:00
Matthew Flatt
6352009def sometimes-faster fixnum / via quotient
Try `fxquotient` with a `fx*` check to implement `/` on fixnums.
That's fast enough to be much faster when it works, and only slows
down a more general `/` a little.

original commit: e91430be9b71f4913965db688a15f6d7206b38f3
2019-12-25 08:04:09 -06:00
Matthew Flatt
29abe3e317 sync expected-error patch file
original commit: 77854d418b6d05bd0e0b913f421f0e475b06ec30
2019-12-18 12:29:57 -07:00
Matthew Flatt
ecaec06f64 add string-append-immutable
original commit: 353ee30534757fb37bfe231e9be21482d9f858ce
2019-12-17 19:29:10 -07:00
Matthew Flatt
c8ea435c85 make strings within symbols always immutable
original commit: 7859d16dac7bae6ab836e2200003583dc572deba
2019-12-16 17:11:49 -07:00
Matthew Flatt
f858bec12a skip <xlocale.h> on Linux
It's not available with musl, either, musl intentionally
doesn't provide a preprocessor test, and we're avoiding
(for now) `configure`-time tests in the style of autoconf.

original commit: a9bfb72027fc83ed6bb690d033bc6fed0629dba7
2019-12-11 14:41:07 -07:00
Matthew Flatt
01a40286c2 propagate CC and CPPFLAGS to ZLib and LZ4 builds
original commit: cbb7c5f21a879ee90293c3abf99d344c4fc42b7f
2019-12-09 08:34:50 -07:00
Gustavo Massaccesi
b8508e5170 Alternative version of enable-type-recovery
Don't run cptypes, when cp0 is disabled, for example with
(run-cp0 (lamba (cp0 x) x)

This is easier to understand because run-cp0 is a single point to control
all the cp reductions. The reductions in cptypes can be independently disable
using enable-type-recovery.

original commit: b23645e669fbf02806a261a2d87160fdbe06db93
2019-12-08 11:41:15 -03:00
Gustavo Massaccesi
30beb65af3 add uninterned-symbols to cptypes
original commit: e85c19895bd47126a434364ae8007b6c40a87393
2019-12-07 16:59:23 -03:00
Gustavo Massaccesi
19819ef4bf don't copy propagate uninterned symbols in cp0 and cptypes
original commit: 9758171949520e9f97e54f1140ae14083b168a8e
2019-12-07 16:44:29 -03:00
Matthew Flatt
50e529364d fasl: move uptr continue bit from low to high
Use the high bit of a byte to continue instead of the low bit.
That way, ASCII strings look like themselves in uncompressed fasl
form.

original commit: 89a8d24cc051123a7b2b6818c5c4aef144d48797
2019-12-06 16:43:26 -07:00
Matthew Flatt
4998cda524 fix version in Mf-install
original commit: 999a4fe636fde497a7b203132dee9d496bf64013
2019-12-05 20:11:22 -07:00
Matthew Flatt
71072b7221 cpvalid: obey enable-error-source-expression
original commit: 45af7f62cfe9b0f77bb2c58e49c7543b9603458b
2019-12-05 16:41:47 -07:00
Matthew Flatt
4b61c87227 cp0: more reliably set accessor/mutator/predicate names
original commit: 17414888f010ea7407cd3663bec5f19e1e3e20d8
2019-12-05 09:16:03 -07:00
Matthew Flatt
de2dedcdd7 Add uninterned symbols
Uninterned symbols are slightly more expensive to allocate than 0- or
1-argument calls to `gensym`, but they're much cheaper to hash (and
print). They're also more consistently distinct when unfasled, and the
fasled form is determinsitic.

original commit: 3167083008031b1f880e76a6f573563c7d9c888c
2019-12-04 12:43:35 -07:00
Matthew Flatt
7e36c21d81 document enable-type-recovery
original commit: 30033287ad504058bc6810b1ef4ff5ecbe927dac
2019-11-26 07:15:16 -07:00
Matthew Flatt
ee54863999 enable hyperlinks in CSUG
original commit: 0060fea5806b3238be207abd9843ee5f0a7d9039
2019-11-26 07:09:52 -07:00
Matthew Flatt
232b230e65 add enable-error-source-expression
original commit: 02f383510653bb16c65fc812eb0c619bcb0347b5
2019-11-26 06:31:48 -07:00
Matthew Flatt
ddf4322ef2 ignore result of mktime
The result of `mktime` is -1 for an error. The result is also -1 if
the time is 1 second before the epoch. That's not useful, so ignore
it.

original commit: aa8ca31cef223128fd8ed1abdc76beb31a0e077a
2019-11-23 19:54:30 -05:00
Gustavo Massaccesi
6789fd84c1 Use system flag of primitives to avoid check in primvars.ms
With this flag the primitive is not tested in primvars.ms but other
parts of the compiler can use the signature/flags.

Also, add a signature to every system boolean primitive.

  primvars.ms, primdata.ss

original commit: ee023c673bda6557bc223de7f8b0e732600619bc
2019-11-15 17:03:00 -03:00