Commit Graph

3389 Commits

Author SHA1 Message Date
Eric Dobson
729d2e9d4a Remove unused export.
original commit: 8e51f2b5acd9dfba558b7ef9f82684b95d8ef972
2013-12-15 14:01:03 -08:00
Eric Dobson
482a9111d7 Cleanup duplication in check-subforms-unit.
original commit: 1d0164f51b9730aa35324bda6222a5b3d718f924
2013-12-14 09:42:50 -08:00
Eric Dobson
3def8438c1 Minor cleanup in prims.
original commit: ee47fe5f259d254fbd47d2a11f6a972342de3f5b
2013-12-14 09:42:50 -08:00
Eric Dobson
593fc00875 Make better interface for properties with only booleans.
original commit: fced81a541dd620386029a52dd940d43759e51ba
2013-12-14 09:42:50 -08:00
Eric Dobson
ae129f9c90 Make syntax class for syntax properties.
original commit: 15fddbafe052a4bafd94e446a8609134a9adbe1e
2013-12-14 09:40:16 -08:00
Robby Findler
d12722eeff fix some bugs in the traversal function in any-wrap that I introduced
Also, rename the function so that errors like this don't take me as long to find

original commit: 1f1550ae5535a476ad9c2c50cdebeb41ae30c80d
2013-12-12 22:48:57 -06:00
Asumu Takikawa
14547ed763 Quote the identifier in the declaration error msg
Please merge to v6.0

original commit: 34c5b327463db014fb0d3c42922d60e75e4ada63
2013-12-12 16:25:21 -05:00
Asumu Takikawa
c95008e2c3 Better error msg for annotations on unbound ids
Closes PR 14246

Please merge to v6.0

original commit: f1d35f6ec94e1c9dff2d149c5f7f7a777a78f547
2013-12-12 16:25:21 -05:00
Robby Findler
371472e5ed fix spelling error
original commit: af8f13b16ac93c7acd50de295379dd589bb9d769
2013-12-12 15:24:02 -06:00
Eric Dobson
48dcf14b58 Add types to hasheq and hasheqv.
Merge to 6.0.

original commit: 48a16b2b8a6cb0af6607a3056f6723f34da855f3
2013-12-12 08:32:06 -08:00
Robby Findler
1fd8631786 Change contract system so that projections are more first-order friendly
The main changes are the addition of a new way to specify projections,
using the #:val-first-projection keyword argument; the main goal of the
new API is that more information can be supplied to the projection on
the server side of the contract boundary. In addition, the arrow contracts
will now, internally and in some cases (see define-module-boundary-contract)
return functions that accept one additional argument than the original
function did and then insert the name of the negative party into call sites.

The rough idea is that if you have a program like this one:

  #lang racket/base
  (define (f x) (+ x 1))
  (provide (contract-out [f (-> integer? integer?)]))

then the contract system produces something much closer to this:

  #lang racket/base
  (define (f x) (+ x 1))

  (provide (rename-out [external-f f]))
  (define (external-f neg-party x)
    (check-integer neg-party x)
    (define ans (f x))
    (check-integer neg-party ans)
    ans)

  (define local-blame-information ...)
  (define (check-integer neg-party v)
    (unless (integer? v)
      (raise-blame-error local-blame-information
                         #:missing-party neg-party
                         ...)))

where 'raise-blame-error' can now cope with blame objects that don't
have negative part information in them (when the #:missing-party
argument is supplied, essentially just reassembling the original blame
record at that point)

Then, on the client side, if we had

   (f x)

