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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 579233002: Fix ConstantPropagator::VisitBinaryDoubleOp to work with all integer types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | « no previous file | runtime/vm/il_printer.cc » ('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 e5019017db1d796a316dc58b159f2ee608384e6c..8c4babef444ecaf1569d5c11395e6883a2941f82 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -8505,19 +8505,28 @@ void ConstantPropagator::VisitMaterializeObject(MaterializeObjectInstr* instr) {
}
+static bool IsIntegerOrDouble(const Object& value) {
+ return value.IsInteger() || value.IsDouble();
+}
+
+
+static double ToDouble(const Object& value) {
+ return value.IsInteger() ? Integer::Cast(value).AsDoubleValue()
+ : Double::Cast(value).value();
Florian Schneider 2014/09/18 12:33:14 Please align : and ?.
Vyacheslav Egorov (Google) 2014/09/18 12:46:53 Done.
+}
+
+
void ConstantPropagator::VisitBinaryDoubleOp(
BinaryDoubleOpInstr* instr) {
const Object& left = instr->left()->definition()->constant_value();
const Object& right = instr->right()->definition()->constant_value();
if (IsNonConstant(left) || IsNonConstant(right)) {
SetValue(instr, non_constant_);
- } else if (IsConstant(left) && IsConstant(right)) {
- ASSERT(left.IsSmi() || left.IsDouble());
- ASSERT(right.IsSmi() || right.IsDouble());
- double left_val = left.IsSmi()
- ? Smi::Cast(left).AsDoubleValue() : Double::Cast(left).value();
- double right_val = right.IsSmi()
- ? Smi::Cast(right).AsDoubleValue() : Double::Cast(right).value();
+ } else if (left.IsInteger() && right.IsInteger()) {
+ SetValue(instr, non_constant_);
+ } else if (IsIntegerOrDouble(left) && IsIntegerOrDouble(right)) {
+ const double left_val = ToDouble(left);
+ const double right_val = ToDouble(right);
double result_val = 0.0;
switch (instr->op_kind()) {
case Token::kADD:
« no previous file with comments | « no previous file | runtime/vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698