OLD | NEW |
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/compiler/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
6 #include "src/types-inl.h" | 6 #include "src/types-inl.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace compiler { | 10 namespace compiler { |
11 | 11 |
12 // static | 12 // static |
13 FieldAccess AccessBuilder::ForMap() { | 13 FieldAccess AccessBuilder::ForMap() { |
14 return {kTaggedBase, HeapObject::kMapOffset, MaybeHandle<Name>(), Type::Any(), | 14 FieldAccess access = {kTaggedBase, HeapObject::kMapOffset, |
15 kMachAnyTagged}; | 15 MaybeHandle<Name>(), Type::Any(), kMachAnyTagged}; |
| 16 return access; |
16 } | 17 } |
17 | 18 |
18 | 19 |
19 // static | 20 // static |
20 FieldAccess AccessBuilder::ForJSObjectProperties() { | 21 FieldAccess AccessBuilder::ForJSObjectProperties() { |
21 return {kTaggedBase, JSObject::kPropertiesOffset, MaybeHandle<Name>(), | 22 FieldAccess access = {kTaggedBase, JSObject::kPropertiesOffset, |
22 Type::Any(), kMachAnyTagged}; | 23 MaybeHandle<Name>(), Type::Any(), kMachAnyTagged}; |
| 24 return access; |
23 } | 25 } |
24 | 26 |
25 | 27 |
26 // static | 28 // static |
27 FieldAccess AccessBuilder::ForJSObjectElements() { | 29 FieldAccess AccessBuilder::ForJSObjectElements() { |
28 return {kTaggedBase, JSObject::kElementsOffset, MaybeHandle<Name>(), | 30 FieldAccess access = {kTaggedBase, JSObject::kElementsOffset, |
29 Type::Internal(), kMachAnyTagged}; | 31 MaybeHandle<Name>(), Type::Internal(), kMachAnyTagged}; |
| 32 return access; |
30 } | 33 } |
31 | 34 |
32 | 35 |
33 // static | 36 // static |
34 FieldAccess AccessBuilder::ForJSFunctionContext() { | 37 FieldAccess AccessBuilder::ForJSFunctionContext() { |
35 return {kTaggedBase, JSFunction::kContextOffset, MaybeHandle<Name>(), | 38 FieldAccess access = {kTaggedBase, JSFunction::kContextOffset, |
36 Type::Internal(), kMachAnyTagged}; | 39 MaybeHandle<Name>(), Type::Internal(), kMachAnyTagged}; |
| 40 return access; |
37 } | 41 } |
38 | 42 |
39 | 43 |
40 // static | 44 // static |
41 FieldAccess AccessBuilder::ForJSFunctionSharedFunctionInfo() { | 45 FieldAccess AccessBuilder::ForJSFunctionSharedFunctionInfo() { |
42 return {kTaggedBase, JSFunction::kSharedFunctionInfoOffset, Handle<Name>(), | 46 FieldAccess access = {kTaggedBase, JSFunction::kSharedFunctionInfoOffset, |
43 Type::Any(), kMachAnyTagged}; | 47 Handle<Name>(), Type::Any(), kMachAnyTagged}; |
| 48 return access; |
44 } | 49 } |
45 | 50 |
46 | 51 |
47 // static | 52 // static |
48 FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() { | 53 FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() { |
49 return {kTaggedBase, JSArrayBuffer::kBackingStoreOffset, MaybeHandle<Name>(), | 54 FieldAccess access = {kTaggedBase, JSArrayBuffer::kBackingStoreOffset, |
50 Type::UntaggedPointer(), kMachPtr}; | 55 MaybeHandle<Name>(), Type::UntaggedPointer(), kMachPtr}; |
| 56 return access; |
51 } | 57 } |
52 | 58 |
53 | 59 |
54 // static | 60 // static |
55 FieldAccess AccessBuilder::ForJSDateField(JSDate::FieldIndex index) { | 61 FieldAccess AccessBuilder::ForJSDateField(JSDate::FieldIndex index) { |
56 return {kTaggedBase, JSDate::kValueOffset + index * kPointerSize, | 62 FieldAccess access = {kTaggedBase, |
57 MaybeHandle<Name>(), Type::Number(), kMachAnyTagged}; | 63 JSDate::kValueOffset + index * kPointerSize, |
| 64 MaybeHandle<Name>(), Type::Number(), kMachAnyTagged}; |
| 65 return access; |
58 } | 66 } |
59 | 67 |
60 | 68 |
61 // static | 69 // static |
62 FieldAccess AccessBuilder::ForFixedArrayLength() { | 70 FieldAccess AccessBuilder::ForFixedArrayLength() { |
63 // TODO(turbofan): 2^30 is a valid upper limit for the FixedArray::length | 71 // TODO(turbofan): 2^30 is a valid upper limit for the FixedArray::length |
64 // field, although it's not the best. If we had a Zone we could create an | 72 // field, although it's not the best. If we had a Zone we could create an |
65 // appropriate range type instead. | 73 // appropriate range type instead. |
66 STATIC_ASSERT(FixedArray::kMaxLength <= 1 << 30); | 74 STATIC_ASSERT(FixedArray::kMaxLength <= 1 << 30); |
67 return {kTaggedBase, FixedArray::kLengthOffset, MaybeHandle<Name>(), | 75 FieldAccess access = { |
68 Type::Intersect(Type::Unsigned30(), Type::TaggedSigned()), | 76 kTaggedBase, FixedArray::kLengthOffset, MaybeHandle<Name>(), |
69 kMachAnyTagged}; | 77 Type::Intersect(Type::Unsigned30(), Type::TaggedSigned()), |
| 78 kMachAnyTagged}; |
| 79 return access; |
70 } | 80 } |
71 | 81 |
72 | 82 |
73 // static | 83 // static |
74 FieldAccess AccessBuilder::ForExternalArrayPointer() { | 84 FieldAccess AccessBuilder::ForExternalArrayPointer() { |
75 return {kTaggedBase, ExternalArray::kExternalPointerOffset, | 85 FieldAccess access = {kTaggedBase, ExternalArray::kExternalPointerOffset, |
76 MaybeHandle<Name>(), Type::UntaggedPointer(), kMachPtr}; | 86 MaybeHandle<Name>(), Type::UntaggedPointer(), kMachPtr}; |
| 87 return access; |
77 } | 88 } |
78 | 89 |
79 | 90 |
80 // static | 91 // static |
81 FieldAccess AccessBuilder::ForDescriptorArrayEnumCache() { | 92 FieldAccess AccessBuilder::ForDescriptorArrayEnumCache() { |
82 return {kTaggedBase, DescriptorArray::kEnumCacheOffset, Handle<Name>(), | 93 FieldAccess access = {kTaggedBase, DescriptorArray::kEnumCacheOffset, |
83 Type::TaggedPointer(), kMachAnyTagged}; | 94 Handle<Name>(), Type::TaggedPointer(), kMachAnyTagged}; |
| 95 return access; |
84 } | 96 } |
85 | 97 |
86 | 98 |
87 // static | 99 // static |
88 FieldAccess AccessBuilder::ForDescriptorArrayEnumCacheBridgeCache() { | 100 FieldAccess AccessBuilder::ForDescriptorArrayEnumCacheBridgeCache() { |
89 return {kTaggedBase, DescriptorArray::kEnumCacheBridgeCacheOffset, | 101 FieldAccess access = {kTaggedBase, |
90 Handle<Name>(), Type::TaggedPointer(), kMachAnyTagged}; | 102 DescriptorArray::kEnumCacheBridgeCacheOffset, |
| 103 Handle<Name>(), Type::TaggedPointer(), kMachAnyTagged}; |
| 104 return access; |
91 } | 105 } |
92 | 106 |
93 | 107 |
94 // static | 108 // static |
95 FieldAccess AccessBuilder::ForMapBitField3() { | 109 FieldAccess AccessBuilder::ForMapBitField3() { |
96 return {kTaggedBase, Map::kBitField3Offset, Handle<Name>(), | 110 FieldAccess access = {kTaggedBase, Map::kBitField3Offset, Handle<Name>(), |
97 Type::UntaggedUnsigned32(), kMachUint32}; | 111 Type::UntaggedUnsigned32(), kMachUint32}; |
| 112 return access; |
98 } | 113 } |
99 | 114 |
100 | 115 |
101 // static | 116 // static |
102 FieldAccess AccessBuilder::ForMapDescriptors() { | 117 FieldAccess AccessBuilder::ForMapDescriptors() { |
103 return {kTaggedBase, Map::kDescriptorsOffset, Handle<Name>(), | 118 FieldAccess access = {kTaggedBase, Map::kDescriptorsOffset, Handle<Name>(), |
104 Type::TaggedPointer(), kMachAnyTagged}; | 119 Type::TaggedPointer(), kMachAnyTagged}; |
| 120 return access; |
105 } | 121 } |
106 | 122 |
107 | 123 |
108 // static | 124 // static |
109 FieldAccess AccessBuilder::ForMapInstanceType() { | 125 FieldAccess AccessBuilder::ForMapInstanceType() { |
110 return {kTaggedBase, Map::kInstanceTypeOffset, Handle<Name>(), | 126 FieldAccess access = {kTaggedBase, Map::kInstanceTypeOffset, Handle<Name>(), |
111 Type::UntaggedUnsigned8(), kMachUint8}; | 127 Type::UntaggedUnsigned8(), kMachUint8}; |
| 128 return access; |
112 } | 129 } |
113 | 130 |
114 | 131 |
115 // static | 132 // static |
116 FieldAccess AccessBuilder::ForStringLength(Zone* zone) { | 133 FieldAccess AccessBuilder::ForStringLength(Zone* zone) { |
117 return {kTaggedBase, String::kLengthOffset, Handle<Name>(), | 134 FieldAccess access = { |
118 Type::Intersect(Type::Range(0, String::kMaxLength, zone), | 135 kTaggedBase, String::kLengthOffset, Handle<Name>(), |
119 Type::TaggedSigned(), zone), | 136 Type::Intersect(Type::Range(0, String::kMaxLength, zone), |
120 kMachAnyTagged}; | 137 Type::TaggedSigned(), zone), |
| 138 kMachAnyTagged}; |
| 139 return access; |
121 } | 140 } |
122 | 141 |
123 | 142 |
124 // static | 143 // static |
125 FieldAccess AccessBuilder::ForValue() { | 144 FieldAccess AccessBuilder::ForValue() { |
126 return {kTaggedBase, JSValue::kValueOffset, Handle<Name>(), Type::Any(), | 145 FieldAccess access = {kTaggedBase, JSValue::kValueOffset, Handle<Name>(), |
127 kMachAnyTagged}; | 146 Type::Any(), kMachAnyTagged}; |
| 147 return access; |
128 } | 148 } |
129 | 149 |
130 | 150 |
131 // static | 151 // static |
132 FieldAccess AccessBuilder::ForContextSlot(size_t index) { | 152 FieldAccess AccessBuilder::ForContextSlot(size_t index) { |
133 int offset = Context::kHeaderSize + static_cast<int>(index) * kPointerSize; | 153 int offset = Context::kHeaderSize + static_cast<int>(index) * kPointerSize; |
134 DCHECK_EQ(offset, | 154 DCHECK_EQ(offset, |
135 Context::SlotOffset(static_cast<int>(index)) + kHeapObjectTag); | 155 Context::SlotOffset(static_cast<int>(index)) + kHeapObjectTag); |
136 return {kTaggedBase, offset, Handle<Name>(), Type::Any(), kMachAnyTagged}; | 156 FieldAccess access = {kTaggedBase, offset, Handle<Name>(), Type::Any(), |
| 157 kMachAnyTagged}; |
| 158 return access; |
137 } | 159 } |
138 | 160 |
139 | 161 |
140 // static | 162 // static |
141 FieldAccess AccessBuilder::ForPropertyCellValue() { | 163 FieldAccess AccessBuilder::ForPropertyCellValue() { |
142 return {kTaggedBase, PropertyCell::kValueOffset, Handle<Name>(), Type::Any(), | 164 FieldAccess access = {kTaggedBase, PropertyCell::kValueOffset, Handle<Name>(), |
143 kMachAnyTagged}; | 165 Type::Any(), kMachAnyTagged}; |
| 166 return access; |
144 } | 167 } |
145 | 168 |
146 | 169 |
147 // static | 170 // static |
148 FieldAccess AccessBuilder::ForSharedFunctionInfoTypeFeedbackVector() { | 171 FieldAccess AccessBuilder::ForSharedFunctionInfoTypeFeedbackVector() { |
149 return {kTaggedBase, SharedFunctionInfo::kFeedbackVectorOffset, | 172 FieldAccess access = {kTaggedBase, SharedFunctionInfo::kFeedbackVectorOffset, |
150 Handle<Name>(), Type::Any(), kMachAnyTagged}; | 173 Handle<Name>(), Type::Any(), kMachAnyTagged}; |
| 174 return access; |
151 } | 175 } |
152 | 176 |
153 | 177 |
154 // static | 178 // static |
155 ElementAccess AccessBuilder::ForFixedArrayElement() { | 179 ElementAccess AccessBuilder::ForFixedArrayElement() { |
156 return {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), kMachAnyTagged}; | 180 ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), |
| 181 kMachAnyTagged}; |
| 182 return access; |
157 } | 183 } |
158 | 184 |
159 | 185 |
160 // static | 186 // static |
161 ElementAccess AccessBuilder::ForTypedArrayElement(ExternalArrayType type, | 187 ElementAccess AccessBuilder::ForTypedArrayElement(ExternalArrayType type, |
162 bool is_external) { | 188 bool is_external) { |
163 BaseTaggedness taggedness = is_external ? kUntaggedBase : kTaggedBase; | 189 BaseTaggedness taggedness = is_external ? kUntaggedBase : kTaggedBase; |
164 int header_size = is_external ? 0 : FixedTypedArrayBase::kDataOffset; | 190 int header_size = is_external ? 0 : FixedTypedArrayBase::kDataOffset; |
165 switch (type) { | 191 switch (type) { |
166 case kExternalInt8Array: | 192 case kExternalInt8Array: { |
167 return {taggedness, header_size, Type::Signed32(), kMachInt8}; | 193 ElementAccess access = {taggedness, header_size, Type::Signed32(), |
| 194 kMachInt8}; |
| 195 return access; |
| 196 } |
168 case kExternalUint8Array: | 197 case kExternalUint8Array: |
169 case kExternalUint8ClampedArray: | 198 case kExternalUint8ClampedArray: { |
170 return {taggedness, header_size, Type::Unsigned32(), kMachUint8}; | 199 ElementAccess access = {taggedness, header_size, Type::Unsigned32(), |
171 case kExternalInt16Array: | 200 kMachUint8}; |
172 return {taggedness, header_size, Type::Signed32(), kMachInt16}; | 201 return access; |
173 case kExternalUint16Array: | 202 } |
174 return {taggedness, header_size, Type::Unsigned32(), kMachUint16}; | 203 case kExternalInt16Array: { |
175 case kExternalInt32Array: | 204 ElementAccess access = {taggedness, header_size, Type::Signed32(), |
176 return {taggedness, header_size, Type::Signed32(), kMachInt32}; | 205 kMachInt16}; |
177 case kExternalUint32Array: | 206 return access; |
178 return {taggedness, header_size, Type::Unsigned32(), kMachUint32}; | 207 } |
179 case kExternalFloat32Array: | 208 case kExternalUint16Array: { |
180 return {taggedness, header_size, Type::Number(), kMachFloat32}; | 209 ElementAccess access = {taggedness, header_size, Type::Unsigned32(), |
181 case kExternalFloat64Array: | 210 kMachUint16}; |
182 return {taggedness, header_size, Type::Number(), kMachFloat64}; | 211 return access; |
| 212 } |
| 213 case kExternalInt32Array: { |
| 214 ElementAccess access = {taggedness, header_size, Type::Signed32(), |
| 215 kMachInt32}; |
| 216 return access; |
| 217 } |
| 218 case kExternalUint32Array: { |
| 219 ElementAccess access = {taggedness, header_size, Type::Unsigned32(), |
| 220 kMachUint32}; |
| 221 return access; |
| 222 } |
| 223 case kExternalFloat32Array: { |
| 224 ElementAccess access = {taggedness, header_size, Type::Number(), |
| 225 kMachFloat32}; |
| 226 return access; |
| 227 } |
| 228 case kExternalFloat64Array: { |
| 229 ElementAccess access = {taggedness, header_size, Type::Number(), |
| 230 kMachFloat64}; |
| 231 return access; |
| 232 } |
183 } | 233 } |
184 UNREACHABLE(); | 234 UNREACHABLE(); |
185 return {kUntaggedBase, 0, Type::None(), kMachNone}; | 235 ElementAccess access = {kUntaggedBase, 0, Type::None(), kMachNone}; |
| 236 return access; |
186 } | 237 } |
187 | 238 |
188 | 239 |
189 // static | 240 // static |
190 ElementAccess AccessBuilder::ForSeqStringChar(String::Encoding encoding) { | 241 ElementAccess AccessBuilder::ForSeqStringChar(String::Encoding encoding) { |
191 switch (encoding) { | 242 switch (encoding) { |
192 case String::ONE_BYTE_ENCODING: | 243 case String::ONE_BYTE_ENCODING: { |
193 return {kTaggedBase, SeqString::kHeaderSize, Type::Unsigned32(), | 244 ElementAccess access = {kTaggedBase, SeqString::kHeaderSize, |
194 kMachUint8}; | 245 Type::Unsigned32(), kMachUint8}; |
195 case String::TWO_BYTE_ENCODING: | 246 return access; |
196 return {kTaggedBase, SeqString::kHeaderSize, Type::Unsigned32(), | 247 } |
197 kMachUint16}; | 248 case String::TWO_BYTE_ENCODING: { |
| 249 ElementAccess access = {kTaggedBase, SeqString::kHeaderSize, |
| 250 Type::Unsigned32(), kMachUint16}; |
| 251 return access; |
| 252 } |
198 } | 253 } |
199 UNREACHABLE(); | 254 UNREACHABLE(); |
200 return {kUntaggedBase, 0, Type::None(), kMachNone}; | 255 ElementAccess access = {kUntaggedBase, 0, Type::None(), kMachNone}; |
| 256 return access; |
201 } | 257 } |
202 | 258 |
203 | 259 |
204 // static | 260 // static |
205 FieldAccess AccessBuilder::ForStatsCounter() { | 261 FieldAccess AccessBuilder::ForStatsCounter() { |
206 return {kUntaggedBase, 0, MaybeHandle<Name>(), Type::Signed32(), kMachInt32}; | 262 FieldAccess access = {kUntaggedBase, 0, MaybeHandle<Name>(), Type::Signed32(), |
| 263 kMachInt32}; |
| 264 return access; |
207 } | 265 } |
208 | 266 |
209 | 267 |
210 // static | 268 // static |
211 FieldAccess AccessBuilder::ForFrameCallerFramePtr() { | 269 FieldAccess AccessBuilder::ForFrameCallerFramePtr() { |
212 return {kUntaggedBase, StandardFrameConstants::kCallerFPOffset, | 270 FieldAccess access = {kUntaggedBase, StandardFrameConstants::kCallerFPOffset, |
213 MaybeHandle<Name>(), Type::Internal(), kMachPtr}; | 271 MaybeHandle<Name>(), Type::Internal(), kMachPtr}; |
| 272 return access; |
214 } | 273 } |
215 | 274 |
216 | 275 |
217 // static | 276 // static |
218 FieldAccess AccessBuilder::ForFrameMarker() { | 277 FieldAccess AccessBuilder::ForFrameMarker() { |
219 return {kUntaggedBase, StandardFrameConstants::kMarkerOffset, | 278 FieldAccess access = {kUntaggedBase, StandardFrameConstants::kMarkerOffset, |
220 MaybeHandle<Name>(), Type::Tagged(), kMachAnyTagged}; | 279 MaybeHandle<Name>(), Type::Tagged(), kMachAnyTagged}; |
| 280 return access; |
221 } | 281 } |
222 | 282 |
223 } // namespace compiler | 283 } // namespace compiler |
224 } // namespace internal | 284 } // namespace internal |
225 } // namespace v8 | 285 } // namespace v8 |
OLD | NEW |