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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 11098009: Implement SmiToInt and DoubleToInt. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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/disassembler_ia32.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_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 13429)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -890,7 +890,7 @@
ASSERT(call->HasICData());
const ICData& ic_data = *call->ic_data();
if ((ic_data.NumberOfChecks() == 0) || !ic_data.HasOneTarget()) {
- // No type feedback collected.
+ // No type feedback collected or multiple targets found.
return false;
}
Function& target = Function::Handle();
@@ -917,6 +917,31 @@
return true;
}
+ const intptr_t cid0 = class_ids[0];
+ if ((recognized_kind == MethodRecognizer::kIntegerToInteger) &&
+ ((cid0 == kSmiCid) || (cid0 == kMintCid) || (cid0 == kBigintCid))) {
+ // TODO(srdjan): implement also for mixed integer cids.
+ InsertBefore(call,
+ new CheckSmiInstr(call->ArgumentAt(0)->value()->Copy(),
+ call->deopt_id()),
+ call->env(),
+ Definition::kEffect);
+ call->ReplaceUsesWith(call->ArgumentAt(0));
+ RemovePushArguments(call);
+ call->RemoveFromGraph();
+ return true;
+ }
+
+ if ((recognized_kind == MethodRecognizer::kDoubleToInteger) &&
+ (class_ids[0] == kDoubleCid)) {
+ AddCheckClass(call, call->ArgumentAt(0)->value()->Copy());
+ DoubleToIntegerInstr* d2int_instr =
+ new DoubleToIntegerInstr(call->ArgumentAt(0)->value(), call);
+ call->ReplaceWith(d2int_instr, current_iterator());
+ RemovePushArguments(call);
+ return true;
+ }
+
if (recognized_kind == MethodRecognizer::kStringBaseIsEmpty) {
if (!ic_data.HasOneTarget()) {
// Target is not only StringBase_get_length.
@@ -930,6 +955,8 @@
}
+// Tries to optimize instance call by replacing it with a faster instruction
+// (e.g, binary op, field load, ..).
void FlowGraphOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
if (instr->HasICData() && (instr->ic_data()->NumberOfChecks() > 0)) {
const Token::Kind op_kind = instr->token_kind();
@@ -3052,6 +3079,12 @@
}
+void ConstantPropagator::VisitDoubleToInteger(DoubleToIntegerInstr* instr) {
+ // TODO(kmillikin): Handle conversion.
+ SetValue(instr, non_constant_);
+}
+
+
void ConstantPropagator::VisitConstant(ConstantInstr* instr) {
SetValue(instr, instr->value());
}
« no previous file with comments | « runtime/vm/disassembler_ia32.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698