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

Unified Diff: runtime/vm/flow_graph_inliner.cc

Issue 19370003: Enable allocation sinking for closures. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: fixed bug in polymorphic inliner 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
Index: runtime/vm/flow_graph_inliner.cc
===================================================================
--- runtime/vm/flow_graph_inliner.cc (revision 25661)
+++ runtime/vm/flow_graph_inliner.cc (working copy)
@@ -681,6 +681,13 @@
new LoadFieldInstr(new Value(closure),
Closure::context_offset(),
Type::ZoneHandle());
+ AllocateObjectInstr* alloc =
+ closure_call->ArgumentAt(0)->AsAllocateObject();
+ if (alloc != NULL && !alloc->closure_function().IsNull()) {
srdjan 2013/08/01 00:54:47 Add ()
Florian Schneider 2013/08/05 14:41:55 Done.
+ ASSERT(!alloc->context_field().IsNull());
+ context->set_field(&alloc->context_field());
+ }
+
context->set_ssa_temp_index(caller_graph()->alloc_ssa_temp_index());
context->InsertAfter(callee_entry);
StoreContextInstr* set_context =
@@ -803,9 +810,19 @@
ClosureCallInstr* call = calls[i];
// Find the closure of the callee.
ASSERT(call->ArgumentCount() > 0);
- const CreateClosureInstr* closure =
+ Function& target = Function::ZoneHandle();
+ CreateClosureInstr* closure =
call->ArgumentAt(0)->AsCreateClosure();
- if (closure == NULL) {
+ if (closure != NULL) {
+ target ^= closure->function().raw();
+ }
+ AllocateObjectInstr* alloc =
+ call->ArgumentAt(0)->AsAllocateObject();
+ if (alloc != NULL && !alloc->closure_function().IsNull()) {
srdjan 2013/08/01 00:54:47 add parentheses
Florian Schneider 2013/08/05 14:41:55 Done.
+ target ^= alloc->closure_function().raw();
+ ASSERT(target.signature_class() == alloc->cls().raw());
+ }
+ if (target.IsNull()) {
TRACE_INLINING(OS::Print(" Bailout: non-closure operator\n"));
continue;
}
@@ -814,7 +831,7 @@
arguments.Add(call->PushArgumentAt(i)->value());
}
InlinedCallData call_data(call, &arguments);
- if (TryInlining(closure->function(),
+ if (TryInlining(target,
call->argument_names(),
&call_data)) {
InlineCall(&call_data);
@@ -1180,6 +1197,10 @@
callee_entry->AsGraphEntry()->normal_entry();
cursor->LinkTo(target->next());
target->ReplaceAsPredecessorWith(current_block);
+
+ // Unuse the graph entry. It is not in the graph anymore.
+ callee_entry->UnuseAllInputs();
Florian Schneider 2013/07/31 13:52:28 I created a separate CL with a regression test for
+
// All blocks that were dominated by the normal entry are now
// dominated by the current block.
for (intptr_t j = 0;
@@ -1230,6 +1251,10 @@
if (callee_entry->IsGraphEntry()) {
// Unshared.
true_target = callee_entry->AsGraphEntry()->normal_entry();
+
+ // Unuse the graph entry. It is not in the graph anymore.
+ callee_entry->UnuseAllInputs();
+
} else if (callee_entry->IsTargetEntry()) {
// Shared inlined body and this is the first entry. We have already
// constructed a join and this target jumps to it.

Powered by Google App Engine
This is Rietveld 408576698