OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/typer.h" | 5 #include "src/compiler/typer.h" |
6 | 6 |
7 #include <iomanip> | 7 #include <iomanip> |
8 | 8 |
9 #include "src/base/flags.h" | 9 #include "src/base/flags.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 Type* index = Operand(node, 0); | 1564 Type* index = Operand(node, 0); |
1565 Type* length = Operand(node, 1); | 1565 Type* length = Operand(node, 1); |
1566 index = Type::Intersect(index, Type::Integral32(), zone()); | 1566 index = Type::Intersect(index, Type::Integral32(), zone()); |
1567 if (!index->IsInhabited() || !length->IsInhabited()) return Type::None(); | 1567 if (!index->IsInhabited() || !length->IsInhabited()) return Type::None(); |
1568 double min = std::max(index->Min(), 0.0); | 1568 double min = std::max(index->Min(), 0.0); |
1569 double max = std::min(index->Max(), length->Max() - 1); | 1569 double max = std::min(index->Max(), length->Max() - 1); |
1570 if (max < min) return Type::None(); | 1570 if (max < min) return Type::None(); |
1571 return Type::Range(min, max, zone()); | 1571 return Type::Range(min, max, zone()); |
1572 } | 1572 } |
1573 | 1573 |
| 1574 Type* Typer::Visitor::TypeCheckHeapObject(Node* node) { |
| 1575 Type* type = Operand(node, 0); |
| 1576 return type; |
| 1577 } |
| 1578 |
| 1579 Type* Typer::Visitor::TypeCheckIf(Node* node) { |
| 1580 UNREACHABLE(); |
| 1581 return nullptr; |
| 1582 } |
| 1583 |
1574 Type* Typer::Visitor::TypeCheckMaps(Node* node) { | 1584 Type* Typer::Visitor::TypeCheckMaps(Node* node) { |
1575 UNREACHABLE(); | 1585 UNREACHABLE(); |
1576 return nullptr; | 1586 return nullptr; |
1577 } | 1587 } |
1578 | 1588 |
1579 Type* Typer::Visitor::TypeCheckNumber(Node* node) { | 1589 Type* Typer::Visitor::TypeCheckNumber(Node* node) { |
1580 Type* arg = Operand(node, 0); | 1590 Type* arg = Operand(node, 0); |
1581 return Type::Intersect(arg, Type::Number(), zone()); | 1591 return Type::Intersect(arg, Type::Number(), zone()); |
1582 } | 1592 } |
1583 | 1593 |
| 1594 Type* Typer::Visitor::TypeCheckSmi(Node* node) { |
| 1595 Type* arg = Operand(node, 0); |
| 1596 return Type::Intersect(arg, Type::SignedSmall(), zone()); |
| 1597 } |
| 1598 |
1584 Type* Typer::Visitor::TypeCheckString(Node* node) { | 1599 Type* Typer::Visitor::TypeCheckString(Node* node) { |
1585 Type* arg = Operand(node, 0); | 1600 Type* arg = Operand(node, 0); |
1586 return Type::Intersect(arg, Type::String(), zone()); | 1601 return Type::Intersect(arg, Type::String(), zone()); |
1587 } | 1602 } |
1588 | 1603 |
1589 Type* Typer::Visitor::TypeCheckIf(Node* node) { | |
1590 UNREACHABLE(); | |
1591 return nullptr; | |
1592 } | |
1593 | |
1594 Type* Typer::Visitor::TypeCheckTaggedPointer(Node* node) { | |
1595 Type* type = Operand(node, 0); | |
1596 return type; | |
1597 } | |
1598 | |
1599 Type* Typer::Visitor::TypeCheckTaggedSigned(Node* node) { | |
1600 Type* arg = Operand(node, 0); | |
1601 return Type::Intersect(arg, typer_->cache_.kSmi, zone()); | |
1602 } | |
1603 | |
1604 Type* Typer::Visitor::TypeCheckFloat64Hole(Node* node) { | 1604 Type* Typer::Visitor::TypeCheckFloat64Hole(Node* node) { |
1605 Type* type = Operand(node, 0); | 1605 Type* type = Operand(node, 0); |
1606 return type; | 1606 return type; |
1607 } | 1607 } |
1608 | 1608 |
1609 Type* Typer::Visitor::TypeCheckTaggedHole(Node* node) { | 1609 Type* Typer::Visitor::TypeCheckTaggedHole(Node* node) { |
1610 Type* type = Operand(node, 0); | 1610 Type* type = Operand(node, 0); |
1611 type = Type::Intersect(type, Type::NonInternal(), zone()); | 1611 type = Type::Intersect(type, Type::NonInternal(), zone()); |
1612 return type; | 1612 return type; |
1613 } | 1613 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1716 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 1716 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { |
1717 if (Type::IsInteger(*value)) { | 1717 if (Type::IsInteger(*value)) { |
1718 return Type::Range(value->Number(), value->Number(), zone()); | 1718 return Type::Range(value->Number(), value->Number(), zone()); |
1719 } | 1719 } |
1720 return Type::Constant(value, zone()); | 1720 return Type::Constant(value, zone()); |
1721 } | 1721 } |
1722 | 1722 |
1723 } // namespace compiler | 1723 } // namespace compiler |
1724 } // namespace internal | 1724 } // namespace internal |
1725 } // namespace v8 | 1725 } // namespace v8 |
OLD | NEW |