This change makes CTX available by not caching the current
context while in Dart code. Instead the current context
is held in a local variable (:saved_current_context_var) and
is passed as argument in CTX at calls.
This also simplifies a lot of code in the debugger: As a result,
Isolate::top_context is not needed anymore since the current context
can always be extracted from a Dart frame.
R=vegorov@google.com
Review URL: https://codereview.chromium.org//678763004
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41422 260f80e4-7a28-3924-810f-c04153c831b5
Using the implicit initial null value makes the comparison in the dispatch
prologue of async closures polymorphic (Null|Smi). Initializing to it -1
eliminates the unnecessary class check for null.
Small clean up of scopes and internal variables used for async functions:
Capture them in the parser, so that there is no need to do this later in the
async-transformer.
R=hausner@google.com
Review URL: https://codereview.chromium.org//655773003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41123 260f80e4-7a28-3924-810f-c04153c831b5
The expression ‘await e’ always suspends the enclosing function. If e does not
evaluate to a an object o of type Future, a new Future is created using Future.value(o).
A small change in the backend allows a return instruction to be followed by
other instructions. In async functions, a return can suspend the function and the
continuation point is in the same code block after the return.
Other small changes:
- More user-friendly error message if async/await is not enabled.
- Programs no longer need to import dart:async when using async/await.
R=fschneider@google.com
Review URL: https://codereview.chromium.org//634603002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41105 260f80e4-7a28-3924-810f-c04153c831b5
When an async function is compiled, it creates a closure that contains the code of the async function’s body. Before this change, a new function object is created each time the async function is compiled. This change looks up previously created closures and reuses them, similar to what the parser does for local functions.
R=rmacnak@google.com
Review URL: https://codereview.chromium.org//651013002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41084 260f80e4-7a28-3924-810f-c04153c831b5
The creation and assignment of a fresh loop variable appeared to be outside
of the loop body. When the assignment fails, e.g. due to a type check, the
stack walking code could thus access the wrong context variables.
This CL fixes code and PC descriptor generation for for-in loops and also
fixes a separate bug that crashed the VM when printing an internal error
message.
Fixes issue 20999.
R=regis@google.com
Review URL: https://codereview.chromium.org//577423005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40552 260f80e4-7a28-3924-810f-c04153c831b5
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
async. These functions contain a so-called async closure (with the actual body)
that should not just return when encountering a return statement, but rather call
the completer first and then return (null).
Previously the last return node has been replaced with a completer.complete call.
This does not work for return statements in nested blocks or try-catch-finally
blocks.
Instead of replacing return statements we now call the completer after
resolving all steps necessary for return nodes, i.e., right after inlining all
finally blocks.
We also need "continuation" returns later on that do not complete the
completer. We differentiate by whether a return node has its scope set or not.
BUG=
R=hausner@google.com, srdjan@google.com
Review URL: https://codereview.chromium.org//460763002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39167 260f80e4-7a28-3924-810f-c04153c831b5