Chromium Code Reviews| 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_allocator.h" | 10 #include "vm/flow_graph_allocator.h" |
| (...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1622 // value of the comparison is not used outside the branch anymore. | 1622 // value of the comparison is not used outside the branch anymore. |
| 1623 ASSERT(comp->input_use_list() == NULL); | 1623 ASSERT(comp->input_use_list() == NULL); |
| 1624 comp->ClearSSATempIndex(); | 1624 comp->ClearSSATempIndex(); |
| 1625 comp->ClearTempIndex(); | 1625 comp->ClearTempIndex(); |
| 1626 } | 1626 } |
| 1627 } | 1627 } |
| 1628 return this; | 1628 return this; |
| 1629 } | 1629 } |
| 1630 | 1630 |
| 1631 | 1631 |
| 1632 static bool MayBeBoxableNumber(intptr_t cid) { | |
| 1633 return (cid == kDynamicCid) || | |
| 1634 (cid == kMintCid) || | |
| 1635 (cid == kBigintCid) || | |
| 1636 (cid == kDoubleCid); | |
| 1637 } | |
| 1638 | |
| 1639 | |
| 1640 static bool MaybeNumber(CompileType* type) { | |
| 1641 ASSERT(Type::Handle(Type::Number()).IsMoreSpecificThan( | |
| 1642 Type::Handle(Type::Number()), NULL)); | |
| 1643 return type->ToAbstractType()->IsDynamicType() | |
| 1644 || type->IsMoreSpecificThan(Type::Handle(Type::Number())); | |
| 1645 } | |
| 1646 | |
| 1647 | |
| 1632 Definition* StrictCompareInstr::Canonicalize(FlowGraph* flow_graph) { | 1648 Definition* StrictCompareInstr::Canonicalize(FlowGraph* flow_graph) { |
| 1649 // Use propagated cid and type information to eliminate number checks. | |
| 1650 // If one of the inputs is not a boxable number (Mint, Double, Bigint), or | |
| 1651 // is not a subtype of num, no need for number checks. | |
| 1652 if (needs_number_check()) { | |
| 1653 if (!MayBeBoxableNumber(left()->Type()->ToCid()) || | |
| 1654 !MayBeBoxableNumber(right()->Type()->ToCid())) { | |
| 1655 set_needs_number_check(false); | |
| 1656 } else if (!MaybeNumber(left()->Type()) || !MaybeNumber(right()->Type())) { | |
|
srdjan
2013/10/17 17:06:45
Wouldn't it be enough to just check for MayBeNumbe
Florian Schneider
2013/10/18 10:55:27
It would work, but the check on the AbstractType d
| |
| 1657 set_needs_number_check(false); | |
| 1658 } | |
| 1659 } | |
| 1660 | |
| 1633 bool negated = false; | 1661 bool negated = false; |
| 1634 Definition* replacement = CanonicalizeStrictCompare(this, &negated); | 1662 Definition* replacement = CanonicalizeStrictCompare(this, &negated); |
| 1635 if (negated && replacement->IsComparison()) { | 1663 if (negated && replacement->IsComparison()) { |
| 1636 ASSERT(replacement != this); | 1664 ASSERT(replacement != this); |
| 1637 replacement->AsComparison()->NegateComparison(); | 1665 replacement->AsComparison()->NegateComparison(); |
| 1638 } | 1666 } |
| 1639 return replacement; | 1667 return replacement; |
| 1640 } | 1668 } |
| 1641 | 1669 |
| 1642 | 1670 |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2771 return kCosRuntimeEntry; | 2799 return kCosRuntimeEntry; |
| 2772 default: | 2800 default: |
| 2773 UNREACHABLE(); | 2801 UNREACHABLE(); |
| 2774 } | 2802 } |
| 2775 return kSinRuntimeEntry; | 2803 return kSinRuntimeEntry; |
| 2776 } | 2804 } |
| 2777 | 2805 |
| 2778 #undef __ | 2806 #undef __ |
| 2779 | 2807 |
| 2780 } // namespace dart | 2808 } // namespace dart |
| OLD | NEW |