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

Side by Side Diff: src/compiler/types.cc

Issue 2390823011: [turbofan] HeapConstant types should compare by handle address (Closed)
Patch Set: HeapConstantType holds a HeapObject. Created 4 years, 2 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
« no previous file with comments | « src/compiler/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 <iomanip> 5 #include <iomanip>
6 6
7 #include "src/compiler/types.h" 7 #include "src/compiler/types.h"
8 8
9 #include "src/handles-inl.h" 9 #include "src/handles-inl.h"
10 #include "src/ostreams.h" 10 #include "src/ostreams.h"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 !i::IsMinusZero(value); 395 !i::IsMinusZero(value);
396 } 396 }
397 397
398 // static 398 // static
399 bool OtherNumberConstantType::IsOtherNumberConstant(Object* value) { 399 bool OtherNumberConstantType::IsOtherNumberConstant(Object* value) {
400 return value->IsHeapNumber() && 400 return value->IsHeapNumber() &&
401 IsOtherNumberConstant(HeapNumber::cast(value)->value()); 401 IsOtherNumberConstant(HeapNumber::cast(value)->value());
402 } 402 }
403 403
404 HeapConstantType::HeapConstantType(BitsetType::bitset bitset, 404 HeapConstantType::HeapConstantType(BitsetType::bitset bitset,
405 i::Handle<i::Object> object) 405 i::Handle<i::HeapObject> object)
406 : TypeBase(kHeapConstant), bitset_(bitset), object_(object) { 406 : TypeBase(kHeapConstant), bitset_(bitset), object_(object) {
407 // All number types should be expressed as Ranges, OtherNumberConstants, 407 DCHECK(!object->IsHeapNumber());
408 // or bitsets (nan, negative-zero).
409 DCHECK(!object->IsSmi() && !object->IsHeapNumber());
410 } 408 }
411 409
412 // ----------------------------------------------------------------------------- 410 // -----------------------------------------------------------------------------
413 // Predicates. 411 // Predicates.
414 412
415 bool Type::SimplyEquals(Type* that) { 413 bool Type::SimplyEquals(Type* that) {
416 DisallowHeapAllocation no_allocation; 414 DisallowHeapAllocation no_allocation;
417 if (this->IsHeapConstant()) { 415 if (this->IsHeapConstant()) {
418 return that->IsHeapConstant() && 416 return that->IsHeapConstant() &&
419 *this->AsHeapConstant()->Value() == *that->AsHeapConstant()->Value(); 417 this->AsHeapConstant()->Value().address() ==
418 that->AsHeapConstant()->Value().address();
420 } 419 }
421 if (this->IsOtherNumberConstant()) { 420 if (this->IsOtherNumberConstant()) {
422 return that->IsOtherNumberConstant() && 421 return that->IsOtherNumberConstant() &&
423 this->AsOtherNumberConstant()->Value() == 422 this->AsOtherNumberConstant()->Value() ==
424 that->AsOtherNumberConstant()->Value(); 423 that->AsOtherNumberConstant()->Value();
425 } 424 }
426 if (this->IsRange()) { 425 if (this->IsRange()) {
427 if (that->IsHeapConstant() || that->IsOtherNumberConstant()) return false; 426 if (that->IsHeapConstant() || that->IsOtherNumberConstant()) return false;
428 } 427 }
429 if (this->IsTuple()) { 428 if (this->IsTuple()) {
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 return OtherNumberConstant(value, zone); 774 return OtherNumberConstant(value, zone);
776 } 775 }
777 776
778 Type* Type::NewConstant(i::Handle<i::Object> value, Zone* zone) { 777 Type* Type::NewConstant(i::Handle<i::Object> value, Zone* zone) {
779 if (IsInteger(*value)) { 778 if (IsInteger(*value)) {
780 double v = value->Number(); 779 double v = value->Number();
781 return Range(v, v, zone); 780 return Range(v, v, zone);
782 } else if (value->IsHeapNumber()) { 781 } else if (value->IsHeapNumber()) {
783 return NewConstant(value->Number(), zone); 782 return NewConstant(value->Number(), zone);
784 } 783 }
785 return HeapConstant(value, zone); 784 return HeapConstant(i::Handle<i::HeapObject>::cast(value), zone);
786 } 785 }
787 786
788 Type* Type::Union(Type* type1, Type* type2, Zone* zone) { 787 Type* Type::Union(Type* type1, Type* type2, Zone* zone) {
789 // Fast case: bit sets. 788 // Fast case: bit sets.
790 if (type1->IsBitset() && type2->IsBitset()) { 789 if (type1->IsBitset() && type2->IsBitset()) {
791 return BitsetType::New(type1->AsBitset() | type2->AsBitset()); 790 return BitsetType::New(type1->AsBitset() | type2->AsBitset());
792 } 791 }
793 792
794 // Fast case: top or bottom types. 793 // Fast case: top or bottom types.
795 if (type1->IsAny() || type2->IsNone()) return type1; 794 if (type1->IsAny() || type2->IsNone()) return type1;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32; 993 return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32;
995 } 994 }
996 995
997 BitsetType::bitset BitsetType::UnsignedSmall() { 996 BitsetType::bitset BitsetType::UnsignedSmall() {
998 return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31; 997 return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31;
999 } 998 }
1000 999
1001 } // namespace compiler 1000 } // namespace compiler
1002 } // namespace internal 1001 } // namespace internal
1003 } // namespace v8 1002 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/types.h ('k') | test/cctest/test-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698