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

Unified Diff: runtime/vm/flow_graph_inliner.cc

Issue 19721004: Allow inlining of closures with a context change. (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 | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_inliner.cc
===================================================================
--- runtime/vm/flow_graph_inliner.cc (revision 25200)
+++ runtime/vm/flow_graph_inliner.cc (working copy)
@@ -668,11 +668,31 @@
&CompilerStats::graphinliner_subst_timer,
Isolate::Current());
+ // For closure calls: Store context value.
+ FlowGraph* callee_graph = call_data->callee_graph;
+ TargetEntryInstr* callee_entry =
+ callee_graph->graph_entry()->normal_entry();
+ ClosureCallInstr* closure_call = call_data->call->AsClosureCall();
+ if (closure_call != NULL) {
+ // TODO(fschneider): Avoid setting the context, if not needed.
+ Definition* closure =
+ closure_call->PushArgumentAt(0)->value()->definition();
+ LoadFieldInstr* context =
+ new LoadFieldInstr(new Value(closure),
+ Closure::context_offset(),
+ Type::ZoneHandle());
+ context->set_ssa_temp_index(caller_graph()->alloc_ssa_temp_index());
+ context->InsertAfter(callee_entry);
+ StoreContextInstr* set_context =
+ new StoreContextInstr(new Value(context));
+ set_context->InsertAfter(context);
+ }
+
+
// Plug result in the caller graph.
- FlowGraph* callee_graph = call_data->callee_graph;
InlineExitCollector* exit_collector = call_data->exit_collector;
exit_collector->PrepareGraphs(callee_graph);
- exit_collector->ReplaceCall(callee_graph->graph_entry()->normal_entry());
+ exit_collector->ReplaceCall(callee_entry);
// Replace each stub with the actual argument or the caller's constant.
// Nulls denote optional parameters for which no actual was given.
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698