Commit Graph

6065 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Ismael Luceno
44964359ae Chez Scheme: fix missing include in externs.h
The correct header is needed to build with musl.
2021-03-12 19:50:40 -07:00
Robby Findler
288d13b85a add blame-replaced-negative? 2021-03-11 17:02:53 -06:00
Gustavo Massaccesi
3d04b71ced Chez Scheme: add maybe-char to cptypes
chars are immediates, so the previous change doesn't add automatically
the combinations like maybe-char. Add also eof/char that is commonly
used and has the same problem.

And rename in ctypes the internal symbol $immediate/true to
true-immediate because in all the other instances / is used for unions.
2021-03-10 14:27:00 -03:00
Matthew Flatt
8ba89cbd2a Chez Scheme: avoid floating-point register shuffling on x86_64
For floating-point arithmetic, encourage the register allocator to use
the same register for an argument and destination in arithmetic.
2021-03-09 17:36:21 -07:00
Matthew Flatt
5a2b6aab1e Chez Scheme: update docs for expand/optimize and run-cp0
Mention that it runs cptypes.
2021-03-08 09:55:45 -07:00
Matthew Flatt
75ba7ff5bc cptypes: discard call form around an error, better cm support
An an example of better error handling,

 (f (error 'x "x") y x)

turns into

 (error 'x "x")

which may allow further propagation through `begin` and `if` as
alerady implemented.

Also, make cp0 and cptypes more aware of
`call-{setting,getting,cosuming}-continuation-attachment` in terms of
result types and single-valuedness. The single-valued part requires
some generalization to the existing `single-valued?` support (by
default, "single-valued" => "doesn't inspect/changed immediate mark")
in both cp0 and cptypes.

Finally, the "optimize.rktl" test suite is now enabled for Racket CS.
The tests helped expose some missed opportunities and bugs, and it
should be particularly helpful going forward, since we're back to
having a place for Racket-level optimization tests. Not all tests
written for BC pass with CS. Grep for 'chez-scheme for missed
optimization opportunities.
2021-03-08 09:10:18 -07:00
Matthew Flatt
73eeff4f60 fix problems with continuation-mark-key chaperones
CS: When `with-continuation-mark` for a chaperoned key is in tail
position for a mark (such as a `parameterize`), make sure the existing
mark is still in place while (non-tail-)calling the chaperone's
interposition function.

BC: Don't collapse immediately nested `with-continuation-mark`s for
the same key if the key might be chaperoned. Also, repair treatment of
module-level bindings as potentially chaperoned.
2021-03-07 20:08:49 -07:00
Matthew Flatt
87d84a59c1 cs & schemify: cptypes-nice inline of authentic access and mutate
Change schemify to inline accessors and mutators of authentic
structure types in a way that lets cptypes eliminate checks for
subsequent operations.
2021-03-07 19:11:21 -07:00
Matthew Flatt
9651b45c83 cs & schemify: fix inlining that fold to #f
When the schemify inliner tries to inline, and inlining is supposed to
succeed with a result expression `#f`, the #f was being treated as a
failure to inline.
2021-03-07 16:55:18 -07:00
Philip McGrath
e45cd87511 version/check: use https; actually enforce timeout; guard reading params
Also, add an environment variable for testing purposes
and document the fact that `check-version` may block.
2021-03-07 11:12:57 -05:00
Bogdan Popa
81e0c86fc3 pkg: show bad deps in check-dependencies 2021-03-07 07:37:42 -07:00
yjqww6
b4d05e7a41 add [unsafe-]assert-unreachable 2021-03-07 06:48:50 -07:00
Matthew Flatt
fac8463082 cs: fix raco exe for OpenBSD
The repair involvea adding a `-E` flag to Racket for use by the wrap
executable that `raco exe` created, because OpenBSD (intentionally)
does not have a way to access the executable file of the current
process.

Closes #3717
2021-03-07 05:03:50 -07:00
Matthew Flatt
a3bf702ac9 cs & io: fix simplify-path for 'up relative to a root
Closes #3716
2021-03-06 09:37:10 -07:00
Matthew Flatt
07c7ff51ff repairs for NetBSD 2021-03-06 09:37:10 -07:00
xxyzz
d03456b55e
Skip keywords in invalid-option-placement (#3621)
Close #3603

* skip keywords in invalid-option-placement
* replace check-duplicate with check-duplicates
* add skip keywords test
* add require and fix syntax-e error
* update comment of invalid-option-placement
* add mixture keywords and arguments test
* forget to skip keyword in loop
* and another two tests for syntax-parse
* define splicing-formals-no-rest as @Metaxal suggested
* add formals link
* rename splicing-formals-no-rest to formals-no-rest
* add attributes to formals
* remove racket/dict import
2021-03-06 00:55:52 +01:00
Matthew Flatt
076426e796 unbreak unzip
Commit 71b7f21fdb changed the scope of a shadowing binding.
2021-03-03 09:29:10 -07:00
Matthew Flatt
a5b61f7ac8 unzip: add option to insist on a zip archive
The fact that a non-zip archive has always been silently ignored seems
bad, but adding an error might break code that (probably accidentally)
relies on the behavior. This change makes sane behavior at least
available by adding a `#:must-unzip?` option.

Relevant to #3613
2021-03-03 09:07:06 -07:00
Matthew Flatt
71b7f21fdb unzip: avoid blocking on break exception
The `dynamic-wind` that causes problems dos not appear to be needed.

Closes #3703
2021-03-03 08:20:41 -07:00
Matthew Flatt
1e56ca9cc1 treat uname result as locale encoding instead of UTF-8 2021-03-03 07:06:07 -07:00
Philip McGrath
261d73abdb racket/src/cs/c/Makefile.in: use $(SHELL) rather than hard-coded /bin/sh
This change facilitates building in environments where `/bin/sh` is not
available, such as Nix and GNU Guix.
The GNU Autoconf manual lists several additional systems where `/bin/sh`
is either missing or not POSIX-compliant:
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/The-Make-Macro-SHELL.html

Related to https://github.com/racket/racket/issues/3707
2021-03-03 07:04:51 -07:00
Philip McGrath
fdb2ad7892 Chez Scheme: avoid hard-coded paths for utilities in build scripts
These changes facilitate building Chez Scheme in environments where
utility commands are not available at their usual absolute paths,
such as Nix and GNU Guix.

Specific changes:
  - `cc` -> `$(CC)`
  - `/bin/rm` -> `rm`
  - `/bin/ln` -> `ln`
  - `/bin/cp` -> `cp`
  - `/bin/echo` -> `echo`
  - in `makefiles/installsh`, add a case to find `true`
    at an unusual path or as a shell builtin

Related to https://github.com/racket/racket/issues/3707
2021-03-03 07:04:51 -07:00
Matthew Flatt
5114fec2c7 file/resource: support REG_EXPAND_SZ
Also, provide workarounds for some broken conversions --- especially
the 'string/utf-16 conversion for reading. For writing, allow
specifying raw bytes that end up in REG_SZ or REG_EXPAND_SZ via
'bytes/string or 'bytes/expand-string.
2021-03-03 06:41:16 -07:00
Matthew Flatt
e615294e78 change (system-type 'machine) to use C-library uname
Thanks to @LiberalArtist for pointer out that uname(3) exists!

Related to #3707
2021-03-02 17:33:27 -07:00
Matthew Flatt
afe522ab9c find-executable-path: avoid conversion of PATH to string
Send bytes directly to `path-list-string->path-list`, since it can
handle bytes and convert directly to paths. Also check that the
argument to `path-list-string->path-list` has no nul character or byte.
2021-03-02 15:51:53 -07:00
Gustavo Massaccesi
421dce228d Chez Scheme: add maybe predicates to cptypes
Actually, use a more general decomposition with a part for an
$immediate, a part for a $record and a third part for other types
like string?, vector?, ...

This is not as general as an arbitrary union, but it is enough for
the common cases, and also to handles the common objects in Racket
that are implemented in CS as the corresponding object and a record
for the impersonator.
2021-02-28 17:05:20 -03:00
Matthew Flatt
37ee8a793c Chez Scheme: make "immediate" consistently mean type-immediate
Exposing `$immediate?` as just "immediate" will be useful to cptypes.
Meanwhile, introduce "fixmediate" as the term for a union of "fixnum"
and "immediate" (i.e., values that are not allocated).

The new terminology helps avoid internal inconsistencies, such as the
`Simmediatep` kernel macro meaning "immediate" while the `$immediate?`
primitive meant the union.
2021-02-28 08:45:17 -07:00
Matthew Flatt
04e78c4bb7 repair handling of PLTCOMPILEDROOTS
Commit a110c58e52 broke the interaction with `PLTCOMPILEDROOTS`.
Instead of reverting to the old behavior that coerced 'same to a path,
this change makes `path-list-string->path-list` a little more
flexible.

Closes #3704
2021-02-27 19:16:21 -07:00
Matthew Flatt
2b79ba6d4f add ephemeron hash tables
Weak hash tables retain keys weakly, but they hold each corresponding
value strongly as long as the key is accessible. As a result, weak
hash tables suffer from the key-in-value problem: if the value refers
to the key, the key cannot become inaccesible and be removed from the
table.

Previously, the way around that problem was to map a key to an
ephemeron that combines the key and value. The extra cost of involving
ephemerons (a constant factor) is why ephemerons storage is not the
default behavior of weak hash tables.[*] Having ephemeron hash tables
as a distinct variant avoids imposing a cost where its not needed, and
compared to using explicit ephemerons, it's easier to drop into a
program that was written to use strong or merely weak hash tables.

For Racket CS, the change is especially straightforward, because
ephemeron tables already exist in Chez Scheme (at least for the Racket
variant, in the case of eqv- and equal-based tables).

[*] Also, non-emphemeron hash tables turn out to be needed for certain
    finalization tasks.
2021-02-27 19:08:05 -07:00
Matthew Flatt
c89f885578 Chez Scheme: fix test involving CAS
Replace an unnecessary `box-cas!` in a test with `set-box!`. The use
of `box-cas!` was wrong in that it didn't accomodate a spurious CAS
failure.
2021-02-27 12:20:09 -07:00
Matthew Flatt
be7c7755b2 struct: syntax error for #:prefab plus #:authentic
Prior to this change, the combination was documented as a syntax
error, but it was only a run-time error --- and not even that as of
v8.0 for Racket CS (but it was always a run-time error for BC).

Closes #3700
2021-02-26 16:58:31 -07:00
Matthew Flatt
999c300f7f cs: fix byte-ready? on the result of make-input-port
When an evt is returned by the byte-peeking function, the evt needs to
be polled.

Relevant to racket/datalog#13
2021-02-26 11:34:05 -07:00
Ryan Kramer
0841af7992 add tests and scribble documentation for XML indentation 2021-02-26 09:24:31 -05:00
Ryan Kramer
a5f95a4a41 adding different indentation to XML 2021-02-26 09:24:31 -05:00
Matthew Flatt
0ab75d1675 read: avoid quadratic-time string->number integer conversion
For bases other than powers of 2, I think reading is at least
O(n^1.58), due to multiplication with Karatsubra --- but that turns
out to be a lot faster than O(n^2) by the time you get to 1M digits.
For powers of 2, the time should be linear.
2021-02-25 14:58:02 -07:00
Matthew Flatt
70c763833d repair collection-file-path and default current-compiled-file-roots
The `collection-file-path` function did not handle compiled-file root
paths correctly. The problem was exposed by a recent change to the
default for `current-compiled-file-roots`, which made it match the
documentation, but this commit changes it back and fixes the
documentation.
2021-02-25 13:31:17 -07:00
Cameron Moy
7f34da35e7 Fail random generation of range contracts with bad bounds 2021-02-25 11:34:00 -06:00
Matthew Flatt
f1fb22f0a7 Chez Scheme: faster bignum printing for power-of-two bases
Insteda of using the generic strategy that involves division, walk
through the bits of a bignum to convert to a power-of-two base.
2021-02-25 06:35:46 -07:00
Matthew Flatt
c2b46b1e96 Chez Scheme: Burnikel-Ziegler division for very large integers
Adapted from Peter Bex's Scheme version of CHICKEN's implementation
here:
 https://www.more-magic.net/posts/numeric-tower-part-3.html

Improving dvision has a large effect on printing large integers in
base 10, such as printing `(expt 2 8000000)`.
2021-02-25 06:35:46 -07:00
Matthew Flatt
35116f6015 Chez Scheme: improve multiplication with trailing 0s
Multiplying bignums with trailing 0s is common enough to be worth a
special case.
2021-02-25 06:35:46 -07:00
Matthew Flatt
0cb9643fcb Chez Scheme: improve multiplication and scheduling
Raise the threshold for using Karatsuba. The experimentally determined
threshold (on an M1 Mac) matches the GMP default threshold, so that
seems like a good sign.

Also, adjust kernel bignum operations to decrease the trap counter.
Otherwise, a program that performs many big multiplcations or
divisions does not check for Ctl-C or swap threads often enough.
2021-02-25 06:35:46 -07:00
Cameron Moy
c8bc0c76ad Improve flat-murec-contract with random generation 2021-02-24 15:51:45 -06:00
Matthew Flatt
18435e3a08 cs: fix interactio of unsafe capture and barriers
Fix `unsafe-call-with-composable-continuation/no-wind` so that it's
not blocked by a barrier, since it's supposed to have thread-like
capturing ability.

Closes #3696
2021-02-23 13:03:39 -07:00
Matthew Flatt
fff39d0306 Chez Scheme: fix expected-error log
Repair after commit 0523a5311c.
2021-02-23 13:03:39 -07:00
yjqww6
4110761f94 cs: optimize pattern matching on authentic structs 2021-02-23 11:25:04 -07:00
Matthew Flatt
23dc67c1a4 unixstyle install: fix when "share/pkgs" is not created 2021-02-22 19:28:36 -07:00
Matthew Flatt
5855fcd0ae more acks.rkt catchup 2021-02-22 19:28:36 -07:00
Matthew Flatt
d3b4d14287 correction to unixstyle-install for raco commands 2021-02-21 09:47:51 -07:00
Matthew Flatt
441cf9a85c correction to unixstyle-install for libzo mode 2021-02-21 09:41:05 -07:00
Matthew Flatt
4df60bb819 unbreak make install step for non-Unix-style, too 2021-02-21 08:29:33 -07:00
Matthew Flatt
9dbcf179b6 unbreak make install step 2021-02-21 08:16:27 -07:00
Matthew Flatt
51b8606861 unix-style install: ".zo"s in "lib" instead of "share"
For a Unix-style installation, change the default mode to put
"compiled" directories under "lib" instead of "shared", since they're
architecture-specific for Racket CS.

This installation mode relies on the new 'compiled-file-roots config
entry. The installation process updates "config.rktl" so that
`current-compiled-file-roots` is initialized to find ".zo" files under
"lib".

Use `--enable-sharezo` to get the old behavior, either for installing
Racket BC or if you want to ignore "lib"-vs.-"share" guidelines to
simplify the installation.
2021-02-21 07:58:29 -07:00
Matthew Flatt
a110c58e52 add 'compiled-file-roots to "config.rktd" 2021-02-21 07:58:29 -07:00
Matthew Flatt
404c91ed55 fix sorting in "acks.rkt" 2021-02-21 07:58:29 -07:00
Matthew Flatt
95ee83e486 cs: remove reference to racket_exit
Was supposed to be part of 1fd516c502, but was missed because the
change wasn't saved.
2021-02-21 07:58:29 -07:00
Matthew Flatt
cff766ab84 change Git package references to use default branch
If a Git package source does not include "#" followed by a ref, then
use the branch/commit designated by a server as the default branch or
commit (i.e., the one for the "HEAD" symref), instead of assuming the
branch "master".

This is technically a backward-incompatible change to the
interpretation of Git package sources, but explicit branch
specification continues to work the same. For the forseeable future,
to support recent versions, packages in a branch other than "master"
will still need to be specified using the branch name, such as
including "#main" at the end of the package source. Eventually,
relevant versions of Racket will support the new default.

Relevant to #3672
2021-02-20 07:21:10 -07:00
Matthew Flatt
f0e41cf143 git-checkout: add support for 'head as a ref
Also, change the default ref from "master" to 'head. This is
technically a backward-incompatible change, but so far it seems more
likely to make things work right than to break them.
2021-02-19 16:01:29 -07:00
Matthew Flatt
19c3ee456b configure: fix --collectsdir and --appsdir handling
Thanks to @tgbugs for the report an initial repair.

Closes #3692
2021-02-19 09:26:58 -07:00
Matthew Flatt
eaeb49d0d1 update acks.rkt 2021-02-19 09:26:58 -07:00
David Van Horn
f060ba5cd5 Spelling 2021-02-18 10:46:41 -05:00
Matthew Flatt
89130bd64f unbreak cross build 2021-02-17 11:09:54 -07:00
Matthew Flatt
bf8741e727 add #:callback-exns? to _fun and _cprocedure
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.
2021-02-17 08:41:09 -07:00
David Van Horn
5743e1a143 Occurrences of http -> https that don't redirect. 2021-02-16 22:19:47 -05:00
David Van Horn
4438dec280 Wayback for old MSDN doc. 2021-02-16 22:19:47 -05:00
Matthew Flatt
616daa2239 windows: fix finding self for boot files
Use a wide-character function instead of an ASCII function
to open the executable. Otherwise, Racket breaks when installed
into a non-ASCII path.
2021-02-16 17:24:11 -07:00
Ryan Culpepper
f502cf3b4e db: simplify locking 2021-02-16 12:56:15 +01:00
Ryan Culpepper
f1a5dab4c7 db: update sqlite3 to use ffi-common mixin 2021-02-16 12:56:15 +01:00
Ryan Culpepper
594dfafdf4 db: factor out ffi-common mixin 2021-02-16 12:56:15 +01:00
Matthew Flatt
cf0e45b763 cs: unbreak Windows errno
Restores the repair in 6e58310176, which accomodates certain modes of
compiling the Chez Scheme kernel on Windows.
2021-02-15 17:52:56 -07:00
Matthew Flatt
1fd516c502 cs: fix exit on startup error
Also, simplify errno and exit handling, because Chez Scheme always
provided "(cs)s_errno", and "(cs)c_exit" now does what Racket needs.

Closes #3687
2021-02-15 17:41:25 -07:00
Matthew Flatt
688094e622 Chez Scheme: make default exit handler normal
If a script uses `(exit 1)`, for example, the script should
exit with status 1.
2021-02-15 17:23:55 -07:00
Matthew Flatt
b9ef307b30 cs & regexp: fix regexp-match/end on large strings
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
2021-02-14 10:22:03 -07:00
Matthew Flatt
2dd59a706c bc: unbreak JIT 2021-02-13 08:58:57 -07:00
Matthew Flatt
0523a5311c add structure-type sealing
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.
2021-02-13 08:46:31 -07:00
Matthew Flatt
1f68962d67 cs & schemfiy: avoid crash with 1 extra argument to make-struct-type 2021-02-12 19:45:08 -07:00
Matthew Flatt
ae80c890e9 update source READMEs on modifying versions and pb bootfiles 2021-02-12 16:50:32 -07:00
Matthew Flatt
4c836a1dd1 rktio: always set signal mask to empty after fork
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.
2021-02-12 16:50:32 -07:00
Matthew Flatt
3e2245d40e rktio: unbreak for Windows 2021-02-11 17:39:07 -07:00
Matthew Flatt
eba9be1b39 cooperate with nohup
If SIGHUP is initially ignored, don't set a SIGHUP handler.
2021-02-11 15:27:29 -07:00
Matthew Flatt
2cbaeb7865 Unix: restore all signal handlers after creating a subprocess fork
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
2021-02-11 15:27:29 -07:00
Anish Athalye
c07e9cde09 Improve errors for forbidden ops on weak sets
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
2021-02-11 12:41:46 -05:00
Matthew Flatt
0137c1c545 Chez Scheme: repair expected-error log 2021-02-10 07:55:23 -07:00
Bogdan Popa
f3793bb4d7 xexpr: micro-optimize xexpr-write
This improves write performance by between 15% and 40% on large xexprs.
2021-02-10 09:09:39 -05:00
Matthew Flatt
9f6f988150 Chez Schme: change struct predicate implementation
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
2021-02-10 06:53:53 -07:00
Matthew Flatt
3a49533ff5 fix accidental change 2021-02-07 13:45:54 -07:00
Matthew Flatt
8a08704012 cs: support Android on 32-bit and 64-bit ARM
Various configure and makefile improvements apply more broadly to
environments that, say, lack iconv or target 32-bit ARM without Thumb.
2021-02-07 10:49:25 -07:00
Matthew Flatt
342bd6645c update cross-build info for Racket CS 2021-02-07 07:09:08 -07:00
Matthew Flatt
d07d256f18 racket/src/configure: correct default when CS and BC are both enabled 2021-02-06 10:51:24 -07:00
Matthew Flatt
41623f3027 Chez Scheme: move write-barrier fixnum guard outside write fence
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.
2021-02-03 10:30:24 -07:00
Matthew Flatt
0a945cd5f7 fix continuation-marks on thread without prompt
Closes #3675
2021-02-03 07:14:07 -07:00
yjqww6
5c6d7a3934
ChezScheme: use types to eliminate some dirty stores 2021-02-03 06:16:16 -07:00
Matthew Flatt
f968945e26 cs & schemify: with-continuation-mark optimization
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.
2021-02-01 09:05:56 -07:00
Matthew Flatt
53b3cc5eb4 makefile: make just nmake make
Use a comment trick to make `nmake` see a different default target
than `make`, which will save a small amount of hassle from forgetting
to type `nmake win`.
2021-02-01 09:05:56 -07:00
Ryan Culpepper
ee43d982e4 db: fix for disconnect during query in OS thread
This change allows a query that is run in an OS thread to succeed even
when the connection is custodian-disconnected. Previously, the part in
the OS thread would complete, and then the operations needed to
package the result would fail. This fix moves some of those operations
to the OS thread and makes read-tx-status work when disconnected.
2021-01-31 07:13:03 +01:00
Sorawee Porncharoenwase
0101f584fb struct*: fix incorrect struct-info extraction
Also add tests for `struct-copy` and `struct*` for cases
where struct-field-info is not available

Fixes #3662
2021-01-30 08:16:11 -07:00
Ryan Culpepper
c9861931ad db: use ffi/unsafe/os-async-channel
Also:
- use one OS thread per connection instead of one per query
- when using OS thread, finish disconnect in OS thread
2021-01-30 08:54:40 +01:00
Matthew Flatt
4e76091c64 add ffi/unsafe/os-async-channel 2021-01-29 12:54:23 -07:00
Matthew Flatt
24f539087f ffi/unsafe/schedler: add unsafe-make-signal-received 2021-01-29 11:09:22 -07:00
Matthew Flatt
f685a27b41 cs & thread: add missing check on thread-suspend
Also, fix non-atomic check for shut-down custodian in `thread-resume`.

Closes #3660
2021-01-29 07:05:58 -07:00
Matthew Flatt
b55f268510 cs: fix list-{ref,tail} error messages
Closes #3661
2021-01-29 07:05:47 -07:00
shuhung
a7fef69f33
cs: print extra ellipses if the context is truncated 2021-01-29 05:36:43 -07:00
Matthew Flatt
1fea5f8e3f cs: don't display via prop:exn:srclocs when context length is 0
It's not clear that supressing source locations with the context
length is set to 0 is the right choie, but it's consistent with BC.
2021-01-27 14:47:58 -07:00
Gustavo Massaccesi
0ff8d18be5 cs: reimplement the predicate lattice in cptypes
Clean up the implementation. For example predicate-union was
calling predicate-implies? like 20 times. With the new
implementation this can be done in a single pass.

Also, this changes the results of the functions for 'bottom and
#f so they behave like sets. So this removes some special cases
and makes the functions more consistent.
2021-01-27 15:47:35 -03:00
Ryan Culpepper
ad6bbe9809 db: add option to run query in separate OS thread 2021-01-27 14:58:18 +01:00
Matthew Flatt
e110b07cc8 racket/fasl: use current-directory for relative-path unmarshaling
Relative-path handling for `fasl->s-exp` was meant to be like code
unmarshaling, but it did not fall back to `(current-directory)` when
`(current-load-relative-directory)` is #f. There's some risk to
changing the behavior of `fasl->s-exp`, but better matching the intent
seems at least as likely to fix problems as create them. One problem
it fixes is in CS code marshaling.

Closes racket/drracket#421 (again)
2021-01-26 11:29:43 -07:00
Matthew Flatt
91060487ca sync pre-built files
Needed a rebuild after changes to avoid naming via keyword arguments.
2021-01-26 11:29:43 -07:00
Matthew Flatt
18954fdc70 Chez Scheme: fix compilation problems for MinGW 2021-01-26 05:59:03 -07:00
Alexis King
c54ab626f7 Ensure block does not evaluate define-syntaxes RHSs multiple times
As described in #3635, there isn’t currently any good way to use
first-class definition contexts without evaluating define-syntaxes RHSs
multiple times. For macros like `class` and `unit`, it’s unclear if that
can be avoided, but for `block`, the first-class definition context
turns out to not be necessary.

This commit changes the implementation strategy used by `block` to a
trampolining macro rather than a first-class definition context. This
has the nice side-effect of avoiding the issue described in #3198, too.
2021-01-25 15:51:53 -06:00
shhyou
7894e97fd2 Stop keyworded functions from changing args' name 2021-01-25 06:55:31 -07:00
yjqww6
ef165fedda cs: add pariah for slow path of define-inline 2021-01-25 06:52:10 -07:00
Bogdan Popa
dcb7257d3f cs,alloc: close off sweep_next chain along with thread local segment 2021-01-25 06:51:18 -07:00
Matthew Flatt
87bf20c581 Windows: turn on string pooling for CS executables
Visual Studio 2015 duplicates the "Replace me for EXE hack" string in
the GRacket executable, which breaks the hack. Adding the /GF compiler
flag counteracts that duplication, and it's consistent with
`<StringPooling>true</StringPooling>` in the BC projects.
2021-01-23 16:04:40 -07:00
Matthew Flatt
442d7d2d00 Chez Scheme: repair for reify-cc register saving on arm32
This repair is simpler approach than the original, and it makes the
manual register allocation a little less fragile.
2021-01-23 10:46:01 -07:00
Matthew Flatt
00ce8904c7 repair prop:exn:srcloc handling
For CS, the default error display handler was not using `prop:exn:srcloc`.

For BC, a bad `prop:exn:srcloc` that returned a value other than a
list of srclocs coudl cause a crash.

Related to #3645
2021-01-23 09:33:48 -07:00
Bogdan Popa
3baed0966d build: fix make install for cross builds
W/o this change, some targets (like `copytree-run`) fail because they
try to run the target Racket executable instead of the host.
2021-01-23 06:42:00 -07:00
Matthew Flatt
c084ead2f3 Chez Scheme: fix continuation-attachments compilation
On AArch{32,64}, compiling `call-setting-continuation-attachment` in a
non-tail position could run out of registers for saving/restoring
around th intrinsic to reify the continuation.

Closes #3646
2021-01-23 06:35:48 -07:00
Matthew Flatt
be42b9a24a Chez Scheme: always disable X11 support on Mac OS 2021-01-22 09:35:59 -07:00
Matthew Flatt
9c8d7b3ebf bump version for Chez Scheme sync
After pulling in patches that change the Chez Scheme version to 9.5.5
(with not much changing besides the version, since we've pulled other
patches), update the Racket version number to reflect the change to
compiled files.
2021-01-22 08:47:16 -07:00
Bob Burger
53dcd3c439 update release notes 2021-01-22 08:36:06 -07:00
dyb
2613740431 9.5.5 changes: - updated version to 9.5.5 BUILDING NOTICE makefiles/Mf-install.in scheme.1.in c/Makefile.a6nt c/Makefile.i3nt c/Makefile.ta6nt c/Makefile.ti3nt mats/Mf-a6nt mats/Mf-i3nt mats/Mf-ta6nt mats/Mf-ti3nt workarea c/scheme.rc s/cmacros.ss release_notes/release_notes.stex csug/copyright.stex csug/csug.stex bintar/Makefile rpm/Makefile pkg/Makefile wininstall/Makefile wininstall/a6nt.wxs wininstall/i3nt.wxs wininstall/ta6nt.wxs wininstall/ti3nt.wxs - newrelease no longer logs as updated files with no actual changes newrelease 2021-01-22 08:36:03 -07:00
dyb
6c1d6b49dc updated version to 9.5.4 BUILDING NOTICE makefiles/Mf-install.in makefiles/Makefile-csug.in scheme.1.in c/Makefile.a6nt c/Makefile.i3nt c/Makefile.ta6nt c/Makefile.ti3nt mats/Mf-a6nt mats/Mf-i3nt mats/Mf-ta6nt mats/Mf-ti3nt workarea c/scheme.rc s/7.ss s/cmacros.ss release_notes/release_notes.stex csug/copyright.stex csug/csug.stex bintar/Makefile rpm/Makefile pkg/Makefile wininstall/Makefile wininstall/a6nt.wxs wininstall/i3nt.wxs wininstall/ta6nt.wxs wininstall/ti3nt.wxs 2021-01-22 08:35:47 -07:00
dyb
aa2208eb04 fixed S_condition_wait Y2038 bug; rounding ns to ms on Windows - now using 64-bit arithmetic for seconds in S_condition_wait to prevent a potential 2038 bug, at least on platforms where time_t is 64 bits. also now rounding rather than truncating nanoseconds in the coversion to milliseconds on Windows. thread.c 2021-01-22 08:35:37 -07:00
Matthew Flatt
13ee990165 rktboot: adjust for newer nanopass 2021-01-22 08:35:29 -07:00
dyb
416a6790c3 added textual-output-port checks for record-writer write argument print.ss, record.ms, root-experr* 2021-01-22 08:35:20 -07:00
Jarhmander
14a685af77 use Unicode for Windows error messages (#521) 2021-01-22 08:35:09 -07:00
Jarhmander
f74a9dea56 use lowercase winbase.h for Windows (#520) 2021-01-22 08:35:02 -07:00
Matthew Flatt
e4518f662d allow #f argument to continuation-mark-set->{list[*],iterator}
There's a small performance advantage in avoiding a call to
`(current-continuation-marks)`. CS already allowed #f, but did not
handle it correctly.
2021-01-20 07:44:11 -07:00
Matthew Flatt
3ca0799714 cs: fix system.rktd 'link entry on Unix 2021-01-18 08:21:45 -07:00
Bogdan Popa
6b0b3e0a1e
ios: constrain recent allocation segments generation, fix for tarm64->tarm64 cross-compilation
Includes new `force-host-out?' arg to `compile-to-file'.
When the host and target machines match during
"cross"-compilation (eg. M1 Mac to iOS), we still need to generate
host .so files so that the build works out.
2021-01-18 07:53:54 -07:00
Bogdan Popa
764b552ac5 bc: fix build for iOS
`MAP_JIT' is available but does not work and `pthread_jit_write_protect_np'
is not available at all on iOS.
2021-01-18 07:50:37 -07:00
Bogdan Popa
c1159fb02e
cs: add support for cross-compiling to iOS
Includes documentation notes about cross-compiling CS for iOS
and makefile improvements.

The changes also include improvements to `raco exe`.
Racket CS cannot currently read fasl files for platforms other than
the host, but `compiler/embed` has to be able to read compiled code in
order to figure out what code needs to be embedded into an output
image and which runtime paths need to be included.  This change makes
it so that host code is used to figure all of that information out,
but that code is then replaced by target machine code before it is
written to the output image. The new logic only applies when the
right cross-compilation flags are set (per `cross-multi-compile?`).
2021-01-17 08:16:02 -07:00
Matthew Flatt
b09e10d066 cs: prevent a future from waiting on a semaphore
A `semaphore-wait` or `semaphore-post` has a shortcut that uses a CAS
operation, which means that a future could affect a semaphore if it's
allowed to take that shortcut. But futures aren't supposed to succeed
in that way, because thread-level synchronization should generally
suspend a future. Disallow the shortcut when in a future.
2021-01-15 16:00:25 -07:00
Matthew Flatt
e56d8c5ded cs: fix make-ctype on converter that accepts extra arguments
Related to #3457
2021-01-15 12:49:54 -07:00
Gustavo Massaccesi
9079d1b3d7 cptypes: fix arity in primitive reduction 2021-01-13 10:46:14 -03:00
Matthew Flatt
c64bf5d961 expander: repair for cross-module inlining during recompilation
When recompiling from machine-independent form to an VM- and
platform-specific form, cross-module inlining could fail due to an
module path index being resolved in the wrong mode (loading versus
non-loading).

As a concrete example, "racket/draw/private/bitmap.rkt" tended to be
recompiled in a way that did not inline `_ubyte` as `_uint8`, which in
turn made `ptr-set!` and `ptr-ref` operations much slower, which would
make certain bitmap operations drastically slower.

Related to racket/drracket#350
2021-01-12 20:15:38 -07:00
Matthew Flatt
7a52e81c33 raco setup: don't count stdout/stderr output as failure
Although compiling modules really should not write output, one problem
is that `parser-tools/yacc` has long reported shift/reduce conflicts
to stderr.

Only parallel mode was treating stdout/stderr output as failure, which
made `raco setup` inconsistent. Make parallel mode allow output, like
sequential mode does.

Related to #3457
2021-01-12 06:46:34 -07:00
Matthew Flatt
36e04fdbcd Racket HISTORY.txt notes for v8.0 2021-01-09 09:53:38 -07:00
John Clements
259f92a5a4 Post-release version for the v8.0 release 2021-01-08 12:40:02 -08:00
Matthew Flatt
1d0fd9c40b cs & thread: fix thread termination with pending timeout callback
In other words, follow a note on line 77 of "atomic.rkt":

     ;; There's a small chance that `end-atomic-callback`
     ;; was set by the scheduler after the check and
     ;; before we exit atomic mode. Make sure that rare
     ;; possibility remains ok.

That note was originally written in the context of changes for
futures, but it also applies to plain old thread scheduling, where
`engine-timeout` can be installed as a callback, but it's not allowed
if an engine isn't running.
2021-01-08 13:23:19 -07:00
Matthew Flatt
f347fe299a cs & io: fix atomic-mode step in sync/enable-break 2021-01-08 13:23:19 -07:00
Sorawee Porncharoenwase
c81b628282 Rename define-simple-macro to define-syntax-parse-rule
This PR is based on @lexi-lambda's #1310.
It resolves the conflicts in the mentioned PR and
adjusts the version so that it's up-to-date.
2021-01-07 17:32:25 +01:00
Sorawee Porncharoenwase
5ee0f73957 further simplification 2021-01-07 09:52:16 -05:00
Sorawee Porncharoenwase
64067704bc reduce unnecessary vector-ref 2021-01-07 09:52:16 -05:00
Sorawee Porncharoenwase
6ace62a717 list: optimize in-combinations and combinations
This PR in a sense reverts f83cec1b04 and attempts to directly fix
the bug that the commit tries to address with an approach similar to the
original one.

The problem with the aforementioned commit is that, Gosper's hack
only works efficiently when the length of `l` is small enough that
the number representation can fit into a fixnum
(so that all bit operations take constant time).
When the length of `l` is large, the number representation could
become a bignum with length proportional to the length of `l`.
This is not ideal because it causes the time complexity of the algorithm
to be `O({|l| choose k} |l|)` instead of `O({|l| choose k} k)`, which
would be a significant performance degradation when `|l|` is much
larger than `k`.
2021-01-07 09:52:16 -05:00
sorawee
d40c4d31c7
bc and cs: make srcloc->string compatible
Currently, in Racket BC, the following program:

```
(srcloc->string (make-srcloc "x.rkt" #f #f 90 #f))
(srcloc->string (make-srcloc "x.rkt" #f 80 #f #f))
(srcloc->string (make-srcloc "x.rkt" #f #f #f #f))

(srcloc->string (make-srcloc "x.rkt" #f 80 90 #f))
(srcloc->string (make-srcloc "x.rkt" 70 #f 90 #f))
(srcloc->string (make-srcloc "x.rkt" 70 80 #f #f))
(srcloc->string (make-srcloc "x.rkt" 70 80 90 #f))
```

results in:

```
"x.rkt::90"
"x.rkt::80"
"x.rkt::-1"
"x.rkt::80"
"x.rkt:70:90"
"x.rkt:70:80"
"x.rkt:70:80"
```

This output is very confusing and inconsistent.
When we see "x.rkt::90", we can never be sure if it's a srcloc
whose position is 90, or a srcloc whose column is 90.
The same applies for "x.rkt:70:90".

Moreover, the srloc "x.rkt::-1" is weird and is arguably incorrect
(see #1371).

For CS, the output would sometimes contain `#f`, and that is fixed
here by not trying to add position information when it's not available.
2021-01-07 07:44:29 -07:00
Matthew Flatt
bdc43a891a cs: force all foreign callbacks to be in atomic mode
Non-atomic mode is questionable at best with BC, and more so with CS.

With BC, a thread swap at least copies the fragment of the C stack
that is between a foreign call and a callback; that can work with some
C libraries, but it goes wrong often enough that it really shouldn't
be relied on. On the plus side, if it's going to go wrong, at least it
tends to go wrong right away (i.e., something in the C frame tends to
get broken in normal runs).

With CS, the C stack is not captured as part of a thread, and so
non-atomic mode 's even more broken. Non-atomic mode could work if you
know that no other thread is running that can involve foreign calls
and callbacks, but that assumption is usually not a good one. Worse,
when things finally go wrong, it's likely several scheduling steps and
thread interleavings away from the problem (e.g., #3459).

There's a chance that this change will stop some existing programs
from working ok on CS. It's more likely to make existing programs work
as intended on CS; the common case is that atomic mode is technically
needed even though non-atomic mode happened to work in practice with
BC.
2021-01-07 05:39:35 -07:00
yjqww6
e71c217758
cs: inline non-authentic struct predicate 2021-01-06 13:29:07 -07:00
Sorawee Porncharoenwase
f41b180b48 fix typos in datum->syntax error message 2021-01-06 14:12:12 -05:00
Pavel Panchekha
b56276c670 Allow variables in unquote-splicing terms
I think that in general, `null-terminated?` should admit all patterns
that _could_ match a list, instead of just the ones that _only_ match
a list. That means that `(app f)` patterns and many others should also
be valid, though those are harder to implement, so I haven't tried
those yet.
2021-01-04 18:42:30 -06:00
Matthew Flatt
4c6bb055b0 cs: fix transparent internal structure types
Commit d96273bc0a broke internal "system" structures in the expander
that need to be transparent.
2021-01-04 06:28:32 -07:00
Matthew Flatt
d96273bc0a object-name: return #f for some built-in kinds of values
This change is mostly for making CS consistent with BC, but in the
case of `(object-name #'x)`, it also makes BC consistent with BC
before the macro-expander rewrite.

Closes racket/pconvert#9
2021-01-03 09:49:01 -07:00
Matthew Flatt
ecd2234d56 syntax/module-reader: make language name after meta-reader syntax-original?
Thanks to Robby for the test.
2021-01-02 16:44:28 -07:00
Matthew Flatt
7438586cf0 cs & thread: fix atomic timeouts
Commit 9a3eb15d8b broke atomic-timeout handling. As aresult, for
example, using the scroll thumb on Mac OS could freeze DrRacket as
long as something is running for a canvas refresh.
2021-01-02 08:22:14 -07:00
Matthew Flatt
f299c4304d Chez Scheme: save an instruction on record predicates
Combine separate subtraction and comparison instructions into one in
the case of non-sealed record types.
2020-12-31 07:43:46 -07:00
Matthew Flatt
30eb35b99c cs & schemify: improve folding of procedure? and procedure-arity-includes? 2020-12-30 17:14:43 -07:00
Matthew Flatt
23300fd18d cs: use nongenerative records in core 2020-12-30 15:34:46 -07:00
Matthew Flatt
e604c2deb9 Chez Scheme: change record-type predicate to constant-time
Change the representation of records to keep an ancestor vector
instead of just a parent, so a record-type predicate (for a non-sealed
type) can be constant-time.
2020-12-30 14:02:38 -07:00
Matthew Flatt
a8819af26a cs & schemify: further refinments to left-to-right and letrec
More cases where the code can be mostly left alone, and then cp0 and
company can make further improvements.
2020-12-30 09:23:29 -07:00
David Van Horn
001ad13297
Check numeric argument to real->decimal-string
Closes #3565
2020-12-30 05:09:14 -07:00
Matthew Flatt
15bda57d77 cs & io: fix UDP receive poller registration
Closes #3590
2020-12-30 05:05:28 -07:00
Matthew Flatt
dbe36162ac cs: fix some predefined struct-operation procedure names
Closes #3592
2020-12-30 04:54:06 -07:00
Matthew Flatt
c7ca4414ca cs & io: small clean-ups to seconds->date
Streamline some things that probably needed to be different along the
way.
2020-12-30 04:49:48 -07:00
Matthew Flatt
4b7b1872dc version bump for seconds->date change 2020-12-30 03:44:14 -07:00
shuhung
4b4ed24c65
Implement seconds->date in the io layer 2020-12-30 03:41:33 -07:00
Matthew Flatt
4936977c56 cs & schemify: prevent reorder of allocation and continuation capture 2020-12-29 16:23:47 -07:00
Matthew Flatt
95e5acdb0d Chez Scheme: enable more let lifting
For example, allow
  (cdr (let ([x (f)]) (cons x x)))
to be turned into
  (let ([x (f)]) (cdr (cons x x)))
and then just
  ($value (f))
2020-12-29 14:07:43 -07:00
Matthew Flatt
ea96e2d304 add unsafe-set-immutable-{car,cdr}!
Reluctantly, with intentionally oxymoronic names, and with the key
caveat: using these requires making correct assumptions about Racket's
implementation.

With BC, a related assumption was that `unsafe-set-mcar!` and
`unsafe-set-mcdr!` mutate pairs, but that's not the case with CS. So,
adding these functions supports a kind of portability between BC and
CS.
2020-12-29 08:55:40 -07:00
Matthew Flatt
becf34a79b expander: fix check on syntax-local-lift-provide
Closes #3589
2020-12-28 14:07:10 -07:00
Matthew Flatt
70a600e1b5 build-instruction typos and clarifications 2020-12-27 19:08:19 -07:00
Matthew Flatt
8869f0eb9e Chez Scheme: remove a debugging leftover
A do-nothing loop, which was probably a debugging check at some point,
wasn't correct and could break vfasl loading.
2020-12-26 10:14:57 -07:00
Matthew Flatt
4d7f52e7dd expose WTF-8 converters on all platforms 2020-12-25 08:00:32 -07:00
Matthew Flatt
dd1061f069 cs & io: fix conversion from UTF-8-ish
The UTF-8-ish decoder incorrectly allowed a surrogate pair encoded as
two unpaired surrogates, and it treated an unpaired surrogate at the
of a stream as complete instead of a potential error.

Related to #3578
2020-12-24 15:43:59 -07:00
shhyou
6e58310176 Use foreign function from MSVCRT on Windows 2020-12-24 10:14:41 -07:00
Bogdan Popa
f4cd7ab8a0 pkg: improve CI template for new packages
Related to #1500.

This improves the following aspects of the CI config:

* The config now tracks the current stable version of Racket so
package authors don't have to remember to upgrade the config on new
releases.  This is a double-edged sword, because it makes it easy to
use features of new Racket version and potentially break
backwards-compatibility by accident.  Running CI against a set of
static Racket versions doesn't have this problem since any such change
would end up failing.  Maybe a better change here would be to
interpolate the current `(version)` into the CI file instead.

* The job is now set to fail on the first error it encounters on the
assumption that most packages fail due to internal issues and not due
to mismatches between Racket versions.  The intent with this change is
to use fewer resources overall when possible.  Additionally, the
packages' dependencies are now validated during the setup step.

* Lastly, the install step now avoids building documentation for
dependencies, which can shave off significant amounts of time.
2020-12-23 10:25:24 -05:00
David Van Horn
c93837c2ce Fix rationalize with +nan.0 tolerance
Calling `rationalize` with `+nan.0` as the second argument was causing
a "no exact representation error."  This commit changes it to produce
`+nan.0`.

There was an unexercised set of tests for `rationalize` in the test
suite which, once called, demonstrate the bug.

Those tests also specify that `rationalize` should produce an exact
result when the first argument is exact and the second is an infinity.
That's not what the implementation does; it coerces the result to
inexact.  I changed the test cases to match the implementation, which
is consistent with other Schemes (Chez, MIT) and standards (R6RS).
2020-12-23 08:20:31 -07:00
Sam Tobin-Hochstadt
6369646116 Order keys when writing JSON output.
More significant on Racket CS because ordering is often different
than creation order.

Closes #3537.
2020-12-23 10:01:08 -05:00
David Van Horn
72a852ca43 cs: fix {u,s}16vector-{ref,set!} when memory is not bytes?
When a {u,s}16vector points to memory that's not bytes (e.g. from ffi)
then referencing or setting the memory results in a Chez error:

```
foreign-set!: unrecognized type 'int16
```

The fix is to change the type argument to `'integer-16` and
`'unsigned-16`.
2020-12-23 07:49:23 -07:00
Matthew Flatt
cc9fc20a07 raco dist: signing repairs for ARM Mac OS 2020-12-22 15:55:47 -07:00
Matthew Flatt
d7e9628caf clean up some debugging leftovers 2020-12-22 13:07:15 -07:00
Matthew Flatt
a450246ee7 mach-o: infer machine type instead of depending on cross information
Directly inferring the machine type works more easily for some Racket
CS build steps.
2020-12-22 12:58:17 -07:00
Matthew Flatt
15ab674ef8 ffi/unsafe/objc: repair use of objc_msgSendSuper_stret
TTo keep stack alignment correct, the `objc_msgSendSuper_stret`
function needs to be used with a structure return type on i386,
instead of making the implicit return-pointer argument explicit.
(For BC, libffi apparently makes the wrong style work anyway.)
2020-12-22 10:51:54 -07:00
Matthew Flatt
b8f0c96756 Chez Scheme: repair i386 Mac OS __collect_safe ABI
A wrapper to align the stack during activation was dropped if the
return type was `void` for a foreign callable, and a callee-popped
argument was not handled right for a foreign call.
2020-12-22 10:51:45 -07:00
Matthew Flatt
33fd201947 Chez Scheme: revert incorrect cp0 simplification
It's not necessarily ok to inline a function wrapper by
`make-wrapper-procedure`, because the wrapper might get mutated. We
could add immutable wrapper procedures, but we can also just revert to
a previous approach for code that needed the optimization.
2020-12-21 16:46:21 -07:00
Matthew Flatt
0041354e1f fix some uses of peek-bytes-avail! that do not expect specials
Closes #3572
2020-12-21 08:06:43 -07:00
Matthew Flatt
c93e4f1328 cs: repair ctype alignment
Currently, this repair matters only for PPC32 Mac OS, which is the
only place where alignment of some primitive atomic type is not the
same as its size.
2020-12-21 07:31:09 -07:00
Matthew Flatt
8cd96ec5df bc: repair for foreign callbacks
Fix an array whose size needs to be connected to the number of
arguments to `ffi-callback-maker`.
2020-12-20 20:35:49 -07:00
Matthew Flatt
763c5465f6 revert argument change in #%foreign exports
The changed functions are documented and turn out to be used by the
`gui` package.
2020-12-20 16:51:22 -07:00
Matthew Flatt
c006fa902f ffi/unsafe: add #:varargs-after to function-type options
Needed on ARM Mac OS to call a function like `fcntl`.
2020-12-20 13:32:36 -07:00
Matthew Flatt
6033237ed6 Chez Scheme: generalize __varargs to (__varargs_after <n>)
The non-standard ARM Mac OS ABI doesn't just use a different
convention if the function has varargs: it puts each vararg in a
different place than a non-vararg argument of the same type and
position. So, `foreign-procedure` and `foreign-callable` need to know
where varargs start. A `__varargs` declaration is shorthand for
`(__varargs_after 1)`.

For PPC32 Mac OS, we retain the trick that makes varargs foreign calls
work without a `__varargs` declaration, but `(__varargs_after <n>)`
fixes up callable support --- in the extremely unlikely case that
someone needs general varargs callables on PPC32 Mac OS.
2020-12-20 11:21:20 -07:00
Matthew Flatt
0ce89f53c4 Chez Scheme: repair for call-with-values ... values cp0 conversion
Closes #3576
2020-12-20 09:09:54 -07:00
Matthew Flatt
72d278cb84 cs: take advantage of new lifting in Chez Scheme
Since Chez Scheme now performs the kind of closure conversion that
Racket does --- ensuring that a closure is not allocated if it is
bound to an identifier that is used only in application positions ---
the variant in schemify is not longer run. The hacky macro-based
lifter in the "rumble" layer can also go.

The lifting pass is still preserved in schemify, because it is still
useful to cify. It's not clear whether interpreter mode (which is used
during macro expansion for compile-time code that doesn't cross a
module boundary) is better off with or without schemify's lift, but
it's gone for now.
2020-12-20 08:18:51 -07:00
yjqww6
97d9825801
ChezScheme: Add a pass to lift well-known closures 2020-12-20 08:00:52 -07:00
Matthew Flatt
f62e97d8b6 Chez Scheme: repair for 32-bit Windows makefile 2020-12-19 20:37:13 -07:00
Matthew Flatt
4d0aa443b1 cs & thread: fix problems with sync and breaks
This commit fixes two bugs:

 * `sync/enable-break` didn't implement the guarantee that an event is
   selected or a break exception raised, but not both; the problem was
   in the handling of making the break-enable state ignored after
   committing to an event

 * `sync` didn't cancel asynchronous pending commits when a break is
   received at certain points; the bug in `sync/enable-break` masked
   this bug for existing test cases

Closes #3574
2020-12-19 16:06:16 -07:00
Matthew Flatt
c05d0a6fa5 Chez Scheme: repair to support vfasl boot in Rosetta
When Rosetta 2 runs x86_64 code, it doesn't enforce W^X, but the
`read` system call still refuses to write into executable memory.
2020-12-19 10:53:47 -07:00
Matthew Flatt
ec064bee31 cs: improve error reporting for FFI conversions
Match the error messages from BC.
2020-12-19 08:28:15 -07:00
Matthew Flatt
585f9d8201 mach-o: fix linkedit vm length when ad hoc signing 2020-12-19 07:08:59 -07:00
Sam Tobin-Hochstadt
0e4f57f44c Enable inlining for define-inline calls as arguments.
A seemingly-unintentional choice made the following not behave
as expected:

    (define-inline (f x) (+ x 1))
    (f (f 2))

because the `(f 2)` was not inlined.

Reported by @mflatt and Liwei Chou.
2020-12-18 13:53:09 -05:00
Matthew Flatt
b7c0130a75 cs: new vfasl writer to support cross compilation
Replace the vfasl writer (which was in C) with a new implementation
(in Scheme). The main result is that the vfasl writer can be used in
cross-build mode.

Racket uses the vfasl format for its boot images, because they can
load faster --- cutting the Chez Scheme plus boot files startup time
in half, which saves about 40msec on a typical machine. That's not
enough to matter for something like DrRacket, but it can matter for
small Racket scripts. Formerly, cross builds disabled vfasl
generation.

A vfasl file is roughly an image of code and data as it will appear in
memory, and a relatively fast linking step makes the image work in a
running process. The old implementation was in C because it reused GC
structures and code, treating fasl creation as copying objects into a
vfasl image instead of a new generation. The new implementation is
more like a fasl reader, loading objects into a vfasl image instead of
the live heap. The two implementations are about the same amount of
code and both involve a certain amount of repeated implementation
(i.e., imitating a collection or fasl load), but the Scheme
implementation is more flexible and works for cross compilation.
2020-12-18 07:36:25 -07:00
Ryan Culpepper
a08a6b4904 fix custodian-managed-list: omit custodian-boxes 2020-12-17 14:32:25 +01:00
Matthew Flatt
bcfbf2249e cs: avoid race with GC in (current-memory-use 'cumulative)
Thanks to Alex Harsanyi for reporting the problem.
2020-12-15 19:09:56 -07:00
Matthew Flatt
4590c51d32 cs: declare a no-return call 2020-12-14 19:04:02 -07:00
Sorawee Porncharoenwase
eff84fa302 cs: kill accidentally added debugging print 2020-12-14 19:03:03 -07:00
Matthew Flatt
0a28dd1064 cs: adjust result-arity error messages
Relevant to #3325
2020-12-14 16:10:14 -07:00
Matthew Flatt
f76b814dd7 cs: tweaks for mpairs 2020-12-14 15:10:38 -07:00
Matthew Flatt
0561d71e60 reader: fix imprecision reading some flonums
Reading `1.0e45` produced a different (and less precise) result than
`1e35`. The problem was in the reader's fast path for simple flonum
conversions, where it converts the mantissa and exponent separately
and then combines them. 10^44 is not represented exactly as a flonum,
so there's imprecision when multiplicy it by 10 versus multiplying
1e45 by 1.

Closes #3548
2020-12-14 13:41:11 -07:00
Matthew Flatt
986c73244e racket/port: fix spinning by peeking-input-port on blocked input 2020-12-14 10:13:18 -07:00
Matthew Flatt
a959c7f988 cs: enable GC during atomic callbacks
Callbacks from C generally need to be in atomic mode, but they don't
need to have interrupts disabled at the Chez Scheme level, because
that disables GC.

Without this change, dragging a scrollbar or resizing the window in
DrRacket would suspend GCs as long as the mouse button is pressed ---
which could allocate arbitrary amounts of memory fairly quickly
meanwhile.
2020-12-14 07:17:24 -07:00
Matthew Flatt
635005e882 Chez Scheme: unbreak $app/value rendering for expand/optimize 2020-12-13 19:59:19 -07:00
shuhung
2c26dc1e1a
Format the name of continuation prompt tags
This change recovers Racket-BC style formatting
of continuation prompt tags for Racket CS.
2020-12-13 16:29:14 -07:00
Matthew Flatt
b4a3c7d3da Chez Scheme: unbreak app rendering for expand/optimize
Also, fix some cp0 tests for interpret mode.
2020-12-13 11:06:53 -07:00
Matthew Flatt
1e19e660c9 expander: track core #%datum expansion in 'origin 2020-12-12 20:23:35 -07:00
Matthew Flatt
400f4fa4fb expander: 'implicit-made-explicit property on introduced #%app, etc. 2020-12-12 11:02:58 -07:00
Matthew Flatt
79ccd514c3 Chez Scheme: allow some extra inlining of system primitives
Cross-library inlining is willing to inline a procedure body that
refers to a system primitive, but wasn't willing to propagate a
system primitive directly. Enable that, and use it to simplify
`unsafe-struct` inlining.

Related to #3546
2020-12-12 10:30:40 -07:00
Matthew Flatt
e7cef677ad expander: attach original property to #%app made explicit
Copy any syntax-original property from the parentheses assodictaed
with a `#%app` made explicit, so that originalness is tracked in
the 'origin property.
2020-12-12 08:50:03 -07:00
Matthew Flatt
426b6adc79 bc: sync expanded expander 2020-12-12 08:50:03 -07:00
Matthew Flatt
6603fe3ad4 cs: improve single-value and no-return tracking
New `#%app/no-return` and `#%app/value` functions at the Chez Scheme
level allow schemify to communicate that function calls will not
return or will return a single value. The schmeify pass may have this
information because a Racket-level primitive is declared that way
(such as `error` or `raise-argument-error` for no-return, or most
functions for single-valued) or because single-valuedness is inferred.

There's currently no inference for no-return functions, because those
are relatively rare. An `#%app/value` is used by schemify only for
imported, non-inlined functions, since cp0 can already deal with local
functions and primitives.

There's a start here at adapting the "optimize.rktl" test suite for CS
--- and that effort triggered these improvements plus some other
low-hanging fruit. But a lot more is needed to adapt "optimize.rktl"
and to make some additional optimizations happen.
2020-12-11 13:29:35 -07:00
Matthew Flatt
d228aeb060 cs: fix name of pending-unmarshal procedures
The new encoding of struct constructors and predicates collided with
the encoding of another kind of procedures --- ones that are
unmarshaled on demand in especially large modules. The resulting
symptom was that `object-name` was broken for on-demand procedures.
2020-12-09 12:54:43 -07:00
Sam Tobin-Hochstadt
1173006212 Create racket/place/dynamic to reduce dependencies.
Also adjust implementation of th-places slightly to avoid startup
time dependencies.
2020-12-09 11:50:24 -07:00
Matthew Flatt
5986bc9250 Chez Scheme: adjust optimizer test for profiling mode 2020-12-09 09:45:38 -07:00
Matthew Flatt
e02c417de0 cs: change struct procedure representation and inlining
Avoid a global table to register structure procedures, and instead use
a wrapper procedure. At the same time, adjust schemify to more
agressively inline structure operations, which can avoid a significant
performance penalty for local structure types.

Closes #3535
2020-12-09 07:53:52 -07:00
Matthew Flatt
0de549800e Chez Scheme: repair cp0 record optimization 2020-12-09 07:53:51 -07:00
Matthew Flatt
535fa16813 Chez Scheme: make inlining see through make-wrapper-procedure
For example,

 (let ([f (make-wrapper-procedure (lambda (x) x) 2 'metadata)])
   (f 5))

optimizes to just 5.
2020-12-09 07:53:51 -07:00
yjqww6
cbd7a2b2af add cross-library inlining support for procedure with improper formals 2020-12-09 07:53:45 -07:00
Matthew Flatt
d7a226053e cs & schemify: repair treatment of property procedures
A procedures that is a value for a structure-type property was not
always inspected correctly. For example, if such a procedure was the
only one to mutate a module variable, then the variable might not be
detected as mutable.
2020-12-07 20:40:27 -07:00
Matthew Flatt
3c382284a4 cs: better equal-secondary-hash-code
Since CS doesn't use secondary hash code internally, the
`equal-secondary-hash-code` function wasn't really implemented.
Implement it reasonably for applications that might use it to
implement other data structures.

Testing exposed other problems related to error reporting for a broken
hash-function result and for using values within immutable hash
tables.

Closes #3536
2020-12-07 20:40:27 -07:00