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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 266783002: Save the entry context for a function that has captured loop variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_builder.cc
diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc
index 9315c2257f09df23c7ad54988454534d809f1819..c40045dc5bf693872af3b8850124a8d765969f42 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -18,6 +18,7 @@
#include "vm/isolate.h"
#include "vm/longjump.h"
#include "vm/object.h"
+#include "vm/object_store.h"
#include "vm/os.h"
#include "vm/parser.h"
#include "vm/resolver.h"
@@ -3464,6 +3465,16 @@ void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) {
}
}
}
+ } else if (MustSaveRestoreContext(node)) {
+ // Even when the current scope has no context variables, we may
+ // still need to save the current context if, for example, there
+ // are loop scopes below this which will allocate a context
+ // object.
+ BuildSaveContext(
+ *owner()->parsed_function()->saved_entry_context_var());
+ AddInstruction(
+ new StoreContextInstr(Bind(new ConstantInstr(Object::ZoneHandle(
+ Isolate::Current()->object_store()->empty_context())))));
}
// This check may be deleted if the generated code is leaf.
@@ -3531,7 +3542,6 @@ void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) {
if (is_open()) {
if (MustSaveRestoreContext(node)) {
- ASSERT(num_context_variables > 0);
BuildRestoreContext(
*owner()->parsed_function()->saved_entry_context_var());
} else if (num_context_variables > 0) {
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698