Commit Graph

38051 Commits

Author SHA1 Message Date
Matthew Flatt
8a7852ebbf fix re-expansion of a simple #%module-body form with submodules
Closes #1538
2016-12-15 08:05:02 -07:00
Matthew Flatt
4683b023ab fix another space-safety issue in interpreter loop
When the main interpreter loop is called for an application where the
argument array coincides with the current runstack pointer, then the
protocol is that the callee gets to modify that space --- and it
should modify that space as arguments become unused. The interpreter
was always copying arguments to a fresh space, though.
2016-12-15 08:05:02 -07:00
Gustavo Massaccesi
f2be44dea4 optimizer: allow wcm with multiple return value in noncm_expression 2016-12-15 10:39:16 -03:00
Gustavo Massaccesi
22d61c41d5 optimizer: merge single_valued_expression and definitely_no_wcm_in_tail
Both function have a similar purpose and implementation, so merge them to consider
all the special cases for both uses.

In particular, detect that:
  (if x (error 'e) (void)) is single-valued
  (with-continuation-mark <chaperone-key> <val> <omittable>) is  not tail sensitive.

Also, as ensure_single_value was checking also that the expression was has not a
continuation mark in tail position, it added in some cases an unnecessary
wrapper. Now ensure_single_value checks only that the expression produces
a single vale and a new function ensure_single_value_noncm checks both
properties like the old function.
2016-12-14 20:18:21 -03:00
Gustavo Massaccesi
6d1018fbe8 optimizer: fix interaction of arithmetic reductions and wcm
Also fix a similar problem with branches reduction in a Boolean context.
2016-12-14 20:13:28 -03:00
Matthew Flatt
dc0898f5ef ffi/unsafe/objc: check for bad protocol
Raise an exception instead of installing NULL as a protocol for a
class.
2016-12-14 13:39:29 -07:00
Matthew Flatt
ce370c2f64 fix preservation of properties absent a source location 2016-12-14 08:13:17 -07:00
Matthew Flatt
6ec5b27f81 JIT: simplify output for begin0 that's just for its non-tail effect
Don't store away and restore multiple results if it's obvious
that nothing happens in between.
2016-12-13 19:20:41 -07:00
Matthew Flatt
7204d3136b avoid unnecessary void accumulator for for[*] 2016-12-13 19:20:41 -07:00
Matthew Flatt
d7b18e7a9c adjust map and for ... in-list to not retain their lists
Adjust list and stream handling as sequences so that during the body

 (for ([i (in-list l)])
   ....)

then `i` and its cons cell in `l` are not implicitly retained while
the body is evaluated. A `for .... in-stream` similarly avoids
retaining the stream whose head is being used in the loop body.

The `map`, `for-each`, `andmap`, and `ormap` functions are similarly
updated.

The `make-do-sequence` protocol allows an optional extra result so
that new sequence types could have the same properties. It's not clear
that using `make-do-sequence` is any more useful than creating the new
sequence as a stream, but it was easier to expose the new
functionality than to hide it.

Making this work required a repair to the optimizer, which would
incorrectly move an `if` expression in a way that could affect
space complexity, as well as a few repairs to the run-time system
(especially in the vicinity of the built-in `map`, which we should
just get rid of eventually, anyway).
2016-12-13 19:20:41 -07:00
Matthew Flatt
5e94a906cd compile simple for/list to avoid reverse
Compile a `for[*]/list` form to behave more like `map` by `cons`ing
onto a recursive call, instead of accumulating a list to reverse.

This style of compilation requires a different strategy than before.
A form like

 (for*/fold ([v 0]) ([i (in-range M)]
                     [j (in-range N)])
   j)

compiles as nested loops, like

 (let i-loop ([v 0] [i 0])
   (if (unsafe-fx< i M)
       (i-loop (let j-loop ([v v] [j 0])
                 (if (unsafe-fx< j N)
                     (j-loop (SEL v j) (unsafe-fx+ j 1))
                     v))
               (unsafe-fx+ i 1))
       v))

instead of mutually recursive loops, like

 (let i-loop ([v 0] [i 0])
   (if (unsafe-fx< i M)
       (let j-loop ([v v] [j 0])
         (if (unsafe-fx< j N)
             (j-loop (SEL v j) (unsafe-fx+ j 1))
             (i-loop v (unsafe-fx+ i 1))))
       v))

The former runs slightly faster. It's difficult to say why, for
certain, but the reason may be that the JIT can generate more direct
jumps for self-recursion than mutual recursion. (In the case of mutual
recursion, the JIT has to generate one function or the other to get a
known address to jump to.)

Nested loops con't work for `for/list`, though, since each `cons`
needs to be wrapped around the whole continuation of the computation.
So, the `for` compiler adapts, depending on the initial form. (With a
base, CPS-like approach to support `for/list`, it's easy to use the
nested mode when it works by just not fully CPSing.)

Forms that use `#:break` or `#:final` use the mutual-recursion
approach, because `#:break` and #:final` are easier and faster that
way. Internallt, that simplies the imoplementation. Externally, a
`for` loop with `#:break` or `#:final` can be slightly faster than
before.
2016-12-13 18:27:06 -07:00
Ben Greenman
8de6f581f3 doc: fix types in regexp constructors
- change return types of `pregexp` etc. to use the right predicate
- change input of `byte-regexp` and `byte-pregexp` from `string?` to `bytes?`
2016-12-13 01:43:43 -05:00
Ryan Culpepper
e0ccdc769a syntax/parse: factor out stxclass options passed on to pattern reps
And fix recent pattern-has-cut? for stxclasses w/ no-delimit-cut option.
2016-12-12 11:34:48 -05:00
Ryan Culpepper
8e5ccd3239 syntax/parse: improve minimatch stx errors 2016-12-12 11:00:38 -05:00
Ryan Culpepper
bcc8535b78 syntax/parse: reduce allocation when parsing cannot fail
When parsing cannot fail, avoid allocating expectstacks and
failures (thanks samth for the idea). Allocation still happens
for progress and failuresets (conses of #t, now), though.

Compile with `PLTSTDERR="debug@syntax-parse"` to log cannot-fail
syntax-parse expressions and syntax class definitions.
2016-12-12 11:00:38 -05:00
Ryan Culpepper
e676ba74a5 syntax/parse: add pattern-has-cut? 2016-12-12 11:00:38 -05:00
Alexis King
db8d8f8d75 Improve the type error messages for many functions from racket/list
related to discussion in #1533
2016-12-10 20:38:44 -08:00
Alexis King
62170e6218 Add index(es)-of and index(es)-where to racket/list 2016-12-10 13:01:12 -08:00
Matthew Flatt
07eb3be4b6 net/imap: detect full set of special characters for encoding
Quote marks (at a minimum) should be triggered by any of the
characters in `atom-specials` from the IMAP RFC. The previous trigger
would not have worked for a password that includes parentheses, curly
braces, or an open quare bracket, for example.
2016-12-09 10:25:07 -07:00
Matthew Flatt
c7e8166725 split optimizer and JIT test suites 2016-12-09 09:20:52 -07:00
Matthew Flatt
9c1b870769 optimizer: fix interaction of escaping expressions and wcm
The optimizer can detect that some expressions will escape through
an error, and it can discard surrounding code in that case. It should
not change the tailness of a `with-continuation-mark` form by
liftng it out of a nested position, however. Doing so can eliminate
stack frames that should be visible via errotrace, for example.
This change fixes the optimizer to wrap an extra `(begin ... (void))`
around an expression if it's lifted out of a nested context and
might have a `with-continuation-mark` form in tail position.
2016-12-09 08:58:40 -07:00
Matthew Flatt
7812c604f4 fix native stack traversal for stack dumps
When caching the result of a stack traversal, adjust
the actual stack only after the traversal is complete
to avoid interfering with libunwind's decoding of the
stack.
2016-12-09 06:47:43 -07:00
Jay McCarthy
2b3128cdb4 Protect raco setup from default deps value (see line 638 and 557) 2016-12-08 15:43:15 -05:00
Matthew Flatt
8f9d4860fd change syntax to preserve all properties on a template
In

 (with-syntax ([x ....])
   #'(x y))

and property on the source syntax object `(x y)` was lost in
constructing a new syntax object to substitute for `x`, while
properties on preserved literal syntax objects, such as `y`
were intact. Change `syntax` to preserve properties for
reconstructed parts of the template.

This change exposes a problem with 'transparent taint modes,
where the internal "is original?" property was preserved while
losing scopes that wuld cancel originalness. So, that's fixed
here, too.
2016-12-07 09:15:14 -07:00
Matthew Flatt
24c2f8077c fix declaration mismatch for no-places build 2016-12-06 14:37:16 -07:00
Matthew Flatt
2605437617 unbreak no-futures build 2016-12-06 14:30:12 -07:00
Matthew Flatt
6fe17be82f fix interaction of futures with memory limits
The continuation of a future being evaluated concurrently was not
correctly attributed to the future's custodian (as inherited from
from the creating thread).
2016-12-06 11:21:30 -07:00
Matthew Flatt
20842aaf3a make make-vector future-safe
One interesting corner case is when a vector is allocated
in a way that would exceed a memory limit. The custodian
captured with a future is used to guard large allocations.
2016-12-06 11:21:30 -07:00
Sam Tobin-Hochstadt
8b915ea977 Avoid uninitialized-variable warning. 2016-12-05 10:01:03 -05:00
Gustavo Massaccesi
25dc89a238 more reductions in ignored expressions
extend optimize_ignore to go inside expressions with
begin, begin0 and let.

Also, try to reuse begin's in the first argument of
make_discarding_sequence.
2016-12-04 23:18:43 -03:00
Matthew Flatt
200fbe9b95 fix rename-file-or-directory for raising exn:failsystem:fail:exists
Broken by 0133954c84, which avoided a made-up `EEXIST` but left in
place a no-loner-appropriate test for raising `exn:failsystem:fail:exists`.
2016-12-01 10:21:11 -07:00
Matthew Flatt
af555731a6 adjust generated #ifdefs in FFI
Make sure `#` is start at the start of the line using
the `IFDEF` function, although we'll probably never
again use a compiler old enough for this to matter.
2016-12-01 10:21:11 -07:00
Robby Findler
cbcbc6ae0c avoid adding bogus names to arguments of various contract combinators
closes #1528
2016-12-01 09:34:16 -06:00
Vincent St-Amour
3d63b76730 FIx typo in HTTP client docs.
Reported by nyaacarD on IRC.
2016-11-30 10:02:56 -06:00
Vincent St-Amour
8130b571c4 Fix compilation on ARM.
From Juan Francisco Cantero Hurtado.

Closes #748.
2016-11-29 12:26:26 -06:00
Matthew Flatt
ac04d1e544 repair broken allocation
Commit 4b02c169d7 incorrectly used a size calculation for
structs in the case a serialized structure representation.
2016-11-28 19:38:32 -07:00
Matthew Flatt
ba1f5be532 fix potential crash when printing a changing hash table
If a mutable hash table changes while it's being printed,
various parts of the printing function could see a mismatch
between the current size and an old array size. To avoid this
problem, extract the size whenever extracting the array.
2016-11-28 18:17:36 -07:00
Matthew Flatt
4b02c169d7 improve allocation reports, especially in backtrace mode
Track total bytes allocated for various tags and categories
in backtrace mode, and improve structure reporting to include
byte counts.

Strip away a more ad-hoc counting that was added recently.
2016-11-28 08:49:07 -07:00
Robby Findler
31ca626910 document a default 2016-11-25 09:17:28 -06:00
Sam Tobin-Hochstadt
34fdd2863a Avoid traversing immutable vectors when specified.
This adds #:eager as an option for controlling this behavior.

Using `#:eager 10` is a 2x improvement in performance for configuration 010001
of the suffixtree benchmark from Takikawa et al, POPL 2016.

The default behavior is unchanged. This is configurable because some
programs are much faster when eager checking is performed. For example:

(require racket/contract)
(collect-garbage)
(time (for/sum ([_ 100000])
        (vector-ref (contract (vectorof integer? #:eager #t) #(1) 'pos 'neg)
                    0)))
(collect-garbage)

(time (for/sum ([_ 100000])
        (vector-ref (contract (vectorof integer? #:eager #f) #(1) 'pos 'neg)
                    0)))

The second loop is 3-4 times slower than the first. However, making
the vector much larger will make the difference go the other way.
2016-11-22 11:28:30 -05:00
Matthew Flatt
201d3760b7 fix syntax-source-module repair
Try again on 3a782d01db, which broke contract tests by
mangling the module path index attached to a module.
2016-11-21 20:43:46 -07:00
Matthew Flatt
3a782d01db fix interaction of module->namespace and syntax-source-module
An identifier that gets a module context via `module->namespace` plus
`namespace-syntax-introduce` should not count as having the module as
its source as reported by `syntax-source-module`.

The correct behavior happened for the wrong reason prior to commit
cb6af9664c.

Closes #1515
2016-11-21 17:40:44 -07:00
Vincent St-Amour
87161fc5f3 Add more missing properties. 2016-11-21 15:46:25 -06:00
Matthew Flatt
02b0a30988 improve ellipsis-count checking wrapper
For a template expression that involevs ellipses, a wrapper is added
to catch failures an report as an "incompatible ellipsis match count"
error. The wrapper was only added when there are multiple pattern
variables with ellipses, but it turns out that it's possible to fail
with incompatible counts using a single pattern variable.

Besides handlign that case, the revised check avoids an unnecessary
wrapper in cases where multiple pattern variables have ellipses but
they are used independently in a template.

Closes #1511
2016-11-21 10:01:36 -07:00
Vincent St-Amour
cf2030b0b1 Add missing properties to contract chaperone. 2016-11-21 11:00:02 -06:00
Sam Tobin-Hochstadt
c5cce7aa7b Fix test for values, and simplify test case. (#1525)
Repairs 7c22c42c7.
2016-11-21 11:02:56 -05:00
Matthew Flatt
4902b5e10c more forceful update of Scribble common files for docs
racket/scribble#69
2016-11-21 08:02:09 -07:00
Matthew Flatt
7c22c42c72 fix optimizer imprecision for values
Without this repair,

 #lang racket/base
 (require 2htdp/abstraction)
 (for/list ((dropping-which-one (in-naturals)))
   1)

fails to compile with a "optimizer clock tracking has gone wrong"
error. A variant of this test (that doesn't depend on `2htdp`)
is now in the "optimize.rktl"; a simpler and more direct test
should be possible, but I wasn't able to construct one.
2016-11-20 18:06:46 -07:00
Robby Findler
09c1174f7e add the #:extra-delay argument to recursive-contract 2016-11-19 15:56:18 -06:00
Ryan Culpepper
f1128cca97 syntax/parse: fix literal-set->predicate and datum-literals 2016-11-16 18:58:44 -05:00