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_TYPES_H_ | 5 #ifndef V8_TYPES_H_ |
6 #define V8_TYPES_H_ | 6 #define V8_TYPES_H_ |
7 | 7 |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/handles.h" | 10 #include "src/handles.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // ----------------------------------------------------------------------------- | 153 // ----------------------------------------------------------------------------- |
154 // Values for bitset types | 154 // Values for bitset types |
155 | 155 |
156 #define MASK_BITSET_TYPE_LIST(V) \ | 156 #define MASK_BITSET_TYPE_LIST(V) \ |
157 V(Representation, 0xff800000u) \ | 157 V(Representation, 0xff800000u) \ |
158 V(Semantic, 0x007ffffeu) | 158 V(Semantic, 0x007ffffeu) |
159 | 159 |
160 #define REPRESENTATION(k) ((k) & BitsetType::kRepresentation) | 160 #define REPRESENTATION(k) ((k) & BitsetType::kRepresentation) |
161 #define SEMANTIC(k) ((k) & BitsetType::kSemantic) | 161 #define SEMANTIC(k) ((k) & BitsetType::kSemantic) |
162 | 162 |
163 #define REPRESENTATION_BITSET_TYPE_LIST(V) \ | 163 #define REPRESENTATION_BITSET_TYPE_LIST(V) \ |
164 V(None, 0) \ | 164 V(None, 0) \ |
165 V(UntaggedInt1, 1u << 23 | kSemantic) \ | 165 V(UntaggedInt1, 1u << 23 | kSemantic) \ |
166 V(UntaggedInt8, 1u << 24 | kSemantic) \ | 166 V(UntaggedInt8, 1u << 24 | kSemantic) \ |
167 V(UntaggedInt16, 1u << 25 | kSemantic) \ | 167 V(UntaggedInt16, 1u << 25 | kSemantic) \ |
168 V(UntaggedInt32, 1u << 26 | kSemantic) \ | 168 V(UntaggedInt32, 1u << 26 | kSemantic) \ |
169 V(UntaggedFloat32, 1u << 27 | kSemantic) \ | 169 V(UntaggedFloat32, 1u << 27 | kSemantic) \ |
170 V(UntaggedFloat64, 1u << 28 | kSemantic) \ | 170 V(UntaggedFloat64, 1u << 28 | kSemantic) \ |
171 V(UntaggedPtr, 1u << 29 | kSemantic) \ | 171 V(UntaggedPtr, 1u << 29 | kSemantic) \ |
172 V(TaggedInt, 1u << 30 | kSemantic) \ | 172 V(TaggedInt, 1u << 30 | kSemantic) \ |
173 V(TaggedPtr, 1u << 31 | kSemantic) \ | 173 V(TaggedPtr, 1u << 31 | kSemantic) \ |
174 \ | 174 \ |
175 V(UntaggedInt, kUntaggedInt1 | kUntaggedInt8 | \ | 175 V(UntaggedInt, kUntaggedInt1 | kUntaggedInt8 | \ |
176 kUntaggedInt16 | kUntaggedInt32) \ | 176 kUntaggedInt16 | kUntaggedInt32) \ |
177 V(UntaggedFloat, kUntaggedFloat32 | kUntaggedFloat64) \ | 177 V(UntaggedFloat, kUntaggedFloat32 | kUntaggedFloat64) \ |
178 V(UntaggedNumber, kUntaggedInt | kUntaggedFloat) \ | 178 V(UntaggedNumber, kUntaggedInt | kUntaggedFloat) \ |
179 V(Untagged, kUntaggedNumber | kUntaggedPtr) \ | 179 V(Untagged, kUntaggedNumber | kUntaggedPtr) \ |
180 V(Tagged, kTaggedInt | kTaggedPtr) | 180 V(Tagged, kTaggedInt | kTaggedPtr) |
181 | 181 |
182 #define INTERNAL_BITSET_TYPE_LIST(V) \ | 182 #define SEMANTIC_BITSET_TYPE_LIST(V) \ |
183 V(OtherUnsigned31, 1u << 1 | REPRESENTATION(kTagged | kUntaggedNumber)) \ | 183 V(Null, 1u << 1 | REPRESENTATION(kTaggedPtr)) \ |
184 V(OtherUnsigned32, 1u << 2 | REPRESENTATION(kTagged | kUntaggedNumber)) \ | 184 V(Undefined, 1u << 2 | REPRESENTATION(kTaggedPtr)) \ |
185 V(OtherSigned32, 1u << 3 | REPRESENTATION(kTagged | kUntaggedNumber)) \ | 185 V(Boolean, 1u << 3 | REPRESENTATION(kTaggedPtr)) \ |
186 V(OtherNumber, 1u << 4 | REPRESENTATION(kTagged | kUntaggedNumber)) | 186 V(UnsignedSmall, 1u << 4 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
187 | 187 V(OtherSignedSmall, 1u << 5 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
188 #define SEMANTIC_BITSET_TYPE_LIST(V) \ | 188 V(OtherUnsigned31, 1u << 6 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
189 V(NegativeSignedSmall, 1u << 5 | REPRESENTATION(kTagged | kUntaggedNumber)) \ | 189 V(OtherUnsigned32, 1u << 7 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
190 V(Null, 1u << 6 | REPRESENTATION(kTaggedPtr)) \ | 190 V(OtherSigned32, 1u << 8 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
191 V(Undefined, 1u << 7 | REPRESENTATION(kTaggedPtr)) \ | 191 V(MinusZero, 1u << 9 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
192 V(Boolean, 1u << 8 | REPRESENTATION(kTaggedPtr)) \ | 192 V(NaN, 1u << 10 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
193 V(UnsignedSmall, 1u << 9 | REPRESENTATION(kTagged | kUntaggedNumber)) \ | 193 V(OtherNumber, 1u << 11 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
194 V(MinusZero, 1u << 10 | REPRESENTATION(kTagged | kUntaggedNumber)) \ | 194 V(Symbol, 1u << 12 | REPRESENTATION(kTaggedPtr)) \ |
195 V(NaN, 1u << 11 | REPRESENTATION(kTagged | kUntaggedNumber)) \ | 195 V(InternalizedString, 1u << 13 | REPRESENTATION(kTaggedPtr)) \ |
196 V(Symbol, 1u << 12 | REPRESENTATION(kTaggedPtr)) \ | 196 V(OtherString, 1u << 14 | REPRESENTATION(kTaggedPtr)) \ |
197 V(InternalizedString, 1u << 13 | REPRESENTATION(kTaggedPtr)) \ | 197 V(Undetectable, 1u << 15 | REPRESENTATION(kTaggedPtr)) \ |
198 V(OtherString, 1u << 14 | REPRESENTATION(kTaggedPtr)) \ | 198 V(Array, 1u << 16 | REPRESENTATION(kTaggedPtr)) \ |
199 V(Undetectable, 1u << 15 | REPRESENTATION(kTaggedPtr)) \ | 199 V(Buffer, 1u << 17 | REPRESENTATION(kTaggedPtr)) \ |
200 V(Array, 1u << 16 | REPRESENTATION(kTaggedPtr)) \ | 200 V(Function, 1u << 18 | REPRESENTATION(kTaggedPtr)) \ |
201 V(Buffer, 1u << 17 | REPRESENTATION(kTaggedPtr)) \ | 201 V(RegExp, 1u << 19 | REPRESENTATION(kTaggedPtr)) \ |
202 V(Function, 1u << 18 | REPRESENTATION(kTaggedPtr)) \ | 202 V(OtherObject, 1u << 20 | REPRESENTATION(kTaggedPtr)) \ |
203 V(RegExp, 1u << 19 | REPRESENTATION(kTaggedPtr)) \ | 203 V(Proxy, 1u << 21 | REPRESENTATION(kTaggedPtr)) \ |
204 V(OtherObject, 1u << 20 | REPRESENTATION(kTaggedPtr)) \ | 204 V(Internal, 1u << 22 | REPRESENTATION(kTagged | kUntagged)) \ |
205 V(Proxy, 1u << 21 | REPRESENTATION(kTaggedPtr)) \ | 205 \ |
206 V(Internal, 1u << 22 | REPRESENTATION(kTagged | kUntagged)) \ | 206 V(SignedSmall, kUnsignedSmall | kOtherSignedSmall) \ |
207 \ | 207 V(Signed32, kSignedSmall | kOtherUnsigned31 | kOtherSigned32) \ |
208 V(SignedSmall, kUnsignedSmall | kNegativeSignedSmall) \ | 208 V(Unsigned32, kUnsignedSmall | kOtherUnsigned31 | kOtherUnsigned32) \ |
209 V(Signed32, kSignedSmall | kOtherUnsigned31 | kOtherSigned32) \ | 209 V(Integral32, kSigned32 | kUnsigned32) \ |
210 V(NegativeSigned32, kNegativeSignedSmall | kOtherSigned32) \ | 210 V(OrderedNumber, kIntegral32 | kMinusZero | kOtherNumber) \ |
211 V(NonNegativeSigned32, kUnsignedSmall | kOtherUnsigned31) \ | 211 V(Number, kOrderedNumber | kNaN) \ |
212 V(Unsigned32, kNonNegativeSigned32 | kOtherUnsigned32) \ | 212 V(String, kInternalizedString | kOtherString) \ |
213 V(Integral32, kSigned32 | kUnsigned32) \ | 213 V(UniqueName, kSymbol | kInternalizedString) \ |
214 V(PlainNumber, kIntegral32 | kOtherNumber) \ | 214 V(Name, kSymbol | kString) \ |
215 V(OrderedNumber, kPlainNumber | kMinusZero) \ | 215 V(NumberOrString, kNumber | kString) \ |
216 V(Number, kOrderedNumber | kNaN) \ | 216 V(PlainPrimitive, kNumberOrString | kBoolean | kNull | kUndefined) \ |
217 V(String, kInternalizedString | kOtherString) \ | 217 V(Primitive, kSymbol | kPlainPrimitive) \ |
218 V(UniqueName, kSymbol | kInternalizedString) \ | 218 V(DetectableObject, kArray | kFunction | kRegExp | kOtherObject) \ |
219 V(Name, kSymbol | kString) \ | 219 V(DetectableReceiver, kDetectableObject | kProxy) \ |
220 V(NumberOrString, kNumber | kString) \ | 220 V(Detectable, kDetectableReceiver | kNumber | kName) \ |
221 V(PlainPrimitive, kNumberOrString | kBoolean | kNull | kUndefined) \ | 221 V(Object, kDetectableObject | kUndetectable) \ |
222 V(Primitive, kSymbol | kPlainPrimitive) \ | 222 V(Receiver, kObject | kProxy) \ |
223 V(DetectableObject, kArray | kFunction | kRegExp | kOtherObject) \ | 223 V(Unique, kBoolean | kUniqueName | kNull | kUndefined | \ |
224 V(DetectableReceiver, kDetectableObject | kProxy) \ | 224 kReceiver) \ |
225 V(Detectable, kDetectableReceiver | kNumber | kName) \ | 225 V(NonNumber, kUnique | kString | kInternal) \ |
226 V(Object, kDetectableObject | kUndetectable) \ | 226 V(Any, 0xfffffffeu) |
227 V(Receiver, kObject | kProxy) \ | |
228 V(Unique, kBoolean | kUniqueName | kNull | kUndefined | \ | |
229 kReceiver) \ | |
230 V(NonNumber, kUnique | kString | kInternal) \ | |
231 V(Any, 0xfffffffeu) | |
232 | 227 |
233 /* | 228 /* |
234 * The following diagrams show how integers (in the mathematical sense) are | 229 * The following diagrams show how integers (in the mathematical sense) are |
235 * divided among the different atomic numerical types. | 230 * divided among the different atomic numerical types. |
236 * | 231 * |
237 * If SmiValuesAre31Bits(): | 232 * If SmiValuesAre31Bits(): |
238 * | 233 * |
239 * ON OS32 OSS US OU31 OU32 ON | 234 * ON OS32 OSS US OU31 OU32 ON |
240 * ______[_______[_______[_______[_______[_______[_______ | 235 * ______[_______[_______[_______[_______[_______[_______ |
241 * -2^31 -2^30 0 2^30 2^31 2^32 | 236 * -2^31 -2^30 0 2^30 2^31 2^32 |
242 * | 237 * |
243 * Otherwise: | 238 * Otherwise: |
244 * | 239 * |
245 * ON OSS US OU32 ON | 240 * ON OSS US OU32 ON |
246 * ______[_______________[_______________[_______[_______ | 241 * ______[_______________[_______________[_______[_______ |
247 * -2^31 0 2^31 2^32 | 242 * -2^31 0 2^31 2^32 |
248 * | 243 * |
249 * | 244 * |
250 * E.g., OtherUnsigned32 (OU32) covers all integers from 2^31 to 2^32-1. | 245 * E.g., OtherUnsigned32 (OU32) covers all integers from 2^31 to 2^32-1. |
251 * | 246 * |
252 * NOTE: OtherSigned32 (OS32) and OU31 (OtherUnsigned31) are empty if Smis are | 247 * NOTE: OtherSigned32 (OS32) and OU31 (OtherUnsigned31) are empty if Smis are |
253 * 32-bit wide. They should thus never be used directly, only indirectly | 248 * 32-bit wide. They should thus never be used directly, only indirectly |
254 * via e.g. Number. | 249 * via e.g. Number. |
255 */ | 250 */ |
256 | 251 |
257 #define PROPER_BITSET_TYPE_LIST(V) \ | 252 #define PROPER_BITSET_TYPE_LIST(V) \ |
258 REPRESENTATION_BITSET_TYPE_LIST(V) \ | 253 REPRESENTATION_BITSET_TYPE_LIST(V) \ |
259 SEMANTIC_BITSET_TYPE_LIST(V) | 254 SEMANTIC_BITSET_TYPE_LIST(V) |
260 | 255 |
261 #define BITSET_TYPE_LIST(V) \ | 256 #define BITSET_TYPE_LIST(V) \ |
262 MASK_BITSET_TYPE_LIST(V) \ | 257 MASK_BITSET_TYPE_LIST(V) \ |
263 REPRESENTATION_BITSET_TYPE_LIST(V) \ | 258 PROPER_BITSET_TYPE_LIST(V) |
264 INTERNAL_BITSET_TYPE_LIST(V) \ | |
265 SEMANTIC_BITSET_TYPE_LIST(V) | |
266 | 259 |
267 | 260 |
268 // ----------------------------------------------------------------------------- | 261 // ----------------------------------------------------------------------------- |
269 // The abstract Type class, parameterized over the low-level representation. | 262 // The abstract Type class, parameterized over the low-level representation. |
270 | 263 |
271 // struct Config { | 264 // struct Config { |
272 // typedef TypeImpl<Config> Type; | 265 // typedef TypeImpl<Config> Type; |
273 // typedef Base; | 266 // typedef Base; |
274 // typedef Struct; | 267 // typedef Struct; |
275 // typedef Region; | 268 // typedef Region; |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 #define DECLARE_TYPE(type, value) k##type = (value), | 585 #define DECLARE_TYPE(type, value) k##type = (value), |
593 BITSET_TYPE_LIST(DECLARE_TYPE) | 586 BITSET_TYPE_LIST(DECLARE_TYPE) |
594 #undef DECLARE_TYPE | 587 #undef DECLARE_TYPE |
595 kUnusedEOL = 0 | 588 kUnusedEOL = 0 |
596 }; | 589 }; |
597 | 590 |
598 bitset Bitset() { return Config::as_bitset(this); } | 591 bitset Bitset() { return Config::as_bitset(this); } |
599 | 592 |
600 static TypeImpl* New(bitset bits) { | 593 static TypeImpl* New(bitset bits) { |
601 DCHECK(bits == kNone || IsInhabited(bits)); | 594 DCHECK(bits == kNone || IsInhabited(bits)); |
602 | |
603 if (FLAG_enable_slow_asserts) { | |
604 // Check that the bitset does not contain any holes in number ranges. | |
605 bitset mask = kSemantic; | |
606 if (!i::SmiValuesAre31Bits()) { | |
607 mask &= ~(kOtherUnsigned31 | kOtherSigned32); | |
608 } | |
609 bitset number_bits = bits & kPlainNumber & mask; | |
610 if (number_bits != 0) { | |
611 bitset lub = Lub(Min(number_bits), Max(number_bits)) & mask; | |
612 CHECK(lub == number_bits); | |
613 } | |
614 } | |
615 | |
616 return Config::from_bitset(bits); | 595 return Config::from_bitset(bits); |
617 } | 596 } |
618 static TypeHandle New(bitset bits, Region* region) { | 597 static TypeHandle New(bitset bits, Region* region) { |
619 DCHECK(bits == kNone || IsInhabited(bits)); | 598 DCHECK(bits == kNone || IsInhabited(bits)); |
620 return Config::from_bitset(bits, region); | 599 return Config::from_bitset(bits, region); |
621 } | 600 } |
622 // TODO(neis): Eventually allow again for types with empty semantics | 601 // TODO(neis): Eventually allow again for types with empty semantics |
623 // part and modify intersection and possibly subtyping accordingly. | 602 // part and modify intersection and possibly subtyping accordingly. |
624 | 603 |
625 static bool IsInhabited(bitset bits) { | 604 static bool IsInhabited(bitset bits) { |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 bool Narrows(BoundsImpl that) { | 1064 bool Narrows(BoundsImpl that) { |
1086 return that.lower->Is(this->lower) && this->upper->Is(that.upper); | 1065 return that.lower->Is(this->lower) && this->upper->Is(that.upper); |
1087 } | 1066 } |
1088 }; | 1067 }; |
1089 | 1068 |
1090 typedef BoundsImpl<ZoneTypeConfig> Bounds; | 1069 typedef BoundsImpl<ZoneTypeConfig> Bounds; |
1091 | 1070 |
1092 } } // namespace v8::internal | 1071 } } // namespace v8::internal |
1093 | 1072 |
1094 #endif // V8_TYPES_H_ | 1073 #endif // V8_TYPES_H_ |
OLD | NEW |