Commit Graph

42908 Commits

Author SHA1 Message Date
Matthew Flatt
8668ad6959 docs: correction on register-external-file 2021-03-27 09:02:32 -06:00
Matthew Flatt
e31003b0ad racket/stream: unbreak chained lazy streams
The new implementation attempting to collapse lazy streams was broken.
2021-03-27 08:23:55 -06:00
Matthew Flatt
a5615a7bae racket/stream: add more control over laziness
Add `#:eager` options to `stream-cons` to control whether the head
and/or tail expression is delayed. Also add `stream-lazy` to
explicitly construct a lazy stream and `stream-force` (normally not
needed) to force a stream.

Delayed expressions in `stream-cons` are now non-reentrant, like
promises created by `delay`. This is a change in behavior, but I'm
hoping that no one relied on the old behavior, which has the bad
property that the delayed expression is retained until its result is
received.

For consistency, this commit also changes `stream*` to delay the
stream-construction expression when its the only one expression that
is given.

Internally, changes to the stream implementation reduce allocation.

The `stream-lazy` form would be more natrally called `stream-delay`,
but that creates a conflict with existing packages.
2021-03-26 19:52:42 -06:00
Matthew Flatt
4704dc6962 makefile: fix RACKET_FOR_BOOTFILES 2021-03-26 10:43:40 -06:00
yjqww6
4328b3acdb fix signatures of $fx+? and $fx-? 2021-03-26 15:07:51 +08:00
Alex Knauth
5c2949d051
add make-struct-type-property/generic and make-generic-struct-type-property (#3627) 2021-03-25 19:44:40 -04:00
Matthew Flatt
ca7404f2e3 docs: PLT_SETUP_OPTIONS as makefile variable
Although setting `PLT_SETUP_OPTIONS` as an environment variable works
for the makefile created by `configure` in a source distribution, it's
better used/described as a makefile variable.

Closes #3735
2021-03-23 17:33:46 -06:00
Matthew Flatt
c7b40ee2a4 makefile: clone single pb branch by default
Another try at the commit reverted by 471f18c02d, but this time with a
`SINGLE_BRANCH_FLAG` makefile variable that can be set to turn it off
for the rare system that has Git older than version 1.7.10.
2021-03-23 17:28:46 -06:00
Matthew Flatt
cd2d5f0ac7 cs: fix some error-message formatting
Some Chez Scheme error messages were not converted correctly,
leaving the values to be printed by Chez Scheme's printer.
2021-03-23 16:41:30 -06:00
Brian Adkins
f65560ed4c Optimize when sep is unspecified or the default regexp 2021-03-23 16:16:07 -06:00
Brian Adkins
754b3457c3 Verify the argument is a string?
For the fast path of splitting on whitespace, verify the str
argument is a string, so that internal-split will handle the
invalid argument error.
2021-03-23 16:16:07 -06:00
Brian Adkins
d061df81ce Optimize splitting strings on whitespace
Use an optimized function, instead of regexp-split, when string-split
is called with the default separator and trim setting.
2021-03-23 16:16:07 -06:00
Matthew Flatt
2a718d8162 Chez Scheme: repair for cross-library inlining
The cross-library inlining improvement in commit 6020b944ef did not
manage internal names correctly, and it could mix up bindings that
have the same printed form.

Closes racket/ChezScheme#35
2021-03-23 15:33:10 -06:00
Matthew Flatt
281eed7dda Chez Scheme: fix some typos 2021-03-23 13:42:05 -06:00
Gustavo Massaccesi
61cca93086 Chez Scheme: improve eq[v]? reductions in cptypes
Improve eq? and eq? handling to reduce expressions like
(eq? (newline) (void)) => (begin (newline) #t)
2021-03-23 15:14:56 -03:00
Gustavo Massaccesi
355b9f51be Chez Scheme: fix too much propagation of numbers in cptypes
In this example, after the check with eq? or eqv? the value of
the variables x and y are known, so cptypes replaced the
reference to the variable with it. But it can interact badly
with the eq? test, for example in this case the first (eq? x y)
can be #f and the second be reduced by the compiler to #t.

In spite eq? cannot be used to compare numbers reliably, this
behavior is too confusing and it's better to avoid it.

(define (one)
  (let ([r (random 2)])
    (if (= r 0) (one) r)))

(define (f x y)
  (define first-comparison (eq? x y))
    (when (and (eqv? x 7.0)
               (eqv? y 7.0))
      (define second-comparison (eq? x y))
      (eq? first-comparison second-comparison)))

(f (+ 6.0 (one)) (+ 6.0 (one)))))
2021-03-23 15:14:56 -03:00
Matthew Flatt
ef0ff679d0 correct some hash-table locking cases
BC did not take a lock for `hash-clear!`. Maybe the intent was that a
lock isn't needed from the perspective of `hash-clear!` when it isn't
traversing the table, but failing to take a lock before modifying the
table can break other operations (that do take a lock) in progress.
Furthermore, some iterations that intentionally did not take a lock
also did not guard against changes well enough. Various repairs here
avoid crashes, and now `hash-clear!` consistently takes a lock.

