Commit Graph

3953 Commits

Author SHA1 Message Date
Matthew Flatt
daba4f518b places: repair detection of mutable prefabs 2018-10-04 15:37:06 -06:00
Matthew Flatt
c2b5e4404a rumble: fix hash-set error message 2018-10-04 15:36:51 -06:00
Matthew Flatt
adfe862a0b cs: make make expander-demo work in a fresh checkout 2018-10-03 08:58:44 -06:00
Matthew Flatt
8a5de6c27f reader: remove some broken tests 2018-10-03 08:58:44 -06:00
Paulo Matos
5bbbe44a7b Fix ubsan runtime error due to large shift 2018-10-02 14:14:04 -06:00
Paulo Matos
15523f68ec Fix sizeof argument 2018-10-01 10:56:36 -05:00
Paulo Matos
5834a4b938 Remove unused code
Fixes #2290.
2018-10-01 10:56:12 -05:00
Paulo Matos
bc3777792d Only copy argv if not NULL
Fixes #2283.
2018-09-24 05:28:47 -06:00
Matthew Flatt
e83ca7a9e5 native-libs: merge Pango repair for emoji iteration 2018-09-22 20:37:34 -06:00
Matthew Flatt
27bb075113 native-libs: restore a Cairo patch
When upgrading native-library versions, a still-relevant
patch got lost. The patch corrects a problem with empty
glyphs getting treated as missing glyphs.

Closes racket/pict#42
2018-09-22 20:28:13 -06:00
Matthew Flatt
45af149fc0 dynamic-place: fix use of expanders module-predefined?
Closes #2278
2018-09-22 18:34:43 -06:00
Matthew Flatt
d06f6e7c4e cs: offer compiler-pass statistics
When `PLT_LINKLET_TIMES` is set, enable pass timing and report
a simple summary along with other times.
2018-09-22 18:34:43 -06:00
Paulo Matos
48302284a8 Avoid shift by negative number by turning condition around
Avoid undefined behaviour in condition which could shift by negative i. By checking first if `i >= 0` we avoid that case.
2018-09-22 14:19:10 -06:00
Paulo Matos
49d31414b7 Fix condition to avoid undef behaviour
Coverity scan uncovered an issue where by if `p == 31`, the following shift `1 << (p + 1)` will cause undefined behaviour.
2018-09-21 09:02:25 -06:00
Ryan Culpepper
0ceb67ebc6 openssl: guard default cert location setup with libcrypto check
Commit dc8a2ca6 removed the check, which caused problems
when libcrypto.so is not found.
2018-09-17 15:51:58 +02:00
Ben Greenman
710cbd25bf stream*: allow 1 argument 2018-09-16 21:21:06 -04:00
Ryan Culpepper
2670a932f8 fix bugs caught by optimizer etc warnings 2018-09-15 21:05:04 +02:00
Alexis King
c0788127ae Make cond track disappeared-uses for => and else 2018-09-13 13:15:34 -05:00
Matthew Flatt
d5aa191fb2 custom-hash: fix ephemeron race
The pattern

  (ephemeron-value
   (hash-ref! intern key
     (lambda ()
       (make-ephemeron key (wrap key)))))

is wrong, because a GC might happen between the time that the
epehemeron is found in the table (or the time that the key was just
added to the table) and the time that `ephemeron-value` is called to
extract the value. If the key is not otherwise accessible, the value
may no longer be in the ephemeron.
2018-09-13 11:11:27 -06:00
Matthew Flatt
9772c05040 cs: fix more problems with GC in an arbitrary Scheme thread 2018-09-13 10:48:26 -06:00
Matthew Flatt
4a763c72d0 cs: repairs for Windows build 2018-09-13 10:48:26 -06:00
Matthew Flatt
2a053caa1a makefile: always make automatic checkout of Chez Scheme
If `make cs` is run without specifying a SCHEME_SRC, then make sure
that `configure` and `make` are re-run in the Chez Scheme checkout,
in case it was updated.
2018-09-13 10:48:26 -06:00
Matthew Flatt
287157cc6d cs: _stdcall for Windows -> __stdcall for Windows x86 2018-09-13 10:48:26 -06:00
Matthew Flatt
2e8e479a52 thread & io: makefile repairs to work with nmake 2018-09-13 10:48:26 -06:00
shhyou
40b8ae7a33 Coerce the arg in contract-random-generate/choose 2018-09-13 10:48:43 -05:00
Matthew Flatt
efd601cb51 cs: avoid thread misuse during GC
A collection can only invoke certain callabcks (e.g., for DrRacket's
GC icon) when the collection is performed in the main thread. Also,
delay posting GC logging events to receivers that cannot work at
interrupt time.
2018-09-13 06:05:58 -06:00
Alexis King
6b56156d55 Revert "Allow local-expand to opt-out of implicit extension of the stop list"
This reverts commit 41fd4f3a5e.

The problems this change was intended to solve can be solved in other
ways, without loosening guarantees about expansion order. See the
discussion in #2154 for more details.

closes #2154
2018-09-12 15:06:33 -05:00
Ryan Culpepper
5be4109495 openssl: change dummy path name to avoid spaces 2018-09-12 15:32:03 +02:00
Ryan Culpepper
fc19d75b40 openssl: add workaround for natipkg openssl lib cert locations
Reference: https://www.happyassassin.net/2015/01/12/a-note-about-ssltls-trusted-certificate-stores-and-platforms/
2018-09-12 15:32:03 +02:00
Ryan Culpepper
dc8a2ca6ec openssl: log error if no existing cert locations
This may help with situations like #1919 and #2184.
2018-09-12 15:32:03 +02:00
Matthew Flatt
b2e4d51b1b raco setup: fix problem with processes-based build
The procsses-based build was technically broken with the addition of a
"prefetch" thread (some time back) to improve parallelism, because the
`write`-based implementation of messages did not protect again
interleaving by different threads. The problem turns out to be easier
to expose when running with RacketCS.
2018-09-12 06:17:47 -06:00
Matthew Flatt
fd730a6772 raco setup: add --places and --processes flags
Provide access to subprocess-based parallel builds even when places
are available.
2018-09-11 19:08:59 -06:00
shhyou
dabbfed09f Randomly shuffle contracts in contract-exercise 2018-09-11 16:15:24 -05:00
Matthew Flatt
9cf9be60b0 io: fix retention of blocked log receiver
Don't GC a log receiver that is blocked on a logger that
might receiver relevant events.
2018-09-11 12:15:07 -06:00
Matthew Flatt
862c05d64a thread & cs: fix place bugs 2018-09-11 09:55:11 -06:00
Matthew Flatt
30fb62e438 cs: add sanity check for proper callbacks during blocking callouts 2018-09-11 09:55:11 -06:00
Matthew Flatt
2e7d608fb3 native-libs: update openssl build, especially for natipkg
Record a recoganizable dummy path as the default location for
certificates.
2018-09-11 08:39:52 -06:00
Matthew Flatt
0e2ad7d596 raco pkg: change --scope-dir search-path handling
Formerly, `--scope-dir` would include only the specified directory in
the search path for already installed packages, etc., which means that
it would only work right as a kind of installation scope that is a
step beyond "installation" on the "user"-to-"installation" spectrum.
The `'pkgs-search-dirs` confiugration entry, meanwhile, provides more
control over search ordering in installation scope. Make `--scope-dir`
work more consistently with that search-path configration.

This change also makes "instllation"-scope operations use the search
path more consistently, since some actions used to use the whole
search list while others pruned any prefix before the main
installation directory in the search list.
2018-09-10 06:14:34 -06:00
Matthew Flatt
292dac4e51 cify: repair for big-endian platforms
Relevant to #2018
2018-09-09 14:01:09 -06:00
Matthew Flatt
138e6c11c0 ffi/objc: add with-blocking-tell
Add a way to declare an Objective-C method call as blocking in the
sense of the `#:blocking?` argument to `_cprocedure`.

