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

Side by Side Diff: src/types.cc

Issue 237143002: Re-reland "More tests for Union & Intersect" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixing handlification of tests Created 6 years, 8 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 | « src/types.h ('k') | 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 "types.h" 5 #include "types.h"
6 6
7 #include "string-stream.h" 7 #include "string-stream.h"
8 #include "types-inl.h" 8 #include "types-inl.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 return false; 300 return false;
301 } 301 }
302 302
303 return false; 303 return false;
304 } 304 }
305 305
306 306
307 template<class Config> 307 template<class Config>
308 bool TypeImpl<Config>::NowIs(TypeImpl* that) { 308 bool TypeImpl<Config>::NowIs(TypeImpl* that) {
309 // TODO(rossberg): this is incorrect for
310 // Union(Constant(V), T)->NowIs(Class(M))
311 // but fuzzing does not cover that!
309 DisallowHeapAllocation no_allocation; 312 DisallowHeapAllocation no_allocation;
310 if (this->IsConstant()) { 313 if (this->IsConstant()) {
311 i::Object* object = *this->AsConstant(); 314 i::Object* object = *this->AsConstant();
312 if (object->IsHeapObject()) { 315 if (object->IsHeapObject()) {
313 i::Map* map = i::HeapObject::cast(object)->map(); 316 i::Map* map = i::HeapObject::cast(object)->map();
314 for (Iterator<i::Map> it = that->Classes(); !it.Done(); it.Advance()) { 317 for (Iterator<i::Map> it = that->Classes(); !it.Done(); it.Advance()) {
315 if (*it.Current() == map) return true; 318 if (*it.Current() == map) return true;
316 } 319 }
317 } 320 }
318 } 321 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 431
429 // Slow case: may need to produce a Unioned object. 432 // Slow case: may need to produce a Unioned object.
430 int size = 0; 433 int size = 0;
431 if (!type1->IsBitset()) { 434 if (!type1->IsBitset()) {
432 size += (type1->IsUnion() ? Config::struct_length(type1->AsUnion()) : 1); 435 size += (type1->IsUnion() ? Config::struct_length(type1->AsUnion()) : 1);
433 } 436 }
434 if (!type2->IsBitset()) { 437 if (!type2->IsBitset()) {
435 size += (type2->IsUnion() ? Config::struct_length(type2->AsUnion()) : 1); 438 size += (type2->IsUnion() ? Config::struct_length(type2->AsUnion()) : 1);
436 } 439 }
437 int bitset = type1->GlbBitset() | type2->GlbBitset(); 440 int bitset = type1->GlbBitset() | type2->GlbBitset();
438 if (IsInhabited(bitset)) ++size; 441 if (bitset != kNone) ++size;
439 ASSERT(size >= 1); 442 ASSERT(size >= 1);
440 StructHandle unioned = Config::struct_create(kUnionTag, size, region); 443 StructHandle unioned = Config::struct_create(kUnionTag, size, region);
441 444
442 size = 0; 445 size = 0;
443 if (IsInhabited(bitset)) { 446 if (bitset != kNone) {
444 Config::struct_set(unioned, size++, Config::from_bitset(bitset, region)); 447 Config::struct_set(unioned, size++, Config::from_bitset(bitset, region));
445 } 448 }
446 size = ExtendUnion(unioned, type1, size); 449 size = ExtendUnion(unioned, type1, size);
447 size = ExtendUnion(unioned, type2, size); 450 size = ExtendUnion(unioned, type2, size);
448 451
449 if (size == 1) { 452 if (size == 1) {
450 return Config::struct_get(unioned, 0); 453 return Config::struct_get(unioned, 0);
451 } else { 454 } else {
452 Config::struct_shrink(unioned, size); 455 Config::struct_shrink(unioned, size);
453 return Config::from_struct(unioned); 456 return Config::from_struct(unioned);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 if (type1->IsNone() || type2->IsAny()) return type1; 498 if (type1->IsNone() || type2->IsAny()) return type1;
496 if (type2->IsNone() || type1->IsAny()) return type2; 499 if (type2->IsNone() || type1->IsAny()) return type2;
497 500
498 // Semi-fast case: Unioned objects are neither involved nor produced. 501 // Semi-fast case: Unioned objects are neither involved nor produced.
499 if (!(type1->IsUnion() || type2->IsUnion())) { 502 if (!(type1->IsUnion() || type2->IsUnion())) {
500 if (type1->Is(type2)) return type1; 503 if (type1->Is(type2)) return type1;
501 if (type2->Is(type1)) return type2; 504 if (type2->Is(type1)) return type2;
502 } 505 }
503 506
504 // Slow case: may need to produce a Unioned object. 507 // Slow case: may need to produce a Unioned object.
505 int size = INT_MAX; 508 int size = 0;
506 if (!type1->IsBitset()) { 509 if (!type1->IsBitset()) {
507 size = (type1->IsUnion() ? Config::struct_length(type1->AsUnion()) : 1); 510 size += (type1->IsUnion() ? Config::struct_length(type1->AsUnion()) : 1);
508 } 511 }
509 if (!type2->IsBitset()) { 512 if (!type2->IsBitset()) {
510 size = Min(size, 513 size += (type2->IsUnion() ? Config::struct_length(type2->AsUnion()) : 1);
511 type2->IsUnion() ? Config::struct_length(type2->AsUnion()) : 1);
512 } 514 }
513 int bitset = type1->GlbBitset() & type2->GlbBitset(); 515 int bitset = type1->GlbBitset() & type2->GlbBitset();
514 if (IsInhabited(bitset)) ++size; 516 if (bitset != kNone) ++size;
515 ASSERT(size >= 1); 517 ASSERT(size >= 1);
516 StructHandle unioned = Config::struct_create(kUnionTag, size, region); 518 StructHandle unioned = Config::struct_create(kUnionTag, size, region);
517 519
518 size = 0; 520 size = 0;
519 if (IsInhabited(bitset)) { 521 if (bitset != kNone) {
520 Config::struct_set(unioned, size++, Config::from_bitset(bitset, region)); 522 Config::struct_set(unioned, size++, Config::from_bitset(bitset, region));
521 } 523 }
522 size = ExtendIntersection(unioned, type1, type2, size); 524 size = ExtendIntersection(unioned, type1, type2, size);
523 size = ExtendIntersection(unioned, type2, type1, size); 525 size = ExtendIntersection(unioned, type2, type1, size);
524 526
525 if (size == 0) { 527 if (size == 0) {
526 return None(region); 528 return None(region);
527 } else if (size == 1) { 529 } else if (size == 1) {
528 return Config::struct_get(unioned, 0); 530 return Config::struct_get(unioned, 0);
529 } else { 531 } else {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; 677 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>;
676 678
677 template TypeImpl<ZoneTypeConfig>::TypeHandle 679 template TypeImpl<ZoneTypeConfig>::TypeHandle
678 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( 680 TypeImpl<ZoneTypeConfig>::Convert<HeapType>(
679 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); 681 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*);
680 template TypeImpl<HeapTypeConfig>::TypeHandle 682 template TypeImpl<HeapTypeConfig>::TypeHandle
681 TypeImpl<HeapTypeConfig>::Convert<Type>( 683 TypeImpl<HeapTypeConfig>::Convert<Type>(
682 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); 684 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*);
683 685
684 } } // namespace v8::internal 686 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/types.h ('k') | test/cctest/test-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698