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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 static Type* ToNumber(Type*, Typer*); | 240 static Type* ToNumber(Type*, Typer*); |
241 static Type* ToObject(Type*, Typer*); | 241 static Type* ToObject(Type*, Typer*); |
242 static Type* ToString(Type*, Typer*); | 242 static Type* ToString(Type*, Typer*); |
243 static Type* NumberCeil(Type*, Typer*); | 243 static Type* NumberCeil(Type*, Typer*); |
244 static Type* NumberFloor(Type*, Typer*); | 244 static Type* NumberFloor(Type*, Typer*); |
245 static Type* NumberRound(Type*, Typer*); | 245 static Type* NumberRound(Type*, Typer*); |
246 static Type* NumberTrunc(Type*, Typer*); | 246 static Type* NumberTrunc(Type*, Typer*); |
247 static Type* NumberToInt32(Type*, Typer*); | 247 static Type* NumberToInt32(Type*, Typer*); |
248 static Type* NumberToUint32(Type*, Typer*); | 248 static Type* NumberToUint32(Type*, Typer*); |
249 | 249 |
| 250 static Type* ObjectIsCallable(Type*, Typer*); |
250 static Type* ObjectIsNumber(Type*, Typer*); | 251 static Type* ObjectIsNumber(Type*, Typer*); |
251 static Type* ObjectIsReceiver(Type*, Typer*); | 252 static Type* ObjectIsReceiver(Type*, Typer*); |
252 static Type* ObjectIsSmi(Type*, Typer*); | 253 static Type* ObjectIsSmi(Type*, Typer*); |
253 static Type* ObjectIsString(Type*, Typer*); | 254 static Type* ObjectIsString(Type*, Typer*); |
254 static Type* ObjectIsUndetectable(Type*, Typer*); | 255 static Type* ObjectIsUndetectable(Type*, Typer*); |
255 | 256 |
256 static Type* JSAddRanger(RangeType*, RangeType*, Typer*); | 257 static Type* JSAddRanger(RangeType*, RangeType*, Typer*); |
257 static Type* JSSubtractRanger(RangeType*, RangeType*, Typer*); | 258 static Type* JSSubtractRanger(RangeType*, RangeType*, Typer*); |
258 static Type* JSDivideRanger(RangeType*, RangeType*, Typer*); | 259 static Type* JSDivideRanger(RangeType*, RangeType*, Typer*); |
259 static Type* JSModulusRanger(RangeType*, RangeType*, Typer*); | 260 static Type* JSModulusRanger(RangeType*, RangeType*, Typer*); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 return Type::Intersect( | 551 return Type::Intersect( |
551 Type::Union(type, t->cache_.kSingletonZero, t->zone()), | 552 Type::Union(type, t->cache_.kSingletonZero, t->zone()), |
552 Type::Unsigned32(), t->zone()); | 553 Type::Unsigned32(), t->zone()); |
553 } | 554 } |
554 return Type::Unsigned32(); | 555 return Type::Unsigned32(); |
555 } | 556 } |
556 | 557 |
557 | 558 |
558 // Type checks. | 559 // Type checks. |
559 | 560 |
| 561 Type* Typer::Visitor::ObjectIsCallable(Type* type, Typer* t) { |
| 562 if (type->Is(Type::Function())) return t->singleton_true_; |
| 563 if (type->Is(Type::Primitive())) return t->singleton_false_; |
| 564 return Type::Boolean(); |
| 565 } |
560 | 566 |
561 Type* Typer::Visitor::ObjectIsNumber(Type* type, Typer* t) { | 567 Type* Typer::Visitor::ObjectIsNumber(Type* type, Typer* t) { |
562 if (type->Is(Type::Number())) return t->singleton_true_; | 568 if (type->Is(Type::Number())) return t->singleton_true_; |
563 if (!type->Maybe(Type::Number())) return t->singleton_false_; | 569 if (!type->Maybe(Type::Number())) return t->singleton_false_; |
564 return Type::Boolean(); | 570 return Type::Boolean(); |
565 } | 571 } |
566 | 572 |
567 | 573 |
568 Type* Typer::Visitor::ObjectIsReceiver(Type* type, Typer* t) { | 574 Type* Typer::Visitor::ObjectIsReceiver(Type* type, Typer* t) { |
569 if (type->Is(Type::Receiver())) return t->singleton_true_; | 575 if (type->Is(Type::Receiver())) return t->singleton_true_; |
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 UNREACHABLE(); | 1987 UNREACHABLE(); |
1982 return nullptr; | 1988 return nullptr; |
1983 } | 1989 } |
1984 | 1990 |
1985 | 1991 |
1986 Type* Typer::Visitor::TypeStoreElement(Node* node) { | 1992 Type* Typer::Visitor::TypeStoreElement(Node* node) { |
1987 UNREACHABLE(); | 1993 UNREACHABLE(); |
1988 return nullptr; | 1994 return nullptr; |
1989 } | 1995 } |
1990 | 1996 |
| 1997 Type* Typer::Visitor::TypeObjectIsCallable(Node* node) { |
| 1998 return TypeUnaryOp(node, ObjectIsCallable); |
| 1999 } |
1991 | 2000 |
1992 Type* Typer::Visitor::TypeObjectIsNumber(Node* node) { | 2001 Type* Typer::Visitor::TypeObjectIsNumber(Node* node) { |
1993 return TypeUnaryOp(node, ObjectIsNumber); | 2002 return TypeUnaryOp(node, ObjectIsNumber); |
1994 } | 2003 } |
1995 | 2004 |
1996 | 2005 |
1997 Type* Typer::Visitor::TypeObjectIsReceiver(Node* node) { | 2006 Type* Typer::Visitor::TypeObjectIsReceiver(Node* node) { |
1998 return TypeUnaryOp(node, ObjectIsReceiver); | 2007 return TypeUnaryOp(node, ObjectIsReceiver); |
1999 } | 2008 } |
2000 | 2009 |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2545 } | 2554 } |
2546 if (Type::IsInteger(*value)) { | 2555 if (Type::IsInteger(*value)) { |
2547 return Type::Range(value->Number(), value->Number(), zone()); | 2556 return Type::Range(value->Number(), value->Number(), zone()); |
2548 } | 2557 } |
2549 return Type::Constant(value, zone()); | 2558 return Type::Constant(value, zone()); |
2550 } | 2559 } |
2551 | 2560 |
2552 } // namespace compiler | 2561 } // namespace compiler |
2553 } // namespace internal | 2562 } // namespace internal |
2554 } // namespace v8 | 2563 } // namespace v8 |
OLD | NEW |