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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 14031035: Cleanup implementation of SmiToDouble to use unboxed double result. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: emit SmiToDouble only at monomorphic sites Created 7 years, 8 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 | « no previous file | 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
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index 3170079780a1003b7fe9020bf0f21a09cd77c7bd..f8288dd332d0ea839083709e48534daaa1e558e6 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -1605,11 +1605,10 @@ bool FlowGraphOptimizer::TryInlineInstanceMethod(InstanceCallInstr* call) {
}
if ((recognized_kind == MethodRecognizer::kIntegerToDouble) &&
+ (ic_data.NumberOfChecks() == 1) &&
(class_ids[0] == kSmiCid)) {
- SmiToDoubleInstr* s2d_instr = new SmiToDoubleInstr(call);
- call->ReplaceWith(s2d_instr, current_iterator());
- // Pushed arguments are not removed because SmiToDouble is implemented
- // as a call.
+ AddReceiverCheck(call);
+ ReplaceCall(call, new SmiToDoubleInstr(new Value(call->ArgumentAt(0))));
return true;
}
@@ -4675,8 +4674,13 @@ void ConstantPropagator::VisitUnarySmiOp(UnarySmiOpInstr* instr) {
void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) {
- // TODO(kmillikin): Handle conversion.
- SetValue(instr, non_constant_);
+ const Object& value = instr->value()->definition()->constant_value();
+ if (IsConstant(value) && value.IsInteger()) {
+ SetValue(instr, Double::Handle(
+ Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld)));
+ } else if (IsNonConstant(value)) {
+ SetValue(instr, non_constant_);
+ }
}
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698