Usingf `with-blocking-tell` should allow the Cocoa backend for
`racket/gui` to wait for events in the main place without blocking
other places.
2018-09-09 11:56:26 -06:00
Matthew Flatt
9776e4cd8e cs: fully enable places
Fix various problems with the implementation of places, and let
`processor-count` return the actual number of processors. A parallel
build via `raco setup` seems to work but not scale well.
2018-09-09 11:33:33 -06:00
Matthew Flatt
bf9a5f2730 move processor-count core to rktio
Also, repair various problems with places in RacketCS, but make
`(processor-count)` still return 1 for now, since there are still
problems.
2018-09-08 18:59:10 -06:00
Matthew Flatt
3b0336a30a rktio: make fd transfer across rktio_ts explicit
Instead of defining `rktio_fd_t` to be independent of a `rktio_t`,
which isnt quite true, introduce `rktio_fd_detach` and
`rktio_fd_attach` functions to make a transfer explicit, such as when
a file descriptor goes through a place channel.

This adjustment avoids a corner case in cleaning up a file descriptor
from an abandoned channel, where the finalizer might run in a Chez
Scheme thread that is not associated with any place.
2018-09-08 15:57:34 -06:00
Matthew Flatt
ef72554fe4 cs & io: fix potential file-descriptor leak
If a file descriptor is in a place channel message that is never
received and the channel becomes inaccessible, finalize the place
channel.
2018-09-08 13:31:11 -06:00
Matthew Flatt
cd9071cb9b bytecode optimizer: fix inlining bug
When a single-use function is inlined late enough in the optimization
process, and when the body has the only use of some variable computed
by an expression that can be move in place of the use in the inlined
function (but not in the non-inlined function), then it's a problem if
the function binding isn't pruned away early enough. Make sure the
binding to the function is marked as unused after the function is
inlined.

This bug was exposed by a recent change to the "dssl2" package.
2018-09-05 20:33:05 -06:00
Matthew Flatt
66b624e8ca byte compiler: unsafe-make-place-local should not fold 2018-09-05 16:11:12 -06:00
Matthew Flatt
c50d2753c0 cs, thread & io: finish implementing places
Implement place channels and messages, and change `place-enabled?` to
claim that places are enabled, but `processor-count` still reports 1.

The implementation of place channels has an interesting use of
ephemerons --- that is, a use that isn't just solving a key-in-value
problem. Using epehemerons solves the problem of forgetting a place
channel and any thread blocked on the read end when there are no
producers on the write end. Along similar lines, when only the write
end is retained (i.e., no readers), the channel data is forgotten and
writes become a no-op. The read end holds a "read key" and references
the channel data through an ephemeron keyed by a "write key"; the
write end similarly holds a "write key" and uses an ephemeron keyed by
the "read key". This use of an epehemeron implements a reachability
"and": retain the place-channel data only if the read end *and* the
write end are both reachable. (Minor point: a read end also holds onto
the "write key" anytime the channel already has data.)
2018-09-05 16:02:19 -06:00
Matthew Flatt
aad98e563d avoid a compiler warning 2018-09-04 14:53:22 -06:00
Matthew Flatt
8ff8b36bdf racket/place: remove place-sleep
The `place-sleep` function was undocumented, should not have existed,
and has no uses that I find.
2018-09-04 14:53:22 -06:00
Matthew Flatt
fa3c5abd00 syntax-parametereize: fix set! with rename transformers
Relevant to bootstrapworld/curr#423
2018-09-04 14:53:22 -06:00
Matthew Flatt
62a5086b2a thread, io, & cs: fill in stdio setup for places 2018-09-04 14:53:22 -06:00
Robby Findler
988e0d441b add another special case to and/c to detect a situation that's really just integer-in 2018-09-03 20:30:07 -05:00
Matthew Flatt
416447e842 thread, io, & cs: place startup, wait, break, & kill
Fill in more of place creation and termination, which exposed
additional places that the thread layer needs place-specific
variables.
2018-09-03 16:47:00 -06:00
Matthew Flatt
35af40d850 cs & thread: move places API to the thread layer
The Rumble layer provides a primitive `fork-place` operation and
`start-place` hook to tie in place initialization from other layers
(especially "io"), but the rest can live in the "thread" layer,
especially to handle place-channel synchronization.
2018-09-03 09:12:52 -06:00
Matthew Flatt
f03d5c0076 raco exe: add ++lang support
When a stand-alone executable created by `raco exe` needs to load
modules that start with a `#lang` line, there have been various
obstacles to adding the right run-time support via `++lib`. The
`++lang` flag addresses those problems and makes it easy to indicate
that enough should be embedded to support loading modules with a
specified language.

There are problems in the way that various handlers interact for the
"lang/reader.rkt" versus `(submod "." reader)` search path that
converts a language name to a reader. To accomodate the search in a
standalone executable (that does not provide access to collections in
general), the module name resolver must refrain from raising an
exception for a non-existent submodule path that refers to a
non-existent collection.
2018-09-02 07:53:47 -06:00
Matthew Flatt
3127bc239b raco exe: fix declare-preserve-for-embedding submodule 2018-09-02 07:25:16 -06:00
Matthew Flatt
8c5eebc513 cs: fix races with places in the Rumble layer 2018-09-02 07:25:16 -06:00
shhyou
ef5467a9d4 Fix dom exercisers in randomly generated function 2018-08-30 13:46:13 -05:00
Matthew Flatt
7faf874000 cs: first cut at support for places
There's no place-channel communication yet --- just enough of a
conversion to thread-load storage to make places possible.

In contrast to traditional Racket, where the expander linklet is
instantiated once per place, the flattened expander linklet is
instantiated only once in RacketCS (because it's inlined into a Chez
Scheme library). The expander therefore needs to keep per-place state
separate, and the same for the thread, io, and regexp laters.

In the expander/thread/io/regexp source, place-local state is put in
an unsafe place-local cell. For traditional Racket, a place-local cell
is just a box. For RacketCS, the thread through expander layers are
compiled in a way that maps each cell to a fixed index in a vector
that is stored in a virtual register, so the value is roughly two
pointer indirections away (thread context -> virtual register array ->
place-local vector). Multiple Chez Scheme threads in a place, such as
threads to run futures, share the same place-local vector.

Although `place-enabled?` reports #f, `dynamic-place` from `'#%place`
can create a place as a Chez Scheme thread and load a module there.
2018-08-29 09:52:29 -06:00
shhyou
1ad4d82691 Have arg-dep-ctcs return the contract directly 2018-08-28 15:42:31 -05:00
Matthew Flatt
37c9169874 expander: fix body scope for letrec-syntax
An extra scope is needed to separate the bindings of a `letrec` from
the `letrec` body, in case a macro moves right-hand-side expressions
to the body.

Michael Ballantyne and William Hatch reported this problem and its
solution in December 2016, but I forgot to add the repair.

