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

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: 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
Index: runtime/vm/scopes.cc
diff --git a/runtime/vm/scopes.cc b/runtime/vm/scopes.cc
index f0c5080b8e4a5a384c68a2098d14d3687d504ba2..701e3e244999031a1f0881bfda55220292f02b5f 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) {
+ LocalScope* scope = this;
+ while (scope != top_scope->parent()) {
+ ASSERT(scope->function_level() == function_level());
hausner 2015/09/02 22:07:55 Tiny detail: you could do the assertion outside of
regis 2015/09/03 01:28:04 Done.
+ 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(); }
}
« runtime/vm/parser.cc ('K') | « runtime/vm/scopes.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698