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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 19569002: Replace ChainContextInstr with existing IL instructions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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/flow_graph_optimizer.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
===================================================================
--- runtime/vm/flow_graph_builder.cc (revision 25088)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -3094,22 +3094,30 @@
Value* allocated_context =
Bind(new AllocateContextInstr(node->token_pos(),
num_context_variables));
-
- // If this node_sequence is the body of the function being compiled, and if
- // this function allocates context variables, but none of its enclosing
- // functions do, the context on entry is not linked as parent of the
- // allocated context but saved on entry and restored on exit as to prevent
- // memory leaks.
- // In this case, the parser pre-allocates a variable to save the context.
- if (MustSaveRestoreContext(node)) {
+ { LocalVariable* tmp_var = EnterTempLocalScope(allocated_context);
+ // If this node_sequence is the body of the function being compiled, and
+ // if this function allocates context variables, but none of its enclosing
+ // functions do, the context on entry is not linked as parent of the
+ // allocated context but saved on entry and restored on exit as to prevent
+ // memory leaks.
+ // In this case, the parser pre-allocates a variable to save the context.
+ if (MustSaveRestoreContext(node)) {
+ Value* current_context = Bind(new CurrentContextInstr());
+ Do(BuildStoreTemp(
+ *owner()->parsed_function()->saved_entry_context_var(),
+ current_context));
+ Value* null_context = Bind(new ConstantInstr(Object::ZoneHandle()));
+ AddInstruction(new StoreContextInstr(null_context));
+ }
Value* current_context = Bind(new CurrentContextInstr());
- Do(BuildStoreTemp(*owner()->parsed_function()->saved_entry_context_var(),
- current_context));
- Value* null_context = Bind(new ConstantInstr(Object::ZoneHandle()));
- AddInstruction(new StoreContextInstr(null_context));
+ Value* tmp_val = Bind(new LoadLocalInstr(*tmp_var));
+ Do(new StoreVMFieldInstr(tmp_val,
+ Context::parent_offset(),
+ current_context,
+ Type::ZoneHandle()));
+ AddInstruction(
+ new StoreContextInstr(Bind(ExitTempLocalScope(tmp_var))));
}
-
- AddInstruction(new ChainContextInstr(allocated_context));
owner()->set_context_level(scope->context_level());
// If this node_sequence is the body of the function being compiled, copy
« no previous file with comments | « no previous file | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698