This CL fixes several scoping/context issues:
* Do not reuse scopes in SequenceNode_s as they might introduce a new context
level. In that case we would trigger context allocationg multiple times
resulting in scope/contexts being out of sync.
* Properly save and restore saved_try_context in try/catch/finally blocks and
nesting closures. For this we need to keep track of async closures top scopes.
R=hausner@google.com
Review URL: https://codereview.chromium.org//520223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39775 260f80e4-7a28-3924-810f-c04153c831b5
We are not allowed to reuse LocalScope in different SequenceNode_s. The problem is that if a context needs to be created for that scope the FlowGraphbuilder will insert context creation code at all SequenNoce_s that use this scope. This results in scopes and contexts being out of sync and writing garbage. The fix is to just chain a new scope that is on the same function- and loop-level.
Also fix recognizing of "await" in async functions. A follow up CL will enable await in loops, if, return, ...
BUG=
R=hausner@google.com
Review URL: https://codereview.chromium.org//508643004
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39571 260f80e4-7a28-3924-810f-c04153c831b5
If a final instance variable is initialized at the point of declaration, it
is a runtime error if it is initialized again in a constructor’s initializer
list or by an initializing formal.
If any instance field is initialized more than once in the initializer list of
a constructor, or by an initializing formal parameter, it is a compile time
error.
Adding a new test to cover the expected runtime error.
Fixes issue 13335.
R=regis@google.com
Review URL: https://codereview.chromium.org//505033002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39562 260f80e4-7a28-3924-810f-c04153c831b5
This CL adds basic infrastructure needed for awaitable expressions. Implementation of continuations is not part of this CL.
Expressions containing ``await'' are transformed into a series of operations on intermediates, effectively getting rid
of the temporary expression stack. Currently only expressions evaluating to an actual value (read: non-future) are supported.
Also, not all kinds of statements support awaitable expressions yet.
Missing:
* Capturing all (needed) variables
* Continuations (connecting a preamble with await statements; re-adding the closure to the run queue)
BUG=
R=hausner@google.com
Review URL: https://codereview.chromium.org//447003003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39345 260f80e4-7a28-3924-810f-c04153c831b5
First step towards deferred library support:
- Parse the “deferred as” import clause.
- Implement p.loadLibrary() which returns a future that
completes when the library is loaded.
- Treat type annotations of deferred types as malformed.
- Throw NoSuchMethodError when calling functions from
unloaded libraries.
- Libraries are still read synchronously, but items in the
library won’t be visible through the deferred prefix until
the future returned by loadLibrary() completes.
Review URL: https://codereview.chromium.org//208323015
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34481 260f80e4-7a28-3924-810f-c04153c831b5
This also covers "closurization" of the .call method.
This relies on the fact that f.call === f if f is a closure.
This means that adding a simple getter to _FunctionImpl that
returns this is enough. No need for a separate dispatch.
This CL reverts the previous fix for issue 12602 (modulo the
additional tests).
BUG=dartbug.com/17473, dartbug.com/12602
R=iposva@google.com
Review URL: https://codereview.chromium.org//200193002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33736 260f80e4-7a28-3924-810f-c04153c831b5
Calling closures via .call does now work in the VM - it was working in
dart2js already. Calling .call on a closure is implemented to go through
a dispatcher method. These dispatcher methods are automatically created and
cached in the same way as NoSuchMethod- or field-invocation dispatchers.
This CL does not change the way regular closure invocation works in
the VM. It is therefore performance-neutral for normal closure calls.
BUG=dartbug.com/12602
TEST=language/call_test
R=iposva@google.com
Review URL: https://codereview.chromium.org//188703004
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33576 260f80e4-7a28-3924-810f-c04153c831b5
A name that is not resolved in the local scope gets looked up
in the global scope of the library to which the code being compiled
belongs. The local name dictionary gets searched first, then the
dictionary of each imported library (and and their re-exported
libraries.) Each dictionary lookup includes the lookup of the
mangled getter and setter names, which means that we concatenate
the same name many times.
This change introduces a cache that stores the result of a previous
name lookup, including negative lookup results. The latter is important
to speed up the resolution of names that are not in the global name
space, e.g. class members like .length in lists.
Experiments running dart2js (with VM option --compile_all) show
that this reduces the number of name mangling calls by a factor of 10
and speeds up compiling dart2js by 15%.
R=asiva@google.com
Review URL: https://codereview.chromium.org//135123011
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32385 260f80e4-7a28-3924-810f-c04153c831b5
The AST cannot distinguish between (x) and x. Adding a check
to the VM compiler that detects syntactically illegal assignments
like (x) = 0. The existing checks only analyze the AST so we
didn’t detect some illegal cases.
Looking at the source to detect syntactically illegal left hand
expressions is a bit ugly because we can’t easily look at
previous tokens. This change rewinds the token iterator a few
positions and then moves forward to check whether the last token
of the expression is an identifier or a closing bracket ].
Added new test. We did not have a single test case for this :)
R=regis@google.com
Review URL: https://codereview.chromium.org//106843002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30904 260f80e4-7a28-3924-810f-c04153c831b5
The AST for static getters differs between parsing the first time, and
subsequent parsings. This leads to a mismatch in deoptimization-ids
between the optimized and the unoptimized code.
This CL avoids creating different ASTs for the same static getters. To allow
better inlining of these getters, the initialization expression is wrapped in a
hidden static initializer-function. As a result the size of such getters is
constant and does not depend on the initializer expression.
R=srdjan@google.com
Review URL: https://codereview.chromium.org//51123003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29680 260f80e4-7a28-3924-810f-c04153c831b5