Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: src/types.h

Issue 577563002: Re-reland "Use unsigned type bitsets to limit undefined behaviour" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/types.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/factory.h" 8 #include "src/factory.h"
9 #include "src/handles.h" 9 #include "src/handles.h"
10 #include "src/ostreams.h" 10 #include "src/ostreams.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // over types. For example, constructors are injective, subtyping is a complete 115 // over types. For example, constructors are injective, subtyping is a complete
116 // partial order, union and intersection satisfy the usual algebraic properties. 116 // partial order, union and intersection satisfy the usual algebraic properties.
117 // 117 //
118 // See test/cctest/test-types.cc for a comprehensive executable specification, 118 // See test/cctest/test-types.cc for a comprehensive executable specification,
119 // especially with respect to the properties of the more exotic 'temporal' 119 // especially with respect to the properties of the more exotic 'temporal'
120 // constructors and predicates (those prefixed 'Now'). 120 // constructors and predicates (those prefixed 'Now').
121 // 121 //
122 // IMPLEMENTATION 122 // IMPLEMENTATION
123 // 123 //
124 // Internally, all 'primitive' types, and their unions, are represented as 124 // Internally, all 'primitive' types, and their unions, are represented as
125 // bitsets. Class is a heap pointer to the respective map. Only Constant's, or 125 // bitsets. Bit 0 is reserved for tagging. Class is a heap pointer to the
126 // unions containing Class'es or Constant's, currently require allocation. 126 // respective map. Only structured types require allocation.
127 // Note that the bitset representation is closed under both Union and Intersect. 127 // Note that the bitset representation is closed under both Union and Intersect.
128 // 128 //
129 // There are two type representations, using different allocation: 129 // There are two type representations, using different allocation:
130 // 130 //
131 // - class Type (zone-allocated, for compiler and concurrent compilation) 131 // - class Type (zone-allocated, for compiler and concurrent compilation)
132 // - class HeapType (heap-allocated, for persistent types) 132 // - class HeapType (heap-allocated, for persistent types)
133 // 133 //
134 // Both provide the same API, and the Convert method can be used to interconvert 134 // Both provide the same API, and the Convert method can be used to interconvert
135 // them. For zone types, no query method touches the heap, only constructors do. 135 // them. For zone types, no query method touches the heap, only constructors do.
136 136
137 137
138 // ----------------------------------------------------------------------------- 138 // -----------------------------------------------------------------------------
139 // Values for bitset types 139 // Values for bitset types
140 140
141 #define MASK_BITSET_TYPE_LIST(V) \ 141 #define MASK_BITSET_TYPE_LIST(V) \
142 V(Representation, static_cast<int>(0xffc00000)) \ 142 V(Representation, 0xff800000u) \
143 V(Semantic, static_cast<int>(0x003fffff)) 143 V(Semantic, 0x007ffffeu)
144 144
145 #define REPRESENTATION(k) ((k) & BitsetType::kRepresentation) 145 #define REPRESENTATION(k) ((k) & BitsetType::kRepresentation)
146 #define SEMANTIC(k) ((k) & BitsetType::kSemantic) 146 #define SEMANTIC(k) ((k) & BitsetType::kSemantic)
147 147
148 #define REPRESENTATION_BITSET_TYPE_LIST(V) \ 148 #define REPRESENTATION_BITSET_TYPE_LIST(V) \
149 V(None, 0) \ 149 V(None, 0) \
150 V(UntaggedInt1, 1 << 22 | kSemantic) \ 150 V(UntaggedInt1, 1u << 23 | kSemantic) \
151 V(UntaggedInt8, 1 << 23 | kSemantic) \ 151 V(UntaggedInt8, 1u << 24 | kSemantic) \
152 V(UntaggedInt16, 1 << 24 | kSemantic) \ 152 V(UntaggedInt16, 1u << 25 | kSemantic) \
153 V(UntaggedInt32, 1 << 25 | kSemantic) \ 153 V(UntaggedInt32, 1u << 26 | kSemantic) \
154 V(UntaggedFloat32, 1 << 26 | kSemantic) \ 154 V(UntaggedFloat32, 1u << 27 | kSemantic) \
155 V(UntaggedFloat64, 1 << 27 | kSemantic) \ 155 V(UntaggedFloat64, 1u << 28 | kSemantic) \
156 V(UntaggedPtr, 1 << 28 | kSemantic) \ 156 V(UntaggedPtr, 1u << 29 | kSemantic) \
157 V(TaggedInt, 1 << 29 | kSemantic) \ 157 V(TaggedInt, 1u << 30 | kSemantic) \
158 /* MSB has to be sign-extended */ \ 158 V(TaggedPtr, 1u << 31 | kSemantic) \
159 V(TaggedPtr, static_cast<int>(~0u << 30) | kSemantic) \
160 \ 159 \
161 V(UntaggedInt, kUntaggedInt1 | kUntaggedInt8 | \ 160 V(UntaggedInt, kUntaggedInt1 | kUntaggedInt8 | \
162 kUntaggedInt16 | kUntaggedInt32) \ 161 kUntaggedInt16 | kUntaggedInt32) \
163 V(UntaggedFloat, kUntaggedFloat32 | kUntaggedFloat64) \ 162 V(UntaggedFloat, kUntaggedFloat32 | kUntaggedFloat64) \
164 V(UntaggedNumber, kUntaggedInt | kUntaggedFloat) \ 163 V(UntaggedNumber, kUntaggedInt | kUntaggedFloat) \
165 V(Untagged, kUntaggedNumber | kUntaggedPtr) \ 164 V(Untagged, kUntaggedNumber | kUntaggedPtr) \
166 V(Tagged, kTaggedInt | kTaggedPtr) 165 V(Tagged, kTaggedInt | kTaggedPtr)
167 166
168 #define SEMANTIC_BITSET_TYPE_LIST(V) \ 167 #define SEMANTIC_BITSET_TYPE_LIST(V) \
169 V(Null, 1 << 0 | REPRESENTATION(kTaggedPtr)) \ 168 V(Null, 1u << 1 | REPRESENTATION(kTaggedPtr)) \
170 V(Undefined, 1 << 1 | REPRESENTATION(kTaggedPtr)) \ 169 V(Undefined, 1u << 2 | REPRESENTATION(kTaggedPtr)) \
171 V(Boolean, 1 << 2 | REPRESENTATION(kTaggedPtr)) \ 170 V(Boolean, 1u << 3 | REPRESENTATION(kTaggedPtr)) \
172 V(UnsignedSmall, 1 << 3 | REPRESENTATION(kTagged | kUntaggedNumber)) \ 171 V(UnsignedSmall, 1u << 4 | REPRESENTATION(kTagged | kUntaggedNumber)) \
173 V(OtherSignedSmall, 1 << 4 | REPRESENTATION(kTagged | kUntaggedNumber)) \ 172 V(OtherSignedSmall, 1u << 5 | REPRESENTATION(kTagged | kUntaggedNumber)) \
174 V(OtherUnsigned31, 1 << 5 | REPRESENTATION(kTagged | kUntaggedNumber)) \ 173 V(OtherUnsigned31, 1u << 6 | REPRESENTATION(kTagged | kUntaggedNumber)) \
175 V(OtherUnsigned32, 1 << 6 | REPRESENTATION(kTagged | kUntaggedNumber)) \ 174 V(OtherUnsigned32, 1u << 7 | REPRESENTATION(kTagged | kUntaggedNumber)) \
176 V(OtherSigned32, 1 << 7 | REPRESENTATION(kTagged | kUntaggedNumber)) \ 175 V(OtherSigned32, 1u << 8 | REPRESENTATION(kTagged | kUntaggedNumber)) \
177 V(MinusZero, 1 << 8 | REPRESENTATION(kTagged | kUntaggedNumber)) \ 176 V(MinusZero, 1u << 9 | REPRESENTATION(kTagged | kUntaggedNumber)) \
178 V(NaN, 1 << 9 | REPRESENTATION(kTagged | kUntaggedNumber)) \ 177 V(NaN, 1u << 10 | REPRESENTATION(kTagged | kUntaggedNumber)) \
179 V(OtherNumber, 1 << 10 | REPRESENTATION(kTagged | kUntaggedNumber)) \ 178 V(OtherNumber, 1u << 11 | REPRESENTATION(kTagged | kUntaggedNumber)) \
180 V(Symbol, 1 << 11 | REPRESENTATION(kTaggedPtr)) \ 179 V(Symbol, 1u << 12 | REPRESENTATION(kTaggedPtr)) \
181 V(InternalizedString, 1 << 12 | REPRESENTATION(kTaggedPtr)) \ 180 V(InternalizedString, 1u << 13 | REPRESENTATION(kTaggedPtr)) \
182 V(OtherString, 1 << 13 | REPRESENTATION(kTaggedPtr)) \ 181 V(OtherString, 1u << 14 | REPRESENTATION(kTaggedPtr)) \
183 V(Undetectable, 1 << 14 | REPRESENTATION(kTaggedPtr)) \ 182 V(Undetectable, 1u << 15 | REPRESENTATION(kTaggedPtr)) \
184 V(Array, 1 << 15 | REPRESENTATION(kTaggedPtr)) \ 183 V(Array, 1u << 16 | REPRESENTATION(kTaggedPtr)) \
185 V(Buffer, 1 << 16 | REPRESENTATION(kTaggedPtr)) \ 184 V(Buffer, 1u << 17 | REPRESENTATION(kTaggedPtr)) \
186 V(Function, 1 << 17 | REPRESENTATION(kTaggedPtr)) \ 185 V(Function, 1u << 18 | REPRESENTATION(kTaggedPtr)) \
187 V(RegExp, 1 << 18 | REPRESENTATION(kTaggedPtr)) \ 186 V(RegExp, 1u << 19 | REPRESENTATION(kTaggedPtr)) \
188 V(OtherObject, 1 << 19 | REPRESENTATION(kTaggedPtr)) \ 187 V(OtherObject, 1u << 20 | REPRESENTATION(kTaggedPtr)) \
189 V(Proxy, 1 << 20 | REPRESENTATION(kTaggedPtr)) \ 188 V(Proxy, 1u << 21 | REPRESENTATION(kTaggedPtr)) \
190 V(Internal, 1 << 21 | REPRESENTATION(kTagged | kUntagged)) \ 189 V(Internal, 1u << 22 | REPRESENTATION(kTagged | kUntagged)) \
191 \ 190 \
192 V(SignedSmall, kUnsignedSmall | kOtherSignedSmall) \ 191 V(SignedSmall, kUnsignedSmall | kOtherSignedSmall) \
193 V(Signed32, kSignedSmall | kOtherUnsigned31 | kOtherSigned32) \ 192 V(Signed32, kSignedSmall | kOtherUnsigned31 | kOtherSigned32) \
194 V(Unsigned32, kUnsignedSmall | kOtherUnsigned31 | kOtherUnsigned32) \ 193 V(Unsigned32, kUnsignedSmall | kOtherUnsigned31 | kOtherUnsigned32) \
195 V(Integral32, kSigned32 | kUnsigned32) \ 194 V(Integral32, kSigned32 | kUnsigned32) \
196 V(OrderedNumber, kIntegral32 | kMinusZero | kOtherNumber) \ 195 V(OrderedNumber, kIntegral32 | kMinusZero | kOtherNumber) \
197 V(Number, kOrderedNumber | kNaN) \ 196 V(Number, kOrderedNumber | kNaN) \
198 V(String, kInternalizedString | kOtherString) \ 197 V(String, kInternalizedString | kOtherString) \
199 V(UniqueName, kSymbol | kInternalizedString) \ 198 V(UniqueName, kSymbol | kInternalizedString) \
200 V(Name, kSymbol | kString) \ 199 V(Name, kSymbol | kString) \
201 V(NumberOrString, kNumber | kString) \ 200 V(NumberOrString, kNumber | kString) \
202 V(Primitive, kNumber | kName | kBoolean | kNull | kUndefined) \ 201 V(Primitive, kNumber | kName | kBoolean | kNull | kUndefined) \
203 V(DetectableObject, kArray | kFunction | kRegExp | kOtherObject) \ 202 V(DetectableObject, kArray | kFunction | kRegExp | kOtherObject) \
204 V(DetectableReceiver, kDetectableObject | kProxy) \ 203 V(DetectableReceiver, kDetectableObject | kProxy) \
205 V(Detectable, kDetectableReceiver | kNumber | kName) \ 204 V(Detectable, kDetectableReceiver | kNumber | kName) \
206 V(Object, kDetectableObject | kUndetectable) \ 205 V(Object, kDetectableObject | kUndetectable) \
207 V(Receiver, kObject | kProxy) \ 206 V(Receiver, kObject | kProxy) \
208 V(NonNumber, kBoolean | kName | kNull | kReceiver | \ 207 V(NonNumber, kBoolean | kName | kNull | kReceiver | \
209 kUndefined | kInternal) \ 208 kUndefined | kInternal) \
210 V(Any, -1) 209 V(Any, 0xfffffffeu)
211 210
212 #define BITSET_TYPE_LIST(V) \ 211 #define BITSET_TYPE_LIST(V) \
213 MASK_BITSET_TYPE_LIST(V) \ 212 MASK_BITSET_TYPE_LIST(V) \
214 REPRESENTATION_BITSET_TYPE_LIST(V) \ 213 REPRESENTATION_BITSET_TYPE_LIST(V) \
215 SEMANTIC_BITSET_TYPE_LIST(V) 214 SEMANTIC_BITSET_TYPE_LIST(V)
216 215
217 216
218 // ----------------------------------------------------------------------------- 217 // -----------------------------------------------------------------------------
219 // The abstract Type class, parameterized over the low-level representation. 218 // The abstract Type class, parameterized over the low-level representation.
220 219
221 // struct Config { 220 // struct Config {
222 // typedef TypeImpl<Config> Type; 221 // typedef TypeImpl<Config> Type;
223 // typedef Base; 222 // typedef Base;
224 // typedef Struct; 223 // typedef Struct;
225 // typedef Region; 224 // typedef Region;
226 // template<class> struct Handle { typedef type; } // No template typedefs... 225 // template<class> struct Handle { typedef type; } // No template typedefs...
227 // template<class T> static Handle<T>::type handle(T* t); // !is_bitset(t) 226 // template<class T> static Handle<T>::type handle(T* t); // !is_bitset(t)
228 // template<class T> static Handle<T>::type cast(Handle<Type>::type); 227 // template<class T> static Handle<T>::type cast(Handle<Type>::type);
229 // static bool is_bitset(Type*); 228 // static bool is_bitset(Type*);
230 // static bool is_class(Type*); 229 // static bool is_class(Type*);
231 // static bool is_struct(Type*, int tag); 230 // static bool is_struct(Type*, int tag);
232 // static int as_bitset(Type*); 231 // static bitset as_bitset(Type*);
233 // static i::Handle<i::Map> as_class(Type*); 232 // static i::Handle<i::Map> as_class(Type*);
234 // static Handle<Struct>::type as_struct(Type*); 233 // static Handle<Struct>::type as_struct(Type*);
235 // static Type* from_bitset(int bitset); 234 // static Type* from_bitset(bitset);
236 // static Handle<Type>::type from_bitset(int bitset, Region*); 235 // static Handle<Type>::type from_bitset(bitset, Region*);
237 // static Handle<Type>::type from_class(i::Handle<Map>, Region*); 236 // static Handle<Type>::type from_class(i::Handle<Map>, Region*);
238 // static Handle<Type>::type from_struct(Handle<Struct>::type, int tag); 237 // static Handle<Type>::type from_struct(Handle<Struct>::type, int tag);
239 // static Handle<Struct>::type struct_create(int tag, int length, Region*); 238 // static Handle<Struct>::type struct_create(int tag, int length, Region*);
240 // static void struct_shrink(Handle<Struct>::type, int length); 239 // static void struct_shrink(Handle<Struct>::type, int length);
241 // static int struct_tag(Handle<Struct>::type); 240 // static int struct_tag(Handle<Struct>::type);
242 // static int struct_length(Handle<Struct>::type); 241 // static int struct_length(Handle<Struct>::type);
243 // static Handle<Type>::type struct_get(Handle<Struct>::type, int); 242 // static Handle<Type>::type struct_get(Handle<Struct>::type, int);
244 // static void struct_set(Handle<Struct>::type, int, Handle<Type>::type); 243 // static void struct_set(Handle<Struct>::type, int, Handle<Type>::type);
245 // template<class V> 244 // template<class V>
246 // static i::Handle<V> struct_get_value(Handle<Struct>::type, int); 245 // static i::Handle<V> struct_get_value(Handle<Struct>::type, int);
247 // template<class V> 246 // template<class V>
248 // static void struct_set_value(Handle<Struct>::type, int, i::Handle<V>); 247 // static void struct_set_value(Handle<Struct>::type, int, i::Handle<V>);
249 // } 248 // }
250 template<class Config> 249 template<class Config>
251 class TypeImpl : public Config::Base { 250 class TypeImpl : public Config::Base {
252 public: 251 public:
253 // Auxiliary types. 252 // Auxiliary types.
254 253
255 class BitsetType; // Internal 254 typedef uint32_t bitset; // Internal
256 class StructuralType; // Internal 255 class BitsetType; // Internal
257 class UnionType; // Internal 256 class StructuralType; // Internal
257 class UnionType; // Internal
258 258
259 class ClassType; 259 class ClassType;
260 class ConstantType; 260 class ConstantType;
261 class RangeType; 261 class RangeType;
262 class ContextType; 262 class ContextType;
263 class ArrayType; 263 class ArrayType;
264 class FunctionType; 264 class FunctionType;
265 265
266 typedef typename Config::template Handle<TypeImpl>::type TypeHandle; 266 typedef typename Config::template Handle<TypeImpl>::type TypeHandle;
267 typedef typename Config::template Handle<ClassType>::type ClassHandle; 267 typedef typename Config::template Handle<ClassType>::type ClassHandle;
268 typedef typename Config::template Handle<ConstantType>::type ConstantHandle; 268 typedef typename Config::template Handle<ConstantType>::type ConstantHandle;
269 typedef typename Config::template Handle<RangeType>::type RangeHandle; 269 typedef typename Config::template Handle<RangeType>::type RangeHandle;
270 typedef typename Config::template Handle<ContextType>::type ContextHandle; 270 typedef typename Config::template Handle<ContextType>::type ContextHandle;
271 typedef typename Config::template Handle<ArrayType>::type ArrayHandle; 271 typedef typename Config::template Handle<ArrayType>::type ArrayHandle;
272 typedef typename Config::template Handle<FunctionType>::type FunctionHandle; 272 typedef typename Config::template Handle<FunctionType>::type FunctionHandle;
273 typedef typename Config::template Handle<UnionType>::type UnionHandle; 273 typedef typename Config::template Handle<UnionType>::type UnionHandle;
274 typedef typename Config::Region Region; 274 typedef typename Config::Region Region;
275 275
276 // Constructors. 276 // Constructors.
277 277
278 #define DEFINE_TYPE_CONSTRUCTOR(type, value) \ 278 #define DEFINE_TYPE_CONSTRUCTOR(type, value) \
279 static TypeImpl* type() { return BitsetType::New(BitsetType::k##type); } \ 279 static TypeImpl* type() { \
280 return BitsetType::New(BitsetType::k##type); \
281 } \
280 static TypeHandle type(Region* region) { \ 282 static TypeHandle type(Region* region) { \
281 return BitsetType::New(BitsetType::k##type, region); \ 283 return BitsetType::New(BitsetType::k##type, region); \
282 } 284 }
283 BITSET_TYPE_LIST(DEFINE_TYPE_CONSTRUCTOR) 285 BITSET_TYPE_LIST(DEFINE_TYPE_CONSTRUCTOR)
284 #undef DEFINE_TYPE_CONSTRUCTOR 286 #undef DEFINE_TYPE_CONSTRUCTOR
285 287
286 static TypeHandle Class(i::Handle<i::Map> map, Region* region) { 288 static TypeHandle Class(i::Handle<i::Map> map, Region* region) {
287 return ClassType::New(map, region); 289 return ClassType::New(map, region);
288 } 290 }
289 static TypeHandle Constant(i::Handle<i::Object> value, Region* region) { 291 static TypeHandle Constant(i::Handle<i::Object> value, Region* region) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 452 }
451 TypeImpl* unhandle() { return this; } 453 TypeImpl* unhandle() { return this; }
452 454
453 // Internal inspection. 455 // Internal inspection.
454 456
455 bool IsNone() { return this == None(); } 457 bool IsNone() { return this == None(); }
456 bool IsAny() { return this == Any(); } 458 bool IsAny() { return this == Any(); }
457 bool IsBitset() { return Config::is_bitset(this); } 459 bool IsBitset() { return Config::is_bitset(this); }
458 bool IsUnion() { return Config::is_struct(this, StructuralType::kUnionTag); } 460 bool IsUnion() { return Config::is_struct(this, StructuralType::kUnionTag); }
459 461
460 int AsBitset() { 462 bitset AsBitset() {
461 DCHECK(this->IsBitset()); 463 DCHECK(this->IsBitset());
462 return static_cast<BitsetType*>(this)->Bitset(); 464 return static_cast<BitsetType*>(this)->Bitset();
463 } 465 }
464 UnionType* AsUnion() { return UnionType::cast(this); } 466 UnionType* AsUnion() { return UnionType::cast(this); }
465 467
466 // Auxiliary functions. 468 // Auxiliary functions.
467 469
468 int BitsetGlb() { return BitsetType::Glb(this); } 470 bitset BitsetGlb() { return BitsetType::Glb(this); }
469 int BitsetLub() { return BitsetType::Lub(this); } 471 bitset BitsetLub() { return BitsetType::Lub(this); }
470 int InherentBitsetLub() { return BitsetType::InherentLub(this); } 472 bitset InherentBitsetLub() { return BitsetType::InherentLub(this); }
471 473
472 bool SlowIs(TypeImpl* that); 474 bool SlowIs(TypeImpl* that);
473 475
474 TypeHandle Rebound(int bitset, Region* region); 476 TypeHandle Rebound(bitset bound, Region* region);
475 int BoundBy(TypeImpl* that); 477 bitset BoundBy(TypeImpl* that);
476 int IndexInUnion(int bound, UnionHandle unioned, int current_size); 478 int IndexInUnion(bitset bound, UnionHandle unioned, int current_size);
477 static int ExtendUnion( 479 static int ExtendUnion(
478 UnionHandle unioned, int current_size, TypeHandle t, 480 UnionHandle unioned, int current_size, TypeHandle t,
479 TypeHandle other, bool is_intersect, Region* region); 481 TypeHandle other, bool is_intersect, Region* region);
480 }; 482 };
481 483
482 484
483 // ----------------------------------------------------------------------------- 485 // -----------------------------------------------------------------------------
484 // Bitset types (internal). 486 // Bitset types (internal).
485 487
486 template<class Config> 488 template<class Config>
487 class TypeImpl<Config>::BitsetType : public TypeImpl<Config> { 489 class TypeImpl<Config>::BitsetType : public TypeImpl<Config> {
488 protected: 490 protected:
489 friend class TypeImpl<Config>; 491 friend class TypeImpl<Config>;
490 492
491 enum { 493 enum {
492 #define DECLARE_TYPE(type, value) k##type = (value), 494 #define DECLARE_TYPE(type, value) k##type = (value),
493 BITSET_TYPE_LIST(DECLARE_TYPE) 495 BITSET_TYPE_LIST(DECLARE_TYPE)
494 #undef DECLARE_TYPE 496 #undef DECLARE_TYPE
495 kUnusedEOL = 0 497 kUnusedEOL = 0
496 }; 498 };
497 499
498 int Bitset() { return Config::as_bitset(this); } 500 bitset Bitset() { return Config::as_bitset(this); }
499 501
500 static TypeImpl* New(int bitset) { 502 static TypeImpl* New(bitset bits) { return Config::from_bitset(bits); }
501 return static_cast<BitsetType*>(Config::from_bitset(bitset)); 503 static TypeHandle New(bitset bits, Region* region) {
502 } 504 return Config::from_bitset(bits, region);
503 static TypeHandle New(int bitset, Region* region) {
504 return Config::from_bitset(bitset, region);
505 } 505 }
506 506
507 static bool IsInhabited(int bitset) { 507 static bool IsInhabited(bitset bits) {
508 return (bitset & kRepresentation) && (bitset & kSemantic); 508 return (bits & kRepresentation) && (bits & kSemantic);
509 } 509 }
510 510
511 static bool Is(int bitset1, int bitset2) { 511 static bool Is(bitset bits1, bitset bits2) {
512 return (bitset1 | bitset2) == bitset2; 512 return (bits1 | bits2) == bits2;
513 } 513 }
514 514
515 static int Glb(TypeImpl* type); // greatest lower bound that's a bitset 515 static bitset Glb(TypeImpl* type); // greatest lower bound that's a bitset
516 static int Lub(TypeImpl* type); // least upper bound that's a bitset 516 static bitset Lub(TypeImpl* type); // least upper bound that's a bitset
517 static int Lub(i::Object* value); 517 static bitset Lub(i::Object* value);
518 static int Lub(double value); 518 static bitset Lub(double value);
519 static int Lub(int32_t value); 519 static bitset Lub(int32_t value);
520 static int Lub(uint32_t value); 520 static bitset Lub(uint32_t value);
521 static int Lub(i::Map* map); 521 static bitset Lub(i::Map* map);
522 static int Lub(double min, double max); 522 static bitset Lub(double min, double max);
523 static int InherentLub(TypeImpl* type); 523 static bitset InherentLub(TypeImpl* type);
524 524
525 static const char* Name(int bitset); 525 static const char* Name(bitset);
526 static void Print(OStream& os, int bitset); // NOLINT 526 static void Print(OStream& os, bitset); // NOLINT
527 using TypeImpl::PrintTo; 527 using TypeImpl::PrintTo;
528 }; 528 };
529 529
530 530
531 // ----------------------------------------------------------------------------- 531 // -----------------------------------------------------------------------------
532 // Superclass for non-bitset types (internal). 532 // Superclass for non-bitset types (internal).
533 // Contains a tag and a variable number of type or value fields. 533 // Contains a tag and a variable number of type or value fields.
534 534
535 template<class Config> 535 template<class Config>
536 class TypeImpl<Config>::StructuralType : public TypeImpl<Config> { 536 class TypeImpl<Config>::StructuralType : public TypeImpl<Config> {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 return region->isolate(); 859 return region->isolate();
860 } 860 }
861 861
862 template<class T> static inline T* handle(T* type); 862 template<class T> static inline T* handle(T* type);
863 template<class T> static inline T* cast(Type* type); 863 template<class T> static inline T* cast(Type* type);
864 864
865 static inline bool is_bitset(Type* type); 865 static inline bool is_bitset(Type* type);
866 static inline bool is_class(Type* type); 866 static inline bool is_class(Type* type);
867 static inline bool is_struct(Type* type, int tag); 867 static inline bool is_struct(Type* type, int tag);
868 868
869 static inline int as_bitset(Type* type); 869 static inline Type::bitset as_bitset(Type* type);
870 static inline i::Handle<i::Map> as_class(Type* type); 870 static inline i::Handle<i::Map> as_class(Type* type);
871 static inline Struct* as_struct(Type* type); 871 static inline Struct* as_struct(Type* type);
872 872
873 static inline Type* from_bitset(int bitset); 873 static inline Type* from_bitset(Type::bitset);
874 static inline Type* from_bitset(int bitset, Zone* zone); 874 static inline Type* from_bitset(Type::bitset, Zone* zone);
875 static inline Type* from_class(i::Handle<i::Map> map, Zone* zone); 875 static inline Type* from_class(i::Handle<i::Map> map, Zone* zone);
876 static inline Type* from_struct(Struct* structured); 876 static inline Type* from_struct(Struct* structured);
877 877
878 static inline Struct* struct_create(int tag, int length, Zone* zone); 878 static inline Struct* struct_create(int tag, int length, Zone* zone);
879 static inline void struct_shrink(Struct* structure, int length); 879 static inline void struct_shrink(Struct* structure, int length);
880 static inline int struct_tag(Struct* structure); 880 static inline int struct_tag(Struct* structure);
881 static inline int struct_length(Struct* structure); 881 static inline int struct_length(Struct* structure);
882 static inline Type* struct_get(Struct* structure, int i); 882 static inline Type* struct_get(Struct* structure, int i);
883 static inline void struct_set(Struct* structure, int i, Type* type); 883 static inline void struct_set(Struct* structure, int i, Type* type);
884 template<class V> 884 template<class V>
(...skipping 21 matching lines...) Expand all
906 return region; 906 return region;
907 } 907 }
908 908
909 template<class T> static inline i::Handle<T> handle(T* type); 909 template<class T> static inline i::Handle<T> handle(T* type);
910 template<class T> static inline i::Handle<T> cast(i::Handle<Type> type); 910 template<class T> static inline i::Handle<T> cast(i::Handle<Type> type);
911 911
912 static inline bool is_bitset(Type* type); 912 static inline bool is_bitset(Type* type);
913 static inline bool is_class(Type* type); 913 static inline bool is_class(Type* type);
914 static inline bool is_struct(Type* type, int tag); 914 static inline bool is_struct(Type* type, int tag);
915 915
916 static inline int as_bitset(Type* type); 916 static inline Type::bitset as_bitset(Type* type);
917 static inline i::Handle<i::Map> as_class(Type* type); 917 static inline i::Handle<i::Map> as_class(Type* type);
918 static inline i::Handle<Struct> as_struct(Type* type); 918 static inline i::Handle<Struct> as_struct(Type* type);
919 919
920 static inline Type* from_bitset(int bitset); 920 static inline Type* from_bitset(Type::bitset);
921 static inline i::Handle<Type> from_bitset(int bitset, Isolate* isolate); 921 static inline i::Handle<Type> from_bitset(Type::bitset, Isolate* isolate);
922 static inline i::Handle<Type> from_class( 922 static inline i::Handle<Type> from_class(
923 i::Handle<i::Map> map, Isolate* isolate); 923 i::Handle<i::Map> map, Isolate* isolate);
924 static inline i::Handle<Type> from_struct(i::Handle<Struct> structure); 924 static inline i::Handle<Type> from_struct(i::Handle<Struct> structure);
925 925
926 static inline i::Handle<Struct> struct_create( 926 static inline i::Handle<Struct> struct_create(
927 int tag, int length, Isolate* isolate); 927 int tag, int length, Isolate* isolate);
928 static inline void struct_shrink(i::Handle<Struct> structure, int length); 928 static inline void struct_shrink(i::Handle<Struct> structure, int length);
929 static inline int struct_tag(i::Handle<Struct> structure); 929 static inline int struct_tag(i::Handle<Struct> structure);
930 static inline int struct_length(i::Handle<Struct> structure); 930 static inline int struct_length(i::Handle<Struct> structure);
931 static inline i::Handle<Type> struct_get(i::Handle<Struct> structure, int i); 931 static inline i::Handle<Type> struct_get(i::Handle<Struct> structure, int i);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 bool Narrows(BoundsImpl that) { 996 bool Narrows(BoundsImpl that) {
997 return that.lower->Is(this->lower) && this->upper->Is(that.upper); 997 return that.lower->Is(this->lower) && this->upper->Is(that.upper);
998 } 998 }
999 }; 999 };
1000 1000
1001 typedef BoundsImpl<ZoneTypeConfig> Bounds; 1001 typedef BoundsImpl<ZoneTypeConfig> Bounds;
1002 1002
1003 } } // namespace v8::internal 1003 } } // namespace v8::internal
1004 1004
1005 #endif // V8_TYPES_H_ 1005 #endif // V8_TYPES_H_
OLDNEW
« no previous file with comments | « no previous file | src/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698