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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 #undef DECLARE_METHOD | 277 #undef DECLARE_METHOD |
278 #define DECLARE_METHOD(Name) \ | 278 #define DECLARE_METHOD(Name) \ |
279 static Type* Name(Type* lhs, Type* rhs, Typer* t) { \ | 279 static Type* Name(Type* lhs, Type* rhs, Typer* t) { \ |
280 return t->operation_typer_.Name(lhs, rhs); \ | 280 return t->operation_typer_.Name(lhs, rhs); \ |
281 } | 281 } |
282 SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_METHOD) | 282 SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_METHOD) |
283 SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(DECLARE_METHOD) | 283 SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(DECLARE_METHOD) |
284 #undef DECLARE_METHOD | 284 #undef DECLARE_METHOD |
285 | 285 |
286 static Type* ObjectIsCallable(Type*, Typer*); | 286 static Type* ObjectIsCallable(Type*, Typer*); |
287 static Type* ObjectIsNonCallable(Type*, Typer*); | |
287 static Type* ObjectIsNumber(Type*, Typer*); | 288 static Type* ObjectIsNumber(Type*, Typer*); |
288 static Type* ObjectIsReceiver(Type*, Typer*); | 289 static Type* ObjectIsReceiver(Type*, Typer*); |
289 static Type* ObjectIsSmi(Type*, Typer*); | 290 static Type* ObjectIsSmi(Type*, Typer*); |
290 static Type* ObjectIsString(Type*, Typer*); | 291 static Type* ObjectIsString(Type*, Typer*); |
291 static Type* ObjectIsUndetectable(Type*, Typer*); | 292 static Type* ObjectIsUndetectable(Type*, Typer*); |
292 | 293 |
293 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); | 294 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); |
294 | 295 |
295 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); | 296 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); |
296 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) | 297 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 Type* Typer::Visitor::ToString(Type* type, Typer* t) { | 496 Type* Typer::Visitor::ToString(Type* type, Typer* t) { |
496 // ES6 section 7.1.12 ToString ( argument ) | 497 // ES6 section 7.1.12 ToString ( argument ) |
497 type = ToPrimitive(type, t); | 498 type = ToPrimitive(type, t); |
498 if (type->Is(Type::String())) return type; | 499 if (type->Is(Type::String())) return type; |
499 return Type::String(); | 500 return Type::String(); |
500 } | 501 } |
501 | 502 |
502 // Type checks. | 503 // Type checks. |
503 | 504 |
504 Type* Typer::Visitor::ObjectIsCallable(Type* type, Typer* t) { | 505 Type* Typer::Visitor::ObjectIsCallable(Type* type, Typer* t) { |
505 if (type->Is(Type::Function())) return t->singleton_true_; | 506 if (type->Is(Type::Callable())) return t->singleton_true_; |
bakkot1
2017/01/23 19:26:16
Drive-by comment: document.all is "callable", in t
Benedikt Meurer
2017/02/14 10:18:24
Aye, sorry for the delay, just discovered this com
| |
506 if (type->Is(Type::Primitive())) return t->singleton_false_; | 507 if (!type->Maybe(Type::Callable())) return t->singleton_false_; |
507 return Type::Boolean(); | 508 return Type::Boolean(); |
508 } | 509 } |
509 | 510 |
511 Type* Typer::Visitor::ObjectIsNonCallable(Type* type, Typer* t) { | |
512 if (type->Is(Type::NonCallable())) return t->singleton_true_; | |
513 if (!type->Maybe(Type::NonCallable())) return t->singleton_false_; | |
514 return Type::Boolean(); | |
515 } | |
516 | |
510 Type* Typer::Visitor::ObjectIsNumber(Type* type, Typer* t) { | 517 Type* Typer::Visitor::ObjectIsNumber(Type* type, Typer* t) { |
511 if (type->Is(Type::Number())) return t->singleton_true_; | 518 if (type->Is(Type::Number())) return t->singleton_true_; |
512 if (!type->Maybe(Type::Number())) return t->singleton_false_; | 519 if (!type->Maybe(Type::Number())) return t->singleton_false_; |
513 return Type::Boolean(); | 520 return Type::Boolean(); |
514 } | 521 } |
515 | 522 |
516 | 523 |
517 Type* Typer::Visitor::ObjectIsReceiver(Type* type, Typer* t) { | 524 Type* Typer::Visitor::ObjectIsReceiver(Type* type, Typer* t) { |
518 if (type->Is(Type::Receiver())) return t->singleton_true_; | 525 if (type->Is(Type::Receiver())) return t->singleton_true_; |
519 if (!type->Maybe(Type::Receiver())) return t->singleton_false_; | 526 if (!type->Maybe(Type::Receiver())) return t->singleton_false_; |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1821 | 1828 |
1822 Type* Typer::Visitor::TypeStoreTypedElement(Node* node) { | 1829 Type* Typer::Visitor::TypeStoreTypedElement(Node* node) { |
1823 UNREACHABLE(); | 1830 UNREACHABLE(); |
1824 return nullptr; | 1831 return nullptr; |
1825 } | 1832 } |
1826 | 1833 |
1827 Type* Typer::Visitor::TypeObjectIsCallable(Node* node) { | 1834 Type* Typer::Visitor::TypeObjectIsCallable(Node* node) { |
1828 return TypeUnaryOp(node, ObjectIsCallable); | 1835 return TypeUnaryOp(node, ObjectIsCallable); |
1829 } | 1836 } |
1830 | 1837 |
1838 Type* Typer::Visitor::TypeObjectIsNonCallable(Node* node) { | |
1839 return TypeUnaryOp(node, ObjectIsNonCallable); | |
1840 } | |
1841 | |
1831 Type* Typer::Visitor::TypeObjectIsNumber(Node* node) { | 1842 Type* Typer::Visitor::TypeObjectIsNumber(Node* node) { |
1832 return TypeUnaryOp(node, ObjectIsNumber); | 1843 return TypeUnaryOp(node, ObjectIsNumber); |
1833 } | 1844 } |
1834 | 1845 |
1835 | 1846 |
1836 Type* Typer::Visitor::TypeObjectIsReceiver(Node* node) { | 1847 Type* Typer::Visitor::TypeObjectIsReceiver(Node* node) { |
1837 return TypeUnaryOp(node, ObjectIsReceiver); | 1848 return TypeUnaryOp(node, ObjectIsReceiver); |
1838 } | 1849 } |
1839 | 1850 |
1840 | 1851 |
(...skipping 26 matching lines...) Expand all Loading... | |
1867 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 1878 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { |
1868 if (Type::IsInteger(*value)) { | 1879 if (Type::IsInteger(*value)) { |
1869 return Type::Range(value->Number(), value->Number(), zone()); | 1880 return Type::Range(value->Number(), value->Number(), zone()); |
1870 } | 1881 } |
1871 return Type::NewConstant(value, zone()); | 1882 return Type::NewConstant(value, zone()); |
1872 } | 1883 } |
1873 | 1884 |
1874 } // namespace compiler | 1885 } // namespace compiler |
1875 } // namespace internal | 1886 } // namespace internal |
1876 } // namespace v8 | 1887 } // namespace v8 |
OLD | NEW |