| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/operation-typer.h" | 5 #include "src/compiler/operation-typer.h" |
| 6 | 6 |
| 7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 #include "src/compiler/type-cache.h" | 8 #include "src/compiler/type-cache.h" |
| 9 #include "src/compiler/types.h" | 9 #include "src/compiler/types.h" |
| 10 #include "src/factory.h" | 10 #include "src/factory.h" |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 | 618 |
| 619 Type* OperationTyper::NumberDivide(Type* lhs, Type* rhs) { | 619 Type* OperationTyper::NumberDivide(Type* lhs, Type* rhs) { |
| 620 DCHECK(lhs->Is(Type::Number())); | 620 DCHECK(lhs->Is(Type::Number())); |
| 621 DCHECK(rhs->Is(Type::Number())); | 621 DCHECK(rhs->Is(Type::Number())); |
| 622 | 622 |
| 623 if (!lhs->IsInhabited() || !rhs->IsInhabited()) { | 623 if (!lhs->IsInhabited() || !rhs->IsInhabited()) { |
| 624 return Type::None(); | 624 return Type::None(); |
| 625 } | 625 } |
| 626 | 626 |
| 627 if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return Type::NaN(); | 627 if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return Type::NaN(); |
| 628 |
| 628 // Division is tricky, so all we do is try ruling out -0 and NaN. | 629 // Division is tricky, so all we do is try ruling out -0 and NaN. |
| 629 bool maybe_minuszero = !lhs->Is(cache_.kPositiveIntegerOrNaN) || | |
| 630 !rhs->Is(cache_.kPositiveIntegerOrNaN); | |
| 631 bool maybe_nan = | 630 bool maybe_nan = |
| 632 lhs->Maybe(Type::NaN()) || rhs->Maybe(cache_.kZeroish) || | 631 lhs->Maybe(Type::NaN()) || rhs->Maybe(cache_.kZeroish) || |
| 633 ((lhs->Min() == -V8_INFINITY || lhs->Max() == +V8_INFINITY) && | 632 ((lhs->Min() == -V8_INFINITY || lhs->Max() == +V8_INFINITY) && |
| 634 (rhs->Min() == -V8_INFINITY || rhs->Max() == +V8_INFINITY)); | 633 (rhs->Min() == -V8_INFINITY || rhs->Max() == +V8_INFINITY)); |
| 634 lhs = Type::Intersect(lhs, Type::OrderedNumber(), zone()); |
| 635 rhs = Type::Intersect(rhs, Type::OrderedNumber(), zone()); |
| 636 |
| 637 // Try to rule out -0. |
| 638 bool maybe_minuszero = |
| 639 !lhs->Is(cache_.kInteger) || |
| 640 (lhs->Maybe(cache_.kZeroish) && rhs->Min() < 0.0) || |
| 641 (rhs->Min() == -V8_INFINITY || rhs->Max() == +V8_INFINITY); |
| 635 | 642 |
| 636 // Take into account the -0 and NaN information computed earlier. | 643 // Take into account the -0 and NaN information computed earlier. |
| 637 Type* type = Type::PlainNumber(); | 644 Type* type = Type::PlainNumber(); |
| 638 if (maybe_minuszero) type = Type::Union(type, Type::MinusZero(), zone()); | 645 if (maybe_minuszero) type = Type::Union(type, Type::MinusZero(), zone()); |
| 639 if (maybe_nan) type = Type::Union(type, Type::NaN(), zone()); | 646 if (maybe_nan) type = Type::Union(type, Type::NaN(), zone()); |
| 640 return type; | 647 return type; |
| 641 } | 648 } |
| 642 | 649 |
| 643 Type* OperationTyper::NumberModulus(Type* lhs, Type* rhs) { | 650 Type* OperationTyper::NumberModulus(Type* lhs, Type* rhs) { |
| 644 DCHECK(lhs->Is(Type::Number())); | 651 DCHECK(lhs->Is(Type::Number())); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 return singleton_true(); | 1016 return singleton_true(); |
| 1010 } | 1017 } |
| 1011 | 1018 |
| 1012 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) { | 1019 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) { |
| 1013 return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone()); | 1020 return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone()); |
| 1014 } | 1021 } |
| 1015 | 1022 |
| 1016 } // namespace compiler | 1023 } // namespace compiler |
| 1017 } // namespace internal | 1024 } // namespace internal |
| 1018 } // namespace v8 | 1025 } // namespace v8 |
| OLD | NEW |