Commit Graph

39039 Commits

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

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

* add a regression test for the set->stream fallback
2018-08-01 13:14:05 -04:00
Matthew Flatt
a0ca6d6489 doc correction
Corrects a missed update from moving text form Inside to Foreign.
2018-07-31 10:14:08 -06:00
Matthew Flatt
b7392a688e hash-iterate-value & co.: add an optional bad-index result
The new argument to `hash-iterate-value` and most other
`...-hash-iterate-...` functions determines a result to be returned in
place of raising a "bad index" exception.

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

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

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

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

early enough. Fix post-schemify optimization for `procedure?
by adding both forms of an import name to the `imports` table.
Fix a problem with inlining operations passed to an inlined
function (as reflected by the addition of `find-known+import`).
2018-07-28 15:07:37 -06:00
Matthew Flatt
fa93b55108 make benchmark driver work right with racketcs 2018-07-28 15:07:37 -06:00
yjqww6
759c71e158 fix a broken pattern-expander example (#2197)
pattern expanders shouldn't use `syntax-protect` on their results, and so they shouldn't use `syntax-rules`
2018-07-28 12:18:40 -04:00
Matthew Flatt
a447b5bf6b expander: improve some errors at phase >= 1
At phase 1 and higher, the expander tentatively allows an unbound
identifier so that, for example, `define-for-syntax` can define a
helper function syntactically after a compile-time expression that
uses the helper. While unbound references eventually trigger an error,
the reordering can be consuing, as in the example

  #lang racket

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

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

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

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

Closes #2167
2018-07-27 12:29:59 -06:00
Matthew Flatt
031564b28c expander extract: add --local-rename to minimize startup diffs
The expander's output normally uses a distinct symbolic name for every
distinct binding within a linklet. That property is useful for
consumers like schemify, but it's counterproductive for minimizing the
diff in changes to "startup.inc", since the traditional Racket
compiler doesn't need that guarantee. Use `--local-rename` to generate
"startup.inc", which should make future diffs smaller and more
composable after changes to the expander.
2018-07-27 12:29:59 -06:00
Alex Knauth
f4f22404b3
syntax-parse docs: small examples for #:with, #:attr, #:fail-when, and #:fail-unless (#2185)
* small examples for #:with, #:attr, #:fail-when, and #:fail-unless

* add pattern-directive keywords to doc-index
2018-07-27 11:45:46 -04:00
Leif Andersen
cb0d79a8ae
Ignore this PR (#2189)
Fix bug in serialize test

/ -> root dir

On windows `/` isn't enough to make a complete path.
2018-07-26 14:52:31 -04:00
Matthew Flatt
0b9a7587f6 expander/flatten: better help, error reporting, and - mode for ++knot 2018-07-25 21:27:36 -06:00
Matthew Flatt
a41f58f9d7 cs: use call-setting-continuation-attachment 2018-07-25 19:32:29 -06:00
Matthew Flatt
60977b36c7 cs: remove useless call in delimiting continuations 2018-07-25 16:28:07 -06:00
Ben Greenman
68a83680e0 doc: remove duplicate index entry
Remove the second index entry for `'not-free-identifier=?`
2018-07-24 17:28:28 -04:00
myfreeweb
c7c4efca95 Add FreeBSD/aarch64 platform 2018-07-24 13:14:22 -06:00
Ben Greenman
4c672a5b6a typo: 'orig-d' -> 'orig-id' 2018-07-23 22:56:18 -04:00
Ben Greenman
e97717ef2b pkg new: clarify 'module+ main' and 'module+ test' purpose
- edit the comments, thanks to John B Clements and Alex Gian and Alex McLin
  and Phil McGrath
- add simple example code
2018-07-22 00:23:33 -04:00
Leif Andersen
eaaede9c2c
Fix fasl bug in Racket 7.0 beta! (#2178)
* Fix fasl bug in Racket 7.0 beta

The following program causes racket to error in Racket 7.

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

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

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

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

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

* Add similar tests to serialize library.

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

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

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

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

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

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

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

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

* Move from serialize to relative path.

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

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

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

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

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

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

* Add docs+tests.

* Add a history note.
2018-07-13 13:49:29 -04:00
Tong-Kiat Tan
cc4daf074f Typo (#2169)
* Fix typo for style.scrbl

* Fix typo for scribble.scrbl
2018-07-13 13:49:00 -04:00
Leif Andersen
090eed4b28
Add option to create relative paths for 'serialize' (#2166)
* Add option to create relative paths for 'serialize'

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

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

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

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

* Update serialize to use relative-path.

* Add tests.

* And update docs.
2018-07-12 09:12:48 -04:00
Matthew Flatt
80e353c143 expander: fix order of unbound-identifier compilants at phase > 0
Closes #2167
2018-07-11 04:25:43 -06:00
Matthew Flatt
6bc8369af5 remove accidentally committed debugging in test 2018-07-11 04:17:42 -06:00
Sam Tobin-Hochstadt
738fe8a44f decompiler: print void in a read-able form except under quote. 2018-07-10 11:24:51 -04:00