34 template<
class Config>
36 if (this->IsClass()) {
38 }
else if (this->IsUnion()) {
39 UnionedHandle unioned = this->AsUnion();
41 for (
int i = 0; i < Config::union_length(unioned); ++i) {
42 if (Config::union_get(unioned, i)->IsClass()) ++result;
51 template<
class Config>
53 if (this->IsConstant()) {
55 }
else if (this->IsUnion()) {
56 UnionedHandle unioned = this->AsUnion();
58 for (
int i = 0; i < Config::union_length(unioned); ++i) {
59 if (Config::union_get(unioned, i)->IsConstant()) ++result;
68 template<
class Config>
template<
class T>
72 return type_->IsUnion() ? Config::union_get(type_->AsUnion(), index_) : type_;
78 template<
class Config,
class T>
84 template<
class Config>
94 template<
class Config>
105 template<
class Config>
template<
class T>
106 bool TypeImpl<Config>::Iterator<T>::matches(TypeHandle type) {
110 template<
class Config>
template<
class T>
116 template<
class Config>
template<
class T>
119 if (type_->IsUnion()) {
120 UnionedHandle unioned = type_->AsUnion();
121 for (; index_ < Config::union_length(unioned); ++index_) {
122 if (matches(Config::union_get(unioned, index_)))
return;
124 }
else if (index_ == 0 && matches(type_)) {
132 template<
class Config>
134 if (this->IsBitset()) {
135 return this->AsBitset();
136 }
else if (this->IsUnion()) {
137 UnionedHandle unioned = this->AsUnion();
139 for (
int i = 0; i < Config::union_length(unioned); ++i) {
140 bitset |= Config::union_get(unioned, i)->LubBitset();
143 }
else if (this->IsClass()) {
144 int bitset = Config::lub_bitset(
this);
145 return bitset ? bitset : LubBitset(*this->AsClass());
147 int bitset = Config::lub_bitset(
this);
148 return bitset ? bitset : LubBitset(*this->AsConstant());
153 template<
class Config>
154 int TypeImpl<Config>::LubBitset(
i::Object* value) {
155 if (value->IsSmi())
return kSignedSmall & kTaggedInt;
160 return kTaggedPtr & (
162 value->
ToUint32(&u) ? kUnsigned32 : kFloat);
165 if (value->IsUndefined())
return kUndefined;
166 if (value->IsNull())
return kNull;
167 if (value->IsBoolean())
return kBoolean;
168 if (value->IsTheHole())
return kAny;
169 if (value->IsUninitialized())
return kNone;
172 return LubBitset(map);
176 template<
class Config>
177 int TypeImpl<Config>::LubBitset(
i::Map* map) {
207 return kFloat & kTaggedPtr;
250 return kInternal & kTaggedPtr;
259 template<
class Config>
260 int TypeImpl<Config>::GlbBitset() {
261 if (this->IsBitset()) {
262 return this->AsBitset();
263 }
else if (this->IsUnion()) {
265 return Config::union_get(this->AsUnion(), 0)->GlbBitset();
273 template<
class Config>
276 if (value->IsSmi() ||
279 return Of(value, region);
286 template<
class Config>
289 if (this->IsNone())
return true;
290 if (that->IsBitset()) {
291 return (this->LubBitset() | that->AsBitset()) == that->AsBitset();
295 return this->IsClass() && *this->AsClass() == *that->
AsClass();
298 return this->IsConstant() && *this->AsConstant() == *that->
AsConstant();
302 if (this->IsUnion()) {
303 UnionedHandle unioned = this->AsUnion();
304 for (
int i = 0; i < Config::union_length(unioned); ++i) {
305 TypeHandle this_i = Config::union_get(unioned, i);
306 if (!this_i->Is(that))
return false;
314 if (that->IsUnion()) {
315 UnionedHandle unioned = that->AsUnion();
316 for (
int i = 0; i < Config::union_length(unioned); ++i) {
317 TypeHandle that_i = Config::union_get(unioned, i);
318 if (this->
Is(that_i))
return true;
319 if (this->IsBitset())
break;
328 template<
class Config>
330 return this->
Is(that) ||
331 (this->IsConstant() && that->
IsClass() &&
332 this->AsConstant()->IsHeapObject() &&
338 template<
class Config>
341 if (this->IsBitset()) {
342 return IsInhabited(this->AsBitset() & that->LubBitset());
344 if (that->IsBitset()) {
345 return IsInhabited(this->LubBitset() & that->AsBitset());
349 if (this->IsUnion()) {
350 UnionedHandle unioned = this->AsUnion();
351 for (
int i = 0; i < Config::union_length(unioned); ++i) {
352 TypeHandle this_i = Config::union_get(unioned, i);
353 if (this_i->Maybe(that))
return true;
359 if (that->IsUnion()) {
360 UnionedHandle unioned = that->AsUnion();
361 for (
int i = 0; i < Config::union_length(unioned); ++i) {
362 TypeHandle that_i = Config::union_get(unioned, i);
363 if (this->
Maybe(that_i))
return true;
368 ASSERT(!this->IsUnion() && !that->IsUnion());
369 if (this->IsClass()) {
372 if (this->IsConstant()) {
380 template<
class Config>
383 for (
int i = 0; i < current_size; ++i) {
384 TypeHandle type = Config::union_get(unioned, i);
385 if (this->
Is(type))
return true;
393 template<
class Config>
394 int TypeImpl<Config>::ExtendUnion(
395 UnionedHandle result, TypeHandle type,
int current_size) {
396 int old_size = current_size;
397 if (type->IsClass() || type->IsConstant()) {
398 if (!type->InUnion(result, old_size)) {
399 Config::union_set(result, current_size++, type);
401 }
else if (type->IsUnion()) {
402 UnionedHandle unioned = type->AsUnion();
403 for (
int i = 0; i < Config::union_length(unioned); ++i) {
404 TypeHandle type = Config::union_get(unioned, i);
406 !(type->IsBitset() || type->Is(Config::union_get(unioned, 0))));
407 if (!type->IsBitset() && !type->InUnion(result, old_size)) {
408 Config::union_set(result, current_size++, type);
418 template<
class Config>
422 if (type1->IsBitset() && type2->IsBitset()) {
423 return Config::from_bitset(type1->AsBitset() | type2->AsBitset(), region);
427 if (type1->IsAny())
return type1;
428 if (type2->IsAny())
return type2;
429 if (type1->IsNone())
return type2;
430 if (type2->IsNone())
return type1;
433 if (!(type1->IsUnion() || type2->IsUnion())) {
434 if (type1->Is(type2))
return type2;
435 if (type2->Is(type1))
return type1;
439 int size = type1->IsBitset() || type2->IsBitset() ? 1 : 0;
440 if (!type1->IsBitset()) {
441 size += (type1->IsUnion() ? Config::union_length(type1->AsUnion()) : 1);
443 if (!type2->IsBitset()) {
444 size += (type2->IsUnion() ? Config::union_length(type2->AsUnion()) : 1);
447 UnionedHandle unioned = Config::union_create(size, region);
450 int bitset = type1->GlbBitset() | type2->GlbBitset();
451 if (bitset != kNone) {
452 Config::union_set(unioned, size++, Config::from_bitset(bitset, region));
454 size = ExtendUnion(unioned, type1, size);
455 size = ExtendUnion(unioned, type2, size);
458 return Config::union_get(unioned, 0);
460 Config::union_shrink(unioned, size);
461 return Config::from_union(unioned);
468 template<
class Config>
470 UnionedHandle result, TypeHandle type, TypeHandle other,
int current_size) {
471 int old_size = current_size;
472 if (type->IsClass() || type->IsConstant()) {
473 if (type->Is(other) && !type->InUnion(result, old_size)) {
474 Config::union_set(result, current_size++, type);
476 }
else if (type->IsUnion()) {
477 UnionedHandle unioned = type->AsUnion();
478 for (
int i = 0; i < Config::union_length(unioned); ++i) {
479 TypeHandle type = Config::union_get(unioned, i);
481 !(type->IsBitset() || type->Is(Config::union_get(unioned, 0))));
482 if (!type->IsBitset() && type->Is(other) &&
483 !type->InUnion(result, old_size)) {
484 Config::union_set(result, current_size++, type);
494 template<
class Config>
498 if (type1->IsBitset() && type2->IsBitset()) {
499 return Config::from_bitset(type1->AsBitset() & type2->AsBitset(), region);
503 if (type1->IsNone())
return type1;
504 if (type2->IsNone())
return type2;
505 if (type1->IsAny())
return type2;
506 if (type2->IsAny())
return type1;
509 if (!(type1->IsUnion() || type2->IsUnion())) {
510 if (type1->Is(type2))
return type1;
511 if (type2->Is(type1))
return type2;
516 if (!type1->IsBitset()) {
517 size = (type1->IsUnion() ? Config::union_length(type1->AsUnion()) : 2);
519 if (!type2->IsBitset()) {
520 int size2 = (type2->IsUnion() ? Config::union_length(type2->AsUnion()) : 2);
521 size = (size == 0 ? size2 :
Min(size, size2));
524 UnionedHandle unioned = Config::union_create(size, region);
527 int bitset = type1->GlbBitset() & type2->GlbBitset();
528 if (bitset != kNone) {
529 Config::union_set(unioned, size++, Config::from_bitset(bitset, region));
531 size = ExtendIntersection(unioned, type1, type2, size);
532 size = ExtendIntersection(unioned, type2, type1, size);
536 }
else if (size == 1) {
537 return Config::union_get(unioned, 0);
539 Config::union_shrink(unioned, size);
540 return Config::from_union(unioned);
545 template<
class Config>
546 template<
class OtherType>
548 typename OtherType::TypeHandle type,
Region* region) {
549 if (type->IsBitset()) {
550 return Config::from_bitset(type->AsBitset(), region);
551 }
else if (type->IsClass()) {
552 return Config::from_class(type->AsClass(), type->LubBitset(), region);
553 }
else if (type->IsConstant()) {
554 return Config::from_constant(type->AsConstant(), type->LubBitset(), region);
557 typename OtherType::UnionedHandle unioned = type->AsUnion();
558 int length = OtherType::UnionLength(unioned);
559 UnionedHandle new_unioned = Config::union_create(length, region);
560 for (
int i = 0; i < length; ++i) {
561 Config::union_set(new_unioned, i,
562 Convert<OtherType>(OtherType::UnionGet(unioned, i), region));
564 return Config::from_union(new_unioned);
580 template<
class Config>
582 TypePrint(stdout, dim);
588 template<
class Config>
589 const char* TypeImpl<Config>::bitset_name(
int bitset) {
591 case kAny & kRepresentation:
return "Any";
592 #define PRINT_COMPOSED_TYPE(type, value) \
593 case k##type & kRepresentation: return #type;
595 #undef PRINT_COMPOSED_TYPE
597 #define PRINT_COMPOSED_TYPE(type, value) \
598 case k##type & kSemantic: return #type;
600 #undef PRINT_COMPOSED_TYPE
608 template<
class Config>
609 void TypeImpl<Config>::BitsetTypePrint(FILE* out,
int bitset) {
610 const char*
name = bitset_name(bitset);
614 static const int named_bitsets[] = {
615 #define BITSET_CONSTANT(type, value) k##type & kRepresentation,
617 #undef BITSET_CONSTANT
619 #define BITSET_CONSTANT(type, value) k##type & kSemantic,
621 #undef BITSET_CONSTANT
624 bool is_first =
true;
626 for (
int i(
ARRAY_SIZE(named_bitsets) - 1); bitset != 0 && i >= 0; --i) {
627 int subset = named_bitsets[i];
628 if ((bitset & subset) == subset) {
629 if (!is_first)
PrintF(out,
" | ");
631 PrintF(out,
"%s", bitset_name(subset));
641 template<
class Config>
642 void TypeImpl<Config>::TypePrint(FILE* out, PrintDimension dim) {
643 if (this->IsBitset()) {
644 int bitset = this->AsBitset();
647 BitsetTypePrint(out, bitset & kSemantic);
649 BitsetTypePrint(out, bitset & kRepresentation);
652 BitsetTypePrint(out, bitset & kSemantic);
654 case REPRESENTATION_DIM:
655 BitsetTypePrint(out, bitset & kRepresentation);
658 }
else if (this->IsConstant()) {
659 PrintF(out,
"Constant(%p : ", static_cast<void*>(*this->AsConstant()));
660 Config::from_bitset(this->LubBitset())->TypePrint(out);
662 }
else if (this->IsClass()) {
663 PrintF(out,
"Class(%p < ", static_cast<void*>(*this->AsClass()));
664 Config::from_bitset(this->LubBitset())->TypePrint(out);
666 }
else if (this->IsUnion()) {
668 UnionedHandle unioned = this->AsUnion();
669 for (
int i = 0; i < Config::union_length(unioned); ++i) {
670 TypeHandle type_i = Config::union_get(unioned, i);
671 if (i > 0)
PrintF(out,
" | ");
672 type_i->TypePrint(out);
680 template class TypeImpl<ZoneTypeConfig>;
684 template class TypeImpl<HeapTypeConfig>;
685 template class TypeImpl<HeapTypeConfig>::Iterator<
i::Map>;
686 template class TypeImpl<HeapTypeConfig>::Iterator<
i::Object>;
691 template TypeImpl<HeapTypeConfig>::TypeHandle
692 TypeImpl<HeapTypeConfig>::Convert<
Type>(
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
i::Handle< i::Map > AsClass()
static Representation Smi()
void PrintF(const char *format,...)
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< i::Map > current(typename TypeImpl< Config >::TypeHandle type)
bool ToUint32(uint32_t *value)
static bool matches(typename TypeImpl< Config >::TypeHandle type)
static HeapObject * cast(Object *obj)
static Representation Integer32()
#define SEMANTIC_BITSET_TYPE_LIST(V)
bool ToInt32(int32_t *value)
TypeImpl< ZoneTypeConfig > Type
static bool matches(typename TypeImpl< Config >::TypeHandle type)
#define ASSERT(condition)
static bool matches(typename TypeImpl< Config >::TypeHandle type)
#define REPRESENTATION_BITSET_TYPE_LIST(V)
i::Handle< i::Object > AsConstant()
static Representation Double()
bool Maybe(TypeImpl *that)
static Representation FromType(Type *type)
static i::Handle< i::Object > current(typename TypeImpl< Config >::TypeHandle type)
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 bool IsValid(intptr_t value)
static TypeHandle Convert(typename OtherTypeImpl::TypeHandle type, Region *region)
bool IsCurrently(TypeImpl *that)
static TypeHandle Intersect(TypeHandle type1, TypeHandle type2, Region *reg)
Config::template Handle< TypeImpl >::type TypeHandle
Handle< T > handle(T *t, Isolate *isolate)
InstanceType instance_type()
static TypeHandle OfCurrently(i::Handle< i::Object > value, Region *region)
static TypeHandle Union(TypeHandle type1, TypeHandle type2, Region *reg)
static Representation None()
static Representation Tagged()
TypeImpl< HeapTypeConfig > HeapType
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 deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
static i::Handle< T > current(typename TypeImpl< Config >::TypeHandle type)