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" |
11 #include "src/isolate.h" | 11 #include "src/isolate.h" |
12 | 12 |
13 #include "src/objects-inl.h" | 13 #include "src/objects-inl.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 namespace compiler { | 17 namespace compiler { |
18 | 18 |
19 OperationTyper::OperationTyper(Isolate* isolate, Zone* zone) | 19 OperationTyper::OperationTyper(Isolate* isolate, Zone* zone) |
20 : zone_(zone), cache_(TypeCache::Get()) { | 20 : zone_(zone), cache_(TypeCache::Get()) { |
21 Factory* factory = isolate->factory(); | 21 Factory* factory = isolate->factory(); |
22 infinity_ = Type::Constant(factory->infinity_value(), zone); | 22 infinity_ = Type::Constant(factory->infinity_value(), zone); |
23 minus_infinity_ = Type::Constant(factory->minus_infinity_value(), zone); | 23 minus_infinity_ = Type::Constant(factory->minus_infinity_value(), zone); |
24 // Unfortunately, the infinities created in other places might be different | 24 Type* truncating_to_zero = Type::MinusZeroOrNaN(); |
25 // ones (eg the result of NewNumber in TypeNumberConstant). | |
26 Type* truncating_to_zero = | |
27 Type::Union(Type::Union(infinity_, minus_infinity_, zone), | |
28 Type::MinusZeroOrNaN(), zone); | |
29 DCHECK(!truncating_to_zero->Maybe(Type::Integral32())); | 25 DCHECK(!truncating_to_zero->Maybe(Type::Integral32())); |
30 | 26 |
31 singleton_false_ = Type::Constant(factory->false_value(), zone); | 27 singleton_false_ = Type::Constant(factory->false_value(), zone); |
32 singleton_true_ = Type::Constant(factory->true_value(), zone); | 28 singleton_true_ = Type::Constant(factory->true_value(), zone); |
33 singleton_the_hole_ = Type::Constant(factory->the_hole_value(), zone); | 29 singleton_the_hole_ = Type::Constant(factory->the_hole_value(), zone); |
34 signed32ish_ = Type::Union(Type::Signed32(), truncating_to_zero, zone); | 30 signed32ish_ = Type::Union(Type::Signed32(), truncating_to_zero, zone); |
35 unsigned32ish_ = Type::Union(Type::Unsigned32(), truncating_to_zero, zone); | 31 unsigned32ish_ = Type::Union(Type::Unsigned32(), truncating_to_zero, zone); |
36 } | 32 } |
37 | 33 |
38 Type* OperationTyper::Merge(Type* left, Type* right) { | 34 Type* OperationTyper::Merge(Type* left, Type* right) { |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 return singleton_true(); | 965 return singleton_true(); |
970 } | 966 } |
971 | 967 |
972 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) { | 968 Type* OperationTyper::TypeTypeGuard(const Operator* sigma_op, Type* input) { |
973 return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone()); | 969 return Type::Intersect(input, TypeGuardTypeOf(sigma_op), zone()); |
974 } | 970 } |
975 | 971 |
976 } // namespace compiler | 972 } // namespace compiler |
977 } // namespace internal | 973 } // namespace internal |
978 } // namespace v8 | 974 } // namespace v8 |
OLD | NEW |