Relevant to #2237
2018-08-28 14:08:36 -06:00
Matthew Flatt
1d65a89f53 cs: faster continuation-mark-set-first
Avoid allocating mark-chain elements, and change search function so
that it's more recognizable as a loop.
2018-08-28 14:08:36 -06:00
bruno cuconato
f9e6a8b61b add stream-take + docs (#2181) 2018-08-27 23:19:18 -04:00
shhyou
3825a133ad Recognize cons? and empty? in contract coercion 2018-08-27 15:12:28 -05:00
Matthew Flatt
f5eb600dd7 unbreak cify build 2018-08-25 08:05:34 -06:00
Matthew Flatt
f95723e70e cs: speed up calls to applicable structs 2018-08-25 06:58:15 -06:00
Matthew Flatt
aa75a2fd32 io, read: use fixnum operators 2018-08-25 06:58:15 -06:00
Matthew Flatt
d0eb8f6c53 add unsafe-char=?, etc. 2018-08-25 06:58:14 -06:00
Matthew Flatt
d54c60ae3a cs: enable fxvector field representation 2018-08-25 06:58:14 -06:00
Robby Findler
a1b9fd0965 generalize any/c's random generator to generate some of the built-in structured values 2018-08-24 15:55:39 -05:00
Robby Findler
176f09a7ad add generator for symbols 2018-08-24 15:46:11 -05:00
Matthew Flatt
1d3e3d5a08 bytecode compiler: fix set! repair
Fix problem with generated viable in 53a08c065e.
2018-08-22 09:43:22 -06:00
Matthew Flatt
53a08c065e bytecode compiler: fix order of set! undefined checking
Evaluate the right-hand side of the assignment first.
2018-08-22 07:53:07 -06:00
Matthew Flatt
974988fe3c bytecode compiler: don't discard another set! that should error
The repair in 7176fc4253 did not make the no-discard decision stick
well enough for some cases. Robby found this bug using the Redex model
and random testing, too.
2018-08-21 20:50:58 -06:00
Matthew Flatt
16e496b0c5 expander: avoid parameters for dynamic-extent indicators
Using a parameter for the current expansion context means that if a
macro spawns a thread, the thread thinks that it's in an expansion
context. Switching to a raw continuation mark avoids that problem.

Along the way, bring Racket and RacketCS more in line by making both
have an internal notion of "root" prompt tag that can be used to get
all continuation marks independent of any prompts. That's not structly
necessary, since a continuation mark could be combined with a distinct
tag to make the mark always accessible, but it's simpler and more
lightweight to use a root prompt tag.
2018-08-21 19:37:18 -06:00
Matthew Flatt
eed18fac93 schemify: improve use-before-definition analysis
This improvement removes only a few places where a variable use is
considered possibly too early in the RacketCS implementation, but
the improvement is significant for uses of `input-port?` in "io".
2018-08-21 15:46:22 -06:00
Matthew Flatt
473ec2762e io: streamline read-char and read-byte 2018-08-21 15:46:22 -06:00
Alexis King
2a667dc9a8 Fix reader error message when encountering illegal graph notation
Also, document explicitly that graph notation is not allowed at all in
read-syntax mode.
2018-08-21 15:02:09 -05:00
Matthew Flatt
34231aca7e cs: repairs for chaperoned events
The recent `sync` shortcut was wrong for chaperoned events.
2018-08-20 18:08:11 -06:00
Matthew Flatt
ae7a64b4ea cs: fix weak hash table weakness after iteration 2018-08-20 18:08:11 -06:00
Matthew Flatt
2d09e121c5 cs: fix dependency in makefile 2018-08-19 20:41:25 -06:00
Matthew Flatt
7176fc4253 bytecode compiler: don't discard set! that should error
Robby found this bug using the Redex model and random testing.
2018-08-19 17:17:31 -06:00
Matthew Flatt
4128189499 generalize some function arities
Allow a single argument to comparison functions like `<`, and
support the same arities as the generic version for fixnum and
flonum operations like `fx+` or `fl+`.
2018-08-19 16:56:50 -06:00
Matthew Flatt
008102decc cs (mostly): fix hash table problems
RacketCS weak `equal?`-based hash tables didn't retain flonums, and
hashing of hash tables was not properly insensitive to the order of
keys.

Racket, meanwhile, didn't limit work consistently for different kinds
of hash tables, and it didn't keep a counter value odd as intended
(but the counter never gets large enough to appear to be a mapped
pointer, anyway).
2018-08-19 05:36:26 -06:00
Matthew Flatt
27693843ea fix break checking on continuation applciation
Racket did not check for a break when escaping from a break-disabled
context to a break-enabled context. RacketCS didn't check in other
cases, either. Fix those various cases.
2018-08-18 17:07:38 -06:00
Matthew Flatt
40b5fffb80 cs: avoid unnecessary work in exception handler 2018-08-18 17:07:37 -06:00
Matthew Flatt
ae4b101ec5 cs: add sync shortcuts for simple cases 2018-08-18 17:07:37 -06:00
Matthew Flatt
e15eadd106 unbreak unixstyle-install
Commit 1afcbee381 effctively dropped a conditional case that was
marked as "shouldn't happen" --- but it does happen and makes sense.
Adjust the replacement `delete-directory/files` call to accomodate the
case.

Relevant to #2198 and #2236
2018-08-18 11:22:48 -06:00
Matthew Flatt
a01feffa83 expander: improve error reporting for definitions without expression
Closes #2183
2018-08-18 11:22:48 -06:00
Matthew Flatt
dde342a198 compiler: fix a copy-propagation bug in the letrec checker
The bug could cause reachable code to be replaced with `(void)`.

Closes #2232
2018-08-17 09:54:42 -06:00
Matthew Flatt
1cf6ab7102 places and GC: avoid race in out-of-memory handling
Make the out-of-memory handler thread-local, so that places
don't interfere with each other when setting the handler.
2018-08-16 20:56:08 -06:00
Matthew Flatt
570aa5737d cs: fix missing stack trace frames 2018-08-16 20:56:08 -06:00
Matthew Flatt
9704cc4731 add syntax-binding-set functions
The `syntax-binding-set` functions enable explicit construction of
lexical information for a syntax objects.
2018-08-15 10:34:33 -06:00
Matthew Flatt
9658c723db more consistent expander/linklet performance-logging output 2018-08-15 07:41:48 -06:00
Matthew Flatt
facba8a6ab unbreak cify on "startup.inc"
Commit 7cbeebbb89 broke the input to cify, and eb73837baf uncovered a
different problem.
2018-08-14 20:29:32 -06:00
Matthew Flatt
a25efeb8a9 thread & io: performance improvement
Part of this change restores a `++direct` that was lost in 98ae91e0ba
for "racket/src/thread" to make the atomicity state a virtual
register. Also make `display` on a byte string more directly call
`write-bytes`. That change restores a 5-10% speed improvement for
`racketcs -cl racket/base`.
2018-08-14 19:35:00 -06:00
Matthew Flatt
a58d115bf2 fix problem with parameter impersonator
Closes #2228
2018-08-14 12:27:33 -07:00
Matthew Flatt
bbde12991c cs: faster continuation trace
Reduce the cost of getting a source backtrace for a continuation mark
set (especially as recorded in an exception).
2018-08-14 06:59:51 -07:00
Matthew Flatt
eb73837baf expander: enable performance measurements permanently
Change the expander-performance macro so that it's a very low cost if
not enabled on startup. An extra JIT specialization reduces the cost
further, since the enabled state is known by JIT time.
2018-08-12 11:05:20 -06:00
Matthew Flatt
7cbeebbb89 linklet flattener: repair to name simplifier
The linklet flattener's name-simplification pass (intended to avoid
gratuitious changes in "startup.inc") didn't recognize all binding
forms.
2018-08-12 08:50:35 -06:00
Matthew Flatt
4a7c4d184c optimizer: don't drop application when argument count is wrong
Guard some ad hoc optimizations with an arity check in the cases of 1
or 2 arguments.

