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

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

Issue 2326493002: [turbofan] Remove dead Bounds class from type system. (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | no next file » | 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 #ifndef V8_COMPILER_TYPES_H_ 5 #ifndef V8_COMPILER_TYPES_H_
6 #define V8_COMPILER_TYPES_H_ 6 #define V8_COMPILER_TYPES_H_
7 7
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/handles.h" 9 #include "src/handles.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 714
715 bool SimplyEquals(Type* that); 715 bool SimplyEquals(Type* that);
716 716
717 static int AddToUnion(Type* type, UnionType* result, int size, Zone* zone); 717 static int AddToUnion(Type* type, UnionType* result, int size, Zone* zone);
718 static int IntersectAux(Type* type, Type* other, UnionType* result, int size, 718 static int IntersectAux(Type* type, Type* other, UnionType* result, int size,
719 RangeType::Limits* limits, Zone* zone); 719 RangeType::Limits* limits, Zone* zone);
720 static Type* NormalizeUnion(Type* unioned, int size, Zone* zone); 720 static Type* NormalizeUnion(Type* unioned, int size, Zone* zone);
721 static Type* NormalizeRangeAndBitset(Type* range, bitset* bits, Zone* zone); 721 static Type* NormalizeRangeAndBitset(Type* range, bitset* bits, Zone* zone);
722 }; 722 };
723 723
724 // -----------------------------------------------------------------------------
725 // Type bounds. A simple struct to represent a pair of lower/upper types.
726
727 struct Bounds {
728 Type* lower;
729 Type* upper;
730
731 Bounds()
732 : // Make sure accessing uninitialized bounds crashes big-time.
733 lower(nullptr),
734 upper(nullptr) {}
735 explicit Bounds(Type* t) : lower(t), upper(t) {}
736 Bounds(Type* l, Type* u) : lower(l), upper(u) { DCHECK(lower->Is(upper)); }
737
738 // Unrestricted bounds.
739 static Bounds Unbounded() { return Bounds(Type::None(), Type::Any()); }
740
741 // Meet: both b1 and b2 are known to hold.
742 static Bounds Both(Bounds b1, Bounds b2, Zone* zone) {
743 Type* lower = Type::Union(b1.lower, b2.lower, zone);
744 Type* upper = Type::Intersect(b1.upper, b2.upper, zone);
745 // Lower bounds are considered approximate, correct as necessary.
746 if (!lower->Is(upper)) lower = upper;
747 return Bounds(lower, upper);
748 }
749
750 // Join: either b1 or b2 is known to hold.
751 static Bounds Either(Bounds b1, Bounds b2, Zone* zone) {
752 Type* lower = Type::Intersect(b1.lower, b2.lower, zone);
753 Type* upper = Type::Union(b1.upper, b2.upper, zone);
754 return Bounds(lower, upper);
755 }
756
757 static Bounds NarrowLower(Bounds b, Type* t, Zone* zone) {
758 Type* lower = Type::Union(b.lower, t, zone);
759 // Lower bounds are considered approximate, correct as necessary.
760 if (!lower->Is(b.upper)) lower = b.upper;
761 return Bounds(lower, b.upper);
762 }
763 static Bounds NarrowUpper(Bounds b, Type* t, Zone* zone) {
764 Type* lower = b.lower;
765 Type* upper = Type::Intersect(b.upper, t, zone);
766 // Lower bounds are considered approximate, correct as necessary.
767 if (!lower->Is(upper)) lower = upper;
768 return Bounds(lower, upper);
769 }
770
771 bool Narrows(Bounds that) {
772 return that.lower->Is(this->lower) && this->upper->Is(that.upper);
773 }
774 };
775 } // namespace compiler 724 } // namespace compiler
776 } // namespace internal 725 } // namespace internal
777 } // namespace v8 726 } // namespace v8
778 727
779 #endif // V8_COMPILER_TYPES_H_ 728 #endif // V8_COMPILER_TYPES_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698