In Racket BC, callbacks don't have to be atomic, and it's ok for the
callback to raise an exception (as long as the foreign library is ok
with a longjmp escape). Using `#:callback-exns? #t` on a foreign
callout in both CS and BC allows an atomic callback (invoked during
the foreign call) to raise an exception. Terms and conditions apply.
When a string is large enough, its conversion to bytes is internally
streamed, and `regexp-match/end` did not get the match-ending bytes
correctly.
Closes#3684
The predicate for a seald structure type can be faster than a
predicate for a non-sealed structure type, and Chez Scheme takes
advantage of that opportunity.
The BC JIT could be improved to take advanatge of sealed structure
types, but it isn't.
This commit also fixes CS checking of a supertype for certain shapes
of prefab struct-type declarations.
Saving and restoring the signal-mask state does not work right, since
rktio itself may block SIGCHLD in some cases, and it doesn't seem
useful/right to preserve the mask after fork.
The docs currently state that `flat-contract-predicate` is merely a holdover for backwards compatibility, and that flat contracts can be used directly as predicates now. This isn't correct: _some_ flat contracts can be used directly as predicates, but not all. Ordinary racket values that double as contracts such as numbers and symbols can't be used as predicates without using `flat-contract-predicate`. Additionally, this pull request directs users to `coerce-flat-contract` if they're seeking to build contract combinators that explicitly convert ordinary racket values into flat contracts.
Context: racket/scribble#293.
For each signal handler that is changed, save its state, and restore
the state in a child process after a `fork` and before an `execve`.
Also save and restore the signal mask.
This change requires cooperation from various subsystems, which often
takes the form of a callback registered with the subsystem to be
called before adjusts a signal handler.
Closes#3609
Forbidden set operations on weak sets produced slightly confusing error
messages:
> (define s (weak-set))
> (set-add s 42)
; set-add:
; expected: (not/c set-mutable?)
; given mutable set: (weak-set)
; argument position: 1st
> (set-mutable? s)
#f
Invoking an operation that required an immutable set gave a message
saying that a `(not/c set-mutable?)` was expected, but a `weak-set` is
not recognized by `set-mutable?`, which only recognizes mutable sets
with strongly-held keys. Changing `set-mutable?` to recognize weak sets
seems undesirable.
This patch changes the error message so that the above example produces
the following error:
> (define s (weak-set))
> (set-add s 42)
; set-add:
; expected: (not/c (or/c set-mutable? set-weak?))
; given mutable set: (weak-set)
; argument position: 1st
Instead of keeping a rectord type's ancestry in a vector ordered from
subtype to supertype, keep the vector the other way around, and
include a record type at the end of its own vector. This order makes a
more direct test possible when checking for a known record type,
especially one without a supertype, and it's generally easier to
reason about.
The revised compilation of record predicates trades some speed in one
case for smaller generated code and speed in other cases. The case
that becomes slower is when a predicate succeeds because the record is
an immediate instance of the record type. The cases that go faster are
when a predicate fails for a non-instance record or when a predicate
succeeds for a non-immediate instance. It's possible that an
immediate-instance shortcut is worthwhile on the grounds that it's a
common case for a predicate used as contract, but we opt for simpler
and less code for now, because the difference is small.
Also, add `record-instance?`, which in unsafe mode can skip the check
that its first argument is a record, and cptypes can substitute
`record-instance?` for `record?` in some cases. This change was worked
out independently and earlier by @yjqww6, especially the cptypes part.
Related to #3679
As documented, `define-struct` "is provided for backwards compatibility;
struct is preferred". This PR changes uses of `define-struct` to
`struct` whenever possible in the docs.
On an Apple M1, an example like
(let ([v (make-vector 1000000)])
(for* ([_ (in-range 100)]
[i (in-range 1000000)])
(vector-set! v i (+ 1 i))))
would generate tightly interleaved fence and store operations, which
seems to make the processor unhappy so that the code run 40x slower
than it should.
A key part of the example is that `(+ 1 i)` defeats cp0-level
inference that the result will be a fixnum. A dynamic fixnum test
avoids adding the update to a remembered set as part of the write
barrier, but the memory fence needed for ARM must be before the store,
while the fixnum test was after the store. This change bundles the
write fence and remember-set update under a `fixnum?` guard, so they
happen to gether or not at all --- at the small cost of generating the
store instruction(s) in two branches. In the example above, neither
the fence nor remember-set update happen, but changing `(+ 1 i)` to
`(quote x)` triggers both, and performance is still ok.
Remove a `with-continuation-mark` that is redundant because its both
is another `with-continuation-mark` with the same key. That's useful
for reducing a pattern that appears after some `if`-removing
optimizations on code with errortrace-generated annotations.