128 #define MASK_BITSET_TYPE_LIST(V) \
129 V(Representation, static_cast<int>(0xff800000)) \
130 V(Semantic, static_cast<int>(0x007fffff))
132 #define REPRESENTATION(k) ((k) & kRepresentation)
133 #define SEMANTIC(k) ((k) & kSemantic)
135 #define REPRESENTATION_BITSET_TYPE_LIST(V) \
137 V(UntaggedInt8, 1 << 23 | kSemantic) \
138 V(UntaggedInt16, 1 << 24 | kSemantic) \
139 V(UntaggedInt32, 1 << 25 | kSemantic) \
140 V(UntaggedFloat32, 1 << 26 | kSemantic) \
141 V(UntaggedFloat64, 1 << 27 | kSemantic) \
142 V(UntaggedPtr, 1 << 28 | kSemantic) \
143 V(TaggedInt, 1 << 29 | kSemantic) \
144 V(TaggedPtr, -1 << 30 | kSemantic) \
146 V(UntaggedInt, kUntaggedInt8 | kUntaggedInt16 | kUntaggedInt32) \
147 V(UntaggedFloat, kUntaggedFloat32 | kUntaggedFloat64) \
148 V(UntaggedNumber, kUntaggedInt | kUntaggedFloat) \
149 V(Untagged, kUntaggedNumber | kUntaggedPtr) \
150 V(Tagged, kTaggedInt | kTaggedPtr)
152 #define SEMANTIC_BITSET_TYPE_LIST(V) \
153 V(Null, 1 << 0 | REPRESENTATION(kTaggedPtr)) \
154 V(Undefined, 1 << 1 | REPRESENTATION(kTaggedPtr)) \
155 V(Boolean, 1 << 2 | REPRESENTATION(kTaggedPtr)) \
156 V(SignedSmall, 1 << 3 | REPRESENTATION(kTagged | kUntaggedNumber)) \
157 V(OtherSigned32, 1 << 4 | REPRESENTATION(kTagged | kUntaggedNumber)) \
158 V(Unsigned32, 1 << 5 | REPRESENTATION(kTagged | kUntaggedNumber)) \
159 V(Float, 1 << 6 | REPRESENTATION(kTagged | kUntaggedNumber)) \
160 V(Symbol, 1 << 7 | REPRESENTATION(kTaggedPtr)) \
161 V(InternalizedString, 1 << 8 | REPRESENTATION(kTaggedPtr)) \
162 V(OtherString, 1 << 9 | REPRESENTATION(kTaggedPtr)) \
163 V(Undetectable, 1 << 10 | REPRESENTATION(kTaggedPtr)) \
164 V(Array, 1 << 11 | REPRESENTATION(kTaggedPtr)) \
165 V(Function, 1 << 12 | REPRESENTATION(kTaggedPtr)) \
166 V(RegExp, 1 << 13 | REPRESENTATION(kTaggedPtr)) \
167 V(OtherObject, 1 << 14 | REPRESENTATION(kTaggedPtr)) \
168 V(Proxy, 1 << 15 | REPRESENTATION(kTaggedPtr)) \
169 V(Internal, 1 << 16 | REPRESENTATION(kTagged | kUntagged)) \
171 V(Oddball, kBoolean | kNull | kUndefined) \
172 V(Signed32, kSignedSmall | kOtherSigned32) \
173 V(Number, kSigned32 | kUnsigned32 | kFloat) \
174 V(String, kInternalizedString | kOtherString) \
175 V(UniqueName, kSymbol | kInternalizedString) \
176 V(Name, kSymbol | kString) \
177 V(NumberOrString, kNumber | kString) \
178 V(DetectableObject, kArray | kFunction | kRegExp | kOtherObject) \
179 V(DetectableReceiver, kDetectableObject | kProxy) \
180 V(Detectable, kDetectableReceiver | kNumber | kName) \
181 V(Object, kDetectableObject | kUndetectable) \
182 V(Receiver, kObject | kProxy) \
183 V(NonNumber, kOddball | kName | kReceiver | kInternal) \
184 V(Any, kNumber | kNonNumber)
186 #define BITSET_TYPE_LIST(V) \
187 MASK_BITSET_TYPE_LIST(V) \
188 REPRESENTATION_BITSET_TYPE_LIST(V) \
189 SEMANTIC_BITSET_TYPE_LIST(V)
218 template<
class Config>
219 class TypeImpl :
public Config::Base {
224 #define DEFINE_TYPE_CONSTRUCTOR(type, value) \
225 static TypeImpl* type() { return Config::from_bitset(k##type); } \
226 static TypeHandle type(Region* region) { \
227 return Config::from_bitset(k##type, region); \
230 #undef DEFINE_TYPE_CONSTRUCTOR
233 return Config::from_class(map, LubBitset(*map), region);
236 return Config::from_constant(value, LubBitset(*value), region);
243 return Config::from_bitset(LubBitset(*value), region);
246 bool Is(
TypeImpl* that) {
return this == that || this->SlowIs(that); }
247 template<
class TypeHandle>
250 template<
class TypeHandle>
257 template<
class TypeHandle>
260 bool IsClass() {
return Config::is_class(
this); }
271 bool Done()
const {
return index_ < 0; }
291 if (this->IsBitset())
return Iterator<i::Map>();
295 if (this->IsBitset())
return Iterator<i::Object>();
301 ASSERT(t->IsBitset() || t->IsClass() || t->IsConstant() || t->IsUnion());
305 template<
class OtherTypeImpl>
307 typename OtherTypeImpl::TypeHandle type,
Region* region);
310 enum PrintDimension { BOTH_DIMS, SEMANTIC_DIM, REPRESENTATION_DIM };
311 void TypePrint(PrintDimension = BOTH_DIMS);
312 void TypePrint(FILE* out, PrintDimension = BOTH_DIMS);
323 typedef typename Config::Unioned Unioned;
327 #define DECLARE_TYPE(type, value) k##type = (value),
333 bool IsNone() {
return this ==
None(); }
334 bool IsAny() {
return this == Any(); }
335 bool IsBitset() {
return Config::is_bitset(
this); }
336 bool IsUnion() {
return Config::is_union(
this); }
337 int AsBitset() {
return Config::as_bitset(
this); }
338 UnionedHandle AsUnion() {
return Config::as_union(
this); }
340 static int UnionLength(UnionedHandle unioned) {
341 return Config::union_length(unioned);
343 static TypeHandle UnionGet(UnionedHandle unioned,
int i) {
344 return Config::union_get(unioned, i);
349 static bool IsInhabited(
int bitset) {
350 return (bitset & kRepresentation) && (bitset & kSemantic);
359 bool InUnion(UnionedHandle unioned,
int current_size);
360 static int ExtendUnion(
361 UnionedHandle unioned,
TypeHandle t,
int current_size);
362 static int ExtendIntersection(
366 static const char* bitset_name(
int bitset);
367 static void BitsetTypePrint(FILE* out,
int bitset);
387 tagged->
Add(reinterpret_cast<void*>(tag), zone);
391 static void tagged_shrink(
Tagged* tagged,
int size) {
392 tagged->Rewind(size + 1);
394 static Tag tagged_tag(
Tagged* tagged) {
395 return static_cast<Tag
>(
reinterpret_cast<intptr_t
>(tagged->
at(0)));
398 static T tagged_get(
Tagged* tagged,
int i) {
399 return reinterpret_cast<T>(tagged->
at(i + 1));
402 static void tagged_set(
Tagged* tagged,
int i,
T value) {
403 tagged->
at(i + 1) =
reinterpret_cast<void*
>(value);
405 static int tagged_length(
Tagged* tagged) {
406 return tagged->length() - 1;
423 return reinterpret_cast<intptr_t
>(type) & 1;
435 return static_cast<int>(
reinterpret_cast<intptr_t
>(type) >> 1);
439 return reinterpret_cast<Tagged*
>(type);
455 return reinterpret_cast<Unioned*
>(tagged);
459 return reinterpret_cast<Type*
>((bitset << 1) | 1);
465 return reinterpret_cast<Type*
>(tagged);
468 Tagged* tagged = tagged_create(kClassTag, 2, zone);
469 tagged_set(tagged, 0, lub);
470 tagged_set(tagged, 1, map.location());
474 Tagged* tagged = tagged_create(kConstantTag, 2, zone);
475 tagged_set(tagged, 0, lub);
476 tagged_set(tagged, 1, value.location());
483 return reinterpret_cast<Tagged*
>(unioned);
506 return static_cast<int>(tagged_get<intptr_t>(
as_tagged(type), 0));
566 unioned->Shrink(size);
569 Type* type =
static_cast<Type*
>(unioned->get(i));
571 return i::handle(type, unioned->GetIsolate());
576 unioned->set(i, *type);
579 return unioned->length();
586 typedef TypeImpl<ZoneTypeConfig>
Type;
587 typedef TypeImpl<HeapTypeConfig>
HeapType;
591 template<
class Config>
649 #endif // V8_TYPES_H_
i::ZoneList< Type * > Unioned
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
static Type * from_tagged(Tagged *tagged)
static Type * from_bitset(int bitset, Zone *Zone)
static void union_shrink(i::Handle< Unioned > unioned, int size)
static TypeImpl * cast(typename Config::Base *object)
static int union_length(Unioned *unioned)
i::Handle< i::Map > AsClass()
static i::Handle< Type > from_bitset(int bitset, Isolate *isolate)
static Unioned * tagged_as_union(Tagged *tagged)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf map
static i::Handle< Type > from_union(i::Handle< Unioned > unioned)
TypeImpl< ZoneTypeConfig > Type
static bool is_tagged(Type *type)
static i::Handle< i::Object > as_constant(Type *type)
static Smi * FromInt(int value)
static i::Handle< Unioned > as_union(Type *type)
static void union_set(Unioned *unioned, int i, Type *type)
static HeapObject * cast(Object *obj)
static Handle< T > cast(Handle< S > that)
static i::Handle< i::Map > as_class(Type *type)
static int lub_bitset(Type *type)
static Map * cast(Object *obj)
static Type * from_constant(i::Handle< i::Object > value, int lub, Zone *zone)
static bool is_constant(Type *type)
static BoundsImpl NarrowUpper(BoundsImpl b, TypeHandle t, Region *region)
#define DEFINE_TYPE_CONSTRUCTOR(type, value)
BoundsImpl< ZoneTypeConfig > Bounds
TypeImpl< ZoneTypeConfig > Type
static i::Handle< i::Map > as_class(Type *type)
#define ASSERT(condition)
static Type * from_bitset(int bitset)
Iterator< i::Map > Classes()
i::Handle< i::Object > AsConstant()
static bool tagged_is_union(Tagged *tagged)
#define DECLARE_TYPE(type, value)
bool Maybe(TypeImpl *that)
static bool is_class(Type *type)
static bool is_class(Type *type)
static void union_shrink(Unioned *unioned, int size)
static Smi * cast(Object *object)
static Type * from_union(Unioned *unioned)
static i::Handle< i::Object > as_constant(Type *type)
static bool is_bitset(Type *type)
static i::Handle< Type > from_class(i::Handle< i::Map > map, int lub, Isolate *isolate)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object size
static Type * from_class(i::Handle< i::Map > map, int lub, Zone *zone)
static i::Handle< Unioned > union_create(int size, Isolate *isolate)
static Box * cast(Object *obj)
static void union_set(i::Handle< Unioned > unioned, int i, i::Handle< Type > type)
static int as_bitset(Type *type)
static TypeHandle Convert(typename OtherTypeImpl::TypeHandle type, Region *region)
#define BITSET_TYPE_LIST(V)
static int as_bitset(Type *type)
static Unioned * as_union(Type *type)
Handle< FixedArray > NewFixedArray(int size, PretenureFlag pretenure=NOT_TENURED)
static bool is_bitset(Type *type)
static i::Handle< Type > from_constant(i::Handle< i::Object > value, int lub, Isolate *isolate)
bool IsCurrently(TypeImpl *that)
#define T(name, string, precedence)
bool Maybe(TypeHandle that)
bool Narrows(BoundsImpl that)
Iterator< i::Object > Constants()
static TypeHandle Intersect(TypeHandle type1, TypeHandle type2, Region *reg)
TypeImpl< HeapTypeConfig > Type
Handle< Box > NewBox(Handle< Object > value, PretenureFlag pretenure=NOT_TENURED)
static Tagged * as_tagged(Type *type)
Config::template Handle< TypeImpl >::type TypeHandle
static int lub_bitset(Type *type)
Handle< T > handle(T *t, Isolate *isolate)
static i::Handle< Type > union_get(i::Handle< Unioned > unioned, int i)
static bool is_union(Type *type)
static Type * handle(Type *type)
static bool is_constant(Type *type)
static Type * from_bitset(int bitset)
static BoundsImpl Either(BoundsImpl b1, BoundsImpl b2, Region *region)
BoundsImpl(TypeHandle l, TypeHandle u)
static Type * union_get(Unioned *unioned, int i)
static bool is(Type *type, Tag tag)
Type::TypeHandle TypeHandle
static FixedArray * cast(Object *obj)
static Tagged * tagged_from_union(Unioned *unioned)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
static TypeHandle Constant(i::Handle< i::Object > value, Region *region)
static TypeHandle OfCurrently(i::Handle< i::Object > value, Region *region)
static Unioned * union_create(int size, Zone *zone)
static TypeHandle Union(TypeHandle type1, TypeHandle type2, Region *reg)
static BoundsImpl Unbounded(Region *region)
static TypeHandle Class(i::Handle< i::Map > map, Region *region)
static TypeHandle Of(i::Handle< i::Object > value, Region *region)
static BoundsImpl Both(BoundsImpl b1, BoundsImpl b2, Region *region)
TypeImpl< HeapTypeConfig > HeapType
bool IsCurrently(TypeHandle that)
static bool is_union(Type *type)
static BoundsImpl NarrowLower(BoundsImpl b, TypeHandle t, Region *region)
Vector< T > AddBlock(T value, int count, AllocationPolicy allocator=AllocationPolicy())
static int union_length(i::Handle< Unioned > unioned)
static i::Handle< Type > handle(Type *type)