| 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 | 509 |
| 510 | 510 |
| 511 Type* Typer::Visitor::ObjectIsReceiver(Type* type, Typer* t) { | 511 Type* Typer::Visitor::ObjectIsReceiver(Type* type, Typer* t) { |
| 512 if (type->Is(Type::Receiver())) return t->singleton_true_; | 512 if (type->Is(Type::Receiver())) return t->singleton_true_; |
| 513 if (!type->Maybe(Type::Receiver())) return t->singleton_false_; | 513 if (!type->Maybe(Type::Receiver())) return t->singleton_false_; |
| 514 return Type::Boolean(); | 514 return Type::Boolean(); |
| 515 } | 515 } |
| 516 | 516 |
| 517 | 517 |
| 518 Type* Typer::Visitor::ObjectIsSmi(Type* type, Typer* t) { | 518 Type* Typer::Visitor::ObjectIsSmi(Type* type, Typer* t) { |
| 519 if (type->Is(Type::TaggedSigned())) return t->singleton_true_; | 519 if (!type->Maybe(Type::SignedSmall())) return t->singleton_false_; |
| 520 if (type->Is(Type::TaggedPointer())) return t->singleton_false_; | |
| 521 return Type::Boolean(); | 520 return Type::Boolean(); |
| 522 } | 521 } |
| 523 | 522 |
| 524 Type* Typer::Visitor::ObjectIsString(Type* type, Typer* t) { | 523 Type* Typer::Visitor::ObjectIsString(Type* type, Typer* t) { |
| 525 if (type->Is(Type::String())) return t->singleton_true_; | 524 if (type->Is(Type::String())) return t->singleton_true_; |
| 526 if (!type->Maybe(Type::String())) return t->singleton_false_; | 525 if (!type->Maybe(Type::String())) return t->singleton_false_; |
| 527 return Type::Boolean(); | 526 return Type::Boolean(); |
| 528 } | 527 } |
| 529 | 528 |
| 530 Type* Typer::Visitor::ObjectIsUndetectable(Type* type, Typer* t) { | 529 Type* Typer::Visitor::ObjectIsUndetectable(Type* type, Typer* t) { |
| (...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 Type* arg = Operand(node, 0); | 1579 Type* arg = Operand(node, 0); |
| 1581 return Type::Intersect(arg, Type::String(), zone()); | 1580 return Type::Intersect(arg, Type::String(), zone()); |
| 1582 } | 1581 } |
| 1583 | 1582 |
| 1584 Type* Typer::Visitor::TypeCheckIf(Node* node) { | 1583 Type* Typer::Visitor::TypeCheckIf(Node* node) { |
| 1585 UNREACHABLE(); | 1584 UNREACHABLE(); |
| 1586 return nullptr; | 1585 return nullptr; |
| 1587 } | 1586 } |
| 1588 | 1587 |
| 1589 Type* Typer::Visitor::TypeCheckTaggedPointer(Node* node) { | 1588 Type* Typer::Visitor::TypeCheckTaggedPointer(Node* node) { |
| 1590 Type* arg = Operand(node, 0); | 1589 Type* type = Operand(node, 0); |
| 1591 return Type::Intersect(arg, Type::TaggedPointer(), zone()); | 1590 return type; |
| 1592 } | 1591 } |
| 1593 | 1592 |
| 1594 Type* Typer::Visitor::TypeCheckTaggedSigned(Node* node) { | 1593 Type* Typer::Visitor::TypeCheckTaggedSigned(Node* node) { |
| 1595 Type* arg = Operand(node, 0); | 1594 Type* arg = Operand(node, 0); |
| 1596 return Type::Intersect(arg, typer_->cache_.kSmi, zone()); | 1595 return Type::Intersect(arg, typer_->cache_.kSmi, zone()); |
| 1597 } | 1596 } |
| 1598 | 1597 |
| 1599 Type* Typer::Visitor::TypeCheckFloat64Hole(Node* node) { | 1598 Type* Typer::Visitor::TypeCheckFloat64Hole(Node* node) { |
| 1600 Type* type = Operand(node, 0); | 1599 Type* type = Operand(node, 0); |
| 1601 return type; | 1600 return type; |
| 1602 } | 1601 } |
| 1603 | 1602 |
| 1604 Type* Typer::Visitor::TypeCheckTaggedHole(Node* node) { | 1603 Type* Typer::Visitor::TypeCheckTaggedHole(Node* node) { |
| 1605 Type* type = Operand(node, 0); | 1604 Type* type = Operand(node, 0); |
| 1606 type = Type::Intersect(type, Type::NonInternal(), zone()); | 1605 type = Type::Intersect(type, Type::NonInternal(), zone()); |
| 1607 return type; | 1606 return type; |
| 1608 } | 1607 } |
| 1609 | 1608 |
| 1610 Type* Typer::Visitor::TypeConvertTaggedHoleToUndefined(Node* node) { | 1609 Type* Typer::Visitor::TypeConvertTaggedHoleToUndefined(Node* node) { |
| 1611 Type* type = Operand(node, 0); | 1610 Type* type = Operand(node, 0); |
| 1612 if (type->Maybe(Type::Hole())) { | 1611 if (type->Maybe(Type::Hole())) { |
| 1613 // Turn "the hole" into undefined. | 1612 // Turn "the hole" into undefined. |
| 1614 type = Type::Intersect(type, Type::NonInternal(), zone()); | 1613 type = Type::Intersect(type, Type::NonInternal(), zone()); |
| 1615 type = Type::Union(type, Type::Undefined(), zone()); | 1614 type = Type::Union(type, Type::Undefined(), zone()); |
| 1616 } | 1615 } |
| 1617 return type; | 1616 return type; |
| 1618 } | 1617 } |
| 1619 | 1618 |
| 1620 Type* Typer::Visitor::TypeAllocate(Node* node) { return Type::TaggedPointer(); } | 1619 Type* Typer::Visitor::TypeAllocate(Node* node) { return Type::Any(); } |
| 1621 | 1620 |
| 1622 Type* Typer::Visitor::TypeLoadField(Node* node) { | 1621 Type* Typer::Visitor::TypeLoadField(Node* node) { |
| 1623 return FieldAccessOf(node->op()).type; | 1622 return FieldAccessOf(node->op()).type; |
| 1624 } | 1623 } |
| 1625 | 1624 |
| 1626 Type* Typer::Visitor::TypeLoadBuffer(Node* node) { | 1625 Type* Typer::Visitor::TypeLoadBuffer(Node* node) { |
| 1627 // TODO(bmeurer): This typing is not yet correct. Since we can still access | 1626 // TODO(bmeurer): This typing is not yet correct. Since we can still access |
| 1628 // out of bounds, the type in the general case has to include Undefined. | 1627 // out of bounds, the type in the general case has to include Undefined. |
| 1629 switch (BufferAccessOf(node->op()).external_array_type()) { | 1628 switch (BufferAccessOf(node->op()).external_array_type()) { |
| 1630 #define TYPED_ARRAY_CASE(ElemType, type, TYPE, ctype, size) \ | 1629 #define TYPED_ARRAY_CASE(ElemType, type, TYPE, ctype, size) \ |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1711 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 1710 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { |
| 1712 if (Type::IsInteger(*value)) { | 1711 if (Type::IsInteger(*value)) { |
| 1713 return Type::Range(value->Number(), value->Number(), zone()); | 1712 return Type::Range(value->Number(), value->Number(), zone()); |
| 1714 } | 1713 } |
| 1715 return Type::Constant(value, zone()); | 1714 return Type::Constant(value, zone()); |
| 1716 } | 1715 } |
| 1717 | 1716 |
| 1718 } // namespace compiler | 1717 } // namespace compiler |
| 1719 } // namespace internal | 1718 } // namespace internal |
| 1720 } // namespace v8 | 1719 } // namespace v8 |
| OLD | NEW |