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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 10918142: Use CHA to eliminate checks for calls on receiver of caller: check that there can be only one targe… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 12108)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -686,10 +686,35 @@
if (TryInlineInstanceMethod(instr)) {
return;
}
+ const ICData& unary_checks =
+ ICData::ZoneHandle(instr->ic_data()->AsUnaryClassChecks());
+ if (FLAG_use_cha) {
+ // Check if receiver can have only one target, in which case
+ // we emit call without class checks.
+ Definition* receiver = instr->ArgumentAt(0)->value()->definition();
+ ASSERT(receiver != NULL);
+ const Function& function = flow_graph_->parsed_function().function();
+ if (function.IsDynamicFunction() &&
+ receiver->IsParameter() &&
+ (receiver->AsParameter()->index() == 0)) {
+ intptr_t static_receiver_cid = Class::Handle(function.Owner()).id();
+ ZoneGrowableArray<intptr_t>* subclass_cids =
+ CHA::GetSubclassIdsOf(static_receiver_cid);
+ ZoneGrowableArray<Function*>* overriding_functions =
+ CHA::GetNamedInstanceFunctionsOf(*subclass_cids,
+ instr->function_name());
+ if (overriding_functions->is_empty()) {
+ const bool call_with_checks = false;
+ PolymorphicInstanceCallInstr* call =
+ new PolymorphicInstanceCallInstr(instr, unary_checks,
+ call_with_checks);
+ instr->ReplaceWith(call, current_iterator());
+ return;
+ }
+ }
+ }
const intptr_t kMaxChecks = 4;
if (instr->ic_data()->NumberOfChecks() <= kMaxChecks) {
- const ICData& unary_checks =
- ICData::ZoneHandle(instr->ic_data()->AsUnaryClassChecks());
bool call_with_checks;
// TODO(srdjan): Add check class instr for mixed smi/non-smi.
if (HasOneTarget(unary_checks) &&
« no previous file with comments | « runtime/vm/flow_graph.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698