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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 Type* minus_infinity = Type::Constant(factory->minus_infinity_value(), zone); | 47 Type* minus_infinity = Type::Constant(factory->minus_infinity_value(), zone); |
48 // TODO(neis): Unfortunately, the infinities created in other places might | 48 // TODO(neis): Unfortunately, the infinities created in other places might |
49 // be different ones (eg the result of NewNumber in TypeNumberConstant). | 49 // be different ones (eg the result of NewNumber in TypeNumberConstant). |
50 Type* truncating_to_zero = | 50 Type* truncating_to_zero = |
51 Type::Union(Type::Union(infinity, minus_infinity, zone), | 51 Type::Union(Type::Union(infinity, minus_infinity, zone), |
52 Type::MinusZeroOrNaN(), zone); | 52 Type::MinusZeroOrNaN(), zone); |
53 DCHECK(!truncating_to_zero->Maybe(Type::Integral32())); | 53 DCHECK(!truncating_to_zero->Maybe(Type::Integral32())); |
54 | 54 |
55 singleton_false_ = Type::Constant(factory->false_value(), zone); | 55 singleton_false_ = Type::Constant(factory->false_value(), zone); |
56 singleton_true_ = Type::Constant(factory->true_value(), zone); | 56 singleton_true_ = Type::Constant(factory->true_value(), zone); |
| 57 singleton_the_hole_ = Type::Constant(factory->the_hole_value(), zone); |
57 signed32ish_ = Type::Union(Type::Signed32(), truncating_to_zero, zone); | 58 signed32ish_ = Type::Union(Type::Signed32(), truncating_to_zero, zone); |
58 unsigned32ish_ = Type::Union(Type::Unsigned32(), truncating_to_zero, zone); | 59 unsigned32ish_ = Type::Union(Type::Unsigned32(), truncating_to_zero, zone); |
59 falsish_ = Type::Union( | 60 falsish_ = Type::Union( |
60 Type::Undetectable(), | 61 Type::Undetectable(), |
61 Type::Union(Type::Union(singleton_false_, cache_.kZeroish, zone), | 62 Type::Union( |
62 Type::NullOrUndefined(), zone), | 63 Type::Union(Type::Union(singleton_false_, cache_.kZeroish, zone), |
| 64 Type::NullOrUndefined(), zone), |
| 65 singleton_the_hole_, zone), |
63 zone); | 66 zone); |
64 truish_ = Type::Union( | 67 truish_ = Type::Union( |
65 singleton_true_, | 68 singleton_true_, |
66 Type::Union(Type::DetectableReceiver(), Type::Symbol(), zone), zone); | 69 Type::Union(Type::DetectableReceiver(), Type::Symbol(), zone), zone); |
67 | 70 |
68 decorator_ = new (zone) Decorator(this); | 71 decorator_ = new (zone) Decorator(this); |
69 graph_->AddDecorator(decorator_); | 72 graph_->AddDecorator(decorator_); |
70 } | 73 } |
71 | 74 |
72 | 75 |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 } | 693 } |
691 | 694 |
692 | 695 |
693 Type* Typer::Visitor::JSStrictEqualTyper(Type* lhs, Type* rhs, Typer* t) { | 696 Type* Typer::Visitor::JSStrictEqualTyper(Type* lhs, Type* rhs, Typer* t) { |
694 if (!JSType(lhs)->Maybe(JSType(rhs))) return t->singleton_false_; | 697 if (!JSType(lhs)->Maybe(JSType(rhs))) return t->singleton_false_; |
695 if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return t->singleton_false_; | 698 if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return t->singleton_false_; |
696 if (lhs->Is(Type::Number()) && rhs->Is(Type::Number()) && | 699 if (lhs->Is(Type::Number()) && rhs->Is(Type::Number()) && |
697 (lhs->Max() < rhs->Min() || lhs->Min() > rhs->Max())) { | 700 (lhs->Max() < rhs->Min() || lhs->Min() > rhs->Max())) { |
698 return t->singleton_false_; | 701 return t->singleton_false_; |
699 } | 702 } |
| 703 if ((lhs->Is(t->singleton_the_hole_) || rhs->Is(t->singleton_the_hole_)) && |
| 704 !lhs->Maybe(rhs)) { |
| 705 return t->singleton_false_; |
| 706 } |
700 if (lhs->IsConstant() && rhs->Is(lhs)) { | 707 if (lhs->IsConstant() && rhs->Is(lhs)) { |
701 // Types are equal and are inhabited only by a single semantic value, | 708 // Types are equal and are inhabited only by a single semantic value, |
702 // which is not nan due to the earlier check. | 709 // which is not nan due to the earlier check. |
703 return t->singleton_true_; | 710 return t->singleton_true_; |
704 } | 711 } |
705 return Type::Boolean(); | 712 return Type::Boolean(); |
706 } | 713 } |
707 | 714 |
708 | 715 |
709 Type* Typer::Visitor::JSStrictNotEqualTyper(Type* lhs, Type* rhs, Typer* t) { | 716 Type* Typer::Visitor::JSStrictNotEqualTyper(Type* lhs, Type* rhs, Typer* t) { |
(...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2342 } | 2349 } |
2343 if (Type::IsInteger(*value)) { | 2350 if (Type::IsInteger(*value)) { |
2344 return Type::Range(value->Number(), value->Number(), zone()); | 2351 return Type::Range(value->Number(), value->Number(), zone()); |
2345 } | 2352 } |
2346 return Type::Constant(value, zone()); | 2353 return Type::Constant(value, zone()); |
2347 } | 2354 } |
2348 | 2355 |
2349 } // namespace compiler | 2356 } // namespace compiler |
2350 } // namespace internal | 2357 } // namespace internal |
2351 } // namespace v8 | 2358 } // namespace v8 |
OLD | NEW |