Closes #2222
2018-08-11 17:28:11 -06:00
Matthew Flatt
305d02f46a OpenBSD: constrain W^X-by-signal to x86_64
Closes #2214
2018-08-11 16:40:09 -06:00
Matthew Flatt
89583a4d03 fix inexact->exact on subnormal single-flonums and extflonums
Closes #2223
2018-08-11 16:23:31 -06:00
Matthew Flatt
cf396064c3 places and GC: subtarct terminated place's memory use
When a child place terminates, the parent's count of the child's
memory use needs to be updated. Until this repair, the
`current-memory-use` function has been reporting an incorrectly large
number after a place terminates.
2018-08-11 09:50:49 -06:00
Ryan Culpepper
15186ff41c syntax/parse: fix struct match patterns with wrong number of subpatterns 2018-08-10 18:04:56 +02:00
Ryan Culpepper
31519f827a syntax/parse: fix fixup of and pattern with head subpatterns 2018-08-10 18:04:56 +02:00
Matthew Flatt
0d1f4e3c63 unbreak no-JIT build 2018-08-10 09:59:15 -06:00
Matthew Flatt
c05b9409d5 procedure-arity: fix bug in non-JIT mode
The arity calculation for a `case-lambda` as a `prop:procedure`
argument did not drop the self argument as it should.
2018-08-10 09:11:17 -06:00
Matthew Flatt
696e9143a6 expander: declare readtable structure as #:authentic 2018-08-10 09:10:55 -06:00
Matthew Flatt
b533a13d20 JIT code accounting: add count of procedures
Extends ac601a095b.
2018-08-10 05:06:36 -06:00
Matthew Flatt
59d505c157 JIT: tweak unsafe references
Use a constant offset directly instead of loading into a register
for unsafe vector, struct, etc., access.
2018-08-10 05:06:36 -06:00
Matthew Flatt
7efff33831 JIT: tweak to avoid register reload on some branches 2018-08-10 05:06:36 -06:00
Matthew Flatt
fac3c6fbc6 cify repairs
Fix liveness for "simple" arguments to inlined functions. Fix
handling of non-authrntic structure access and mutation to
allow the possibility of a GC.
2018-08-10 05:06:36 -06:00
Ryan Culpepper
3dd402937b syntax/parse: fix var:literal pattern, closes #2225 2018-08-10 00:09:07 +02:00
Alexis King
d1b8ecb3e0 Make curry properly support functions with keyword arguments
Also, while we're at it, make the functions produced by curry cooperate
better with other parts of Racket. Namely, make the information reported
by procedure-arity and procedure-keywords accurate, and give procedures
more useful dynamic names.
2018-08-09 15:35:49 -05:00
Matthew Flatt
ecbd6f1578 add procedure-arity-mask and procedure-reduce-arity-mask
The mask encoding of an arity is often easier to test and manipulate,
and masked-based functions are sometimes faster than functions that
used the old arity representation (while always being at least as
fast).

