Commit Graph

36066 Commits

Author SHA1 Message Date
Robby Findler
df382ca939 improve warnings and fix small problems with contract combinator constructors 2015-12-30 17:13:23 -06:00
Robby Findler
cb2af327e6 port async-channel/c to late-neg proj
and drop other projection implementations
(mostly to reduce the testing burden)
2015-12-30 17:13:22 -06:00
Robby Findler
9ee264a0ea improve performance of define-generic-created contracts and port to late-neg
This program runs about 10x faster than it did before this commit, but
seems to still be about 100x slower than the version where you change
an-s to just be (s).

  #lang racket/base
  (require racket/contract/base racket/generic)
  (define-generics id [m id x])
  (struct s () #:methods gen:id [(define (m g x) x)])
  (define an-s
    (contract (id/c [m (-> any/c integer? integer?)])
              (s)
              'pos 'neg))
  (time
   (for ([x (in-range 100000)])
     (m an-s 2)))
2015-12-30 17:13:22 -06:00
Robby Findler
a97aa8389b port id-table/c to flat-neg projection 2015-12-30 17:13:22 -06:00
Sam Tobin-Hochstadt
1c3422d420 Fix CI tests for match test move. 2015-12-30 10:39:45 -05:00
Robby Findler
f2f38cdf4a remove overly aggressive use of procedure-specialize 2015-12-30 09:28:58 -06:00
Robby Findler
a5b3d6b3d0 uncopy some code 2015-12-29 21:46:06 -06:00
Robby Findler
46ace3172f clean up interaction between strict set/c contracts and mutable sets 2015-12-29 20:28:22 -06:00
Robby Findler
757adac568 make #f always convert into the same (eq?) contract 2015-12-29 16:13:01 -06:00
Robby Findler
4bdde405f6 improve the way that 'struct-out' cooperates with the
rest of the contract system, creating and using a slightly
more legitmate blame record and calling into the late-neg
projections instead of using `contract`
2015-12-29 15:48:17 -06:00
Sam Tobin-Hochstadt
893bb56762 Rename to make it clear what to run. 2015-12-29 16:01:22 -05:00
Mira Leung
e2bd1b51bc Using in-list in for/list 2015-12-29 15:59:40 -05:00
Mira Leung
404c5b2699 Better code style for f3d888 2015-12-29 15:59:40 -05:00
Mira Leung
56ea9f8b9a Specify names of missing fields for match on structs 2015-12-29 15:59:40 -05:00
Robby Findler
22adc0253b change sets generics so they default to supplying the optional argument
if the given procedure accepts it
2015-12-29 11:26:17 -06:00
Robby Findler
2c5aa96031 change some potentially error-prone provide all-from-outs to explicit provides
and make set load its implementation via relative requires
2015-12-29 11:25:45 -06:00
Robby Findler
7056cd5f2a improve ->i in the case that the dependent contract
turns out to be a predicate.

In that case, just call it instead of creating all of the extra junk
that would normally be created by coercing the predicate to a contract
and invoking it
2015-12-29 11:20:59 -06:00
Matthew Flatt
a516304f6b fix specialization over a nested lambda 2015-12-29 07:04:17 -06:00
Matthew Flatt
26560240f1 adjust "racket-playsound.exe" return code 2015-12-29 07:04:17 -06:00
Robby Findler
d4ca825640 fix set/c name method 2015-12-29 06:56:20 -06:00
Robby Findler
a44ce40b56 fix a bug in 50405a2ca 2015-12-28 22:17:39 -06:00
Robby Findler
f7465f81f1 convert stream/c to late-neg-projection
Also, tune the projection to get a few modest performance gains.

This program gets about 20% faster:

  #lang racket
  (define s (contract (stream/c exact-nonnegative-integer?)
                      (in-naturals) 'pos 'neg))
  (time
   (for ([x (in-range 1000)])
     (for/fold ([s s])
               ([x (in-range 100)])
       (stream-rest s))))

and this program gets about 15% faster:

  #lang racket
  (define f (contract (-> (stream/c exact-nonnegative-integer?)
                          any)
                      (λ (x) 1)
                      'pos 'neg))
  (define l (make-list 10000 0))
  (time (for ([x (in-range 1000)])
          (f l) (f l) (f l) (f l) (f l)))
2015-12-28 21:57:03 -06:00
Robby Findler
ff31b01505 add some error checking for custom set type constructors 2015-12-28 16:59:43 -06:00
Robby Findler
50405a2ca9 fix chaperone-hash-set and impersonate-hash-set for custom-set-types 2015-12-28 16:59:42 -06:00
Matthew Flatt
e08188aeda add source for "racket-playsound.exe" 2015-12-28 07:37:29 -06:00
Matthew Flatt
cefcbdf802 Windows: ensure 'kill subprocesses end with Racket
Use a job object to ensure that subprocesses that are meant
to be killed by the current custodian are reliably terminated
if Racket exits for any reason.
2015-12-28 07:37:29 -06:00
Matthew Flatt
afa01fa763 allow optimizations around procedure-specialize
Although `procedure-specialize` should be useful in places where
inlining does not apply, allowing inlining and related optimizations
through it, anyway.
2015-12-28 07:37:29 -06:00
Robby Findler
b3d05de304 improvements to set/c
- use chaperone-hash-set for set/c when the contract allows only hash-sets

- add a #:lazy flag to allow explicit choice of when to use laziness
  (but have a backwards-compatible default that, roughly, eschews laziness
   only when the resulting contract would be flat)
2015-12-27 22:56:04 -06:00
Robby Findler
bc12019af4 allow the interposition procedures to all be #f in chaperone-hash-set and impersonate-hash-set 2015-12-27 21:02:20 -06:00
Robby Findler
8f2874e4b5 fix impersonator properties for chaperone-hash-set and impersonate-hash-set 2015-12-26 22:37:00 -06:00
Robby Findler
daf19869de chaperone-hash-set fixes 2015-12-26 22:09:14 -06:00
Robby Findler
1b6705f3d9 typo 2015-12-26 17:01:22 -06:00
Robby Findler
d927d04efd generalize tail contract checking for function contracts
Specifically, remove reliance on procedure-closure-contents-eq? to
tell when a pending check is stronger in favor of usint
contract-stronger?

Also, tighten up the specification of contract-stronger? to require
that any contract is stronger than itself

With this commit, this program gets about 10% slower:

  #lang racket/base
  (require racket/contract/base)
  (define f
    (contract
     (-> any/c integer?)
     (λ (x) (if (zero? x)
                0
                (f (- x 1))))
     'pos 'neg))
  (time (f 2000000))

becuase the checking is doing work more explicitly now but because the
checking in more general, it identifies the redundant checking in this
program

  #lang racket/base
  (require racket/contract/base)
  (define f
    (contract
     (-> any/c integer?)
     (contract
      (-> any/c integer?)
      (λ (x) (if (zero? x)
                 0
                 (f (- x 1))))
      'pos 'neg)
     'pos 'neg))
  (time (f 200000))

which makes it run about 13x faster than it did before

I'm not sure if this is a win overall, since the checking can be more
significant in the case of "near misses". For example, with this
program, where neither the new nor the old checking detects the
redundancy is about 40% slower after this commit than it was before:

  #lang racket/base
  (require racket/contract/base)
  (define f
    (contract
     (-> any/c (<=/c 0))
     (contract
      (-> any/c (>=/c 0))
      (λ (x) (if (zero? x)
                 0
                 (f (- x 1))))
      'pos 'neg)
     'pos 'neg))

  (time (f 50000))

(The redundancy isn't detected here because the contract system only
looks at the first pending contract check.)

Overall, despite the fact that it slows down some programs and speeds
up others, my main thought is that it is worth doing because it
eliminates a (painful) reliance on procedure-closure-contents-eq? that
inhibits other approaches to optimizing these contracts we might try.
2015-12-25 22:58:56 -06:00
Robby Findler
f0f85549ce add impersonate-hash-set and chaperone-hash-set 2015-12-25 22:58:55 -06:00
Robby Findler
c9d192f09b make more explicit that define-custom-set-types produces hash sets. 2015-12-25 22:58:55 -06:00
Robby Findler
badf2bd19e audit requires of files that require misc.rkt in racket/contract 2015-12-25 22:58:55 -06:00
Robby Findler
7708b2056a use specialize-procedure on predicate portion or or/c
This seems to give about a 10% speedup on this program:

 #lang racket/base
(require racket/contract/base)
(define f (contract
           (-> (or/c number? symbol?) any)
           (λ (x) 0)
           'pos 'neg))

(time
 (for ([_ (in-range 1000000)])
   (f 'x) (f 'x) (f 'x) (f 'x)))
2015-12-25 14:17:03 -06:00
Matthew Flatt
0840fcd6c8 JIT: avoid assertion failures due to a full buffer 2015-12-25 08:04:22 -06:00
Matthew Flatt
f0d09dbef1 make JIT recognize literal struct predicatates, etc.
Mka the closure specializer handle literal struct operations
(as opposed to just references to struct operations).
2015-12-25 07:14:40 -06:00
Matthew Flatt
843992d0c7 use specialization opportunity for #%apply-values 2015-12-24 12:17:31 -06:00
Matthew Flatt
144da5abd4 Merge pull request #1178 from vendethiel/patch-1
Fix small typo in jit.h
2015-12-24 05:30:35 -07:00
ven
c1950f1ae3 Fix small typo in jit.h
Just noticed it while reading db0a6de1d2
2015-12-24 10:11:56 +01:00
Matthew Flatt
ba2eb6487c restore precision for procedure-closure-contents-eq?
After adding `procedure-specialize`, making
`procedure-closure-contents-eq?` work as before involves
a little extra tracking. I'd prefer to weaken or
even get rid of `procedure-closure-contents-eq?`, but
this adjustment keeps some contract tests passing.
2015-12-23 22:06:18 -07:00
Matthew Flatt
44e1262648 unbreak no-JIT build 2015-12-23 21:51:14 -07:00
Matthew Flatt
db0a6de1d2 add procedure-specialize
The `procedure-specialize` function is the identity function, but it
provides a hint to the JIT to compile the body of a closure
specifically for the values in the closure (as opposed to compiling
the body generically for all closure instances).

This hint is useful to the contract system, where a predicate
is coerced to a projection with

 (lambda (p?)
   (procedure-specialize
    (lambda (v)
      (if (p? v)
          v
          ....))))

Specializing the projection to a given `p?` allows primitive
predicates to be JIT-inlined in the projection's body.
2015-12-23 17:46:56 -07:00
Matthew Flatt
592ae853e3 JIT: fast path for procedure impersonator w/o wrapper proc
Make the JIT-generated function-call dispatch recognize a call to
an impersonator that wraps a procedure only to hold properties.

This change also repairs handling for a arity-reducing wrapper
on a primitive, where the fast path incorrecty treated the
primitive as a JIT-generated function.
2015-12-22 15:05:14 -07:00
Matthew Flatt
b794404333 faster path for a procedure impersonator w/o wrapper proc
Make the call path faster when an impersontor is present
on a procedure only to add impersonator properties.
2015-12-22 15:04:53 -07:00
Matthew Flatt
e8073e699e restore a fast path for a procedure chaperone
When the representation of a redirect changed, the fast
path wasn't updated.
2015-12-22 15:04:53 -07:00
Matthew Flatt
c73bcceafe avoid a string pointer needed only for error reporting 2015-12-22 15:04:53 -07:00
Robby Findler
d2233f95e2 make vectorof also try less hard during or/c checking 2015-12-22 16:02:48 -06:00