• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "src/compiler/access-builder.h"
6 
7 #include "src/compiler/type-cache.h"
8 #include "src/contexts.h"
9 #include "src/frames.h"
10 #include "src/handles-inl.h"
11 #include "src/heap/heap.h"
12 #include "src/objects-inl.h"
13 #include "src/objects/arguments.h"
14 #include "src/objects/js-collection.h"
15 #include "src/objects/js-generator.h"
16 #include "src/objects/module.h"
17 
18 namespace v8 {
19 namespace internal {
20 namespace compiler {
21 
22 // static
ForExternalTaggedValue()23 FieldAccess AccessBuilder::ForExternalTaggedValue() {
24   FieldAccess access = {kUntaggedBase,       0,
25                         MaybeHandle<Name>(), MaybeHandle<Map>(),
26                         Type::Any(),         MachineType::AnyTagged(),
27                         kNoWriteBarrier};
28   return access;
29 }
30 
31 // static
ForExternalUint8Value()32 FieldAccess AccessBuilder::ForExternalUint8Value() {
33   FieldAccess access = {kUntaggedBase,           0,
34                         MaybeHandle<Name>(),     MaybeHandle<Map>(),
35                         TypeCache::Get().kUint8, MachineType::Uint8(),
36                         kNoWriteBarrier};
37   return access;
38 }
39 
40 // static
ForMap()41 FieldAccess AccessBuilder::ForMap() {
42   FieldAccess access = {kTaggedBase,           HeapObject::kMapOffset,
43                         MaybeHandle<Name>(),   MaybeHandle<Map>(),
44                         Type::OtherInternal(), MachineType::TaggedPointer(),
45                         kMapWriteBarrier};
46   return access;
47 }
48 
49 
50 // static
ForHeapNumberValue()51 FieldAccess AccessBuilder::ForHeapNumberValue() {
52   FieldAccess access = {
53       kTaggedBase,        HeapNumber::kValueOffset,  MaybeHandle<Name>(),
54       MaybeHandle<Map>(), TypeCache::Get().kFloat64, MachineType::Float64(),
55       kNoWriteBarrier};
56   return access;
57 }
58 
59 // static
ForBigIntBitfield()60 FieldAccess AccessBuilder::ForBigIntBitfield() {
61   FieldAccess access = {
62       kTaggedBase,        BigInt::kBitfieldOffset, MaybeHandle<Name>(),
63       MaybeHandle<Map>(), TypeCache::Get().kInt32, MachineType::IntPtr(),
64       kNoWriteBarrier};
65   return access;
66 }
67 
68 // static
ForJSObjectPropertiesOrHash()69 FieldAccess AccessBuilder::ForJSObjectPropertiesOrHash() {
70   FieldAccess access = {kTaggedBase,         JSObject::kPropertiesOrHashOffset,
71                         MaybeHandle<Name>(), MaybeHandle<Map>(),
72                         Type::Any(),         MachineType::AnyTagged(),
73                         kPointerWriteBarrier};
74   return access;
75 }
76 
77 
78 // static
ForJSObjectElements()79 FieldAccess AccessBuilder::ForJSObjectElements() {
80   FieldAccess access = {kTaggedBase,         JSObject::kElementsOffset,
81                         MaybeHandle<Name>(), MaybeHandle<Map>(),
82                         Type::Internal(),    MachineType::TaggedPointer(),
83                         kPointerWriteBarrier};
84   return access;
85 }
86 
87 
88 // static
ForJSObjectInObjectProperty(const MapRef & map,int index)89 FieldAccess AccessBuilder::ForJSObjectInObjectProperty(const MapRef& map,
90                                                        int index) {
91   int const offset = map.GetInObjectPropertyOffset(index);
92   FieldAccess access = {kTaggedBase,         offset,
93                         MaybeHandle<Name>(), MaybeHandle<Map>(),
94                         Type::NonInternal(), MachineType::AnyTagged(),
95                         kFullWriteBarrier};
96   return access;
97 }
98 
99 // static
ForJSObjectOffset(int offset,WriteBarrierKind write_barrier_kind)100 FieldAccess AccessBuilder::ForJSObjectOffset(
101     int offset, WriteBarrierKind write_barrier_kind) {
102   FieldAccess access = {kTaggedBase,         offset,
103                         MaybeHandle<Name>(), MaybeHandle<Map>(),
104                         Type::NonInternal(), MachineType::AnyTagged(),
105                         write_barrier_kind};
106   return access;
107 }
108 
109 // static
ForJSCollectionTable()110 FieldAccess AccessBuilder::ForJSCollectionTable() {
111   FieldAccess access = {kTaggedBase,           JSCollection::kTableOffset,
112                         MaybeHandle<Name>(),   MaybeHandle<Map>(),
113                         Type::OtherInternal(), MachineType::TaggedPointer(),
114                         kPointerWriteBarrier};
115   return access;
116 }
117 
118 // static
ForJSCollectionIteratorTable()119 FieldAccess AccessBuilder::ForJSCollectionIteratorTable() {
120   FieldAccess access = {
121       kTaggedBase,           JSCollectionIterator::kTableOffset,
122       MaybeHandle<Name>(),   MaybeHandle<Map>(),
123       Type::OtherInternal(), MachineType::TaggedPointer(),
124       kPointerWriteBarrier};
125   return access;
126 }
127 
128 // static
ForJSCollectionIteratorIndex()129 FieldAccess AccessBuilder::ForJSCollectionIteratorIndex() {
130   FieldAccess access = {kTaggedBase,
131                         JSCollectionIterator::kIndexOffset,
132                         MaybeHandle<Name>(),
133                         MaybeHandle<Map>(),
134                         TypeCache::Get().kFixedArrayLengthType,
135                         MachineType::TaggedSigned(),
136                         kNoWriteBarrier};
137   return access;
138 }
139 
140 // static
ForJSFunctionPrototypeOrInitialMap()141 FieldAccess AccessBuilder::ForJSFunctionPrototypeOrInitialMap() {
142   FieldAccess access = {
143       kTaggedBase,         JSFunction::kPrototypeOrInitialMapOffset,
144       MaybeHandle<Name>(), MaybeHandle<Map>(),
145       Type::Any(),         MachineType::AnyTagged(),
146       kFullWriteBarrier};
147   return access;
148 }
149 
150 // static
ForJSFunctionContext()151 FieldAccess AccessBuilder::ForJSFunctionContext() {
152   FieldAccess access = {kTaggedBase,         JSFunction::kContextOffset,
153                         MaybeHandle<Name>(), MaybeHandle<Map>(),
154                         Type::Internal(),    MachineType::AnyTagged(),
155                         kPointerWriteBarrier};
156   return access;
157 }
158 
159 
160 // static
ForJSFunctionSharedFunctionInfo()161 FieldAccess AccessBuilder::ForJSFunctionSharedFunctionInfo() {
162   FieldAccess access = {
163       kTaggedBase,           JSFunction::kSharedFunctionInfoOffset,
164       Handle<Name>(),        MaybeHandle<Map>(),
165       Type::OtherInternal(), MachineType::TaggedPointer(),
166       kPointerWriteBarrier};
167   return access;
168 }
169 
170 // static
ForJSFunctionFeedbackCell()171 FieldAccess AccessBuilder::ForJSFunctionFeedbackCell() {
172   FieldAccess access = {kTaggedBase,         JSFunction::kFeedbackCellOffset,
173                         Handle<Name>(),      MaybeHandle<Map>(),
174                         Type::Internal(),    MachineType::TaggedPointer(),
175                         kPointerWriteBarrier};
176   return access;
177 }
178 
179 // static
ForJSFunctionCode()180 FieldAccess AccessBuilder::ForJSFunctionCode() {
181   FieldAccess access = {kTaggedBase,           JSFunction::kCodeOffset,
182                         Handle<Name>(),        MaybeHandle<Map>(),
183                         Type::OtherInternal(), MachineType::TaggedPointer(),
184                         kPointerWriteBarrier};
185   return access;
186 }
187 
188 // static
ForJSBoundFunctionBoundTargetFunction()189 FieldAccess AccessBuilder::ForJSBoundFunctionBoundTargetFunction() {
190   FieldAccess access = {
191       kTaggedBase,         JSBoundFunction::kBoundTargetFunctionOffset,
192       Handle<Name>(),      MaybeHandle<Map>(),
193       Type::Callable(),    MachineType::TaggedPointer(),
194       kPointerWriteBarrier};
195   return access;
196 }
197 
198 // static
ForJSBoundFunctionBoundThis()199 FieldAccess AccessBuilder::ForJSBoundFunctionBoundThis() {
200   FieldAccess access = {kTaggedBase,         JSBoundFunction::kBoundThisOffset,
201                         Handle<Name>(),      MaybeHandle<Map>(),
202                         Type::NonInternal(), MachineType::AnyTagged(),
203                         kFullWriteBarrier};
204   return access;
205 }
206 
207 // static
ForJSBoundFunctionBoundArguments()208 FieldAccess AccessBuilder::ForJSBoundFunctionBoundArguments() {
209   FieldAccess access = {
210       kTaggedBase,         JSBoundFunction::kBoundArgumentsOffset,
211       Handle<Name>(),      MaybeHandle<Map>(),
212       Type::Internal(),    MachineType::TaggedPointer(),
213       kPointerWriteBarrier};
214   return access;
215 }
216 
217 // static
ForJSGeneratorObjectContext()218 FieldAccess AccessBuilder::ForJSGeneratorObjectContext() {
219   FieldAccess access = {kTaggedBase,         JSGeneratorObject::kContextOffset,
220                         Handle<Name>(),      MaybeHandle<Map>(),
221                         Type::Internal(),    MachineType::TaggedPointer(),
222                         kPointerWriteBarrier};
223   return access;
224 }
225 
226 // static
ForJSGeneratorObjectFunction()227 FieldAccess AccessBuilder::ForJSGeneratorObjectFunction() {
228   FieldAccess access = {kTaggedBase,         JSGeneratorObject::kFunctionOffset,
229                         Handle<Name>(),      MaybeHandle<Map>(),
230                         Type::Function(),    MachineType::TaggedPointer(),
231                         kPointerWriteBarrier};
232   return access;
233 }
234 
235 // static
ForJSGeneratorObjectReceiver()236 FieldAccess AccessBuilder::ForJSGeneratorObjectReceiver() {
237   FieldAccess access = {kTaggedBase,         JSGeneratorObject::kReceiverOffset,
238                         Handle<Name>(),      MaybeHandle<Map>(),
239                         Type::Internal(),    MachineType::TaggedPointer(),
240                         kPointerWriteBarrier};
241   return access;
242 }
243 
244 // static
ForJSGeneratorObjectContinuation()245 FieldAccess AccessBuilder::ForJSGeneratorObjectContinuation() {
246   FieldAccess access = {
247       kTaggedBase,         JSGeneratorObject::kContinuationOffset,
248       Handle<Name>(),      MaybeHandle<Map>(),
249       Type::SignedSmall(), MachineType::TaggedSigned(),
250       kNoWriteBarrier};
251   return access;
252 }
253 
254 // static
ForJSGeneratorObjectInputOrDebugPos()255 FieldAccess AccessBuilder::ForJSGeneratorObjectInputOrDebugPos() {
256   FieldAccess access = {
257       kTaggedBase,         JSGeneratorObject::kInputOrDebugPosOffset,
258       Handle<Name>(),      MaybeHandle<Map>(),
259       Type::NonInternal(), MachineType::AnyTagged(),
260       kFullWriteBarrier};
261   return access;
262 }
263 
264 
265 // static
ForJSGeneratorObjectParametersAndRegisters()266 FieldAccess AccessBuilder::ForJSGeneratorObjectParametersAndRegisters() {
267   FieldAccess access = {
268       kTaggedBase,         JSGeneratorObject::kParametersAndRegistersOffset,
269       Handle<Name>(),      MaybeHandle<Map>(),
270       Type::Internal(),    MachineType::AnyTagged(),
271       kPointerWriteBarrier};
272   return access;
273 }
274 
275 // static
ForJSGeneratorObjectResumeMode()276 FieldAccess AccessBuilder::ForJSGeneratorObjectResumeMode() {
277   FieldAccess access = {
278       kTaggedBase,         JSGeneratorObject::kResumeModeOffset,
279       Handle<Name>(),      MaybeHandle<Map>(),
280       Type::SignedSmall(), MachineType::TaggedSigned(),
281       kNoWriteBarrier};
282   return access;
283 }
284 
285 // static
ForJSAsyncGeneratorObjectQueue()286 FieldAccess AccessBuilder::ForJSAsyncGeneratorObjectQueue() {
287   FieldAccess access = {
288       kTaggedBase,         JSAsyncGeneratorObject::kQueueOffset,
289       Handle<Name>(),      MaybeHandle<Map>(),
290       Type::NonInternal(), MachineType::AnyTagged(),
291       kFullWriteBarrier};
292   return access;
293 }
294 
295 // static
ForJSAsyncGeneratorObjectIsAwaiting()296 FieldAccess AccessBuilder::ForJSAsyncGeneratorObjectIsAwaiting() {
297   FieldAccess access = {
298       kTaggedBase,         JSAsyncGeneratorObject::kIsAwaitingOffset,
299       Handle<Name>(),      MaybeHandle<Map>(),
300       Type::SignedSmall(), MachineType::TaggedSigned(),
301       kNoWriteBarrier};
302   return access;
303 }
304 
305 // static
ForJSArrayLength(ElementsKind elements_kind)306 FieldAccess AccessBuilder::ForJSArrayLength(ElementsKind elements_kind) {
307   TypeCache const& type_cache = TypeCache::Get();
308   FieldAccess access = {kTaggedBase,
309                         JSArray::kLengthOffset,
310                         Handle<Name>(),
311                         MaybeHandle<Map>(),
312                         type_cache.kJSArrayLengthType,
313                         MachineType::TaggedSigned(),
314                         kFullWriteBarrier};
315   if (IsDoubleElementsKind(elements_kind)) {
316     access.type = type_cache.kFixedDoubleArrayLengthType;
317     access.write_barrier_kind = kNoWriteBarrier;
318   } else if (IsFastElementsKind(elements_kind)) {
319     access.type = type_cache.kFixedArrayLengthType;
320     access.write_barrier_kind = kNoWriteBarrier;
321   }
322   return access;
323 }
324 
325 
326 // static
ForJSArrayBufferBackingStore()327 FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() {
328   FieldAccess access = {
329       kTaggedBase,           JSArrayBuffer::kBackingStoreOffset,
330       MaybeHandle<Name>(),   MaybeHandle<Map>(),
331       Type::OtherInternal(), MachineType::Pointer(),
332       kNoWriteBarrier};
333   return access;
334 }
335 
336 // static
ForJSArrayBufferBitField()337 FieldAccess AccessBuilder::ForJSArrayBufferBitField() {
338   FieldAccess access = {
339       kTaggedBase,        JSArrayBuffer::kBitFieldOffset, MaybeHandle<Name>(),
340       MaybeHandle<Map>(), TypeCache::Get().kUint8,        MachineType::Uint32(),
341       kNoWriteBarrier};
342   return access;
343 }
344 
345 // static
ForJSArrayBufferViewBuffer()346 FieldAccess AccessBuilder::ForJSArrayBufferViewBuffer() {
347   FieldAccess access = {kTaggedBase,           JSArrayBufferView::kBufferOffset,
348                         MaybeHandle<Name>(),   MaybeHandle<Map>(),
349                         Type::OtherInternal(), MachineType::TaggedPointer(),
350                         kPointerWriteBarrier};
351   return access;
352 }
353 
354 // static
ForJSArrayBufferViewByteLength()355 FieldAccess AccessBuilder::ForJSArrayBufferViewByteLength() {
356   FieldAccess access = {kTaggedBase,
357                         JSArrayBufferView::kByteLengthOffset,
358                         MaybeHandle<Name>(),
359                         MaybeHandle<Map>(),
360                         TypeCache::Get().kPositiveInteger,
361                         MachineType::AnyTagged(),
362                         kFullWriteBarrier};
363   return access;
364 }
365 
366 // static
ForJSArrayBufferViewByteOffset()367 FieldAccess AccessBuilder::ForJSArrayBufferViewByteOffset() {
368   FieldAccess access = {kTaggedBase,
369                         JSArrayBufferView::kByteOffsetOffset,
370                         MaybeHandle<Name>(),
371                         MaybeHandle<Map>(),
372                         TypeCache::Get().kPositiveInteger,
373                         MachineType::AnyTagged(),
374                         kFullWriteBarrier};
375   return access;
376 }
377 
378 // static
ForJSTypedArrayLength()379 FieldAccess AccessBuilder::ForJSTypedArrayLength() {
380   FieldAccess access = {kTaggedBase,
381                         JSTypedArray::kLengthOffset,
382                         MaybeHandle<Name>(),
383                         MaybeHandle<Map>(),
384                         TypeCache::Get().kJSTypedArrayLengthType,
385                         MachineType::TaggedSigned(),
386                         kNoWriteBarrier};
387   return access;
388 }
389 
390 // static
ForJSDateValue()391 FieldAccess AccessBuilder::ForJSDateValue() {
392   FieldAccess access = {kTaggedBase,
393                         JSDate::kValueOffset,
394                         MaybeHandle<Name>(),
395                         MaybeHandle<Map>(),
396                         TypeCache::Get().kJSDateValueType,
397                         MachineType::AnyTagged(),
398                         kFullWriteBarrier};
399   return access;
400 }
401 
402 // static
ForJSDateField(JSDate::FieldIndex index)403 FieldAccess AccessBuilder::ForJSDateField(JSDate::FieldIndex index) {
404   FieldAccess access = {
405       kTaggedBase,         JSDate::kValueOffset + index * kPointerSize,
406       MaybeHandle<Name>(), MaybeHandle<Map>(),
407       Type::Number(),      MachineType::AnyTagged(),
408       kFullWriteBarrier};
409   return access;
410 }
411 
412 
413 // static
ForJSIteratorResultDone()414 FieldAccess AccessBuilder::ForJSIteratorResultDone() {
415   FieldAccess access = {kTaggedBase,         JSIteratorResult::kDoneOffset,
416                         MaybeHandle<Name>(), MaybeHandle<Map>(),
417                         Type::NonInternal(), MachineType::AnyTagged(),
418                         kFullWriteBarrier};
419   return access;
420 }
421 
422 
423 // static
ForJSIteratorResultValue()424 FieldAccess AccessBuilder::ForJSIteratorResultValue() {
425   FieldAccess access = {kTaggedBase,         JSIteratorResult::kValueOffset,
426                         MaybeHandle<Name>(), MaybeHandle<Map>(),
427                         Type::NonInternal(), MachineType::AnyTagged(),
428                         kFullWriteBarrier};
429   return access;
430 }
431 
432 // static
ForJSRegExpData()433 FieldAccess AccessBuilder::ForJSRegExpData() {
434   FieldAccess access = {kTaggedBase,         JSRegExp::kDataOffset,
435                         MaybeHandle<Name>(), MaybeHandle<Map>(),
436                         Type::NonInternal(), MachineType::AnyTagged(),
437                         kFullWriteBarrier};
438   return access;
439 }
440 
441 // static
ForJSRegExpFlags()442 FieldAccess AccessBuilder::ForJSRegExpFlags() {
443   FieldAccess access = {kTaggedBase,         JSRegExp::kFlagsOffset,
444                         MaybeHandle<Name>(), MaybeHandle<Map>(),
445                         Type::NonInternal(), MachineType::AnyTagged(),
446                         kFullWriteBarrier};
447   return access;
448 }
449 
450 // static
ForJSRegExpLastIndex()451 FieldAccess AccessBuilder::ForJSRegExpLastIndex() {
452   FieldAccess access = {kTaggedBase,         JSRegExp::kLastIndexOffset,
453                         MaybeHandle<Name>(), MaybeHandle<Map>(),
454                         Type::NonInternal(), MachineType::AnyTagged(),
455                         kFullWriteBarrier};
456   return access;
457 }
458 
459 // static
ForJSRegExpSource()460 FieldAccess AccessBuilder::ForJSRegExpSource() {
461   FieldAccess access = {kTaggedBase,         JSRegExp::kSourceOffset,
462                         MaybeHandle<Name>(), MaybeHandle<Map>(),
463                         Type::NonInternal(), MachineType::AnyTagged(),
464                         kFullWriteBarrier};
465   return access;
466 }
467 
468 
469 // static
ForFixedArrayLength()470 FieldAccess AccessBuilder::ForFixedArrayLength() {
471   FieldAccess access = {kTaggedBase,
472                         FixedArray::kLengthOffset,
473                         MaybeHandle<Name>(),
474                         MaybeHandle<Map>(),
475                         TypeCache::Get().kFixedArrayLengthType,
476                         MachineType::TaggedSigned(),
477                         kNoWriteBarrier};
478   return access;
479 }
480 
481 // static
ForPropertyArrayLengthAndHash()482 FieldAccess AccessBuilder::ForPropertyArrayLengthAndHash() {
483   FieldAccess access = {
484       kTaggedBase,         PropertyArray::kLengthAndHashOffset,
485       MaybeHandle<Name>(), MaybeHandle<Map>(),
486       Type::SignedSmall(), MachineType::TaggedSigned(),
487       kNoWriteBarrier};
488   return access;
489 }
490 
491 // static
ForFixedTypedArrayBaseBasePointer()492 FieldAccess AccessBuilder::ForFixedTypedArrayBaseBasePointer() {
493   FieldAccess access = {
494       kTaggedBase,           FixedTypedArrayBase::kBasePointerOffset,
495       MaybeHandle<Name>(),   MaybeHandle<Map>(),
496       Type::OtherInternal(), MachineType::AnyTagged(),
497       kPointerWriteBarrier};
498   return access;
499 }
500 
501 // static
ForFixedTypedArrayBaseExternalPointer()502 FieldAccess AccessBuilder::ForFixedTypedArrayBaseExternalPointer() {
503   FieldAccess access = {kTaggedBase,
504                         FixedTypedArrayBase::kExternalPointerOffset,
505                         MaybeHandle<Name>(),
506                         MaybeHandle<Map>(),
507                         Type::ExternalPointer(),
508                         MachineType::Pointer(),
509                         kNoWriteBarrier};
510   return access;
511 }
512 
513 // static
ForDescriptorArrayEnumCache()514 FieldAccess AccessBuilder::ForDescriptorArrayEnumCache() {
515   FieldAccess access = {
516       kTaggedBase,           DescriptorArray::kEnumCacheOffset,
517       Handle<Name>(),        MaybeHandle<Map>(),
518       Type::OtherInternal(), MachineType::TaggedPointer(),
519       kPointerWriteBarrier};
520   return access;
521 }
522 
523 // static
ForMapBitField()524 FieldAccess AccessBuilder::ForMapBitField() {
525   FieldAccess access = {
526       kTaggedBase,        Map::kBitFieldOffset,    Handle<Name>(),
527       MaybeHandle<Map>(), TypeCache::Get().kUint8, MachineType::Uint8(),
528       kNoWriteBarrier};
529   return access;
530 }
531 
532 // static
ForMapBitField2()533 FieldAccess AccessBuilder::ForMapBitField2() {
534   FieldAccess access = {
535       kTaggedBase,        Map::kBitField2Offset,   Handle<Name>(),
536       MaybeHandle<Map>(), TypeCache::Get().kUint8, MachineType::Uint8(),
537       kNoWriteBarrier};
538   return access;
539 }
540 
541 // static
ForMapBitField3()542 FieldAccess AccessBuilder::ForMapBitField3() {
543   FieldAccess access = {
544       kTaggedBase,        Map::kBitField3Offset,   Handle<Name>(),
545       MaybeHandle<Map>(), TypeCache::Get().kInt32, MachineType::Int32(),
546       kNoWriteBarrier};
547   return access;
548 }
549 
550 
551 // static
ForMapDescriptors()552 FieldAccess AccessBuilder::ForMapDescriptors() {
553   FieldAccess access = {kTaggedBase,           Map::kDescriptorsOffset,
554                         Handle<Name>(),        MaybeHandle<Map>(),
555                         Type::OtherInternal(), MachineType::TaggedPointer(),
556                         kPointerWriteBarrier};
557   return access;
558 }
559 
560 
561 // static
ForMapInstanceType()562 FieldAccess AccessBuilder::ForMapInstanceType() {
563   FieldAccess access = {
564       kTaggedBase,        Map::kInstanceTypeOffset, Handle<Name>(),
565       MaybeHandle<Map>(), TypeCache::Get().kUint16, MachineType::Uint16(),
566       kNoWriteBarrier};
567   return access;
568 }
569 
570 
571 // static
ForMapPrototype()572 FieldAccess AccessBuilder::ForMapPrototype() {
573   FieldAccess access = {kTaggedBase,         Map::kPrototypeOffset,
574                         Handle<Name>(),      MaybeHandle<Map>(),
575                         Type::Any(),         MachineType::TaggedPointer(),
576                         kPointerWriteBarrier};
577   return access;
578 }
579 
580 // static
ForModuleRegularExports()581 FieldAccess AccessBuilder::ForModuleRegularExports() {
582   FieldAccess access = {kTaggedBase,           Module::kRegularExportsOffset,
583                         Handle<Name>(),        MaybeHandle<Map>(),
584                         Type::OtherInternal(), MachineType::TaggedPointer(),
585                         kPointerWriteBarrier};
586   return access;
587 }
588 
589 // static
ForModuleRegularImports()590 FieldAccess AccessBuilder::ForModuleRegularImports() {
591   FieldAccess access = {kTaggedBase,           Module::kRegularImportsOffset,
592                         Handle<Name>(),        MaybeHandle<Map>(),
593                         Type::OtherInternal(), MachineType::TaggedPointer(),
594                         kPointerWriteBarrier};
595   return access;
596 }
597 
598 // static
ForNameHashField()599 FieldAccess AccessBuilder::ForNameHashField() {
600   FieldAccess access = {kTaggedBase,        Name::kHashFieldOffset,
601                         Handle<Name>(),     MaybeHandle<Map>(),
602                         Type::Unsigned32(), MachineType::Uint32(),
603                         kNoWriteBarrier};
604   return access;
605 }
606 
607 // static
ForStringLength()608 FieldAccess AccessBuilder::ForStringLength() {
609   FieldAccess access = {kTaggedBase,
610                         String::kLengthOffset,
611                         Handle<Name>(),
612                         MaybeHandle<Map>(),
613                         TypeCache::Get().kStringLengthType,
614                         MachineType::TaggedSigned(),
615                         kNoWriteBarrier};
616   return access;
617 }
618 
619 // static
ForConsStringFirst()620 FieldAccess AccessBuilder::ForConsStringFirst() {
621   FieldAccess access = {kTaggedBase,         ConsString::kFirstOffset,
622                         Handle<Name>(),      MaybeHandle<Map>(),
623                         Type::String(),      MachineType::TaggedPointer(),
624                         kPointerWriteBarrier};
625   return access;
626 }
627 
628 // static
ForConsStringSecond()629 FieldAccess AccessBuilder::ForConsStringSecond() {
630   FieldAccess access = {kTaggedBase,         ConsString::kSecondOffset,
631                         Handle<Name>(),      MaybeHandle<Map>(),
632                         Type::String(),      MachineType::TaggedPointer(),
633                         kPointerWriteBarrier};
634   return access;
635 }
636 
637 // static
ForThinStringActual()638 FieldAccess AccessBuilder::ForThinStringActual() {
639   FieldAccess access = {kTaggedBase,         ThinString::kActualOffset,
640                         Handle<Name>(),      MaybeHandle<Map>(),
641                         Type::String(),      MachineType::TaggedPointer(),
642                         kPointerWriteBarrier};
643   return access;
644 }
645 
646 // static
ForSlicedStringOffset()647 FieldAccess AccessBuilder::ForSlicedStringOffset() {
648   FieldAccess access = {kTaggedBase,         SlicedString::kOffsetOffset,
649                         Handle<Name>(),      MaybeHandle<Map>(),
650                         Type::SignedSmall(), MachineType::TaggedSigned(),
651                         kNoWriteBarrier};
652   return access;
653 }
654 
655 // static
ForSlicedStringParent()656 FieldAccess AccessBuilder::ForSlicedStringParent() {
657   FieldAccess access = {kTaggedBase,         SlicedString::kParentOffset,
658                         Handle<Name>(),      MaybeHandle<Map>(),
659                         Type::String(),      MachineType::TaggedPointer(),
660                         kPointerWriteBarrier};
661   return access;
662 }
663 
664 // static
ForExternalStringResourceData()665 FieldAccess AccessBuilder::ForExternalStringResourceData() {
666   FieldAccess access = {kTaggedBase,
667                         ExternalString::kResourceDataOffset,
668                         Handle<Name>(),
669                         MaybeHandle<Map>(),
670                         Type::ExternalPointer(),
671                         MachineType::Pointer(),
672                         kNoWriteBarrier};
673   return access;
674 }
675 
676 // static
ForExternalOneByteStringCharacter()677 ElementAccess AccessBuilder::ForExternalOneByteStringCharacter() {
678   ElementAccess access = {kUntaggedBase, 0, TypeCache::Get().kUint8,
679                           MachineType::Uint8(), kNoWriteBarrier};
680   return access;
681 }
682 
683 // static
ForExternalTwoByteStringCharacter()684 ElementAccess AccessBuilder::ForExternalTwoByteStringCharacter() {
685   ElementAccess access = {kUntaggedBase, 0, TypeCache::Get().kUint16,
686                           MachineType::Uint16(), kNoWriteBarrier};
687   return access;
688 }
689 
690 // static
ForSeqOneByteStringCharacter()691 ElementAccess AccessBuilder::ForSeqOneByteStringCharacter() {
692   ElementAccess access = {kTaggedBase, SeqOneByteString::kHeaderSize,
693                           TypeCache::Get().kUint8, MachineType::Uint8(),
694                           kNoWriteBarrier};
695   return access;
696 }
697 
698 // static
ForSeqTwoByteStringCharacter()699 ElementAccess AccessBuilder::ForSeqTwoByteStringCharacter() {
700   ElementAccess access = {kTaggedBase, SeqTwoByteString::kHeaderSize,
701                           TypeCache::Get().kUint16, MachineType::Uint16(),
702                           kNoWriteBarrier};
703   return access;
704 }
705 
706 // static
ForJSGlobalObjectGlobalProxy()707 FieldAccess AccessBuilder::ForJSGlobalObjectGlobalProxy() {
708   FieldAccess access = {kTaggedBase,         JSGlobalObject::kGlobalProxyOffset,
709                         Handle<Name>(),      MaybeHandle<Map>(),
710                         Type::Receiver(),    MachineType::TaggedPointer(),
711                         kPointerWriteBarrier};
712   return access;
713 }
714 
715 // static
ForJSGlobalObjectNativeContext()716 FieldAccess AccessBuilder::ForJSGlobalObjectNativeContext() {
717   FieldAccess access = {
718       kTaggedBase,         JSGlobalObject::kNativeContextOffset,
719       Handle<Name>(),      MaybeHandle<Map>(),
720       Type::Internal(),    MachineType::TaggedPointer(),
721       kPointerWriteBarrier};
722   return access;
723 }
724 
725 // static
ForJSGlobalProxyNativeContext()726 FieldAccess AccessBuilder::ForJSGlobalProxyNativeContext() {
727   FieldAccess access = {
728       kTaggedBase,         JSGlobalProxy::kNativeContextOffset,
729       Handle<Name>(),      MaybeHandle<Map>(),
730       Type::Internal(),    MachineType::TaggedPointer(),
731       kPointerWriteBarrier};
732   return access;
733 }
734 
735 // static
ForJSArrayIteratorIteratedObject()736 FieldAccess AccessBuilder::ForJSArrayIteratorIteratedObject() {
737   FieldAccess access = {
738       kTaggedBase,         JSArrayIterator::kIteratedObjectOffset,
739       Handle<Name>(),      MaybeHandle<Map>(),
740       Type::Receiver(),    MachineType::TaggedPointer(),
741       kPointerWriteBarrier};
742   return access;
743 }
744 
745 // static
ForJSArrayIteratorNextIndex()746 FieldAccess AccessBuilder::ForJSArrayIteratorNextIndex() {
747   // In generic case, cap to 2^53-1 (per ToLength() in spec) via
748   // kPositiveSafeInteger
749   FieldAccess access = {kTaggedBase,
750                         JSArrayIterator::kNextIndexOffset,
751                         Handle<Name>(),
752                         MaybeHandle<Map>(),
753                         TypeCache::Get().kPositiveSafeInteger,
754                         MachineType::AnyTagged(),
755                         kFullWriteBarrier};
756   return access;
757 }
758 
759 // static
ForJSArrayIteratorKind()760 FieldAccess AccessBuilder::ForJSArrayIteratorKind() {
761   FieldAccess access = {kTaggedBase,
762                         JSArrayIterator::kKindOffset,
763                         Handle<Name>(),
764                         MaybeHandle<Map>(),
765                         TypeCache::Get().kJSArrayIteratorKindType,
766                         MachineType::TaggedSigned(),
767                         kNoWriteBarrier};
768   return access;
769 }
770 
771 // static
ForJSStringIteratorString()772 FieldAccess AccessBuilder::ForJSStringIteratorString() {
773   FieldAccess access = {kTaggedBase,         JSStringIterator::kStringOffset,
774                         Handle<Name>(),      MaybeHandle<Map>(),
775                         Type::String(),      MachineType::TaggedPointer(),
776                         kPointerWriteBarrier};
777   return access;
778 }
779 
780 // static
ForJSStringIteratorIndex()781 FieldAccess AccessBuilder::ForJSStringIteratorIndex() {
782   FieldAccess access = {kTaggedBase,
783                         JSStringIterator::kNextIndexOffset,
784                         Handle<Name>(),
785                         MaybeHandle<Map>(),
786                         TypeCache::Get().kStringLengthType,
787                         MachineType::TaggedSigned(),
788                         kNoWriteBarrier};
789   return access;
790 }
791 
792 // static
ForValue()793 FieldAccess AccessBuilder::ForValue() {
794   FieldAccess access = {kTaggedBase,         JSValue::kValueOffset,
795                         Handle<Name>(),      MaybeHandle<Map>(),
796                         Type::NonInternal(), MachineType::AnyTagged(),
797                         kFullWriteBarrier};
798   return access;
799 }
800 
801 
802 // static
ForArgumentsLength()803 FieldAccess AccessBuilder::ForArgumentsLength() {
804   FieldAccess access = {kTaggedBase,         JSArgumentsObject::kLengthOffset,
805                         Handle<Name>(),      MaybeHandle<Map>(),
806                         Type::NonInternal(), MachineType::AnyTagged(),
807                         kFullWriteBarrier};
808   return access;
809 }
810 
811 
812 // static
ForArgumentsCallee()813 FieldAccess AccessBuilder::ForArgumentsCallee() {
814   FieldAccess access = {
815       kTaggedBase,         JSSloppyArgumentsObject::kCalleeOffset,
816       Handle<Name>(),      MaybeHandle<Map>(),
817       Type::NonInternal(), MachineType::AnyTagged(),
818       kPointerWriteBarrier};
819   return access;
820 }
821 
822 
823 // static
ForFixedArraySlot(size_t index,WriteBarrierKind write_barrier_kind)824 FieldAccess AccessBuilder::ForFixedArraySlot(
825     size_t index, WriteBarrierKind write_barrier_kind) {
826   int offset = FixedArray::OffsetOfElementAt(static_cast<int>(index));
827   FieldAccess access = {kTaggedBase,       offset,
828                         Handle<Name>(),    MaybeHandle<Map>(),
829                         Type::Any(),       MachineType::AnyTagged(),
830                         write_barrier_kind};
831   return access;
832 }
833 
834 
835 // static
ForCellValue()836 FieldAccess AccessBuilder::ForCellValue() {
837   FieldAccess access = {kTaggedBase,      Cell::kValueOffset,
838                         Handle<Name>(),   MaybeHandle<Map>(),
839                         Type::Any(),      MachineType::AnyTagged(),
840                         kFullWriteBarrier};
841   return access;
842 }
843 
844 // static
ForContextSlot(size_t index)845 FieldAccess AccessBuilder::ForContextSlot(size_t index) {
846   int offset = Context::kHeaderSize + static_cast<int>(index) * kPointerSize;
847   DCHECK_EQ(offset,
848             Context::SlotOffset(static_cast<int>(index)) + kHeapObjectTag);
849   FieldAccess access = {kTaggedBase,      offset,
850                         Handle<Name>(),   MaybeHandle<Map>(),
851                         Type::Any(),      MachineType::AnyTagged(),
852                         kFullWriteBarrier};
853   return access;
854 }
855 
856 // static
ForFixedArrayElement()857 ElementAccess AccessBuilder::ForFixedArrayElement() {
858   ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Any(),
859                           MachineType::AnyTagged(), kFullWriteBarrier};
860   return access;
861 }
862 
863 // static
ForFixedArrayElement(ElementsKind kind,LoadSensitivity load_sensitivity)864 ElementAccess AccessBuilder::ForFixedArrayElement(
865     ElementsKind kind, LoadSensitivity load_sensitivity) {
866   ElementAccess access = {kTaggedBase,       FixedArray::kHeaderSize,
867                           Type::Any(),       MachineType::AnyTagged(),
868                           kFullWriteBarrier, load_sensitivity};
869   switch (kind) {
870     case PACKED_SMI_ELEMENTS:
871       access.type = Type::SignedSmall();
872       access.machine_type = MachineType::TaggedSigned();
873       access.write_barrier_kind = kNoWriteBarrier;
874       break;
875     case HOLEY_SMI_ELEMENTS:
876       access.type = TypeCache::Get().kHoleySmi;
877       break;
878     case PACKED_ELEMENTS:
879       access.type = Type::NonInternal();
880       break;
881     case HOLEY_ELEMENTS:
882       break;
883     case PACKED_DOUBLE_ELEMENTS:
884       access.type = Type::Number();
885       access.write_barrier_kind = kNoWriteBarrier;
886       access.machine_type = MachineType::Float64();
887       break;
888     case HOLEY_DOUBLE_ELEMENTS:
889       access.type = Type::NumberOrHole();
890       access.write_barrier_kind = kNoWriteBarrier;
891       access.machine_type = MachineType::Float64();
892       break;
893     default:
894       UNREACHABLE();
895       break;
896   }
897   return access;
898 }
899 
900 // static
ForFixedDoubleArrayElement()901 ElementAccess AccessBuilder::ForFixedDoubleArrayElement() {
902   ElementAccess access = {kTaggedBase, FixedDoubleArray::kHeaderSize,
903                           TypeCache::Get().kFloat64, MachineType::Float64(),
904                           kNoWriteBarrier};
905   return access;
906 }
907 
908 // static
ForEnumCacheKeys()909 FieldAccess AccessBuilder::ForEnumCacheKeys() {
910   FieldAccess access = {kTaggedBase,           EnumCache::kKeysOffset,
911                         MaybeHandle<Name>(),   MaybeHandle<Map>(),
912                         Type::OtherInternal(), MachineType::TaggedPointer(),
913                         kPointerWriteBarrier};
914   return access;
915 }
916 
917 // static
ForEnumCacheIndices()918 FieldAccess AccessBuilder::ForEnumCacheIndices() {
919   FieldAccess access = {kTaggedBase,           EnumCache::kIndicesOffset,
920                         MaybeHandle<Name>(),   MaybeHandle<Map>(),
921                         Type::OtherInternal(), MachineType::TaggedPointer(),
922                         kPointerWriteBarrier};
923   return access;
924 }
925 
926 // static
ForTypedArrayElement(ExternalArrayType type,bool is_external,LoadSensitivity load_sensitivity)927 ElementAccess AccessBuilder::ForTypedArrayElement(
928     ExternalArrayType type, bool is_external,
929     LoadSensitivity load_sensitivity) {
930   BaseTaggedness taggedness = is_external ? kUntaggedBase : kTaggedBase;
931   int header_size = is_external ? 0 : FixedTypedArrayBase::kDataOffset;
932   switch (type) {
933     case kExternalInt8Array: {
934       ElementAccess access = {taggedness,       header_size,
935                               Type::Signed32(), MachineType::Int8(),
936                               kNoWriteBarrier,  load_sensitivity};
937       return access;
938     }
939     case kExternalUint8Array:
940     case kExternalUint8ClampedArray: {
941       ElementAccess access = {taggedness,         header_size,
942                               Type::Unsigned32(), MachineType::Uint8(),
943                               kNoWriteBarrier,    load_sensitivity};
944       return access;
945     }
946     case kExternalInt16Array: {
947       ElementAccess access = {taggedness,       header_size,
948                               Type::Signed32(), MachineType::Int16(),
949                               kNoWriteBarrier,  load_sensitivity};
950       return access;
951     }
952     case kExternalUint16Array: {
953       ElementAccess access = {taggedness,         header_size,
954                               Type::Unsigned32(), MachineType::Uint16(),
955                               kNoWriteBarrier,    load_sensitivity};
956       return access;
957     }
958     case kExternalInt32Array: {
959       ElementAccess access = {taggedness,       header_size,
960                               Type::Signed32(), MachineType::Int32(),
961                               kNoWriteBarrier,  load_sensitivity};
962       return access;
963     }
964     case kExternalUint32Array: {
965       ElementAccess access = {taggedness,         header_size,
966                               Type::Unsigned32(), MachineType::Uint32(),
967                               kNoWriteBarrier,    load_sensitivity};
968       return access;
969     }
970     case kExternalFloat32Array: {
971       ElementAccess access = {taggedness,      header_size,
972                               Type::Number(),  MachineType::Float32(),
973                               kNoWriteBarrier, load_sensitivity};
974       return access;
975     }
976     case kExternalFloat64Array: {
977       ElementAccess access = {taggedness,      header_size,
978                               Type::Number(),  MachineType::Float64(),
979                               kNoWriteBarrier, load_sensitivity};
980       return access;
981     }
982     case kExternalBigInt64Array:
983     case kExternalBigUint64Array:
984       // TODO(neis/jkummerow): Define appropriate types.
985       UNIMPLEMENTED();
986   }
987   UNREACHABLE();
988 }
989 
990 // static
ForHashTableBaseNumberOfElements()991 FieldAccess AccessBuilder::ForHashTableBaseNumberOfElements() {
992   FieldAccess access = {
993       kTaggedBase,
994       FixedArray::OffsetOfElementAt(HashTableBase::kNumberOfElementsIndex),
995       MaybeHandle<Name>(),
996       MaybeHandle<Map>(),
997       Type::SignedSmall(),
998       MachineType::TaggedSigned(),
999       kNoWriteBarrier};
1000   return access;
1001 }
1002 
1003 // static
ForHashTableBaseNumberOfDeletedElement()1004 FieldAccess AccessBuilder::ForHashTableBaseNumberOfDeletedElement() {
1005   FieldAccess access = {
1006       kTaggedBase, FixedArray::OffsetOfElementAt(
1007                        HashTableBase::kNumberOfDeletedElementsIndex),
1008       MaybeHandle<Name>(), MaybeHandle<Map>(), Type::SignedSmall(),
1009       MachineType::TaggedSigned(), kNoWriteBarrier};
1010   return access;
1011 }
1012 
1013 // static
ForHashTableBaseCapacity()1014 FieldAccess AccessBuilder::ForHashTableBaseCapacity() {
1015   FieldAccess access = {
1016       kTaggedBase,
1017       FixedArray::OffsetOfElementAt(HashTableBase::kCapacityIndex),
1018       MaybeHandle<Name>(),
1019       MaybeHandle<Map>(),
1020       Type::SignedSmall(),
1021       MachineType::TaggedSigned(),
1022       kNoWriteBarrier};
1023   return access;
1024 }
1025 
1026 // static
ForOrderedHashTableBaseNextTable()1027 FieldAccess AccessBuilder::ForOrderedHashTableBaseNextTable() {
1028   // TODO(turbofan): This will be redundant with the HashTableBase
1029   // methods above once the hash table unification is done.
1030   FieldAccess const access = {
1031       kTaggedBase,         OrderedHashTableBase::kNextTableOffset,
1032       MaybeHandle<Name>(), MaybeHandle<Map>(),
1033       Type::Any(),         MachineType::AnyTagged(),
1034       kFullWriteBarrier};
1035   return access;
1036 }
1037 
1038 // static
ForOrderedHashTableBaseNumberOfBuckets()1039 FieldAccess AccessBuilder::ForOrderedHashTableBaseNumberOfBuckets() {
1040   // TODO(turbofan): This will be redundant with the HashTableBase
1041   // methods above once the hash table unification is done.
1042   FieldAccess const access = {kTaggedBase,
1043                               OrderedHashTableBase::kNumberOfBucketsOffset,
1044                               MaybeHandle<Name>(),
1045                               MaybeHandle<Map>(),
1046                               TypeCache::Get().kFixedArrayLengthType,
1047                               MachineType::TaggedSigned(),
1048                               kNoWriteBarrier};
1049   return access;
1050 }
1051 
1052 // static
ForOrderedHashTableBaseNumberOfDeletedElements()1053 FieldAccess AccessBuilder::ForOrderedHashTableBaseNumberOfDeletedElements() {
1054   // TODO(turbofan): This will be redundant with the HashTableBase
1055   // methods above once the hash table unification is done.
1056   FieldAccess const access = {
1057       kTaggedBase,
1058       OrderedHashTableBase::kNumberOfDeletedElementsOffset,
1059       MaybeHandle<Name>(),
1060       MaybeHandle<Map>(),
1061       TypeCache::Get().kFixedArrayLengthType,
1062       MachineType::TaggedSigned(),
1063       kNoWriteBarrier};
1064   return access;
1065 }
1066 
1067 // static
ForOrderedHashTableBaseNumberOfElements()1068 FieldAccess AccessBuilder::ForOrderedHashTableBaseNumberOfElements() {
1069   // TODO(turbofan): This will be redundant with the HashTableBase
1070   // methods above once the hash table unification is done.
1071   FieldAccess const access = {kTaggedBase,
1072                               OrderedHashTableBase::kNumberOfElementsOffset,
1073                               MaybeHandle<Name>(),
1074                               MaybeHandle<Map>(),
1075                               TypeCache::Get().kFixedArrayLengthType,
1076                               MachineType::TaggedSigned(),
1077                               kNoWriteBarrier};
1078   return access;
1079 }
1080 
1081 // static
ForOrderedHashMapEntryValue()1082 ElementAccess AccessBuilder::ForOrderedHashMapEntryValue() {
1083   ElementAccess const access = {kTaggedBase,
1084                                 OrderedHashMap::kHashTableStartOffset +
1085                                     OrderedHashMap::kValueOffset * kPointerSize,
1086                                 Type::Any(), MachineType::AnyTagged(),
1087                                 kFullWriteBarrier};
1088   return access;
1089 }
1090 
1091 // static
ForDictionaryMaxNumberKey()1092 FieldAccess AccessBuilder::ForDictionaryMaxNumberKey() {
1093   FieldAccess access = {
1094       kTaggedBase,
1095       FixedArray::OffsetOfElementAt(NumberDictionary::kMaxNumberKeyIndex),
1096       MaybeHandle<Name>(),
1097       MaybeHandle<Map>(),
1098       Type::Any(),
1099       MachineType::AnyTagged(),
1100       kNoWriteBarrier};
1101   return access;
1102 }
1103 
1104 // static
ForDictionaryNextEnumerationIndex()1105 FieldAccess AccessBuilder::ForDictionaryNextEnumerationIndex() {
1106   FieldAccess access = {
1107       kTaggedBase,
1108       FixedArray::OffsetOfElementAt(NameDictionary::kNextEnumerationIndexIndex),
1109       MaybeHandle<Name>(),
1110       MaybeHandle<Map>(),
1111       Type::SignedSmall(),
1112       MachineType::TaggedSigned(),
1113       kNoWriteBarrier};
1114   return access;
1115 }
1116 
1117 // static
ForDictionaryObjectHashIndex()1118 FieldAccess AccessBuilder::ForDictionaryObjectHashIndex() {
1119   FieldAccess access = {
1120       kTaggedBase,
1121       FixedArray::OffsetOfElementAt(NameDictionary::kObjectHashIndex),
1122       MaybeHandle<Name>(),
1123       MaybeHandle<Map>(),
1124       Type::SignedSmall(),
1125       MachineType::TaggedSigned(),
1126       kNoWriteBarrier};
1127   return access;
1128 }
1129 
1130 }  // namespace compiler
1131 }  // namespace internal
1132 }  // namespace v8
1133