| 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 return Type::Number(); | 453 return Type::Number(); |
| 454 } | 454 } |
| 455 | 455 |
| 456 Type* OperationTyper::NumberTrunc(Type* type) { | 456 Type* OperationTyper::NumberTrunc(Type* type) { |
| 457 DCHECK(type->Is(Type::Number())); | 457 DCHECK(type->Is(Type::Number())); |
| 458 if (type->Is(cache_.kIntegerOrMinusZeroOrNaN)) return type; | 458 if (type->Is(cache_.kIntegerOrMinusZeroOrNaN)) return type; |
| 459 // TODO(bmeurer): We could infer a more precise type here. | 459 // TODO(bmeurer): We could infer a more precise type here. |
| 460 return cache_.kIntegerOrMinusZeroOrNaN; | 460 return cache_.kIntegerOrMinusZeroOrNaN; |
| 461 } | 461 } |
| 462 | 462 |
| 463 Type* OperationTyper::NumberToBoolean(Type* type) { |
| 464 DCHECK(type->Is(Type::Number())); |
| 465 if (!type->IsInhabited()) return Type::None(); |
| 466 if (type->Is(cache_.kZeroish)) return singleton_false_; |
| 467 if (type->Is(Type::PlainNumber()) && (type->Max() < 0 || 0 < type->Min())) { |
| 468 return singleton_true_; // Ruled out nan, -0 and +0. |
| 469 } |
| 470 return Type::Boolean(); |
| 471 } |
| 472 |
| 463 Type* OperationTyper::NumberToInt32(Type* type) { | 473 Type* OperationTyper::NumberToInt32(Type* type) { |
| 464 DCHECK(type->Is(Type::Number())); | 474 DCHECK(type->Is(Type::Number())); |
| 465 | 475 |
| 466 if (type->Is(Type::Signed32())) return type; | 476 if (type->Is(Type::Signed32())) return type; |
| 467 if (type->Is(cache_.kZeroish)) return cache_.kSingletonZero; | 477 if (type->Is(cache_.kZeroish)) return cache_.kSingletonZero; |
| 468 if (type->Is(signed32ish_)) { | 478 if (type->Is(signed32ish_)) { |
| 469 return Type::Intersect(Type::Union(type, cache_.kSingletonZero, zone()), | 479 return Type::Intersect(Type::Union(type, cache_.kSingletonZero, zone()), |
| 470 Type::Signed32(), zone()); | 480 Type::Signed32(), zone()); |
| 471 } | 481 } |
| 472 return Type::Signed32(); | 482 return Type::Signed32(); |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 return singleton_true(); | 969 return singleton_true(); |
| 960 } | 970 } |
| 961 | 971 |
| 962 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) { | 972 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) { |
| 963 return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone()); | 973 return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone()); |
| 964 } | 974 } |
| 965 | 975 |
| 966 } // namespace compiler | 976 } // namespace compiler |
| 967 } // namespace internal | 977 } // namespace internal |
| 968 } // namespace v8 | 978 } // namespace v8 |
| OLD | NEW |