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

Unified Diff: runtime/vm/scopes.cc

Issue 1308163006: Reduce the number of captured variables in async code, by only capturing local (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 5 years, 3 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/scopes.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scopes.cc
diff --git a/runtime/vm/scopes.cc b/runtime/vm/scopes.cc
index f0c5080b8e4a5a384c68a2098d14d3687d504ba2..139705a0079817463415683fd9f7b4dcf19c348e 100644
--- a/runtime/vm/scopes.cc
+++ b/runtime/vm/scopes.cc
@@ -617,19 +617,23 @@ LocalScope* LocalScope::RestoreOuterScope(const ContextScope& context_scope) {
}
-void LocalScope::RecursivelyCaptureAllVariables() {
- for (intptr_t i = 0; i < num_variables(); i++) {
- if ((VariableAt(i)->name().raw() == Symbols::StackTraceVar().raw()) ||
- (VariableAt(i)->name().raw() == Symbols::ExceptionVar().raw()) ||
- (VariableAt(i)->name().raw() == Symbols::SavedTryContextVar().raw())) {
- // Don't capture those variables because the VM expects them to be on the
- // stack.
- continue;
+void LocalScope::CaptureLocalVariables(LocalScope* top_scope) {
+ ASSERT(top_scope->function_level() == function_level());
+ LocalScope* scope = this;
+ while (scope != top_scope->parent()) {
+ for (intptr_t i = 0; i < scope->num_variables(); i++) {
+ LocalVariable* variable = scope->VariableAt(i);
+ if ((variable->name().raw() == Symbols::StackTraceVar().raw()) ||
+ (variable->name().raw() == Symbols::ExceptionVar().raw()) ||
+ (variable->name().raw() == Symbols::SavedTryContextVar().raw())) {
+ // Don't capture those variables because the VM expects them to be on
+ // the stack.
+ continue;
+ }
+ scope->CaptureVariable(variable);
}
- CaptureVariable(VariableAt(i));
+ scope = scope->parent();
}
- if (sibling() != NULL) { sibling()->RecursivelyCaptureAllVariables(); }
- if (child() != NULL) { child()->RecursivelyCaptureAllVariables(); }
}
« no previous file with comments | « runtime/vm/scopes.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698