it gets transformed into

   (f '<<my-modules-name>> x)

and if we had

   (let ([g f])
     ...)

you get a slow path:

    (let ([g (lambda (x) (f '<<my-modules-name>> x))])
      ...)

(where we don't create a wrapper lambda, of course, we actually create
a procedure chaperone)

The performance improvements seem pretty good (see below for the
precise programs that I ran and the numbers I got):

  first order contract microbenchmark: 6x speedup
  higher-order contract microbenchmark: 1.5x speedup
  first-order TR contract interop micro benchmark: 6x speedup

This also improves the memory use for DrRacket by about 3% (from about
236.8 mb to 231.3 mb), presumably because more of the data structures
created by the contract system can be created only once, on the server
side.

Be aware, however, that not all combinators are using the new
projections and the code that translates between the two APIs
is slow.

Also there are a bunch of other changes that got made while I was
doing this. Most notably, the change above were not designed for the
performance improvements to arrow contracts, but to make it possible
to implement class/c contracts with a (hopefully) negligible space
overhead. That work is not yet finished, but this commit includes some
changes to the class system to prepare the way for those changes.

Unfortuantely, these changes slow down 'send' on microbenchmarks by
about 24%. The change comes from the addition of an extra 'if' (and
predicate test and possibly the extra let expresison) that's inserted
into the expansion. I'm not happy about that (I was shooting for 10%)
but I'm not sure that we can do much about it (except perhaps double
check my measurements, see below).

Other misc changes:

- improve arity mismatch error messages by including the arity of the
  given procedure (closes PR 14220)

- Adjust case-> so it generates less code. This seems to reduce the
  size of the math library .zo files by about 3% (from 10440k to
  10156k for me)

- speeds up the contract tests a bit

- move recontract out into racket/contract (also, document it)

- added define-module-boundary-contract

- streamline TR's any-wrap/c and adjust it to use
  #:val-first-projection instead of #:projection

- adjust a bunch of contracts to print more nicely

- and, of course, Rackety

--------------------------------

The precise programs that I tried and their timings (the raw data
for the performance claims above):

 #lang racket/base
(module m racket/base
  (require racket/contract/base)
  (define (f x) x)
  (provide (contract-out [f (-> any/c any/c)])))

(require 'm)
(time
 (for ([x (in-range 100000)])
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)))

pre-push timings:

cpu time: 3553 real time: 3552 gc time: 52
cpu time: 3548 real time: 3552 gc time: 52
cpu time: 3525 real time: 3525 gc time: 54
cpu time: 3547 real time: 3547 gc time: 47

post-push timings:

cpu time: 515 real time: 515 gc time: 15
cpu time: 522 real time: 522 gc time: 17
cpu time: 560 real time: 560 gc time: 19
cpu time: 514 real time: 515 gc time: 19
cpu time: 507 real time: 507 gc time: 17

A second order example using vectors (note that vector/c isn't yet
updated to the #:val-first-projection, so it will be way slower)

 #lang racket/base
(module m racket/base
  (require racket/contract/base)
  (define (f x) (vector-ref x 0))
  (provide (contract-out [f (-> (vectorof any/c) any/c)])))

(require 'm)
(define v (vector void))
(time
 (for ([x (in-range 10000)])
   (f v) (f v) (f v) (f v) (f v) (f v) (f v) (f v)
   (f v) (f v) (f v) (f v) (f v) (f v) (f v) (f v)
   (f v) (f v) (f v) (f v) (f v) (f v) (f v) (f v)
   (f v) (f v) (f v) (f v) (f v) (f v) (f v) (f v)
   (f v) (f v) (f v) (f v) (f v) (f v) (f v) (f v)
   (f v) (f v) (f v) (f v) (f v) (f v) (f v) (f v)
   (f v) (f v) (f v) (f v) (f v) (f v) (f v) (f v)))

pre-push timings:

cpu time: 744 real time: 745 gc time: 20
cpu time: 679 real time: 679 gc time: 18
cpu time: 695 real time: 695 gc time: 23
cpu time: 743 real time: 742 gc time: 21
cpu time: 780 real time: 786 gc time: 21
cpu time: 723 real time: 726 gc time: 25

post-push timings:

cpu time: 448 real time: 448 gc time: 18
cpu time: 470 real time: 469 gc time: 19
cpu time: 466 real time: 465 gc time: 16
cpu time: 457 real time: 456 gc time: 15
cpu time: 465 real time: 466 gc time: 24

Using contracts in TR

 #lang racket/base
(module m typed/racket/base
  (: f (Any -> Any))
  (define (f x) x)
  (provide f))

(require 'm)
(time
 (for ([x (in-range 10000)])
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)
   (f 1) (f 2) (f 3) (f 4) (f 5) (f 6) (f 7) (f 8)))

pre-push timings:

cpu time: 357 real time: 357 gc time: 6
cpu time: 446 real time: 447 gc time: 4
cpu time: 361 real time: 359 gc time: 4
cpu time: 366 real time: 366 gc time: 5
cpu time: 368 real time: 367 gc time: 6

post-push timings

cpu time: 63 real time: 63 gc time: 7
cpu time: 64 real time: 63 gc time: 8
cpu time: 63 real time: 64 gc time: 8
cpu time: 58 real time: 58 gc time: 8
cpu time: 59 real time: 59 gc time: 7

Slowdown for 'send':

 #lang racket/base
(require racket/class)
(define c% (class object% (define/public (m x) x) (super-new)))
(define o (new c%))
(time
 (for ([x (in-range 100000)])
   (send o m 1) (send o m 2) (send o m 3) (send o m 4)
   (send o m 5) (send o m 6) (send o m 7) (send o m 8)
   (send o m 1) (send o m 2) (send o m 3) (send o m 4)
   (send o m 5) (send o m 6) (send o m 7) (send o m 8)
   (send o m 1) (send o m 2) (send o m 3) (send o m 4)
   (send o m 5) (send o m 6) (send o m 7) (send o m 8)
   (send o m 1) (send o m 2) (send o m 3) (send o m 4)
   (send o m 5) (send o m 6) (send o m 7) (send o m 8)
   (send o m 1) (send o m 2) (send o m 3) (send o m 4)
   (send o m 5) (send o m 6) (send o m 7) (send o m 8)))

timings pre-push:

cpu time: 251 real time: 251 gc time: 0
cpu time: 275 real time: 275 gc time: 0
cpu time: 250 real time: 250 gc time: 0
cpu time: 246 real time: 246 gc time: 0
cpu time: 247 real time: 246 gc time: 0

timings post-push:

cpu time: 303 real time: 302 gc time: 0
cpu time: 333 real time: 333 gc time: 0
cpu time: 315 real time: 315 gc time: 0
cpu time: 317 real time: 317 gc time: 0
cpu time: 311 real time: 310 gc time: 0

original commit: c321f6dd0c4e2444d44b6c79a3ac49acfb9041bf
2013-12-11 12:05:30 -06:00
Vincent St-Amour
272a17c107 Remove unused type variable.
original commit: 64464faf51c07a98049509d79410060edad1d9c3
2013-12-10 11:52:37 -05:00
Asumu Takikawa
01a7caded8 Fix types for remove and friends.
A few of these had unnecessary uses of type variables.
The type for `remove*` was unsound.

Please merge to v6.0

original commit: a98e4c5474f83cc146b62baf64c3fa2ee8132fef
2013-12-09 23:59:01 -05:00
Vincent St-Amour
a8368048e2 Make type of expt more precise on floats.
Closes PR14228.

original commit: e28a860cc075445996dd6633444a1604e97565c5
2013-12-09 14:08:02 -05:00
Asumu Takikawa
11aeb527f3 Add more documentation for Procedure type
Please merge to v6.0

original commit: 1243d12248214d8e261a0496f273fe1ea7127e28
2013-12-07 22:57:53 -05:00
Asumu Takikawa
287bb05db9 Add tests for some recent base type additions
original commit: 78820bda4528ca100524d5007cf46905d039803d
2013-12-05 23:41:56 -05:00
Vincent St-Amour
5599f3b8ff Fix type expansion suggestion.
Closes PR14212.

original commit: f2de6dfee9934649d361f33b524ef0a77c38ae18
2013-12-05 11:57:36 -05:00
Asumu Takikawa
9ff3fa9ff0 Add type for regexp-replaces
Please merge to v6.0

original commit: 1f74a6713907d7e1770dc8422164ef1bb01b904f
2013-12-05 01:47:41 -05:00
Asumu Takikawa
d138d2df0c Add remaining racket/string types
Please merge to v6.0

original commit: 2d8a3cffda3cd71712b763cda1d2439c480d1bc8
2013-12-05 01:33:27 -05:00
Eric Dobson
2791f89cd2 Add #f as a special case for hash-ref, fix hash-ref!.
Closes PR 14158.

Merge to 6.0.

original commit: 258d9b8e2f53936ff166c069ca0ab267ed77f602
2013-12-01 11:25:52 -08:00
Robby Findler
459a59a954 adjust check syntax so it can show info before expansion completes
and sometimes when there are syntax errors raised

In more detail, rearrange online check syntax's internal plumbing
so that syntax objects can be handed to check syntax at any point
(via a special log message, see the changes to the docs)
not just when expansion is finished

Use this in TR to get check syntax information even when there is
a type error (and also get the check syntax information processing
started before type checking starts (altho this isn't running
in a separate place, so there is no new parallelism here))

original commit: 09920bd8ce46f15d9cf4a5066ab2cfb84bbdd417
2013-11-26 22:46:51 -06:00
Asumu Takikawa
f44c9539f0 Improve type of negate
Now for functions with simple filters, it'll negate the
filters so that, e.g., (negate string?) can be used with
occurrence typing.

Please merge to v6.0

original commit: 0f8ee738142c8e253c638c836fc1c5c893751d32
2013-11-21 22:53:04 -05:00
Asumu Takikawa
1baea70249 Caveat section on macros/phase-1+ code in TR
Please merge to v6.0

original commit: d29256eeb22c1d1cfff79d93654ede26023acf33
2013-11-21 22:53:04 -05:00
Asumu Takikawa
3ff3d7eead TR: Prevent internal error on begin-for-syntax
Closes PR 13878

Please merge to v6.0

original commit: 9da8203c9c3a7c101360f57c6721f7f1a071ca91
2013-11-21 22:53:04 -05:00
Eric Dobson
e9c9d6ae30 Improve comments and change name for unboxable-funs.
original commit: 2fd6a05d462ab7c927168693434c9e4580e6ddc8
2013-11-20 23:46:36 -08:00
Eric Dobson
5278b8ea0c Move more call-site optimization structure into the syntax class.
original commit: 69f690f4b981901e060732aaae392189e1490c14
2013-11-20 23:43:59 -08:00
Eric Dobson
26783b6c7c Make unboxed let-bindings only log their clause.
original commit: af6bc6e8e225cd5ce3bb2bdd2b64a6c362fb6d32
2013-11-20 23:43:57 -08:00
Eric Dobson
2e3f6d3ab6 Make new syntax class for all clauses.
original commit: 74ce1ea748e4d911c4edfea0c30b60ae41706d15
2013-11-20 23:39:10 -08:00
Eric Dobson
ac001357e7 Make standard syntax class so that clauses are in order.
original commit: 3681fe8105f04a173558d363ae631eae5a42fcd9
2013-11-20 23:39:10 -08:00
Eric Dobson
ed24ba5c3e Add more syntax classes for let-clauses.
original commit: 6d84fe3cf24d327aa0421724356234774d2cde62
2013-11-20 23:32:23 -08:00
Eric Dobson
a2327c05f3 Add benchmarks to TR test dependencies.
original commit: 3e37e940002a581b6295014ccf5a5c99ad03fc50
2013-11-20 23:13:39 -08:00
Eric Dobson
a9fc827be7 Correctly typecheck all subelements of vector literals.
Closes PR 14184.

original commit: cbe1b532795819d45c9bc8ccbaf1507c21b01649
2013-11-20 21:25:28 -08:00
Asumu Takikawa
70995fa7b0 Fix provide: when it's after the definition
Closes PR 11172

Please merge into 6.0

original commit: 7e1b3c306d57b5f7d56a16c468518a790c7952ac
2013-11-20 18:42:28 -05:00
Asumu Takikawa
f785630a76 Simplify fix for PR 14030
Please merge into 6.0

original commit: 6a787c963f22d563a67b731914ac204e2e051ebb
2013-11-20 18:38:39 -05:00
Asumu Takikawa
82fa4808d6 Fix make-predicate at the top-level
This solves the immediate problem, but more generally the
handling of ignored syntax at the top-level seems very fishy.
There is a complicated protocol involving the top-level
type-checker returning #<void> for cases with no obvious
return type, but it's unclear if it actually works. That
code in tc-toplevel.rkt should be revamped in the future.

Closes PR 14030

Please merge into 6.0

original commit: f292a9c0f277bc07d0932ed67f893ca1cb022a43
2013-11-20 18:07:51 -05:00
Asumu Takikawa
0e02b13d28 Add types for remaining in-foo functions
Also fixed `in-directory` type

Please merge into 6.0

original commit: 249427afb41907fc974993f7ce310e9014d4938e
2013-11-20 16:12:29 -05:00
Vincent St-Amour
386364df34 Fix source syntax recovery.
original commit: 632ce4e30a06c5a2bf81310f70a646beb993b015
2013-11-19 18:43:26 -05:00
Vincent St-Amour
dfc7a0b8d9 Fix type printing test.
original commit: fab0d0f955e5bf17e21816146f1af6f9caeaf3b1
2013-11-19 18:43:26 -05:00
Vincent St-Amour
95c784c26a Only recommend expanding union types.
Closes PR14166.

original commit: 49cd879bf89dc924520dfa2a86de3a7513490a2a
2013-11-19 14:28:27 -05:00
Sam Tobin-Hochstadt
7bea9d9aa2 Allow clients of recover-source-syntax to ask for early traversal.
original commit: d1abf632b117ad0c145342055ff80022c22c45ac
2013-11-19 12:15:19 -05:00
Sam Tobin-Hochstadt
2aa592eb2e Implement statistical errortrace-based profiling.
Add a mode to the profiler to use continuation marks inserted
by the errortrace annotator instead of the runtime.

Split `syntax/source-syntax` out from Typed Racket as a separate package,
and use it to give better names for errortrace stack frames.
Use caching to speed it up substantially when called repeatedly (as
errortrace does).

Also, document (internally) the format used by errortrace marks.

original commit: 1e7eb34ba170b6aad77ee67c0f4b802950ff1a4b
2013-11-19 12:15:17 -05:00
Asumu Takikawa
9b08a80030 Generate channel contracts in TR
original commit: f2ddc66333512cfc7e24f2cb91de43464f5a59c1
2013-11-19 12:02:10 -05:00
Vincent St-Amour
a6f0db1fdb Add quoting to error message.
Closes PR14160.

original commit: eb67abb2ef18a2b91f6ee3544971f38e33700664
2013-11-18 15:32:12 -05:00
Vincent St-Amour
e861cec692 Fix line breaks in the docs.
original commit: 63572cc0f7b502261bb47ac0a5dbe60b406ed214
2013-11-18 15:09:33 -05:00
Vincent St-Amour
78f8879e1a Document type generalization.
original commit: eb7c7b0d0be00ba529ee1c7f66a6d5568dd081a8
2013-11-18 15:09:33 -05:00
Vincent St-Amour
d51957fcd3 Improve message when simplifying type display at the REPL.
Closes PR14159.

original commit: def31658f193d9db8409a5b8433804d398dcdd98
2013-11-18 15:09:33 -05:00
Eric Dobson
d1e1f0240b Add newline in query-type/result.
original commit: 9f68c959eef5915269f29abe450d60154a3d4978
2013-11-17 20:11:09 -08:00
Eric Dobson
f0beca5e3a Add approprite init calls.
Closes PR 13102.

original commit: e4c07f14abecc621e62ea1c15dea42b64070df0b
2013-11-17 20:11:09 -08:00
Eric Dobson
cfe772df73 Use actual original syntax.
Don't know how to test that this is better since I don't even know if it
is used.

original commit: 02a5616ccd63ca922109d1d744c108e14826dc34
2013-11-17 20:11:09 -08:00
Eric Dobson
eeb7e92fe7 Make top interaction handle module correctly.
Closes PR 14163.

original commit: f8eae8c00d2a370a88ef8514a90d4e0692c39627
2013-11-17 20:11:09 -08:00