| 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 "src/base/flags.h" | 7 #include "src/base/flags.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
| 10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 static Type* ToName(Type*, Typer*); | 241 static Type* ToName(Type*, Typer*); |
| 242 static Type* ToNumber(Type*, Typer*); | 242 static Type* ToNumber(Type*, Typer*); |
| 243 static Type* ToObject(Type*, Typer*); | 243 static Type* ToObject(Type*, Typer*); |
| 244 static Type* ToString(Type*, Typer*); | 244 static Type* ToString(Type*, Typer*); |
| 245 static Type* NumberCeil(Type*, Typer*); | 245 static Type* NumberCeil(Type*, Typer*); |
| 246 static Type* NumberFloor(Type*, Typer*); | 246 static Type* NumberFloor(Type*, Typer*); |
| 247 static Type* NumberRound(Type*, Typer*); | 247 static Type* NumberRound(Type*, Typer*); |
| 248 static Type* NumberTrunc(Type*, Typer*); | 248 static Type* NumberTrunc(Type*, Typer*); |
| 249 static Type* NumberToInt32(Type*, Typer*); | 249 static Type* NumberToInt32(Type*, Typer*); |
| 250 static Type* NumberToUint32(Type*, Typer*); | 250 static Type* NumberToUint32(Type*, Typer*); |
| 251 static Type* NumberConvertHoleNaN(Type*, Typer*); |
| 251 | 252 |
| 252 static Type* ObjectIsCallable(Type*, Typer*); | 253 static Type* ObjectIsCallable(Type*, Typer*); |
| 253 static Type* ObjectIsNumber(Type*, Typer*); | 254 static Type* ObjectIsNumber(Type*, Typer*); |
| 254 static Type* ObjectIsReceiver(Type*, Typer*); | 255 static Type* ObjectIsReceiver(Type*, Typer*); |
| 255 static Type* ObjectIsSmi(Type*, Typer*); | 256 static Type* ObjectIsSmi(Type*, Typer*); |
| 256 static Type* ObjectIsString(Type*, Typer*); | 257 static Type* ObjectIsString(Type*, Typer*); |
| 257 static Type* ObjectIsUndetectable(Type*, Typer*); | 258 static Type* ObjectIsUndetectable(Type*, Typer*); |
| 258 | 259 |
| 259 static Type* JSAddRanger(RangeType*, RangeType*, Typer*); | 260 static Type* JSAddRanger(RangeType*, RangeType*, Typer*); |
| 260 static Type* JSSubtractRanger(RangeType*, RangeType*, Typer*); | 261 static Type* JSSubtractRanger(RangeType*, RangeType*, Typer*); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 if (type->Is(Type::Unsigned32())) return type; | 550 if (type->Is(Type::Unsigned32())) return type; |
| 550 if (type->Is(t->cache_.kZeroish)) return t->cache_.kSingletonZero; | 551 if (type->Is(t->cache_.kZeroish)) return t->cache_.kSingletonZero; |
| 551 if (type->Is(t->unsigned32ish_)) { | 552 if (type->Is(t->unsigned32ish_)) { |
| 552 return Type::Intersect( | 553 return Type::Intersect( |
| 553 Type::Union(type, t->cache_.kSingletonZero, t->zone()), | 554 Type::Union(type, t->cache_.kSingletonZero, t->zone()), |
| 554 Type::Unsigned32(), t->zone()); | 555 Type::Unsigned32(), t->zone()); |
| 555 } | 556 } |
| 556 return Type::Unsigned32(); | 557 return Type::Unsigned32(); |
| 557 } | 558 } |
| 558 | 559 |
| 560 Type* Typer::Visitor::NumberConvertHoleNaN(Type* type, Typer* t) { |
| 561 return Type::Union(type, Type::Undefined(), t->zone()); |
| 562 } |
| 563 |
| 559 // Type checks. | 564 // Type checks. |
| 560 | 565 |
| 561 Type* Typer::Visitor::ObjectIsCallable(Type* type, Typer* t) { | 566 Type* Typer::Visitor::ObjectIsCallable(Type* type, Typer* t) { |
| 562 if (type->Is(Type::Function())) return t->singleton_true_; | 567 if (type->Is(Type::Function())) return t->singleton_true_; |
| 563 if (type->Is(Type::Primitive())) return t->singleton_false_; | 568 if (type->Is(Type::Primitive())) return t->singleton_false_; |
| 564 return Type::Boolean(); | 569 return Type::Boolean(); |
| 565 } | 570 } |
| 566 | 571 |
| 567 Type* Typer::Visitor::ObjectIsNumber(Type* type, Typer* t) { | 572 Type* Typer::Visitor::ObjectIsNumber(Type* type, Typer* t) { |
| 568 if (type->Is(Type::Number())) return t->singleton_true_; | 573 if (type->Is(Type::Number())) return t->singleton_true_; |
| (...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 | 1811 |
| 1807 Type* Typer::Visitor::TypeNumberToUint32(Node* node) { | 1812 Type* Typer::Visitor::TypeNumberToUint32(Node* node) { |
| 1808 return TypeUnaryOp(node, NumberToUint32); | 1813 return TypeUnaryOp(node, NumberToUint32); |
| 1809 } | 1814 } |
| 1810 | 1815 |
| 1811 | 1816 |
| 1812 Type* Typer::Visitor::TypeNumberIsHoleNaN(Node* node) { | 1817 Type* Typer::Visitor::TypeNumberIsHoleNaN(Node* node) { |
| 1813 return Type::Boolean(); | 1818 return Type::Boolean(); |
| 1814 } | 1819 } |
| 1815 | 1820 |
| 1821 Type* Typer::Visitor::TypeNumberConvertHoleNaN(Node* node) { |
| 1822 return TypeUnaryOp(node, NumberConvertHoleNaN); |
| 1823 } |
| 1824 |
| 1816 // static | 1825 // static |
| 1817 Type* Typer::Visitor::ReferenceEqualTyper(Type* lhs, Type* rhs, Typer* t) { | 1826 Type* Typer::Visitor::ReferenceEqualTyper(Type* lhs, Type* rhs, Typer* t) { |
| 1818 if (lhs->IsConstant() && rhs->Is(lhs)) { | 1827 if (lhs->IsConstant() && rhs->Is(lhs)) { |
| 1819 return t->singleton_true_; | 1828 return t->singleton_true_; |
| 1820 } | 1829 } |
| 1821 return Type::Boolean(); | 1830 return Type::Boolean(); |
| 1822 } | 1831 } |
| 1823 | 1832 |
| 1824 | 1833 |
| 1825 Type* Typer::Visitor::TypeReferenceEqual(Node* node) { | 1834 Type* Typer::Visitor::TypeReferenceEqual(Node* node) { |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2686 } | 2695 } |
| 2687 if (Type::IsInteger(*value)) { | 2696 if (Type::IsInteger(*value)) { |
| 2688 return Type::Range(value->Number(), value->Number(), zone()); | 2697 return Type::Range(value->Number(), value->Number(), zone()); |
| 2689 } | 2698 } |
| 2690 return Type::Constant(value, zone()); | 2699 return Type::Constant(value, zone()); |
| 2691 } | 2700 } |
| 2692 | 2701 |
| 2693 } // namespace compiler | 2702 } // namespace compiler |
| 2694 } // namespace internal | 2703 } // namespace internal |
| 2695 } // namespace v8 | 2704 } // namespace v8 |
| OLD | NEW |