CS had a similar (but more subtle and more limited) instance of the
problem in `hash-map` and `hash-for-each`. That problem is corrected
(without adding any new lock acquisitions).

The existing CS implementation of `equal-hash-code` for hash tables
takes a lock more than the BC implementation. A possibly surprising
result: when attempting to add a mutable hash table to itself as part
of a key, the `hash-set!` can block forever on the hash table's lock,
instead of doing something more random as a result of having a mutated
key. The documentation now notes that possibility.

Related to #3738
2021-03-21 13:03:17 -06:00
Matthew Flatt
bcd16840da docs: note in flsingle about its use for single-precision operations
Add some reassurance that `flsingle` can be used to implement
single-precision arithmetic.
2021-03-21 12:46:01 -06:00
Ryan Culpepper
8bf8e3cf82 db: fix error case for disconnect in lock 2021-03-20 18:27:55 +01:00
Ryan Culpepper
5f66fad355 db: fix check for recursive lock acquire 2021-03-20 18:27:55 +01:00
Ryan Culpepper
815910b419 db: fix lock for non-escaping hopeless callbacks 2021-03-20 18:27:55 +01:00
Gustavo Massaccesi
145b72aa62 CS: enable more tests in optimize.rktl
A few optimization have been implemented in previous commits,
so reenable more tests for CS.
2021-03-20 13:02:38 -03:00
Matthew Flatt
a099e18767 sync generated files 2021-03-19 15:11:23 -06:00
Matthew Flatt
206577d701 vector->pseudo-random-generator[!]: accept impersonated vectors 2021-03-19 15:02:30 -06:00
Paulo Matos
eec7514fdb
Run workflow directly in VM (#3731) 2021-03-19 18:23:29 +01:00
Matthew Flatt
873d898ade repair test 2021-03-19 08:28:35 -06:00
Matthew Flatt
a50aa9d164 cs: repair for callbacks that might throw exceptions
The callable used to trigger stack unwinding was unlocked during
initialization, but it shouldn't be.
2021-03-19 07:49:28 -06:00
Gustavo Massaccesi
3952355d30 Chez Scheme: add suport for lists in cptypes
With list-assuming-immutable? and the internal construct
immutable-list the compiler can assume that some lists will
not be mutated.

Also, change the definition of interned-char?, because in CS all chars
are interned.
2021-03-19 09:19:27 -03:00
Gustavo Massaccesi
993b86ffa3 Chez Scheme: fix test in date.ms 2021-03-18 09:55:15 -03:00
Matthew Flatt
56970fdae7 docs: clarifications on identifier-binding results 2021-03-17 20:08:25 -06:00
Matthew Flatt
9a329574b4 docs: fix documented name for get-place-table
Closes #3734
2021-03-17 19:52:26 -06:00
Matthew Flatt
3244fa7a3c normalize error message for mem{ber|q|v}
Restore roughly the old error message for BC, but also adjust it to
use the modern error-message style (with newlines).
2021-03-17 19:52:26 -06:00
Robby Findler
274e4b95b1 give the binding that is introduced to be renamed on provide a source
location so it can be the target of jumps from other files

related to #3733
2021-03-17 19:55:53 -05:00
Robby Findler
2180ae15de mention that expt does like sqrt when it gets 1/2 as a second argument 2021-03-17 19:55:53 -05:00
Matthew Flatt
f43f2f552f docs: correct contract for mem{ber,q,v,f} and ass{oc,q,v,f}
The list-like argument doesn't have to be a list, as long as it's a
chain of pairs to the point where an element is found.
2021-03-17 14:19:02 -06:00
Matthew Flatt
e2cbd9bd73 fix "non-pair" error message for ass{oc,q,v,f} 2021-03-17 14:16:29 -06:00
Matthew Flatt
d0feb5c75a move memq and memv back to core
This commit partly reverts c305dba649 and 88fc9a979f, which was
discusssed in #366.

The original discussion was about allowing an extra argument to
`member` to pick the equality predicate. That change is still in place
in the same (private) Racket module.

The `memq` and `memv` functions are in Scheme for Racket CS and back
to being and in C for Racket BC. The old motivation for moving `memv`
and `memq` --- to get them out of C --- is subsumed by the switch to
CS (granting that some C code got added back to BC meanwhile). The
advantage of moving `memq` and `memv` back to the runtime core is that
the compiler can do more with them, at least in CS.

When `memq` and `memv` were moved previously, they lost checking for
cyclic lists. That wasn't discussed and presumably wasn't on purpose;
check is restored here, including for `member`.

There's no significant performance change in CS, except in cases like
`(memq x '(a b c))` that the compiler unpacks into a combination of
`eq?`s. For BC, the C version is a little faster (10-40%, depending on
the length of the list), but still slower than CS (probably because
`pair?` is slower, which due to representation differences).
2021-03-17 13:36:40 -06:00
Matthew Flatt
db34c62241 schemify: propagate 'compiler-hint:cross-module-inline through values
This change makes

 (begin-encourage-inline
   (define-values (f g h) (values e1 e2 e3)))

equivalent to

 (begin-encourage-inline
   (define f e1)
   (define g e2)
   (define h e3))
2021-03-17 13:33:04 -06:00
Sam Tobin-Hochstadt
4a65dfb1aa Use dd-parse to parse ... patterns inside quasipatterns.
Related to racket/typed-racket#1055.
2021-03-16 21:44:27 -04:00
Matthew Flatt
5058dc5a1a Chez Scheme: fix make-date and date-nanosecond signature 2021-03-16 08:26:06 -06:00
Matthew Flatt
a5db4bf376 Chez Scheme: fix make-time type signature
On a 32-bit platform, the nanosecond argument is not always a fixnum.
2021-03-16 07:47:45 -06:00
Paulo Matos
84328615a1 Fix Chez workflow to run inside a container
Fixes #3730.

By running inside a container we avoid CI breakages caused by changes
in the VM base image. In any case, lso update to use base image
ubuntu-20.04.
2021-03-16 09:37:49 +01:00
Matthew Flatt
a484cd76e5 cs & thread: fix problem with place initialization
The `current-place` place-local variable was initialized relatively
late in the set of place-creation steps. It was possible for the
thread scheduler to get involved before `current-place` was set ---
and in that case, it was possible for semaphores and Racket threads to
end up being used in the wrong place.
2021-03-15 13:51:16 -06:00
Matthew Flatt
c0cfd32bcb Chez Scheme: move cp machine-register indirection
Register allocation needs fresh machine-register state for each
compilation, and that was previously implemented by allocating a new
register record and indirecting references through a parameter. Move
the indirection to the places where conflict-set, index, and precolor
state is manipulated, and pass a state vector though to keep access
efficient. This change makes compilation slightly faster, and it makes
registers easier to work with by not having to introduce
indirections/delays in various places for register references.
2021-03-14 12:10:05 -06:00
Matthew Flatt
467ca64a7f Chez Scheme: split cpprim out of cpnanopass
Moving the np-expand-primtives pass to a separately compiled source
file reduces peak memory use when compiling Chez Scheme from about 1.3
GB to about 0.7 GB on a 64-bit platform. It's also nice from a
code-navigation perspective to split a 19k-line file to a 10k-line
file plus 8k-line file (and some additional small files).

The overall time for Chez Scheme to compile itself is only slightly
affected, even though some support functions, macros, and record
declarations end up getting compiled twice.
2021-03-14 07:39:55 -06:00
Bob Burger
31358698f3 Chez Scheme: sleep of non-positive duration now returns immediately
A negative duration would previously result in an infinite pause in
Windows.
2021-03-13 11:05:51 -07:00
Matthew Flatt
5e1df80a00 unixstyle-install: adjust DESTDIR fixup for "lib" executables with a suffix
More generally, make the path-fixup step insensitive to specific
filenames in the "lib" directory, making it more like the handling of
the "bin" directory.
2021-03-13 10:12:05 -07:00
Gustavo Massaccesi
a6e77a1a0c Chez Scheme: Add more maybe-* and eof/* types
The logic was added in the previous commits, but it's necesary to add
the mapping from the names in primdata to cptypes.

Also add a few subsets of fixnum.
2021-03-13 11:20:02 -03:00
Matthew Flatt
6f58ef5458 make embedding wrapper executable less sensitive to argv[0]
Running a `starter`-based executable with an argv[0] different
than the executable's path can make sense in various situations, but
it doesn't work for finding code embedded in the enxecutable. On
platforms where it's possible to get the current process's executable
(not looking at you, OpenBSD), then use that instead of argv[0] for
the purposes of loading embedded code.

Related to #3685
2021-03-12 20:08:53 -07:00
Matthew Flatt
4a06e4a1e3 Chez Scheme: remove before install
Removing the old executable before copying a new one in place avoids
problems on ARM Mac OS, at least.
2021-03-12 20:08:53 -07:00