Commit Graph

5118 Commits

Author SHA1 Message Date
Matthew Flatt
99af295d99 cs: fix constant-time list?
Closes #3097
2020-04-09 09:44:06 -06:00
Sam Tobin-Hochstadt
c81689bf9f Declare loop-updated variable outside the loop.
Found by scan-build.
2020-04-08 15:03:34 -04:00
Sam Tobin-Hochstadt
92c1ba9a62 Free buffer in error case.
Found by scan-build.
cc @pmatos.
2020-04-08 15:03:34 -04:00
John Clements
36bb3bc21f Post-release version for the v7.7 release 2020-04-08 00:23:46 -07:00
Matthew Flatt
f673534ad7 cs: fix place root for accounting
Avoid charging a thread for a place's allocation just bacuse it refers
to the place.
2020-04-06 09:25:47 -06:00
Matthew Butterick
d396c70d0e
correct function name in error messages
needs to be `s-exp->fasl` not `fasl->s-exp`
2020-04-05 11:30:02 -07:00
Matthew Flatt
282ec8125a cs: use fused garbage collection and memory accounting
Chez Scheme now supports a single-pass combination of `collect` and
`compute-size-increments`, which makes a GC with accounting about
twice as fast. Meanwhile, other GC improvements reduce non-accounting
full-collection times by 10-20%.

Much of the GC implementation is now generated from a "Parenthe-C"
description, so update the bootstrap process for that step.
2020-04-04 10:43:58 -06:00
Matthew Flatt
5c77bfced9 further signed-vs-unsigned repairs to time handling
Changing the result of cpu-time functions to unsigned suggests
further corrections to avoid overflow.
2020-03-28 09:11:38 -06:00
Paulo Matos
9c2b84d849 Change return type of rktio_get_milliseconds to be unsigned
This fixes a major issue in arm 32bits, detected by ubsan, where
conversion of type to milliseconds results in overflow.

