| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 BuildStringCodeUnitAt(call, class_ids[0]); | 1598 BuildStringCodeUnitAt(call, class_ids[0]); |
| 1599 InsertBefore(call, load_char_code, NULL, Definition::kValue); | 1599 InsertBefore(call, load_char_code, NULL, Definition::kValue); |
| 1600 StringFromCharCodeInstr* char_at = | 1600 StringFromCharCodeInstr* char_at = |
| 1601 new StringFromCharCodeInstr(new Value(load_char_code), | 1601 new StringFromCharCodeInstr(new Value(load_char_code), |
| 1602 kOneByteStringCid); | 1602 kOneByteStringCid); |
| 1603 ReplaceCall(call, char_at); | 1603 ReplaceCall(call, char_at); |
| 1604 return true; | 1604 return true; |
| 1605 } | 1605 } |
| 1606 | 1606 |
| 1607 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && | 1607 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && |
| 1608 (ic_data.NumberOfChecks() == 1) && |
| 1608 (class_ids[0] == kSmiCid)) { | 1609 (class_ids[0] == kSmiCid)) { |
| 1609 SmiToDoubleInstr* s2d_instr = new SmiToDoubleInstr(call); | 1610 AddReceiverCheck(call); |
| 1610 call->ReplaceWith(s2d_instr, current_iterator()); | 1611 ReplaceCall(call, new SmiToDoubleInstr(new Value(call->ArgumentAt(0)))); |
| 1611 // Pushed arguments are not removed because SmiToDouble is implemented | |
| 1612 // as a call. | |
| 1613 return true; | 1612 return true; |
| 1614 } | 1613 } |
| 1615 | 1614 |
| 1616 if (class_ids[0] == kDoubleCid) { | 1615 if (class_ids[0] == kDoubleCid) { |
| 1617 switch (recognized_kind) { | 1616 switch (recognized_kind) { |
| 1618 case MethodRecognizer::kDoubleToInteger: { | 1617 case MethodRecognizer::kDoubleToInteger: { |
| 1619 AddReceiverCheck(call); | 1618 AddReceiverCheck(call); |
| 1620 ASSERT(call->HasICData()); | 1619 ASSERT(call->HasICData()); |
| 1621 const ICData& ic_data = *call->ic_data(); | 1620 const ICData& ic_data = *call->ic_data(); |
| 1622 Definition* input = call->ArgumentAt(0); | 1621 Definition* input = call->ArgumentAt(0); |
| (...skipping 3045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4668 if (IsNonConstant(value)) { | 4667 if (IsNonConstant(value)) { |
| 4669 SetValue(instr, non_constant_); | 4668 SetValue(instr, non_constant_); |
| 4670 } else if (IsConstant(value)) { | 4669 } else if (IsConstant(value)) { |
| 4671 // TODO(kmillikin): Handle unary operations. | 4670 // TODO(kmillikin): Handle unary operations. |
| 4672 SetValue(instr, non_constant_); | 4671 SetValue(instr, non_constant_); |
| 4673 } | 4672 } |
| 4674 } | 4673 } |
| 4675 | 4674 |
| 4676 | 4675 |
| 4677 void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) { | 4676 void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) { |
| 4678 // TODO(kmillikin): Handle conversion. | 4677 const Object& value = instr->value()->definition()->constant_value(); |
| 4679 SetValue(instr, non_constant_); | 4678 if (IsConstant(value) && value.IsInteger()) { |
| 4679 SetValue(instr, Double::Handle( |
| 4680 Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld))); |
| 4681 } else if (IsNonConstant(value)) { |
| 4682 SetValue(instr, non_constant_); |
| 4683 } |
| 4680 } | 4684 } |
| 4681 | 4685 |
| 4682 | 4686 |
| 4683 void ConstantPropagator::VisitDoubleToInteger(DoubleToIntegerInstr* instr) { | 4687 void ConstantPropagator::VisitDoubleToInteger(DoubleToIntegerInstr* instr) { |
| 4684 // TODO(kmillikin): Handle conversion. | 4688 // TODO(kmillikin): Handle conversion. |
| 4685 SetValue(instr, non_constant_); | 4689 SetValue(instr, non_constant_); |
| 4686 } | 4690 } |
| 4687 | 4691 |
| 4688 | 4692 |
| 4689 void ConstantPropagator::VisitDoubleToSmi(DoubleToSmiInstr* instr) { | 4693 void ConstantPropagator::VisitDoubleToSmi(DoubleToSmiInstr* instr) { |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5379 if (changed) { | 5383 if (changed) { |
| 5380 // We may have changed the block order and the dominator tree. | 5384 // We may have changed the block order and the dominator tree. |
| 5381 flow_graph->DiscoverBlocks(); | 5385 flow_graph->DiscoverBlocks(); |
| 5382 GrowableArray<BitVector*> dominance_frontier; | 5386 GrowableArray<BitVector*> dominance_frontier; |
| 5383 flow_graph->ComputeDominators(&dominance_frontier); | 5387 flow_graph->ComputeDominators(&dominance_frontier); |
| 5384 } | 5388 } |
| 5385 } | 5389 } |
| 5386 | 5390 |
| 5387 | 5391 |
| 5388 } // namespace dart | 5392 } // namespace dart |
| OLD | NEW |