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

Side by Side Diff: src/type-cache.h

Issue 2289573002: [turbofan] Remove the unused asm.js types from TypeCache. (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 | « src/compiler/typer.cc ('k') | src/type-cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_TYPE_CACHE_H_
6 #define V8_TYPE_CACHE_H_
7
8 #include "src/types.h"
9
10 namespace v8 {
11 namespace internal {
12
13 class TypeCache final {
14 private:
15 // This has to be first for the initialization magic to work.
16 base::AccountingAllocator allocator;
17 Zone zone_;
18
19 public:
20 static TypeCache const& Get();
21
22 TypeCache() : zone_(&allocator) {}
23
24 Type* const kInt8 =
25 CreateNative(CreateRange<int8_t>(), Type::UntaggedIntegral8());
26 Type* const kUint8 =
27 CreateNative(CreateRange<uint8_t>(), Type::UntaggedIntegral8());
28 Type* const kUint8Clamped = kUint8;
29 Type* const kInt16 =
30 CreateNative(CreateRange<int16_t>(), Type::UntaggedIntegral16());
31 Type* const kUint16 =
32 CreateNative(CreateRange<uint16_t>(), Type::UntaggedIntegral16());
33 Type* const kInt32 =
34 CreateNative(Type::Signed32(), Type::UntaggedIntegral32());
35 Type* const kUint32 =
36 CreateNative(Type::Unsigned32(), Type::UntaggedIntegral32());
37 Type* const kFloat32 = CreateNative(Type::Number(), Type::UntaggedFloat32());
38 Type* const kFloat64 = CreateNative(Type::Number(), Type::UntaggedFloat64());
39
40 Type* const kSmi = CreateNative(Type::SignedSmall(), Type::TaggedSigned());
41 Type* const kHoleySmi = Type::Union(kSmi, Type::Hole(), zone());
42 Type* const kHeapNumber = CreateNative(Type::Number(), Type::TaggedPointer());
43
44 Type* const kSingletonZero = CreateRange(0.0, 0.0);
45 Type* const kSingletonOne = CreateRange(1.0, 1.0);
46 Type* const kSingletonTen = CreateRange(10.0, 10.0);
47 Type* const kSingletonMinusOne = CreateRange(-1.0, -1.0);
48 Type* const kZeroOrUndefined =
49 Type::Union(kSingletonZero, Type::Undefined(), zone());
50 Type* const kTenOrUndefined =
51 Type::Union(kSingletonTen, Type::Undefined(), zone());
52 Type* const kMinusOneOrZero = CreateRange(-1.0, 0.0);
53 Type* const kMinusOneToOne = CreateRange(-1.0, 1.0);
54 Type* const kZeroOrOne = CreateRange(0.0, 1.0);
55 Type* const kZeroOrOneOrNaN = Type::Union(kZeroOrOne, Type::NaN(), zone());
56 Type* const kZeroToThirtyOne = CreateRange(0.0, 31.0);
57 Type* const kZeroToThirtyTwo = CreateRange(0.0, 32.0);
58 Type* const kZeroish =
59 Type::Union(kSingletonZero, Type::MinusZeroOrNaN(), zone());
60 Type* const kInteger = CreateRange(-V8_INFINITY, V8_INFINITY);
61 Type* const kIntegerOrMinusZero =
62 Type::Union(kInteger, Type::MinusZero(), zone());
63 Type* const kIntegerOrMinusZeroOrNaN =
64 Type::Union(kIntegerOrMinusZero, Type::NaN(), zone());
65 Type* const kPositiveInteger = CreateRange(0.0, V8_INFINITY);
66 Type* const kPositiveIntegerOrMinusZero =
67 Type::Union(kPositiveInteger, Type::MinusZero(), zone());
68 Type* const kPositiveIntegerOrMinusZeroOrNaN =
69 Type::Union(kPositiveIntegerOrMinusZero, Type::NaN(), zone());
70
71 Type* const kAdditiveSafeInteger =
72 CreateRange(-4503599627370496.0, 4503599627370496.0);
73 Type* const kSafeInteger = CreateRange(-kMaxSafeInteger, kMaxSafeInteger);
74 Type* const kAdditiveSafeIntegerOrMinusZero =
75 Type::Union(kAdditiveSafeInteger, Type::MinusZero(), zone());
76 Type* const kSafeIntegerOrMinusZero =
77 Type::Union(kSafeInteger, Type::MinusZero(), zone());
78 Type* const kPositiveSafeInteger = CreateRange(0.0, kMaxSafeInteger);
79
80 Type* const kUntaggedUndefined =
81 Type::Intersect(Type::Undefined(), Type::Untagged(), zone());
82
83 // Asm.js related types.
84 Type* const kAsmSigned = kInt32;
85 Type* const kAsmUnsigned = kUint32;
86 Type* const kAsmInt = Type::Union(kAsmSigned, kAsmUnsigned, zone());
87 Type* const kAsmFixnum = Type::Intersect(kAsmSigned, kAsmUnsigned, zone());
88 Type* const kAsmFloat = kFloat32;
89 Type* const kAsmDouble = kFloat64;
90 Type* const kAsmFloatQ = Type::Union(kAsmFloat, kUntaggedUndefined, zone());
91 Type* const kAsmDoubleQ = Type::Union(kAsmDouble, kUntaggedUndefined, zone());
92 // Not part of the Asm.js type hierarchy, but represents a part of what
93 // intish encompasses.
94 Type* const kAsmIntQ = Type::Union(kAsmInt, kUntaggedUndefined, zone());
95 Type* const kAsmFloatDoubleQ = Type::Union(kAsmFloatQ, kAsmDoubleQ, zone());
96 // Asm.js size unions.
97 Type* const kAsmSize8 = Type::Union(kInt8, kUint8, zone());
98 Type* const kAsmSize16 = Type::Union(kInt16, kUint16, zone());
99 Type* const kAsmSize32 =
100 Type::Union(Type::Union(kInt32, kUint32, zone()), kAsmFloat, zone());
101 Type* const kAsmSize64 = kFloat64;
102 // Asm.js other types.
103 Type* const kAsmComparable = Type::Union(
104 kAsmSigned,
105 Type::Union(kAsmUnsigned, Type::Union(kAsmDouble, kAsmFloat, zone()),
106 zone()),
107 zone());
108 Type* const kAsmIntArrayElement =
109 Type::Union(Type::Union(kInt8, kUint8, zone()),
110 Type::Union(Type::Union(kInt16, kUint16, zone()),
111 Type::Union(kInt32, kUint32, zone()), zone()),
112 zone());
113
114 // The FixedArray::length property always containts a smi in the range
115 // [0, FixedArray::kMaxLength].
116 Type* const kFixedArrayLengthType = CreateNative(
117 CreateRange(0.0, FixedArray::kMaxLength), Type::TaggedSigned());
118
119 // The FixedDoubleArray::length property always containts a smi in the range
120 // [0, FixedDoubleArray::kMaxLength].
121 Type* const kFixedDoubleArrayLengthType = CreateNative(
122 CreateRange(0.0, FixedDoubleArray::kMaxLength), Type::TaggedSigned());
123
124 // The JSArray::length property always contains a tagged number in the range
125 // [0, kMaxUInt32].
126 Type* const kJSArrayLengthType =
127 CreateNative(Type::Unsigned32(), Type::Tagged());
128
129 // The JSTyped::length property always contains a tagged number in the range
130 // [0, kMaxSmiValue].
131 Type* const kJSTypedArrayLengthType =
132 CreateNative(Type::UnsignedSmall(), Type::TaggedSigned());
133
134 // The String::length property always contains a smi in the range
135 // [0, String::kMaxLength].
136 Type* const kStringLengthType =
137 CreateNative(CreateRange(0.0, String::kMaxLength), Type::TaggedSigned());
138
139 #define TYPED_ARRAY(TypeName, type_name, TYPE_NAME, ctype, size) \
140 Type* const k##TypeName##Array = CreateArray(k##TypeName);
141 TYPED_ARRAYS(TYPED_ARRAY)
142 #undef TYPED_ARRAY
143
144 private:
145 Type* CreateArray(Type* element) { return Type::Array(element, zone()); }
146
147 Type* CreateArrayFunction(Type* array) {
148 Type* arg1 = Type::Union(Type::Unsigned32(), Type::Object(), zone());
149 Type* arg2 = Type::Union(Type::Unsigned32(), Type::Undefined(), zone());
150 Type* arg3 = arg2;
151 return Type::Function(array, arg1, arg2, arg3, zone());
152 }
153
154 Type* CreateNative(Type* semantic, Type* representation) {
155 return Type::Intersect(semantic, representation, zone());
156 }
157
158 template <typename T>
159 Type* CreateRange() {
160 return CreateRange(std::numeric_limits<T>::min(),
161 std::numeric_limits<T>::max());
162 }
163
164 Type* CreateRange(double min, double max) {
165 return Type::Range(min, max, zone());
166 }
167
168 Zone* zone() { return &zone_; }
169 };
170
171 } // namespace internal
172 } // namespace v8
173
174 #endif // V8_TYPE_CACHE_H_
OLDNEW
« no previous file with comments | « src/compiler/typer.cc ('k') | src/type-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698