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

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
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 16185)
+++ 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);
Vyacheslav Egorov (Google) 2012/12/17 12:53:44 It would be great if we could test things like thi
srdjan 2012/12/18 00:12:47 I do manual tests, by tracing deoptimization. I ag
+ } 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_);
Vyacheslav Egorov (Google) 2012/12/17 12:53:44 I think we should stop posponing this to TODOs whe
srdjan 2012/12/18 00:12:47 I think there some work needed to implement consta
Vyacheslav Egorov (Google) 2012/12/18 11:45:10 Agreed about separate CL. I was under impression
+}
+
+
void ConstantPropagator::VisitConstant(ConstantInstr* instr) {
SetValue(instr, instr->value());
}

Powered by Google App Engine
This is Rietveld 408576698