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

Side by Side Diff: src/types.cc

Issue 413983005: Remove unnecesssary auxiliary definitions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | test/cctest/test-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 #include "src/types.h" 5 #include "src/types.h"
6 6
7 #include "src/ostreams.h" 7 #include "src/ostreams.h"
8 #include "src/types-inl.h" 8 #include "src/types-inl.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // Predicates. 241 // Predicates.
242 242
243 // Check this <= that. 243 // Check this <= that.
244 template<class Config> 244 template<class Config>
245 bool TypeImpl<Config>::SlowIs(TypeImpl* that) { 245 bool TypeImpl<Config>::SlowIs(TypeImpl* that) {
246 DisallowHeapAllocation no_allocation; 246 DisallowHeapAllocation no_allocation;
247 247
248 // Fast path for bitsets. 248 // Fast path for bitsets.
249 if (this->IsNone()) return true; 249 if (this->IsNone()) return true;
250 if (that->IsBitset()) { 250 if (that->IsBitset()) {
251 return (BitsetType::Lub(this) | that->AsBitset()) == that->AsBitset(); 251 return BitsetType::Is(BitsetType::Lub(this), that->AsBitset());
252 } 252 }
253 if (this->IsBitset() && SEMANTIC(this->AsBitset()) == BitsetType::kNone) { 253 if (this->IsBitset() && SEMANTIC(this->AsBitset()) == BitsetType::kNone) {
254 // Bitsets only have non-bitset supertypes along the representation axis. 254 // Bitsets only have non-bitset supertypes along the representation axis.
255 int that_bitset = that->BitsetGlb(); 255 return BitsetType::Is(this->AsBitset(), that->BitsetGlb());
256 return (BitsetType::Is(this->AsBitset(), that_bitset));
257 } 256 }
258 257
259 if (that->IsClass()) { 258 if (that->IsClass()) {
260 return this->IsClass() 259 return this->IsClass()
261 && *this->AsClass()->Map() == *that->AsClass()->Map() 260 && *this->AsClass()->Map() == *that->AsClass()->Map()
262 && ((Config::is_class(that) && Config::is_class(this)) || 261 && ((Config::is_class(that) && Config::is_class(this)) ||
263 BitsetType::New(this->BitsetLub())->Is( 262 BitsetType::New(this->BitsetLub())->Is(
264 BitsetType::New(that->BitsetLub()))); 263 BitsetType::New(that->BitsetLub())));
265 } 264 }
266 if (that->IsConstant()) { 265 if (that->IsConstant()) {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 478 }
480 479
481 480
482 template<class Config> 481 template<class Config>
483 int TypeImpl<Config>::IndexInUnion( 482 int TypeImpl<Config>::IndexInUnion(
484 int bound, UnionHandle unioned, int current_size) { 483 int bound, UnionHandle unioned, int current_size) {
485 DCHECK(!this->IsUnion()); 484 DCHECK(!this->IsUnion());
486 for (int i = 0; i < current_size; ++i) { 485 for (int i = 0; i < current_size; ++i) {
487 TypeHandle that = unioned->Get(i); 486 TypeHandle that = unioned->Get(i);
488 if (that->IsBitset()) { 487 if (that->IsBitset()) {
489 if ((bound | that->AsBitset()) == that->AsBitset()) return i; 488 if (BitsetType::Is(bound, that->AsBitset())) return i;
490 } else if (that->IsClass() && this->IsClass()) { 489 } else if (that->IsClass() && this->IsClass()) {
491 if (*this->AsClass()->Map() == *that->AsClass()->Map()) return i; 490 if (*this->AsClass()->Map() == *that->AsClass()->Map()) return i;
492 } else if (that->IsConstant() && this->IsConstant()) { 491 } else if (that->IsConstant() && this->IsConstant()) {
493 if (*this->AsConstant()->Value() == *that->AsConstant()->Value()) 492 if (*this->AsConstant()->Value() == *that->AsConstant()->Value())
494 return i; 493 return i;
495 } else if (that->IsContext() && this->IsContext()) { 494 } else if (that->IsContext() && this->IsContext()) {
496 if (this->Is(that)) return i; 495 if (this->Is(that)) return i;
497 } else if (that->IsArray() && this->IsArray()) { 496 } else if (that->IsArray() && this->IsArray()) {
498 if (this->Is(that)) return i; 497 if (this->Is(that)) return i;
499 } else if (that->IsFunction() && this->IsFunction()) { 498 } else if (that->IsFunction() && this->IsFunction()) {
500 if (this->Is(that)) return i; 499 if (this->Is(that)) return i;
501 } 500 }
502 } 501 }
503 return -1; 502 return -1;
504 } 503 }
505 504
506 505
507 // Get non-bitsets from type, bounded by upper. 506 // Get non-bitsets from type, bounded by upper.
508 // Store at result starting at index. Returns updated index. 507 // Store at result starting at index. Returns updated index.
509 template<class Config> 508 template<class Config>
510 int TypeImpl<Config>::ExtendUnion( 509 int TypeImpl<Config>::ExtendUnion(
511 UnionHandle result, int size, TypeHandle type, 510 UnionHandle result, int size, TypeHandle type,
512 TypeHandle other, bool is_intersect, Region* region) { 511 TypeHandle other, bool is_intersect, Region* region) {
513 int old_size = size;
514 if (type->IsUnion()) { 512 if (type->IsUnion()) {
515 UnionHandle unioned = handle(type->AsUnion()); 513 UnionHandle unioned = handle(type->AsUnion());
516 for (int i = 0; i < unioned->Length(); ++i) { 514 for (int i = 0; i < unioned->Length(); ++i) {
517 TypeHandle type_i = unioned->Get(i); 515 TypeHandle type_i = unioned->Get(i);
518 DCHECK(i == 0 || !(type_i->IsBitset() || type_i->Is(unioned->Get(0)))); 516 DCHECK(i == 0 || !(type_i->IsBitset() || type_i->Is(unioned->Get(0))));
519 if (!type_i->IsBitset()) { 517 if (!type_i->IsBitset()) {
520 size = ExtendUnion(result, size, type_i, other, is_intersect, region); 518 size = ExtendUnion(result, size, type_i, other, is_intersect, region);
521 } 519 }
522 } 520 }
523 } else if (!type->IsBitset()) { 521 } else if (!type->IsBitset()) {
524 DCHECK(type->IsClass() || type->IsConstant() || 522 DCHECK(type->IsClass() || type->IsConstant() ||
525 type->IsArray() || type->IsFunction() || type->IsContext()); 523 type->IsArray() || type->IsFunction() || type->IsContext());
526 int inherent_bound = type->InherentBitsetLub(); 524 int inherent_bound = type->InherentBitsetLub();
527 int old_bound = type->BitsetLub(); 525 int old_bound = type->BitsetLub();
528 int other_bound = type->BoundBy(other->unhandle()) & inherent_bound; 526 int other_bound = type->BoundBy(other->unhandle()) & inherent_bound;
529 int new_bound = 527 int new_bound =
530 is_intersect ? (old_bound & other_bound) : (old_bound | other_bound); 528 is_intersect ? (old_bound & other_bound) : (old_bound | other_bound);
531 if (new_bound != BitsetType::kNone) { 529 if (new_bound != BitsetType::kNone) {
532 int i = type->IndexInUnion(new_bound, result, old_size); 530 int i = type->IndexInUnion(new_bound, result, size);
533 if (i == -1) { 531 if (i == -1) {
534 i = size++; 532 i = size++;
535 } else if (result->Get(i)->IsBitset()) { 533 } else if (result->Get(i)->IsBitset()) {
536 return size; // Already fully subsumed. 534 return size; // Already fully subsumed.
537 } else { 535 } else {
538 int type_i_bound = result->Get(i)->BitsetLub(); 536 int type_i_bound = result->Get(i)->BitsetLub();
539 new_bound |= type_i_bound; 537 new_bound |= type_i_bound;
540 if (new_bound == type_i_bound) return size; 538 if (new_bound == type_i_bound) return size;
541 } 539 }
542 if (new_bound != old_bound) type = type->Rebound(new_bound, region); 540 if (new_bound != old_bound) type = type->Rebound(new_bound, region);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 879
882 880
883 template <class Config> 881 template <class Config>
884 void TypeImpl<Config>::PrintTo(OStream& os, PrintDimension dim) { // NOLINT 882 void TypeImpl<Config>::PrintTo(OStream& os, PrintDimension dim) { // NOLINT
885 DisallowHeapAllocation no_allocation; 883 DisallowHeapAllocation no_allocation;
886 if (dim != REPRESENTATION_DIM) { 884 if (dim != REPRESENTATION_DIM) {
887 if (this->IsBitset()) { 885 if (this->IsBitset()) {
888 BitsetType::Print(os, SEMANTIC(this->AsBitset())); 886 BitsetType::Print(os, SEMANTIC(this->AsBitset()));
889 } else if (this->IsClass()) { 887 } else if (this->IsClass()) {
890 os << "Class(" << static_cast<void*>(*this->AsClass()->Map()) << " < "; 888 os << "Class(" << static_cast<void*>(*this->AsClass()->Map()) << " < ";
891 return BitsetType::New(BitsetType::Lub(this))->PrintTo(os, dim); 889 BitsetType::New(BitsetType::Lub(this))->PrintTo(os, dim);
892 os << ")"; 890 os << ")";
893 } else if (this->IsConstant()) { 891 } else if (this->IsConstant()) {
894 os << "Constant(" << static_cast<void*>(*this->AsConstant()->Value()) 892 os << "Constant(" << static_cast<void*>(*this->AsConstant()->Value())
895 << " : "; 893 << " : ";
896 BitsetType::New(BitsetType::Lub(this))->PrintTo(os, dim); 894 BitsetType::New(BitsetType::Lub(this))->PrintTo(os, dim);
897 os << ")"; 895 os << ")";
898 } else if (this->IsRange()) { 896 } else if (this->IsRange()) {
899 os << "Range(" << this->AsRange()->Min() 897 os << "Range(" << this->AsRange()->Min()
900 << ".." << this->AsRange()->Max() << " : "; 898 << ".." << this->AsRange()->Max() << " : ";
901 BitsetType::New(BitsetType::Lub(this))->PrintTo(os, dim); 899 BitsetType::New(BitsetType::Lub(this))->PrintTo(os, dim);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; 950 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>;
953 951
954 template TypeImpl<ZoneTypeConfig>::TypeHandle 952 template TypeImpl<ZoneTypeConfig>::TypeHandle
955 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( 953 TypeImpl<ZoneTypeConfig>::Convert<HeapType>(
956 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); 954 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*);
957 template TypeImpl<HeapTypeConfig>::TypeHandle 955 template TypeImpl<HeapTypeConfig>::TypeHandle
958 TypeImpl<HeapTypeConfig>::Convert<Type>( 956 TypeImpl<HeapTypeConfig>::Convert<Type>(
959 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); 957 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*);
960 958
961 } } // namespace v8::internal 959 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698