```
rktio_time.c:92:21: runtime error: signed integer overflow: 1584975753 * 1000 cannot be represented in type 'long int'
```
2020-03-28 08:55:24 -06:00
Matthew Flatt
9cb6debf44 cs & thread: memory accounting corrections
Repair trigger of a GC when using `current-memory-use`
on a custodian when a limit was just installed.
2020-03-28 08:39:42 -06:00
Paulo Matos
7621ccbb7b
Explicit zero assign to avoid warning (#3082)
GCC 9.3 things that `h2` might reach line 385 uninitialized.
```
./hash.c:385:14: warning: 'h2' may be used uninitialized in this function [-Wmaybe-uninitialized]
  385 |       h = (h + h2) & mask;
      |           ~~~^~~~~
```
2020-03-27 18:37:19 +01:00
Matthew Flatt
4a2cb6f577 bc: fix optimizer bug
Local-variable type information was not properly removed from
information threaded through optimization.

Closes #3081
2020-03-24 08:51:37 -06:00
Matthew Flatt
9222a135c3 cs: reliable GC callbacks on major GCs
A Chez Scheme garbage collection involves a rendezvous among threads
that are used to implement places and futures (and potentially other
things that create Chez-level threads). The thread that is used to
drive the garbage collection was not formerly specified, and callbacks
like the GC icon in DrRacket can only be run in the initial thread.
When a major collection was run in a non-initial thread, the callback
was simply skipped.

The Racket branch of Chez Scheme now drives a collection in the
initial thread whenever that thread is active. In Racket CS, the
initial thread can be inactive if it's waiting for external events,
and a place can meanwhile trigger a GC. Now, when the Racket CS GC
callback is called for a major collection in any thread other than the
initial one, it defers the major collection to an asynchornous
callback in the main thread (and meanwhile performs a minor
collection).

So, a major collection might now be delayed by just a little while if
the main thread is inactive, such as when it's waiting for external
events, but callbacks like the GC icon in DrRacket will be reliably
invoked for major collections.
2020-03-23 17:50:04 -06:00
Paulo Matos
4a62408b71
Fix typo in comment 2020-03-23 16:58:33 +01:00
Sorawee Porncharoenwase
3c966bc297 Unbreak syntax/to-string tests
It's still unclear what the specification of syntax->string regarding whitespace
before closing parens should be. The implementation also has not dealt with
the issue. This PR therefore removes whitespace before closing parens from
the tests.

Once the discussion at
https://github.com/racket/racket/issues/3071#issuecomment-601984438
has reached a conclusion and implemented, we can add these tests back.
2020-03-22 20:46:12 -04:00
lkh01
d9c064d06c make syntax->string work with unquote, quasiquote, etc. 2020-03-22 15:05:01 -04:00
lkh01
40c589ef8a do not overwrite whitespace after a quote 2020-03-22 15:05:01 -04:00
lkh01
2a8e10b31a account for difference between quote and ' in syntax->string 2020-03-22 15:05:01 -04:00
Matthew Flatt
9effeef7ab cs: fix stencil-vector HAMT for 32-bit platforms 2020-03-17 18:24:30 -06:00
Matthew Flatt
3390896a59 schemify: clean up unnecessary lets in interpreter
Collapse `let` with unused binding to `begin`, and then
collapse resulting nested `begin`s.
2020-03-17 18:24:30 -06:00
Sam Tobin-Hochstadt
c7a9690143 Fix recursive make invocation.
Eliminates warning in DrDr.
2020-03-16 13:35:59 -04:00
Matthew Flatt
8f256c9261 cs: fix error-print-width handling when output just fits the limit
For example, if the limit is 5, then "abcde" should print as "abcde",
not "ab...".
2020-03-13 16:12:34 -06:00
Sorawee Porncharoenwase
74c0844101 Also fix ~.a in 3m 2020-03-13 15:20:10 -06:00
sorawee
8f286fc810 Fix #2986: error-print-width 3 shouldn't error 2020-03-13 15:20:10 -06:00
Matthew Flatt
c52d45613b minor whitespace corrections 2020-03-13 11:32:49 -06:00
Matthew Flatt
f1a177e880 cs: fix applicable struct implemented with applicable struct 2020-03-13 11:14:39 -06:00
Matthew Flatt
edfdcb0b6d add call-in-continuation
The `call-in-continuation` function generalizes applying a
continuation to values by accepting a thunk that is called in the
restored continuation. In other words, insteda of having to use the
pattern

 ((call/cc (lambda (k)
             .... (set! saved-k k) ...
             (lambda ()
               original-result))))
 ...
 (saved-k (lambda () new-result))

The extra call and thunk on the capture side can be omitted:

 (call/cc (lambda (k)
            .... (set! saved-k k) ...
            original-result))
 ...
 (call-in-continuation saved-k (lambda () new-result))

At the Chez Scheme level, a `call-in-continuation` in tail position
within a function can avoid forming a closure for its second argument.
The `call-in-continuation` function at the Racket CS level doesn't yet
provide that benefit.

The `call-in-continuation` operation is called `continuation-slice` in
Feeley's "A Better API for First-Class Continuations".
2020-03-13 09:46:12 -06:00
Matthew Flatt
9ef2124a38 speed up keyword expansion
Expansion of a procedure with keywords is quadratic due to generating
a nested sequence of `let`s, but speed it up by roughly a constant
factor by using a dintinct symbol for each nested layer.

Related to #3070
2020-03-13 09:46:12 -06:00
Matthew Flatt
f98d0a5cc1 cs: use call-in-continuation
Using `call-in-continuation` to apply a thunk within a continuation
slightly simplifies and speeds up parts of the implementation of
delimited continuations.
2020-03-13 09:46:12 -06:00
Matthew Flatt
601ffc9b36 avoid compiler warnings 2020-03-07 14:42:41 -07:00
Matthew Flatt
fab04633f3 makefile: add DISABLE_STATIC_LIBS 2020-03-07 14:24:50 -07:00
Matthew Flatt
0de88f203d struct: don't generate excessive struct-field-index code
The expansion of `struct` created far too much code to parameterize
`struct-field-index`, making expansion of a `struct` form with just
100 or 200 fields take a noticeably long time to expand.
2020-03-07 10:45:33 -07:00
Matthew Flatt
00b6803e36 cs: enable embedding in other applications
The "Inside: Racket C API" manual now has a CS part and a BC part.
2020-03-07 06:39:41 -07:00
Gustavo Massaccesi
d6d30d2fcc cs: sync with Chez Scheme change fix in cptypes 2020-03-07 08:07:30 -03:00
Matthew Flatt
e2c9544ed5 bc: fix hash-set key replacement for eq? values 2020-03-06 11:15:50 -07:00
Matthew Flatt
b4dd4684d9 cs: fix problem getting structure hash codes 2020-03-05 11:28:28 -07:00
Sam Tobin-Hochstadt
8a63d80379 Preserve undocumented args syntax class attribute.
PR #2678 unintentionally removed this attribute, but it was used
at least by "collections-lib" and "static-rename-lib".

cc @sorawee @lexi-lambda @jackfirth @rmculpepper
2020-03-04 15:05:16 -05:00
Sorawee Porncharoenwase
3043dbd35c Expose function-header's name, document attributes, fix links 2020-03-04 13:22:19 -05:00
Sorawee Porncharoenwase
1b4126d1e5 Fix a typo, add examples, switch to non-experimental form 2020-03-04 13:22:19 -05:00
sorawee
29c518abbc
Allow multiple catalogs in raco pkg install and friends
Allow `--catalog` to be specified multiple times.
2020-03-04 07:02:45 -07:00
Ben Greenman
258eee40ce
contract: use impersonator prop. for impersonator-unconstrained-domain->/c (#3055)
rename the contract property from a chaperone prop to an impersonator
prop (looks like this was an old copy/paste error)
2020-03-03 15:50:19 -05:00
James Bornholt
ac41c8a361 Make get-pure-port redirection case-insensitive
GitHub's CDN seems to have recently started returning the `Location` header for a redirect with a lowercase `l`, which breaks the redirect logic. The HTTP spec says that header names are case-insensitive, so we need to look for either version.
2020-02-25 13:38:44 -05:00
Matthew Flatt
fb620d5556 cs: constrain register-process-global to intended behavior
Make `register-process-global` check for byte strings, and avoid
retaining the byte string that it's given (in case that changes, for
example).

Closes #3053
2020-02-24 07:23:59 -07:00
Matthew Flatt
ef856eda76 cs: fix separator for embedded boot files 2020-02-22 17:32:51 -07:00
Matthew Flatt
06cbc94ced sync with updated Chez Scheme 2020-02-22 13:23:52 -07:00
Matthew Flatt
a68c8eadc6 cs: fix hash{,eq,eqv} on an odd number of arguments
Closes #3051
2020-02-21 21:26:18 -07:00
Matthew Flatt
dad9995f56 cs: add glib logging hook
Building glib-specific support into the main Racket executable is
unsatisfying, but it's consistent with Racket BC, and the alternative
is especially tedious to deal with places and namespaces and
allocation.
2020-02-20 14:52:30 -07:00
Matthew Flatt
fe64841290 cs: fix error conversion condition-who is a string
For example, `(string->symbol 10)` raises a Chez Scheme condition with
the string "string->symbol" instead of 'string->symbol.
2020-02-19 20:04:33 -07:00
Matthew Flatt
906af72f82 dump-memory-stats: report bytes used for still-marshaled bytecode 2020-02-19 17:33:49 -07:00
Ben Greenman
5377d00c90 pkg/lib: change pkg-stage contract to return set
Before: contract expected list but the function returns a set
After: contract expects a set

fix #3029
2020-02-17 16:51:17 -05:00
Matthew Flatt
3519f8f3fc racket/class: mark internal wrapped-object as authentic
Combined with a schemify improvement that inlines imported predicates
to expose the record-type test to Chez Scheme, this chage enables
cptypes to prune useless inlined `wrapped-object` selector branches.
That improvement, in turn, reduces code size and redundant checks on
objects that have contracts.
2020-02-17 10:54:05 -07:00
Matthew Flatt
c7059c7c94 cs: encode procedure methodness statically
When a `lambda` form is marked as a method (for arity error reporting)
through a property, translate that to a static flag on the procedure,
instead of a call to `procedure->method`.

The only way we have to attach static information is through the
procedure name, so the encoding already in place for "no name" and
"path-based name" is extended to support a method flag.
2020-02-17 09:02:04 -07:00
Matthew Flatt
5412a4c5fa schemify: remove procedure-naming lets
Since procedures have names that are attached more directly by the
schemify pass, remove simple `let-values` forms wrapping procedures.
This shortcut improves the result of the lifting pass in some cases.
2020-02-17 09:02:04 -07:00
Matthew Flatt
e1c1269939 cs: improve chaperoned structure-property access
Avoid looking up the property twice.
2020-02-17 09:02:04 -07:00
Matthew Flatt
cdd0659438 cs: fix GC:major logging on exit
Also, add `PLT_GCS_ON_EXIT` to force 2 major GCs on exit, which
is useful for checking peak and end memory use.
2020-02-15 09:11:44 -08:00
Matthew Flatt
e90df3f2f2 adjust build of libssl for x64-bit Mac OS 2020-02-12 13:49:21 -07:00
Matthew Flatt
760b2924c6 expander: fix typo
Misplaced paren created a misapplication of `weak-box-value`.
2020-02-11 06:37:08 -07:00
Matthew Flatt
7279a59c27 cs: improve make-struct-type on large field counts 2020-02-11 05:43:08 -07:00
Matthew Flatt
56fe13e6f7 cs: small interpreter clean-ups 2020-02-10 20:11:18 -07:00
Matthew Flatt
5e45dd2e1c cs: use anonymous-field record types
Record types with unnamed fields can be significantly more compact,
excdeption in combination with the constrain the the fields all
contain Scheme objects. Saves 2% for DrRacket's initial footprint.
2020-02-10 19:12:00 -07:00
Paulo Matos
fb63f399ef
Add option --enable-werror (#3038)
This adds configure option `--enable-werror` to `./configure` script which adds `-Werror` to build time CFLAGS.
2020-02-10 20:07:20 +01:00
Matthew Flatt
e8fa0613db cs: fix internal issues in struct [property] layer 2020-02-09 18:27:14 -07:00
Matthew Flatt
fd9a5f0357 cs: clean up and improve dump-memory-stats 2020-02-09 11:34:44 -07:00
Matthew Flatt
c5dc0841c1 cs: mark some parameters a always-succeeds 2020-02-08 14:02:15 -07:00
Matthew Flatt
a3f1ab8b60 cs: tweak for chaperoned structure reference
No need for `|#%app|` on chaperoned operation.
2020-02-08 10:13:44 -07:00
Matthew Flatt
7f729a1a2b cs: fix structure property accessor & predicate names 2020-02-08 09:06:57 -07:00
Matthew Flatt
e4c5d54e37 cs: avoid locks on struct-related tables
Avoing a lock speeds up predicates like `struct-predicate-procedure?`,
which speeds up creation of struct chaperones.
2020-02-08 08:20:06 -07:00
Matthew Flatt
1900c0e57a cs: faster struct impersonation 2020-02-08 07:42:58 -07:00
Matthew Flatt
615e4f707a cs: sync with Chez Scheme change for trap check, again
We had to give back some space savings to avoid potential problems
with allocating in the event callback and running out of stack
space[?] when passing an argument. We get to keep most of the
improvement though.
2020-02-07 16:20:21 -07:00
Matthew Flatt
595b62a038 cs: change code generated for defining module variables
Makes a small difference in code + relocation sizes (about 1%)
2020-02-07 08:57:49 -07:00
Matthew Flatt
df039c1b73 cs: sync with Chez Scheme change for trap check
Less code for a trap check saves about 5% code space for DrRacket,
which is about 2% of the overall starting footprint.
2020-02-06 18:54:35 -07:00
Matthew Flatt
65d77ee00c build 64-bit Mac OS native libraries against the 10.9 SDK 2020-02-06 15:12:47 -07:00
Leo Shen
08d33a773d net/http-client: add support of deflate content encoding 2020-02-06 11:16:32 -07:00
Matthew Flatt
ce85e3c66d ffi/unsafe: fix _enum for non-fixnums
Use `assv` instead of `assq`, because an `_enum` variant's value might
be a non-fixnum integer.

Closes #3036
2020-02-05 06:20:37 -07:00
Matthew Flatt
f615be26a3 cs: fix log-level? and related
Broken cache clearing caused out-of-date results to be returned
sometimes.
2020-02-04 18:04:52 -07:00
Matthew Flatt
e45d0ab9d8 add 'GC:major logging
Racket CS already had a form of 'GC:major logging, but normalize it
and add it to traditional Racket.
2020-02-04 17:36:51 -07:00
Matthew Flatt
4ed253d66e fix line counting with mixed CR and LF
A CR by itself could be incorrectly treated as preceding a later LF,
which would form a CRLF combination if they had been adjacent.

Closes #3033
2020-02-03 17:21:51 -07:00
Matthew Flatt
654f821919 correct pretty-print and improve consistency
Fix a regression in 712494312a, and change other other two printers to
be more consistent for

 #lang racket
 (struct s () #:transparent)
 (define a (s))
 (pretty-print (list (cons a 0) (cons a 0)))
2020-02-03 17:21:51 -07:00
Jon Zeppieri
c358df6de4 [CS] regexp-replace: handle #f submatches
A regexp can match while having sub-patterns that are not used in
the match. In regexp-replace, the "insert" argument can refer to
these unused sub-matches. If a function is given for the "insert"
argument, it will receive these unused submatches as #f values.
If a string or byte-string is given, then any reference to an
unused sub-match (by means of a back-reference) is treated as the
empty string or byte-string.

Fixes #3032.
2020-02-03 17:21:38 -07:00
Matthew Flatt
c81228f31e cs: more clearing of a terminated thread
In particular, clear out the `suspend+resume-callbacks` field so that
retaining the thread object does not retain those callbacks.
2020-02-01 08:15:50 -07:00
Matthew Flatt
67595cc255 cs: include accounting time in reports GC time
When logging GC debugging, a pecentage after the time for a GC reports
what fraction was extra steps after GCing proper, especially the extra
step of memory acounting when that is enabled.

Also, avoid Chez Scheme gensyms even more. Otherwise, using low-level
facilities like `dump-memory-stats` can force the unique name of a
gensym used for a structure type, which causes it to be permanent,
which could be exactly what you don't want when debugging a
memory-rentention problem.
2020-02-01 07:30:00 -07:00
Matthew Flatt
eeb73a6c05 expander: avoid keeping thread in registry lock
Weakly retain the lock holder in a namespace registry. Otherwise, it
can retain a thread that should have been unreachable.
2020-02-01 07:14:49 -07:00
Matthew Flatt
2c9bf94451 cs: faster struct hashing and struct->vector
Take advantage of `$record-type-field-count` to replace
`record-type-field-names`, which isn't constant-time.
2020-01-31 13:29:07 -07:00
Matthew Flatt
9a9a5eef3b cs: improve jitify letrec output 2020-01-31 06:12:42 -07:00
Matthew Flatt
cbcd9505aa racocs decompile: handle linklets in 'interpret mode 2020-01-31 06:10:33 -07:00
Matthew Flatt
4acf864b0e delay cross-system-library-subpath call
In `compiler/private/mach-o` --- which is reachable via `racket` due
to being a dependency of `setup/dirs` --- delay the call to
`cross-system-library-subpath` until needed.
2020-01-31 05:23:18 -07:00
Matthew Flatt
8da6e9bd6b cs: use black hole for unsafe-undefined representation 2020-01-30 20:18:12 -07:00
Matthew Flatt
ad9dc342f8 cs: suppress reundant letrec-variable checking
The schmiefy pass already ensures that variables are defined before
use, so skip cpvalid in Chez Scheme. The difference is tiny, though.
2020-01-30 18:59:02 -07:00
Matthew Flatt
37ce9478cd move symbol->immutable-string and keyword->immutable->string out of racket/base
Move them to new `racket/symbol` and `racket/keyword` libraries to
avoid conflicts with existing packages.
2020-01-30 15:53:16 -07:00
Matthew Flatt
fa6e7101df adjust inliner to avoid infinite inline
Fixes optimization for an expression like

 (define (f x)
   (lambda (y)
     (letrec ([recursion (f x)])
       (+ x y))))

by adjusting the inlining hueristic to support less inlining on a
second pass of `letrec` right-hand sides.

Closes #3027
2020-01-30 08:31:04 -07:00
Matthew Flatt
fb95e9312f racocs decompile: show machine code or assembly
When the "disassemble" package is installed, use it to disassemble the
machine code in a Racket CS linklet.
2020-01-29 20:01:24 -07:00
Matthew Flatt
69932f6f67 add ffi/unsafe/vm
Provide `vm-primitive` and `vm-eval` to regularize access to VM-level
primitives. Document some of the issues for interoperating across the
Racket and (Chez Scheme) VM layers.

The library could have been implemented with just `compile-linklet`
and `instantiate-linklet`, but using an underlying `primitive-lookup`
function is a little nicer.
2020-01-29 11:07:40 -07:00
Matthew Flatt
c48afdb16b repairs for arithmetic-shift
Produce 0, -1, or out-of-memory for bignum shifts. For large fixnum
shifts, check memory limits.

The repairs are mostly for Racket CS, but traditional Racket
incorrectly reported out-of-memory for 0 shifted by a positive bignum.
2020-01-26 09:18:14 -07:00
Gustavo Massaccesi
e72848fa1f fix typo in cs/README.txt 2020-01-25 16:05:52 -03:00
Matthew Flatt
9d43b62282 cs: use fxlogtest instead of (fx= 0 (fxand ...))
For the stencil-vector HAMT implementation, the difference
can be 5-10% improvement on microbenchmarks.
2020-01-24 17:33:47 -07:00
Matthew Flatt
7c06d6d4ab bump version to sync with Chez Scheme change
A more compact representation for return points tends to reduce code
by about 10%. For DrRacket, that translates to a 5% decrease in
overall footprint.
2020-01-24 17:26:13 -07:00
Matthew Flatt
dc2aa03e4e update Windows and Mac OS build instructions
Explain how to deal with the "racket-lib" that is normally included
with a source distribution, but that doesn't have dependencies
specific to Windows or Mac OS.
2020-01-23 19:07:59 -07:00
Matthew Flatt
8d6bdafb45 cs: use unsafe application after schemify
Since schemify adds its own checking for procedureness in an
application, always compile the application as unsafe at the Chez
Scheme level. This simple change saves about 5% in code size for
DrRacket, which is a 1-2% footprint saving overall.
2020-01-23 17:20:15 -07:00
Matthew Flatt
b7fcf4112a update "racket/HISTORY.txt" for v7.6 2020-01-23 13:01:26 -07:00
Matthew Flatt
17aae65664 fix 'inferred-name handling for keyword-supporting define
Closes #3009
2020-01-20 13:44:15 -07:00