| 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 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 return t->singleton_false_; | 820 return t->singleton_false_; |
| 821 } | 821 } |
| 822 if (lhs->IsConstant() && rhs->Is(lhs)) { | 822 if (lhs->IsConstant() && rhs->Is(lhs)) { |
| 823 // Types are equal and are inhabited only by a single semantic value, | 823 // Types are equal and are inhabited only by a single semantic value, |
| 824 // which is not nan due to the earlier check. | 824 // which is not nan due to the earlier check. |
| 825 return t->singleton_true_; | 825 return t->singleton_true_; |
| 826 } | 826 } |
| 827 return Type::Boolean(); | 827 return Type::Boolean(); |
| 828 } | 828 } |
| 829 | 829 |
| 830 Type* Typer::Visitor::JSSameValueZeroTyper(Type* lhs, Type* rhs, Typer* t) { |
| 831 if (!JSType(lhs)->Maybe(JSType(rhs))) return t->singleton_false_; |
| 832 if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return t->singleton_true_; |
| 833 if (lhs->Is(Type::Number()) && rhs->Is(Type::Number()) && |
| 834 (lhs->Max() < rhs->Min() || lhs->Min() > rhs->Max())) { |
| 835 return t->singleton_false_; |
| 836 } |
| 837 if ((lhs->Is(t->singleton_the_hole_) || rhs->Is(t->singleton_the_hole_)) && |
| 838 !lhs->Maybe(rhs)) { |
| 839 return t->singleton_false_; |
| 840 } |
| 841 if (lhs->IsConstant() && rhs->Is(lhs)) { |
| 842 // Types are equal and are inhabited only by a single semantic value, |
| 843 // which is not nan due to the earlier check. |
| 844 return t->singleton_true_; |
| 845 } |
| 846 return Type::Boolean(); |
| 847 } |
| 848 |
| 830 | 849 |
| 831 Type* Typer::Visitor::JSStrictNotEqualTyper(Type* lhs, Type* rhs, Typer* t) { | 850 Type* Typer::Visitor::JSStrictNotEqualTyper(Type* lhs, Type* rhs, Typer* t) { |
| 832 return Invert(JSStrictEqualTyper(lhs, rhs, t), t); | 851 return Invert(JSStrictEqualTyper(lhs, rhs, t), t); |
| 833 } | 852 } |
| 834 | 853 |
| 835 | 854 |
| 836 // The EcmaScript specification defines the four relational comparison operators | 855 // The EcmaScript specification defines the four relational comparison operators |
| 837 // (<, <=, >=, >) with the help of a single abstract one. It behaves like < | 856 // (<, <=, >=, >) with the help of a single abstract one. It behaves like < |
| 838 // but returns undefined when the inputs cannot be compared. | 857 // but returns undefined when the inputs cannot be compared. |
| 839 // We implement the typing analogously. | 858 // We implement the typing analogously. |
| (...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2535 } | 2554 } |
| 2536 if (Type::IsInteger(*value)) { | 2555 if (Type::IsInteger(*value)) { |
| 2537 return Type::Range(value->Number(), value->Number(), zone()); | 2556 return Type::Range(value->Number(), value->Number(), zone()); |
| 2538 } | 2557 } |
| 2539 return Type::Constant(value, zone()); | 2558 return Type::Constant(value, zone()); |
| 2540 } | 2559 } |
| 2541 | 2560 |
| 2542 } // namespace compiler | 2561 } // namespace compiler |
| 2543 } // namespace internal | 2562 } // namespace internal |
| 2544 } // namespace v8 | 2563 } // namespace v8 |
| OLD | NEW |