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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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* ObjectIsNumber(Type*, Typer*); | 250 static Type* ObjectIsNumber(Type*, Typer*); |
251 static Type* ObjectIsReceiver(Type*, Typer*); | 251 static Type* ObjectIsReceiver(Type*, Typer*); |
252 static Type* ObjectIsSmi(Type*, Typer*); | 252 static Type* ObjectIsSmi(Type*, Typer*); |
| 253 static Type* ObjectIsString(Type*, Typer*); |
253 static Type* ObjectIsUndetectable(Type*, Typer*); | 254 static Type* ObjectIsUndetectable(Type*, Typer*); |
254 | 255 |
255 static Type* JSAddRanger(RangeType*, RangeType*, Typer*); | 256 static Type* JSAddRanger(RangeType*, RangeType*, Typer*); |
256 static Type* JSSubtractRanger(RangeType*, RangeType*, Typer*); | 257 static Type* JSSubtractRanger(RangeType*, RangeType*, Typer*); |
257 static Type* JSDivideRanger(RangeType*, RangeType*, Typer*); | 258 static Type* JSDivideRanger(RangeType*, RangeType*, Typer*); |
258 static Type* JSModulusRanger(RangeType*, RangeType*, Typer*); | 259 static Type* JSModulusRanger(RangeType*, RangeType*, Typer*); |
259 | 260 |
260 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); | 261 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); |
261 | 262 |
262 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); | 263 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 return Type::Boolean(); | 571 return Type::Boolean(); |
571 } | 572 } |
572 | 573 |
573 | 574 |
574 Type* Typer::Visitor::ObjectIsSmi(Type* type, Typer* t) { | 575 Type* Typer::Visitor::ObjectIsSmi(Type* type, Typer* t) { |
575 if (type->Is(Type::TaggedSigned())) return t->singleton_true_; | 576 if (type->Is(Type::TaggedSigned())) return t->singleton_true_; |
576 if (type->Is(Type::TaggedPointer())) return t->singleton_false_; | 577 if (type->Is(Type::TaggedPointer())) return t->singleton_false_; |
577 return Type::Boolean(); | 578 return Type::Boolean(); |
578 } | 579 } |
579 | 580 |
| 581 Type* Typer::Visitor::ObjectIsString(Type* type, Typer* t) { |
| 582 if (type->Is(Type::String())) return t->singleton_true_; |
| 583 if (!type->Maybe(Type::String())) return t->singleton_false_; |
| 584 return Type::Boolean(); |
| 585 } |
580 | 586 |
581 Type* Typer::Visitor::ObjectIsUndetectable(Type* type, Typer* t) { | 587 Type* Typer::Visitor::ObjectIsUndetectable(Type* type, Typer* t) { |
582 if (type->Is(Type::Undetectable())) return t->singleton_true_; | 588 if (type->Is(Type::Undetectable())) return t->singleton_true_; |
583 if (!type->Maybe(Type::Undetectable())) return t->singleton_false_; | 589 if (!type->Maybe(Type::Undetectable())) return t->singleton_false_; |
584 return Type::Boolean(); | 590 return Type::Boolean(); |
585 } | 591 } |
586 | 592 |
587 | 593 |
588 // ----------------------------------------------------------------------------- | 594 // ----------------------------------------------------------------------------- |
589 | 595 |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 | 1996 |
1991 Type* Typer::Visitor::TypeObjectIsReceiver(Node* node) { | 1997 Type* Typer::Visitor::TypeObjectIsReceiver(Node* node) { |
1992 return TypeUnaryOp(node, ObjectIsReceiver); | 1998 return TypeUnaryOp(node, ObjectIsReceiver); |
1993 } | 1999 } |
1994 | 2000 |
1995 | 2001 |
1996 Type* Typer::Visitor::TypeObjectIsSmi(Node* node) { | 2002 Type* Typer::Visitor::TypeObjectIsSmi(Node* node) { |
1997 return TypeUnaryOp(node, ObjectIsSmi); | 2003 return TypeUnaryOp(node, ObjectIsSmi); |
1998 } | 2004 } |
1999 | 2005 |
| 2006 Type* Typer::Visitor::TypeObjectIsString(Node* node) { |
| 2007 return TypeUnaryOp(node, ObjectIsString); |
| 2008 } |
2000 | 2009 |
2001 Type* Typer::Visitor::TypeObjectIsUndetectable(Node* node) { | 2010 Type* Typer::Visitor::TypeObjectIsUndetectable(Node* node) { |
2002 return TypeUnaryOp(node, ObjectIsUndetectable); | 2011 return TypeUnaryOp(node, ObjectIsUndetectable); |
2003 } | 2012 } |
2004 | 2013 |
2005 | 2014 |
2006 // Machine operators. | 2015 // Machine operators. |
2007 | 2016 |
2008 Type* Typer::Visitor::TypeLoad(Node* node) { return Type::Any(); } | 2017 Type* Typer::Visitor::TypeLoad(Node* node) { return Type::Any(); } |
2009 | 2018 |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2536 } | 2545 } |
2537 if (Type::IsInteger(*value)) { | 2546 if (Type::IsInteger(*value)) { |
2538 return Type::Range(value->Number(), value->Number(), zone()); | 2547 return Type::Range(value->Number(), value->Number(), zone()); |
2539 } | 2548 } |
2540 return Type::Constant(value, zone()); | 2549 return Type::Constant(value, zone()); |
2541 } | 2550 } |
2542 | 2551 |
2543 } // namespace compiler | 2552 } // namespace compiler |
2544 } // namespace internal | 2553 } // namespace internal |
2545 } // namespace v8 | 2554 } // namespace v8 |
OLD | NEW |