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 #ifndef V8_TYPE_CACHE_H_ | 5 #ifndef V8_COMPILER_TYPE_CACHE_H_ |
6 #define V8_TYPE_CACHE_H_ | 6 #define V8_COMPILER_TYPE_CACHE_H_ |
7 | 7 |
8 #include "src/types.h" | 8 #include "src/types.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
| 12 namespace compiler { |
12 | 13 |
13 class TypeCache final { | 14 class TypeCache final { |
14 private: | 15 private: |
15 // This has to be first for the initialization magic to work. | 16 // This has to be first for the initialization magic to work. |
16 base::AccountingAllocator allocator; | 17 base::AccountingAllocator allocator; |
17 Zone zone_; | 18 Zone zone_; |
18 | 19 |
19 public: | 20 public: |
20 static TypeCache const& Get(); | 21 static TypeCache const& Get(); |
21 | 22 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 71 |
71 Type* const kAdditiveSafeInteger = | 72 Type* const kAdditiveSafeInteger = |
72 CreateRange(-4503599627370496.0, 4503599627370496.0); | 73 CreateRange(-4503599627370496.0, 4503599627370496.0); |
73 Type* const kSafeInteger = CreateRange(-kMaxSafeInteger, kMaxSafeInteger); | 74 Type* const kSafeInteger = CreateRange(-kMaxSafeInteger, kMaxSafeInteger); |
74 Type* const kAdditiveSafeIntegerOrMinusZero = | 75 Type* const kAdditiveSafeIntegerOrMinusZero = |
75 Type::Union(kAdditiveSafeInteger, Type::MinusZero(), zone()); | 76 Type::Union(kAdditiveSafeInteger, Type::MinusZero(), zone()); |
76 Type* const kSafeIntegerOrMinusZero = | 77 Type* const kSafeIntegerOrMinusZero = |
77 Type::Union(kSafeInteger, Type::MinusZero(), zone()); | 78 Type::Union(kSafeInteger, Type::MinusZero(), zone()); |
78 Type* const kPositiveSafeInteger = CreateRange(0.0, kMaxSafeInteger); | 79 Type* const kPositiveSafeInteger = CreateRange(0.0, kMaxSafeInteger); |
79 | 80 |
80 Type* const kUntaggedUndefined = | |
81 Type::Intersect(Type::Undefined(), Type::Untagged(), zone()); | |
82 | |
83 // Asm.js related types. | |
84 Type* const kAsmSigned = kInt32; | |
85 Type* const kAsmUnsigned = kUint32; | |
86 Type* const kAsmInt = Type::Union(kAsmSigned, kAsmUnsigned, zone()); | |
87 Type* const kAsmFixnum = Type::Intersect(kAsmSigned, kAsmUnsigned, zone()); | |
88 Type* const kAsmFloat = kFloat32; | |
89 Type* const kAsmDouble = kFloat64; | |
90 Type* const kAsmFloatQ = Type::Union(kAsmFloat, kUntaggedUndefined, zone()); | |
91 Type* const kAsmDoubleQ = Type::Union(kAsmDouble, kUntaggedUndefined, zone()); | |
92 // Not part of the Asm.js type hierarchy, but represents a part of what | |
93 // intish encompasses. | |
94 Type* const kAsmIntQ = Type::Union(kAsmInt, kUntaggedUndefined, zone()); | |
95 Type* const kAsmFloatDoubleQ = Type::Union(kAsmFloatQ, kAsmDoubleQ, zone()); | |
96 // Asm.js size unions. | |
97 Type* const kAsmSize8 = Type::Union(kInt8, kUint8, zone()); | |
98 Type* const kAsmSize16 = Type::Union(kInt16, kUint16, zone()); | |
99 Type* const kAsmSize32 = | |
100 Type::Union(Type::Union(kInt32, kUint32, zone()), kAsmFloat, zone()); | |
101 Type* const kAsmSize64 = kFloat64; | |
102 // Asm.js other types. | |
103 Type* const kAsmComparable = Type::Union( | |
104 kAsmSigned, | |
105 Type::Union(kAsmUnsigned, Type::Union(kAsmDouble, kAsmFloat, zone()), | |
106 zone()), | |
107 zone()); | |
108 Type* const kAsmIntArrayElement = | |
109 Type::Union(Type::Union(kInt8, kUint8, zone()), | |
110 Type::Union(Type::Union(kInt16, kUint16, zone()), | |
111 Type::Union(kInt32, kUint32, zone()), zone()), | |
112 zone()); | |
113 | |
114 // The FixedArray::length property always containts a smi in the range | 81 // The FixedArray::length property always containts a smi in the range |
115 // [0, FixedArray::kMaxLength]. | 82 // [0, FixedArray::kMaxLength]. |
116 Type* const kFixedArrayLengthType = CreateNative( | 83 Type* const kFixedArrayLengthType = CreateNative( |
117 CreateRange(0.0, FixedArray::kMaxLength), Type::TaggedSigned()); | 84 CreateRange(0.0, FixedArray::kMaxLength), Type::TaggedSigned()); |
118 | 85 |
119 // The FixedDoubleArray::length property always containts a smi in the range | 86 // The FixedDoubleArray::length property always containts a smi in the range |
120 // [0, FixedDoubleArray::kMaxLength]. | 87 // [0, FixedDoubleArray::kMaxLength]. |
121 Type* const kFixedDoubleArrayLengthType = CreateNative( | 88 Type* const kFixedDoubleArrayLengthType = CreateNative( |
122 CreateRange(0.0, FixedDoubleArray::kMaxLength), Type::TaggedSigned()); | 89 CreateRange(0.0, FixedDoubleArray::kMaxLength), Type::TaggedSigned()); |
123 | 90 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 std::numeric_limits<T>::max()); | 128 std::numeric_limits<T>::max()); |
162 } | 129 } |
163 | 130 |
164 Type* CreateRange(double min, double max) { | 131 Type* CreateRange(double min, double max) { |
165 return Type::Range(min, max, zone()); | 132 return Type::Range(min, max, zone()); |
166 } | 133 } |
167 | 134 |
168 Zone* zone() { return &zone_; } | 135 Zone* zone() { return &zone_; } |
169 }; | 136 }; |
170 | 137 |
| 138 } // namespace compiler |
171 } // namespace internal | 139 } // namespace internal |
172 } // namespace v8 | 140 } // namespace v8 |
173 | 141 |
174 #endif // V8_TYPE_CACHE_H_ | 142 #endif // V8_COMPILER_TYPE_CACHE_H_ |
OLD | NEW |