Attempting to assign an arity like `(expt 2 100)` to `(lambda x x)`
won't work anymore; it will raise an out-of-memory exception, because
the arity is represented internally as a mask. The arities that cannot
be represented aren't sensible arities, anyway.
2018-08-09 10:11:41 -06:00
Matthew Flatt
36204b00ca improve procedure-{reduce-arity,rename} performance
The main performance improvement is in calling a function returned by
`procedure-{reduce-arity,rename}` when the arity is not a single
integer. Calls to functions with > 29 arguments can be worse, but
that seems like a much rarer case.
2018-08-09 10:11:41 -06:00
Matthew Flatt
d3a8834f75 cs: improve procedure-{reduce-arity,rename} 2018-08-09 10:11:41 -06:00
Matthew Flatt
ac601a095b add PLT_EAGER_JIT to force JIT on linklet instantiation
Forcing JIT code generation through an environment variable is useful
to get a sense of how much machine code is generated for a program.
Setting `PLT_LINKLET_TIMES` causes the overall memory used by
JIT-generated code (including adminstrative overhead) to be printed on
exit.
2018-08-09 10:11:41 -06:00
Matthew Flatt
3e9196ab5c cs: convert Rumble though expander to boot file
Loading as a boot file saves time later on major GCs.
2018-08-09 10:11:41 -06:00
Matthew Flatt
f2a7405dda syntax/moddep: DAG repair and #:show argument 2018-08-09 10:11:40 -06:00
Ryan Culpepper
088f72c8c5 syntax/parse: parse syntax-class patterns just once; closes #2164
In pass 1, syntax class defns (without #:attributes decl) need to parse
patterns to determine exported attributes. But to allow forward refs,
stxclass references are not resolved until pass 2.

Previously, this was done by just reparsing patterns in pass 2. But that
means pattern expanders get expanded twice, and their expansions might
not agree (eg generate-temporaries). So instead, parse in pass 1, insert
"fixup" patterns to delay stxclass resolution, and resolve fixups in pass 2.
Complication: a fixup pattern is assumed S, but can change to H in pass 2.
2018-08-09 14:37:33 +02:00
Ryan Culpepper
dbfb1e2fe8 syntax/parse: add datum-to-expression helper 2018-08-09 14:37:33 +02:00
Ryan Culpepper
d950049c5a syntax/parse: trim internal provides 2018-08-09 14:37:33 +02:00
Ryan Culpepper
8a4bab5c3e minimatch: add match-lambda 2018-08-09 14:37:33 +02:00
Ryan Culpepper
34e7c8f556 syntax/parse: only collect attrs with interned names 2018-08-09 14:37:33 +02:00
shhyou
0c8c643989 Fix default fallback for contract-struct-generate
The actual problem is that build-chaperone-contract-property
exported to the user defaults #:exercise and #:generate
to false. This commit changes the default fallback value
in the case where #:generate is not a procedure instead
of changing build-chaperone-contract-property directly
to stay consistent with the how contract-struct-exercise
currently does it.
2018-08-08 12:51:14 -05:00
shhyou
aeab2420fa Fix default contract generation and exercise proc
The default values updated in commit ffc5720b5 do
not work for very subtle reasons. In build-contract
in racket/contract/private/prop, the default values
should not accept an extra ctc argument since ctc
is already handled by make-flat-contract. The
default gen procedure should also be (λ (fuel) #f)
instead of (λ (ctc) (λ () #f)) since the latter
would generate false when the generation should
have failed. In build-property, the default procedure
(λ (ctc) (λ (fuel) #f)) is correct and should not
be changed to (λ (ctc) (λ () #f)).
2018-08-08 12:51:14 -05:00
shhyou
43b0cd4a7e Initialize fail-escape in contract-exercise
Some exercise procedure might invoke
contract-random-generate/choose, therefore
fail-escape needs to be initialized.
2018-08-07 10:06:28 -05:00
Matthew Flatt
5ba910d143 read-bytes!: avoid integer overflow in read size
Closes #2211
2018-08-06 20:43:04 -06:00
shuhung
b4e44e71a9 Export contract-random-generate-env? 2018-08-06 12:55:38 -05:00
Ben Greenman
2ef8d60cc6
improve hash-ref error message for non-thunk failure procedure (#2204)
Improve the `hash-ref` error message when the failure result does not
accept zero arguments. (This only changes what the error messages says.)

Example:
```(hash-ref #hash() 'a add1)```

Old message:
```
; add1: arity mismatch;
;  the expected number of arguments does not match the given number
;   expected: 1
;   given: 0
```

New message:
```
; hash-ref: contract violation
;   expected: (-> any)
;   given: #<procedure:add1>
;   argument position: 3rd
```
2018-08-05 23:53:49 -04:00
Philip McGrath
3e6846a8d9 typo: "unintialized" -> "uninitialized" (#2209) 2018-08-05 23:53:21 -04:00
Matthias Felleisen
8deaa4cf91
fixing bad error message for assf
The old error message requested a function of 2 arguments while the quasi-contract demands one of 1 argument.
2018-08-05 17:48:17 -04:00
Matthew Flatt
582e85adf7 support Visual Studio 2017
Requires the Windows 8 SDK for now, I think.
2018-08-05 13:44:48 -07:00
Matthew Flatt
df67d4e9d1 expander: fix problem with define shadowing require
When a `define` that shadows a `require` appears before the `require`,
then the `require` may fail to other, non-shadowed bindings from the
same `require` spec.

Thanks to Matthias for reporting the problem.
2018-08-05 13:46:38 -06:00
shhyou
33b94e6558 Exercise application result in -> contract 2018-08-05 12:57:32 -05:00
Matthew Flatt
d8ea41df23 cs: fix malloc argument parsing
Closes #2207
2018-08-03 06:58:15 -06:00
Robby Findler
258160707f use slightly better language so it makes sense with the swapping that
the error messages do based on positive/negative

inspired by #2205
2018-08-02 13:34:22 -05:00
Alex Knauth
6cc3a2f960
fix typo, stream-empty? -> set-empty? (#2191)
* fix typo, stream-empty? -> set-empty?

* add a regression test for the set->stream fallback
2018-08-01 13:14:05 -04:00
Matthew Flatt
b7392a688e hash-iterate-value & co.: add an optional bad-index result
The new argument to `hash-iterate-value` and most other
`...-hash-iterate-...` functions determines a result to be returned in
place of raising a "bad index" exception.

For most kinds of hash tables, a "bad index" exception will only
happen when the provided index is wrong or when a hash table is
mutated during an iteration. Mutation during iteration is generally a
bad idea, but in the case of a weak hash table, a potential background
mutation by the garbage collector is difficult to suppress or ignore.
Adding an option to control bad-index behavior makes it easier to
write loops that defend against uncooperative tables, including loops
where a hash-table key disappears asynchronously.

Racket's printer was already using this functionality internally, so
the change to `hash-iterate-value` and company mostly exposes existing
functionality.

The `in-hash` form and related sequence constructors similarly support
a bad-index alternate value so iterations can handle that case
explicitly. They do not use the new bad-index support implicitly to
skip missing entries, because that idea does not play well with the
iteration API. A hash-table index can go bad after `in-hash` has
selected the index and determined that it should be used for the next
iteration, and a sequence can't take back that decision.
2018-07-31 10:14:07 -06:00
Matthew Flatt
5526113311 cs: fix some problems with hash tables
In part, the corrections rely on a new `hashtable-cells` procedure
in Chez Scheme.
2018-07-30 17:37:23 -06:00
Matthew Flatt
fcd84113c8 cs: fix impersonator-property accessor failure modes 2018-07-30 07:46:57 -06:00
Matthew Flatt
bb4e7df1c6 cs: fix case of vector-copy! 2018-07-30 07:34:36 -06:00
Matthew Flatt
810d6da3c8 cs: unbreak continuation-mark chaperones 2018-07-30 07:02:59 -06:00
Matthew Flatt
d9ec0705cf add ffi/unsafe/collect-callback
The `ffi/unsafe/collect-callback` library exposes functionality
formerly only available via Racket's C interface, but implement
it for both Racket and RacketCs.
2018-07-29 13:32:44 -06:00
Matthew Flatt
f8297f9c00 thread: fix resume of suspended sync 2018-07-29 09:59:12 -06:00
Matthew Flatt
e066bb44ea repair uninterrupted-exit on continuation application 2018-07-29 07:18:27 -06:00
Matthew Flatt
1b716d5d32 schemify: fix inlining issues
Make `map` inline again, which involves optimizing away

 (variable-reference-from-unsafe? (#%variable-reference))

early enough. Fix post-schemify optimization for `procedure?
by adding both forms of an import name to the `imports` table.
Fix a problem with inlining operations passed to an inlined
function (as reflected by the addition of `find-known+import`).
2018-07-28 15:07:37 -06:00
Matthew Flatt
a447b5bf6b expander: improve some errors at phase >= 1
At phase 1 and higher, the expander tentatively allows an unbound
identifier so that, for example, `define-for-syntax` can define a
helper function syntactically after a compile-time expression that
uses the helper. While unbound references eventually trigger an error,
the reordering can be consuing, as in the example

  #lang racket

  (define-syntax (f stx)
    (syntax-parse stx
      [(_ oops) #'ok]))

which complains about `_` when the real problem is that `syntax-parse`
isn't imported.

To provide better errors, `raise-syntax-error` now implicitly extends
an error message to include a list of previously encountered unbound
identifiersin the current compilation unit. That list will be
non-empty only at phase >= 1. With that change, the error message for the
above example is

 bad.rkt:5:5: _: wildcard not allowed as an expression
  after encountering unbound identifier (which is possibly the real problem):
   syntax-parse
  in: (_ oops)
  ....

Closes #2167
2018-07-27 12:29:59 -06:00
Matthew Flatt
031564b28c expander extract: add --local-rename to minimize startup diffs
The expander's output normally uses a distinct symbolic name for every
distinct binding within a linklet. That property is useful for
consumers like schemify, but it's counterproductive for minimizing the
diff in changes to "startup.inc", since the traditional Racket
compiler doesn't need that guarantee. Use `--local-rename` to generate
"startup.inc", which should make future diffs smaller and more
composable after changes to the expander.
2018-07-27 12:29:59 -06:00
Matthew Flatt
0b9a7587f6 expander/flatten: better help, error reporting, and - mode for ++knot 2018-07-25 21:27:36 -06:00
Matthew Flatt
a41f58f9d7 cs: use call-setting-continuation-attachment 2018-07-25 19:32:29 -06:00
Matthew Flatt
60977b36c7 cs: remove useless call in delimiting continuations 2018-07-25 16:28:07 -06:00
myfreeweb
c7c4efca95 Add FreeBSD/aarch64 platform 2018-07-24 13:14:22 -06:00
Ben Greenman
e97717ef2b pkg new: clarify 'module+ main' and 'module+ test' purpose
- edit the comments, thanks to John B Clements and Alex Gian and Alex McLin
  and Phil McGrath
- add simple example code
2018-07-22 00:23:33 -04:00
Leif Andersen
eaaede9c2c
Fix fasl bug in Racket 7.0 beta! (#2178)
* Fix fasl bug in Racket 7.0 beta

The following program causes racket to error in Racket 7.

(parameterize ([current-write-relative-directory (build-path "/" "a")])
  (s-exp->fasl (build-path "/")))

This bug appears to have been introduced in Racket 7, and not in
Racket 6.x.

* Fix another bug where 'same was put through path-element->bytes

* "/" => (car (root-paths-list))

This is for windows where simply "/" is not a complete path.

* Add similar tests to serialize library.

* Better error message when relative-directory is a bad pair

Before it would give an internal list-tail error, now it returns
a proper bad argument error.

* Better tests, and improved common case
2018-07-21 14:46:44 -04:00
Gustavo Massaccesi
ebb7c0ea82 cs: fix mark-table-prune
Fix the case when the list of marks to remove is empty,
and also change the order of the arguments.
2018-07-20 17:50:24 -03:00
Ben Greenman
859ead9cc3 fix random-ref error message
For an empty sequence, print a message in terms of random-ref

Also, change all error messages to show all arguments
2018-07-20 12:11:34 -04:00
Matthew Flatt
a1e928350b foreign-call lock: repair for use during place termination
Now that `ffi/unsafe/alloc` deallocations are triggered by a place
exit, it's more likely that an ffi-call lock can be contended during a
place's termination. When that happens, the place cannot cooperate as
usual. Accomodate this rare situation by spinning.
2018-07-20 08:34:12 -06:00
Matthew Flatt
b40fdb7dd7 rktio: fix signal mask for subprocesses
... by making `centralized_unblock_child_signal` actually unblock SIGCHLD.

Closes #2176
2018-07-20 06:50:45 -06:00
Matthew Flatt
e2435d7187 expander: different repair for race
The repair in 49a90ba75e reorders two lines in a way that, in
retrospect, seems worrying. I can't construct an example that goes
wrong, so maybe it's fine, but it seems possible (now or with some
future change) that attempting to visit available modules could lead
to the same attempt in the same thread and therefore a loop.

This commit changes the repair to just always take the lock instead of
fixing up the attempted shortcut. There's a tiny extra cost to always
taking the lock, but that extra cost seems like a better choice
overall.
2018-07-18 13:48:34 -06:00
Matthew Flatt
49a90ba75e expander: repair a race condition related to "available" modules
Fix a broken use of a lock intended to prevent threads from
conflicting while forcing "available" modules to "visited" module.
2018-07-18 10:42:27 -06:00
Matthew Flatt
d3a5006721 fix typos in configure help 2018-07-18 09:54:29 -06:00
Matthew Flatt
3c95034a90 thread: don't always convert end-atomic to a thread swap
If interrupts are disabled to prevent thread swaps, then don't react
to `end-atomic` by performing a deferred swap. That might happen
with logger callbacks after a GC where a deferred action was
overlooked due to a rare race condition.
2018-07-17 16:23:17 -06:00
Matthew Flatt
e1c2e5d4f4 cs: make "main.sps" work in script or boot mode
Now that Chez Scheme supports libraries in boot files, make
"racket.so" work when it is converted to a boot file. Loading it as a
boot file can save around 20ms on every major GC, since the
"racket.so" code will be in the static generation.

For now, however, `racketcs` is not set up to use "racket.so" in boot
form.
2018-07-17 09:51:20 -06:00
Matthew Flatt
d67cec6892 cs: switch to __collect_safe
Sync with current ChezScheme (plus PRs), which involves changing
`__thread` FFI directives to `__collect_safe`.
2018-07-17 09:18:56 -06:00
Leif Andersen
91d059c817
Relative paths should still be readable. (#2172)
* Relative paths should still be readable.

The resent PR to enable relative serialization resulted in serialzed
objects that weren't actually readable (containing literal path
elements). This PR converts them to bytes.

* Move from serialize to relative path.

Also change path->bytes to path-element->bytes

* Path elements can also be 'up and 'same.

Also merge in the relevant code from racket/fasl.
2018-07-16 18:45:47 -04:00
Matthew Flatt
5fd23b18e5 repair no-executables assemble-distribution on Windows
Repairs a problem with `raco c-tool --c-mods <file> --runtime <dir>`
as reported by Dmitry Pavlov.
2018-07-16 15:59:31 -06:00
Matthew Flatt
652a0ad0d1 racket/serialize: refinements for relative paths
Allow selection of relative-path encoding for paths in data independent
of whether deserializer module paths are recorded as relative.
2018-07-15 12:22:16 -06:00
Matthew Flatt
c2c04711a3 cs: change continuation-frame marks table
Use an association list instead of an eq hashtable. This choice is
compatible with assumptions in traditional Racket (i.e., that the
number of mark keys per continuation frame will be small) and cuts
about 1/4 of the time in a benchmark like

 (define f
   ((contract (-> (-> integer? integer?))
              (λ () values)
              'pos 'neg)))

 (time
  (for ([x (in-range 1000000)])
    (f x)))
2018-07-15 06:26:40 -06:00
Leif Andersen
99fff46726
Add procedure? as an acceptable type for prop:serialize's deserialize binder. (#2168)
* Add allow the binder in prop:serialize to be a procedure.

This procedure is evaluated at serialize time, and is useful if
the deserializer is not known during object-type creation time,
but is during serialize time.

* Add docs+tests.

* Add a history note.
2018-07-13 13:49:29 -04:00
Leif Andersen
090eed4b28
Add option to create relative paths for 'serialize' (#2166)
* Add option to create relative paths for 'serialize'

Serialize would previously always create complete byte-string paths.
This adds an optional parameter to serialize (#:relative-to) to enable
relative path creation.

Now when deserialize finds a relative path, it resolves it with
respect to `current-load-relative-directory`.

* Moved fasl's path<->relative-path-elements functions

I moved it into the private/relative-path module, so that serialize
can make use of it.

* Update serialize to use relative-path.

* Add tests.

* And update docs.
2018-07-12 09:12:48 -04:00
Matthew Flatt
80e353c143 expander: fix order of unbound-identifier compilants at phase > 0
Closes #2167
2018-07-11 04:25:43 -06:00
Matthew Flatt
7bfe967e87 racket/fasl: repair for pair current-write-relative-directory 2018-07-09 15:54:55 -06:00
Matthew Flatt
8411b403e5 improve linklet performance-logging report 2018-07-09 15:54:55 -06:00
Matthew Flatt
41402ac783 expander: small code improvement 2018-07-09 15:54:55 -06:00
Matthew Flatt
b27ca8c6a9 expander: fix tracking of submodule base scopes
When expanding a `(module* _name #f ...)` submodule, accumulate all
module scopes on the `#f` and use the `#f` for a reexpansion.
Attempting to start each time from the enclosing module's scope loses
scopes that were generated from previous expansions. One consequence
of losind a scope is that an original definition may appear to be
macro-introduced, and the defined variable may become inaccessible
in the module's namespace.
2018-07-05 19:59:15 -06:00
Matthew Flatt
6a1232ee5a io: repairs 2018-07-03 17:26:38 -06:00
Matthew Flatt
d26517b49b thread: add missing end-atomic 2018-07-03 13:43:25 -06:00
Matthew Flatt
89db60abc9 cs: fix exit status on error
Also, fix some error messages in non-CS Racket, and add a
clarification on exit status in the Reference.
2018-07-03 10:56:23 -06:00
Matthew Flatt
99cf003d98 cs: store code as uncompressed by default
Leaving code uncompressed makes it about 5 times as large on disk, but
it loads about twice as fast.
2018-07-02 18:29:44 -06:00
Robby Findler
ffc5720b51 fix default proc for contract generation
closes racket/typed-racket#751
2018-07-02 07:11:35 -10:00
Matthew Flatt
a2f1f11f9b cs: fix PLT_LINKLET_TIMES mode Racket-thread safety 2018-07-02 07:20:44 -06:00
Matthew Flatt
eea40a6350 cs: cache foriegn call and callable wrappers
Generating the code for a `_fun` type takes hundreds ot thousands
of times as long as in the traditional Racket VM, to cache results
to reduce the cost.
2018-07-01 20:53:59 -06:00
Matthew Flatt
a1098bdb46 cs: repairs to variable-reference-constant?
Further correct the implementation of `variable-reference-constant?`
on bindings to primitive variable.

This repair affects method-call ctype caching in `ffi/unsafe/objc`.
Add some logging there to make problems easier to detect. Also,
add and improve linklet-evel performance logging for comparing
the traditional Racket VM to Racket-on-Chez.
2018-07-01 17:03:47 -06:00
Matthew Flatt
0f32765fe4 expander: fix variable-reference-constant? on primitive
When setting up the namespaces that imitate primitive instances,
the "constant" annotation wasn't set. The v6.x expander gets this
wrong, too, for different reasons.
2018-07-01 07:40:52 -06:00
Matthew Flatt
d5bb22c2d9 cs: improve #%variable-reference-constant?
Repair constant detection for unmodified imports.
2018-06-30 20:32:01 -06:00
Matthew Flatt
64b2694986 jitify: reduce unnecessary variable indirections 2018-06-30 14:11:45 -06:00
Matthew Flatt
bff5989cde cs: inline struct accessors/mutators across compilation units
Make schemify inline structure accessors and mutators across linklet
boundaries --- or, in JIT mode, across function boundaries --- by
replacing an accessor or mutator with a `#%record?` test and
`unsafe-struct*-{ref,set!}` operation.
2018-06-30 13:02:35 -06:00
Matthew Flatt
0f1088a150 cs: add cache for JIT mode
When linklets are compiled in JIT mode and a called procedure is to be
compiled on demand, consult a cache of compiled fragments (by default,
"jit.sqlite" in the addons directory) and either use an existing
compiled fragment or add to the cache after compiling.

Results for this initial implementation suggests that the idea is
workable. With the cache, starting a JIT-mode program a second time is
almost as fast as non-JIT mode (i.e., directly loading machine code).

Some refinements are needed: limiting the size of the JIT-fragment
cache, better contention handling, and better inlining of structure
operations in JIT mode (which may be useful to cross-linklet
optimization in non-JIT mode, too).
2018-06-29 11:04:16 -06:00
Matthew Flatt
fc7c4bb42c repairs for srcloc-marshaling change
Handle "." and ".." as one of the last two elements of a path.
2018-06-27 17:21:03 -06:00
Matthew Flatt
caf1b2e275 avoid a compiler warning 2018-06-27 16:08:14 -06:00
Matthew Flatt
9e6f450005 unbreak startup cifiy
Should have been part of ec036a0f5f.
2018-06-27 07:23:51 -06:00
Matthew Flatt
5b8aa67ea4 Windows: project and other repairs for rktio changes
Should have been part of cda4e5befe.
2018-06-27 06:48:22 -06:00
Matthew Flatt
b13f723ac6 serialize srclocs in bytecode; change expander to keep srclocs
To avoid recording absolute paths from a build environment in bytecode
files, the bytecode writer converts paths to relative form based on
`current-write-relative-directory`. For paths that cannot be made
relative in that way and that are in source locations in syntax
objects, the printer in v6.x converted those paths to strings that
drop most of the path.

The v7 expander serializes syntax objects as part of `compile` instead
of `write`, so it can't truncate paths in the traditional way. To help
out the expander, the core `write` function for compiled code now
allows `srcloc` values --- as long as the source field is a path,
string, byte string, symbol, or #f. (Constraining the source field
avoids various problems, including problems that could be created by
cyclic values.) As the core `write` for compiled code prints a path,
it truncates a source path in the traditional way.

The expander doesn't constrain source locations in syntax objects to
have path, string, etc., source values. It can serialize syntax
objects with non-path source values at `compile` time, so there's no
loss of functionality.

The end result is to fix abolute paths that were getting stored in the
bytecode for compiled packages, since that's no good for installing
packages in built form (which happens, for example, during a
distribution build).
2018-06-27 06:36:20 -06:00
Matthew Flatt
cda4e5befe add sha1-bytes, sha224-bytes, and sha256-bytes via rktio
Although SHA-1 hashing functions are available from `openssl`
libraries, a fast crytopgraphic hash is useful for many purposes below
the layer where the OpenSSL library has been opened. And SHA-1 is
reasonably easy to add to rktio.

Meanwhile, provide an equally convenient SHA-2 function to discourage
bad security practices (i.e., using SHA-1 where SHA-2 should be
preferred).
2018-06-27 06:36:20 -06:00
Matthew Flatt
d72b70f8e1 schemify: speed up jitify a little 2018-06-27 06:36:20 -06:00
Matthew Flatt
ec036a0f5f schemify: remove reannotate arguments
Passing them in instead of direct access to `datum->correlated` was a
holdover from the old setup that schemified directly to annotations.
2018-06-27 06:36:20 -06:00
Matthias Felleisen
5bb837661c for #2058, issue discovered by Sam 2018-06-25 14:06:48 -04:00
Matthew Flatt
a6e6bc0ebd cs: make JIT mode generate non-nested fragments
Applying jitify to a linklet now generates fragments of code that
are not nested. The drawback of this approach is that calling
a nested function needs an extra indirection, and the closure
has an extra slot. The advantage is that the fragments can be
separately compiled and fasled, which could enable a cache of
compiled fragments.
2018-06-22 15:57:50 -06:00
Matthew Flatt
4fa8a9870d cs: report file for bad-version errors 2018-06-22 13:39:08 -06:00
Matthew Flatt
00b9acdac3 cs: fix procedure names
Use a `(let ([<name> ....]) <name>)` wrapper to communicate
an 'inferred-name property from correlated objects to
Chez Scheme. This stategy relies on a Chez Scheme patch to
make the wrapper work consistently.
2018-06-22 12:32:17 -06:00
Matthew Flatt
cf0b38aee9 cs: drop unused correlation early
The improvements reported in 74012f8c57 were actually due to a broken
experiment that dropped source locations on application forms, instead
of preserving them in marshaled code. Adjust the expansion pipeline
to do that earlier and intentionally.

The xify pas doesn't help all that much after all, but it's still more
comfortable to be independent of local-variable names.
2018-06-22 11:04:00 -06:00
Matthew Flatt
74012f8c57 cs: add xify pass for JIT mode
The xify pass replaces local variable names with `x0`, `x1`, etc.
Using a minimal set of symbols makes the fasled form smaller
and typically take only 60-70% as long to read.
2018-06-22 09:57:50 -06:00
Matthew Flatt
d8832723e9 expander: fix corner for syntax-debug-info
Add a missing argument in the implementation of binding traversals for
"all bindings" mode.
2018-06-22 09:57:03 -06:00
Leif Andersen
eb97c7f54e Update deserialize-module-guard. (#2147)
It can now optionally return a pair to redirect the module
that is dynamic-required.
2018-06-22 10:48:12 -04:00
Matthew Flatt
d061970a01 adjust place tests and failure mode
The places test suite included some tests that create lots of places
and don't wait for them, which can lead to an overload of places that
exhausts resources such as file descriptors. Improve the tests, and
also improve a failure behavior from a crash to an error message.
2018-06-21 10:16:02 -06:00
Matthew Flatt
8678fbc90c place-kill: wait for place to finish
The `place-kill` function sends a message to another place to
terminate, but it didn't wait for that message to take
effect before returning. Worse, it put the place object in a
state that claimed that the place had terminated.
2018-06-21 09:00:15 -06:00
Matthew Flatt
d4fc865319 style nit: cond on its own line 2018-06-21 09:00:15 -06:00
Sam Tobin-Hochstadt
b6a3f40bd9 Use a custom implementation of promises.
Saves 43 definitions and 397 lines of (de)compiled code.
2018-06-21 10:37:12 -04:00
Matthew Flatt
f58b99aa74 ffi/unsafe/alloc: add decallocation on place exit
Closes #1830
2018-06-20 16:54:59 -06:00
Matthew Flatt
8fb8d3c936 ffi/unsafe: add _wchar
Closes #1843
2018-06-20 16:54:59 -06:00
Gustavo Massaccesi
6d775e5c5c optimizer: reduce (length '()) ==> 0
This pattern is common in the internal code of the keyword procedures
2018-06-20 17:34:21 -03:00
Matthew Flatt
598a5baf6a JIT: fix miscompilaton of char=?, char<?
When the first subexpression is complex and the second
is a literal character, the generated JIT code swaps the
argument order, but compilation didn't swap the test for
whether one or the other is a literal character to skip
a run-time test.
2018-06-20 13:43:19 -06:00
Matthew Flatt
da41bdf43a syntax/modread: adjust error-message quotes
While we're adjusting error messagaes, change `...' to `...`.
2018-06-19 20:12:01 -06:00
Stephen Chang
8620bc50be clean up check-module-form
- truly ignore expected-module (in err msgs) to match docs
- remove dead code
2018-06-19 20:10:16 -06:00
Paulo Matos
d6fe30156c Fix indentation
Remove tab and add spaces, which is how the rest of the file deals with this.
Avoid a misaligned preview in github editor.
2018-06-19 20:05:35 -06:00
Gustavo Massaccesi
17acb7458b avoid compiler warning in jit 2018-06-19 19:27:35 -06:00
Matthew Flatt
d72ccb521d MzCom: repairs for some Windows configurations
Registration of the typelib seems to be required on some modern
configurations, and myssink must claim to not implement
INoMarshal.
2018-06-19 13:29:19 -06:00
Sam Tobin-Hochstadt
ff867155d1
Add Sarah and Andrew. 2018-06-19 11:25:55 -04:00
AlexKnauth
3996f23879 add src argument to syntax:read-xml
and pass it through into the syntax-source field of the result
2018-06-18 19:52:52 -04:00
Gustavo Massaccesi
9cd3798ca9 schemify: add reduction of (not #f) 2018-06-16 22:44:39 -03:00
Matthew Flatt
96161f68eb fix non-initial call to scheme_basic_env
When an embedding application calls `scheme_basic_env` a
second time, it's supposed to reset the main namespace, but
the new expander wasn't reset correctly.
2018-06-16 15:49:38 -06:00
Matthew Flatt
3c752e008e Racket HISTORY note for v7.0 2018-06-16 09:59:38 -06:00
Matthew Flatt
d3067465e3 setup/unixstyle-install: use delete-directory/files
Use `delete-directory/files` instead of a separate implementation
here to get the special deletion mode for Windows files.
2018-06-16 09:59:38 -06:00
Philip McGrath
5a4ea2cd1b json: small fixes
* Fix handling of single-percision infinities and nan

* Document that non-`hash-eq?` hash tables are accepted by `jsexpr?`.

* Document that the value of `json-null` is recognized using `eq?`

* Use `case` instead of `assoc`.

* Use contracts
2018-06-16 00:42:43 -04:00
Alexis King
41fd4f3a5e Allow local-expand to opt-out of implicit extension of the stop list
Also, adjust the expansion of #%plain-module-begin to reinstate the stop
list after initial partial expansion.
2018-06-15 17:56:52 -05:00
Matthew Flatt
98ae91e0ba expander: repair and further improve flattener
Delay reporting of potential problems until an actual problem
is detected. Correct a mismatch between original and renamed
symbols to restore detection of problems.
2018-06-14 17:27:00 -06:00
Sam Tobin-Hochstadt
62ef3ed1ee Improve flattener. 2018-06-14 14:04:05 -06:00
Matthew Flatt
daa7ddeef8 workarounds for Windows filesystem behavior
* When you delete a file in Windows, then the name doesn't go away
  until the file is closed in all processes (and background tasks like
  search indexing may open files behind your back). Worse, attempting
  to create a new file with the same name reports a permission error,
  not a file-exists error; there's seems to be no way to tell whether
  a permission error was really a file-exists error.

  This creates trouble for `make-temporary-file` when files are
  created, deleted, and created again quickly enough and when
  something like a search indexer runs in the background (which is the
  usual Windows configuration). In practice, that kind of collision
  happens often for `raco setup` on my machine.

  To compensate, make `make-temporary-file` try up to 32 times on a
  permission error. A collision that many times seems extremely
  unlikely, and it seems ok to delay an actual permission error.

  Windows provides a GetTempFileName function from "kernel.dll" that
  must be able to deal with this somehow --- perhaps because it's in
  the kernel --- but it doesn't solve the problem for making temporary
  directories, hence the 32-tries approach for now.

* When a deleted file's name persists because the file is open in some
  process, then a directory containing the file cannot be deleted.

  This creates trouble for `delete-directory/files`, since
  `delete-file` on a directory's content doesn't necessarily make the
  directory empty. In practice, this happens often for package
  upgrades on my machine, where the package system wants to delete a
  short-lived working space that the indexer is trying to scan.

  To compenstate, change `delete-directory/files` to delete a file by
  first moving it to the temporary directory with a fresh name, and
  then delete the file there. It may take a while for a file to
  disappear from the temporary directory, but meanwhile it's not in
  the way of the original enclosing directory.

* When a file is open by any process, it prevents renaming any
  ancestor directory of the file.

  This creates trouble for the package system, which installs a
  package by unpacking it in a temporary place and then moving it by
  renaming. The package system also removes a package by renaming it
  to a subdirectory of a ".trash" directory. If a background indexer
  has a package file open, the move fails. In practice, a move fails
  often on my machine when I'm attempting to upgrade many packages.

  To compensate, make the package system fall back to copy + delete
  if moving fails with a permission error.
2018-06-13 18:57:07 -06:00
Matthew Flatt
09cdbc418c expander: allow rename transformer to primitive in local-expanded
Closes #2119
2018-06-12 19:19:09 -06:00
Matthew Flatt
c7318cab33 expander: fix syntax-local-bind-syntaxes for local-expand
Bind variables in a way that allows `local-expand` (with an empty stop
list) to replace a reference to the binding with one that has the same
scopes as the binding.
2018-06-12 16:23:44 -06:00
Matthew Flatt
380dc42427 expander: fix interaction of expand+eval across namespaces
This repair was motivated by tests in the "rex" package. The
new test added here failed before by finding 'new both times,
but in the "rex" case, the mixup led to the same variable
being imported and exported at the linklet level.
2018-06-12 12:58:56 -06:00
Ben Greenman
cf0c06d810 struct-out: get correct list of super-struct mutators
struct-out was putting the super-struct's accessors into two parts of a
struct-info: the accessor list and the mutator list

this commit puts the accessors only in the accessor list and the
mutators in the mutator list
2018-06-12 08:49:58 -06:00
Matthew Flatt
5c641919a6 fix --enable-jitframe for platforms that use libunwind 2018-06-11 18:16:17 -06:00
Matthew Flatt
0d870fb11c reader: fix bugs in cdot readering 2018-06-11 16:24:34 -06:00
Matthew Flatt
f11b4319b5 catch up on some acknowledgments 2018-06-11 11:42:18 -06:00
Matthew Flatt
a703b608a4 add --enable-jitframe for configure on x86_64
Using a frame pointer for the ABI of internal helper functions
should make the stack friendlier to tools like `perf`. There
may be a small performance cost, though.
2018-06-11 08:35:42 -06:00
Matthew Flatt
2c58937008 expander: fix comment 2018-06-08 09:24:13 +08:00
Vincent St-Amour
a2ab778ddb Post-release version for the v7.0 release 2018-06-07 09:10:05 -05:00
Robby Findler
aabd0e4603 fix random contract generation for </c and >/c when they get +inf.0 or -inf.0 2018-06-07 08:49:02 -05:00
Sam Tobin-Hochstadt
c6dd371ed6 Make stx.rkt cross-phase persistent.
This eliminates more than 70 linklet instance creations.
2018-06-07 09:38:38 -04:00
Matthew Flatt
4e10ed0518 expander: fix another local-expand problem with 'module-begin
Alexis's repair, and as she notes, forcing a `post-expansion` context
value in the core `#%module-begin` expander may allow a simplification
in "definition-context.rkt". But it's not immediately obvious, so save
that potential improvement for later.

Relevant to #2118
2018-06-03 17:10:31 +08:00
Matthew Flatt
9ca8d34e7c expander: clean up post-expansion scope representation
Instead of three different fields in the context to keep in sync,
encode the possibilities witin a single field.
2018-06-03 16:46:46 +08:00
Matthew Flatt
a1b5bab31b expander: repair local-expand with definition context
When `local-expand` receives one or more internal definition contexts,
it would forget about any current post-expansion scopes. That's
particularly a problem in a 'module-begin expansion context, where the
post-expansion scope ensures that any bindings are suitably
phase-specific.

Closes #2115
2018-06-03 10:02:01 +08:00
Gustavo Massaccesi
b9392b2a51 use unsafe-undefined for missing arguments in string-join
This is similar to the recent change of functions with optional
values. Using unsafe-undefined instead of a gensym makes it easier
to avoid the check of the missing argument.
2018-06-01 16:33:16 -03:00
Gustavo Massaccesi
fd149ca1c0 fix cache of regexp in string-{split,trim,normalize-spaces}
When the separator is a string, these function construct a regexp
that is cached to make repeated calls faster. But when the string
is mutated it is necessary to recalculate the regexp.
2018-06-01 16:33:07 -03:00
Matthew Flatt
8d56c29317 expander: fix incorrect addition of shifts
Commit 32b256886e adds shifts in one place where it shoouldn't;
the "determinsitic-zo" test exposed the problem.

Also, avoid adding shifts that will have no effect, which avoids
accumulating useless shifts in some top-level contexts.
2018-06-01 07:41:26 +08:00
Matthew Flatt
2cfd65e972 defend against bad bytecode
Closes #2107
2018-06-01 07:41:25 +08:00