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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 11568044: Add DoubleToSmi optimistically, preventing boxing/unboxing of doubles and propagate smi-nessof the … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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/code_generator.h ('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 16259)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -1203,9 +1203,17 @@
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());
+ ASSERT(call->HasICData());
+ const ICData& ic_data = *call->ic_data();
+ Definition* d2i_instr = NULL;
+ if (ic_data.deopt_reason() == kDeoptDoubleToSmi) {
+ // Do not repeatedly deoptimize because result didn't fit into Smi.
+ d2i_instr = new DoubleToIntegerInstr(call->ArgumentAt(0)->value(), call);
+ } else {
+ // Optimistically assume result fits into Smi.
+ d2i_instr = new DoubleToSmiInstr(call->ArgumentAt(0)->value(), call);
+ }
+ call->ReplaceWith(d2i_instr, current_iterator());
RemovePushArguments(call);
return true;
}
@@ -4047,6 +4055,12 @@
}
+void ConstantPropagator::VisitDoubleToSmi(DoubleToSmiInstr* 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/code_generator.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698