Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1799)

Unified Diff: runtime/vm/ast_transformer.cc

Issue 1079233002: Simplify restoring of saved try contexts in async code by passing around the (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/ast_transformer.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/ast_transformer.cc
===================================================================
--- runtime/vm/ast_transformer.cc (revision 45079)
+++ runtime/vm/ast_transformer.cc (working copy)
@@ -107,30 +107,6 @@
}
-// Restore the currently relevant :saved_try_context_var on the stack
-// from the captured :async_saved_try_ctx_var_<try_index>.
-AstNode* AwaitTransformer::RestoreSavedTryContext(Zone* zone,
- LocalScope* scope,
- int16_t try_index) {
- LocalVariable* saved_try_ctx =
- scope->LocalLookupVariable(Symbols::SavedTryContextVar());
- ASSERT((saved_try_ctx != NULL) && !saved_try_ctx->is_captured());
- const String& async_saved_try_ctx_name = String::ZoneHandle(zone,
- Symbols::New(String::Handle(zone,
- String::NewFormatted("%s%d",
- Symbols::AsyncSavedTryCtxVarPrefix().ToCString(),
- try_index))));
- LocalVariable* async_saved_try_ctx =
- scope->LocalLookupVariable(async_saved_try_ctx_name);
- ASSERT(async_saved_try_ctx != NULL);
- ASSERT(async_saved_try_ctx->is_captured());
- return new (zone) StoreLocalNode(
- Scanner::kNoSourcePos,
- saved_try_ctx,
- new (zone) LoadLocalNode(Scanner::kNoSourcePos, async_saved_try_ctx));
-}
-
-
void AwaitTransformer::VisitAwaitNode(AwaitNode* node) {
// Await transformation:
//
@@ -236,17 +212,21 @@
// If this expression is part of a try block, also append the code for
// restoring the saved try context that lives on the stack and possibly the
// saved try context of the outer try block.
- if (node->try_scope() != NULL) {
- preamble_->Add(RestoreSavedTryContext(Z,
- node->try_scope(),
- node->try_index()));
- if (node->outer_try_scope() != NULL) {
- preamble_->Add(RestoreSavedTryContext(Z,
- node->outer_try_scope(),
- node->outer_try_index()));
+ if (node->saved_try_ctx() != NULL) {
+ preamble_->Add(new (Z) StoreLocalNode(
+ Scanner::kNoSourcePos,
+ node->saved_try_ctx(),
+ new (Z) LoadLocalNode(Scanner::kNoSourcePos,
+ node->async_saved_try_ctx())));
+ if (node->outer_saved_try_ctx() != NULL) {
+ preamble_->Add(new (Z) StoreLocalNode(
+ Scanner::kNoSourcePos,
+ node->outer_saved_try_ctx(),
+ new (Z) LoadLocalNode(Scanner::kNoSourcePos,
+ node->outer_async_saved_try_ctx())));
}
} else {
- ASSERT(node->outer_try_scope() == NULL);
+ ASSERT(node->outer_saved_try_ctx() == NULL);
}
LoadLocalNode* load_error_param = new (Z) LoadLocalNode(
« no previous file with comments | « runtime/vm/ast_transformer.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698