| 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 894 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   905 Type* OperationTyper::NumberImul(Type* lhs, Type* rhs) { |   905 Type* OperationTyper::NumberImul(Type* lhs, Type* rhs) { | 
|   906   DCHECK(lhs->Is(Type::Number())); |   906   DCHECK(lhs->Is(Type::Number())); | 
|   907   DCHECK(rhs->Is(Type::Number())); |   907   DCHECK(rhs->Is(Type::Number())); | 
|   908   // TODO(turbofan): We should be able to do better here. |   908   // TODO(turbofan): We should be able to do better here. | 
|   909   return Type::Signed32(); |   909   return Type::Signed32(); | 
|   910 } |   910 } | 
|   911  |   911  | 
|   912 Type* OperationTyper::NumberMax(Type* lhs, Type* rhs) { |   912 Type* OperationTyper::NumberMax(Type* lhs, Type* rhs) { | 
|   913   DCHECK(lhs->Is(Type::Number())); |   913   DCHECK(lhs->Is(Type::Number())); | 
|   914   DCHECK(rhs->Is(Type::Number())); |   914   DCHECK(rhs->Is(Type::Number())); | 
 |   915   if (!lhs->IsInhabited() || !rhs->IsInhabited()) { | 
 |   916     return Type::None(); | 
 |   917   } | 
|   915   if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) { |   918   if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) { | 
|   916     return Type::NaN(); |   919     return Type::NaN(); | 
|   917   } |   920   } | 
|   918   Type* type = Type::None(); |   921   Type* type = Type::None(); | 
|   919   // TODO(turbofan): Improve minus zero handling here. |   922   // TODO(turbofan): Improve minus zero handling here. | 
|   920   if (lhs->Maybe(Type::NaN()) || rhs->Maybe(Type::NaN())) { |   923   if (lhs->Maybe(Type::NaN()) || rhs->Maybe(Type::NaN())) { | 
|   921     type = Type::Union(type, Type::NaN(), zone()); |   924     type = Type::Union(type, Type::NaN(), zone()); | 
|   922   } |   925   } | 
|   923   lhs = Type::Intersect(lhs, Type::OrderedNumber(), zone()); |   926   lhs = Type::Intersect(lhs, Type::OrderedNumber(), zone()); | 
|   924   rhs = Type::Intersect(rhs, Type::OrderedNumber(), zone()); |   927   rhs = Type::Intersect(rhs, Type::OrderedNumber(), zone()); | 
|   925   if (lhs->Is(cache_.kInteger) && rhs->Is(cache_.kInteger)) { |   928   if (lhs->Is(cache_.kInteger) && rhs->Is(cache_.kInteger)) { | 
|   926     double max = std::max(lhs->Max(), rhs->Max()); |   929     double max = std::max(lhs->Max(), rhs->Max()); | 
|   927     double min = std::max(lhs->Min(), rhs->Min()); |   930     double min = std::max(lhs->Min(), rhs->Min()); | 
|   928     type = Type::Union(type, Type::Range(min, max, zone()), zone()); |   931     type = Type::Union(type, Type::Range(min, max, zone()), zone()); | 
|   929   } else { |   932   } else { | 
|   930     type = Type::Union(type, Type::Union(lhs, rhs, zone()), zone()); |   933     type = Type::Union(type, Type::Union(lhs, rhs, zone()), zone()); | 
|   931   } |   934   } | 
|   932   return type; |   935   return type; | 
|   933 } |   936 } | 
|   934  |   937  | 
|   935 Type* OperationTyper::NumberMin(Type* lhs, Type* rhs) { |   938 Type* OperationTyper::NumberMin(Type* lhs, Type* rhs) { | 
|   936   DCHECK(lhs->Is(Type::Number())); |   939   DCHECK(lhs->Is(Type::Number())); | 
|   937   DCHECK(rhs->Is(Type::Number())); |   940   DCHECK(rhs->Is(Type::Number())); | 
 |   941   if (!lhs->IsInhabited() || !rhs->IsInhabited()) { | 
 |   942     return Type::None(); | 
 |   943   } | 
|   938   if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) { |   944   if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) { | 
|   939     return Type::NaN(); |   945     return Type::NaN(); | 
|   940   } |   946   } | 
|   941   Type* type = Type::None(); |   947   Type* type = Type::None(); | 
|   942   // TODO(turbofan): Improve minus zero handling here. |   948   // TODO(turbofan): Improve minus zero handling here. | 
|   943   if (lhs->Maybe(Type::NaN()) || rhs->Maybe(Type::NaN())) { |   949   if (lhs->Maybe(Type::NaN()) || rhs->Maybe(Type::NaN())) { | 
|   944     type = Type::Union(type, Type::NaN(), zone()); |   950     type = Type::Union(type, Type::NaN(), zone()); | 
|   945   } |   951   } | 
|   946   lhs = Type::Intersect(lhs, Type::OrderedNumber(), zone()); |   952   lhs = Type::Intersect(lhs, Type::OrderedNumber(), zone()); | 
|   947   rhs = Type::Intersect(rhs, Type::OrderedNumber(), zone()); |   953   rhs = Type::Intersect(rhs, Type::OrderedNumber(), zone()); | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1016   return singleton_true(); |  1022   return singleton_true(); | 
|  1017 } |  1023 } | 
|  1018  |  1024  | 
|  1019 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) { |  1025 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) { | 
|  1020   return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone()); |  1026   return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone()); | 
|  1021 } |  1027 } | 
|  1022  |  1028  | 
|  1023 }  // namespace compiler |  1029 }  // namespace compiler | 
|  1024 }  // namespace internal |  1030 }  // namespace internal | 
|  1025 }  // namespace v8 |  1031 }  // namespace v8 | 
| OLD | NEW |