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

Unified Diff: runtime/vm/scopes.cc

Issue 1028473002: Add a flag controlling context sharing. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scopes.cc
===================================================================
--- runtime/vm/scopes.cc (revision 44592)
+++ runtime/vm/scopes.cc (working copy)
@@ -10,6 +10,11 @@
namespace dart {
+DEFINE_FLAG(bool, share_enclosing_context, true,
+ "Allocate captured variables in the existing context of an "
+ "enclosing scope (up to innermost loop) and spare the allocation "
+ "of a local context.");
+
int SourceLabel::FunctionLevel() const {
ASSERT(owner() != NULL);
return owner()->function_level();
@@ -148,7 +153,16 @@
// This scope becomes the current context owner.
set_context_level(1);
*context_owner = this;
+ } else if (!FLAG_share_enclosing_context && ((*context_owner) != this)) {
+ // The captured variable is in a child scope of the context owner and we do
+ // not share contexts.
+ // This scope will allocate and chain a new context.
+ ASSERT(num_context_variables_ == 0);
+ // This scope becomes the current context owner.
+ set_context_level((*context_owner)->context_level() + 1);
+ *context_owner = this;
} else if ((*context_owner)->loop_level() < loop_level()) {
+ ASSERT(FLAG_share_enclosing_context);
// The captured variable is at a deeper loop level than the current context.
// This scope will allocate and chain a new context.
ASSERT(num_context_variables_ == 0);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698