• 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 
14 namespace v8 {
15 namespace internal {
16 namespace compiler {
17 
18 // static
ForExternalDoubleValue()19 FieldAccess AccessBuilder::ForExternalDoubleValue() {
20   FieldAccess access = {kUntaggedBase,       0,
21                         MaybeHandle<Name>(), MaybeHandle<Map>(),
22                         Type::Number(),      MachineType::Float64(),
23                         kNoWriteBarrier};
24   return access;
25 }
26 
27 // static
ForExternalTaggedValue()28 FieldAccess AccessBuilder::ForExternalTaggedValue() {
29   FieldAccess access = {kUntaggedBase,       0,
30                         MaybeHandle<Name>(), MaybeHandle<Map>(),
31                         Type::Any(),         MachineType::AnyTagged(),
32                         kNoWriteBarrier};
33   return access;
34 }
35 
36 // static
ForExternalUint8Value()37 FieldAccess AccessBuilder::ForExternalUint8Value() {
38   FieldAccess access = {kUntaggedBase,           0,
39                         MaybeHandle<Name>(),     MaybeHandle<Map>(),
40                         TypeCache::Get().kUint8, MachineType::Uint8(),
41                         kNoWriteBarrier};
42   return access;
43 }
44 
45 // static
ForMap()46 FieldAccess AccessBuilder::ForMap() {
47   FieldAccess access = {kTaggedBase,           HeapObject::kMapOffset,
48                         MaybeHandle<Name>(),   MaybeHandle<Map>(),
49                         Type::OtherInternal(), MachineType::TaggedPointer(),
50                         kMapWriteBarrier};
51   return access;
52 }
53 
54 
55 // static
ForHeapNumberValue()56 FieldAccess AccessBuilder::ForHeapNumberValue() {
57   FieldAccess access = {
58       kTaggedBase,        HeapNumber::kValueOffset,  MaybeHandle<Name>(),
59       MaybeHandle<Map>(), TypeCache::Get().kFloat64, MachineType::Float64(),
60       kNoWriteBarrier};
61   return access;
62 }
63 
64 
65 // static
ForJSObjectProperties()66 FieldAccess AccessBuilder::ForJSObjectProperties() {
67   FieldAccess access = {kTaggedBase,         JSObject::kPropertiesOffset,
68                         MaybeHandle<Name>(), MaybeHandle<Map>(),
69                         Type::Internal(),    MachineType::TaggedPointer(),
70                         kPointerWriteBarrier};
71   return access;
72 }
73 
74 
75 // static
ForJSObjectElements()76 FieldAccess AccessBuilder::ForJSObjectElements() {
77   FieldAccess access = {kTaggedBase,         JSObject::kElementsOffset,
78                         MaybeHandle<Name>(), MaybeHandle<Map>(),
79                         Type::Internal(),    MachineType::TaggedPointer(),
80                         kPointerWriteBarrier};
81   return access;
82 }
83 
84 
85 // static
ForJSObjectInObjectProperty(Handle<Map> map,int index)86 FieldAccess AccessBuilder::ForJSObjectInObjectProperty(Handle<Map> map,
87                                                        int index) {
88   int const offset = map->GetInObjectPropertyOffset(index);
89   FieldAccess access = {kTaggedBase,         offset,
90                         MaybeHandle<Name>(), MaybeHandle<Map>(),
91                         Type::NonInternal(), MachineType::AnyTagged(),
92                         kFullWriteBarrier};
93   return access;
94 }
95 
96 // static
ForJSObjectOffset(int offset,WriteBarrierKind write_barrier_kind)97 FieldAccess AccessBuilder::ForJSObjectOffset(
98     int offset, WriteBarrierKind write_barrier_kind) {
99   FieldAccess access = {kTaggedBase,         offset,
100                         MaybeHandle<Name>(), MaybeHandle<Map>(),
101                         Type::NonInternal(), MachineType::AnyTagged(),
102                         write_barrier_kind};
103   return access;
104 }
105 
106 // static
ForJSCollectionTable()107 FieldAccess AccessBuilder::ForJSCollectionTable() {
108   FieldAccess access = {kTaggedBase,           JSCollection::kTableOffset,
109                         MaybeHandle<Name>(),   MaybeHandle<Map>(),
110                         Type::OtherInternal(), MachineType::TaggedPointer(),
111                         kPointerWriteBarrier};
112   return access;
113 }
114 
115 // static
ForJSFunctionPrototypeOrInitialMap()116 FieldAccess AccessBuilder::ForJSFunctionPrototypeOrInitialMap() {
117   FieldAccess access = {
118       kTaggedBase,         JSFunction::kPrototypeOrInitialMapOffset,
119       MaybeHandle<Name>(), MaybeHandle<Map>(),
120       Type::Any(),         MachineType::AnyTagged(),
121       kFullWriteBarrier};
122   return access;
123 }
124 
125 // static
ForJSFunctionContext()126 FieldAccess AccessBuilder::ForJSFunctionContext() {
127   FieldAccess access = {kTaggedBase,         JSFunction::kContextOffset,
128                         MaybeHandle<Name>(), MaybeHandle<Map>(),
129                         Type::Internal(),    MachineType::AnyTagged(),
130                         kPointerWriteBarrier};
131   return access;
132 }
133 
134 
135 // static
ForJSFunctionSharedFunctionInfo()136 FieldAccess AccessBuilder::ForJSFunctionSharedFunctionInfo() {
137   FieldAccess access = {
138       kTaggedBase,           JSFunction::kSharedFunctionInfoOffset,
139       Handle<Name>(),        MaybeHandle<Map>(),
140       Type::OtherInternal(), MachineType::TaggedPointer(),
141       kPointerWriteBarrier};
142   return access;
143 }
144 
145 // static
ForJSFunctionFeedbackVector()146 FieldAccess AccessBuilder::ForJSFunctionFeedbackVector() {
147   FieldAccess access = {kTaggedBase,         JSFunction::kFeedbackVectorOffset,
148                         Handle<Name>(),      MaybeHandle<Map>(),
149                         Type::Internal(),    MachineType::TaggedPointer(),
150                         kPointerWriteBarrier};
151   return access;
152 }
153 
154 // static
ForJSFunctionCodeEntry()155 FieldAccess AccessBuilder::ForJSFunctionCodeEntry() {
156   FieldAccess access = {kTaggedBase,           JSFunction::kCodeEntryOffset,
157                         Handle<Name>(),        MaybeHandle<Map>(),
158                         Type::OtherInternal(), MachineType::Pointer(),
159                         kNoWriteBarrier};
160   return access;
161 }
162 
163 // static
ForJSFunctionNextFunctionLink()164 FieldAccess AccessBuilder::ForJSFunctionNextFunctionLink() {
165   FieldAccess access = {
166       kTaggedBase,         JSFunction::kNextFunctionLinkOffset,
167       Handle<Name>(),      MaybeHandle<Map>(),
168       Type::Any(),         MachineType::AnyTagged(),
169       kPointerWriteBarrier};
170   return access;
171 }
172 
173 // static
ForJSGeneratorObjectContext()174 FieldAccess AccessBuilder::ForJSGeneratorObjectContext() {
175   FieldAccess access = {kTaggedBase,         JSGeneratorObject::kContextOffset,
176                         Handle<Name>(),      MaybeHandle<Map>(),
177                         Type::Internal(),    MachineType::TaggedPointer(),
178                         kPointerWriteBarrier};
179   return access;
180 }
181 
182 // static
ForJSGeneratorObjectContinuation()183 FieldAccess AccessBuilder::ForJSGeneratorObjectContinuation() {
184   FieldAccess access = {
185       kTaggedBase,         JSGeneratorObject::kContinuationOffset,
186       Handle<Name>(),      MaybeHandle<Map>(),
187       Type::SignedSmall(), MachineType::TaggedSigned(),
188       kNoWriteBarrier};
189   return access;
190 }
191 
192 // static
ForJSGeneratorObjectInputOrDebugPos()193 FieldAccess AccessBuilder::ForJSGeneratorObjectInputOrDebugPos() {
194   FieldAccess access = {
195       kTaggedBase,         JSGeneratorObject::kInputOrDebugPosOffset,
196       Handle<Name>(),      MaybeHandle<Map>(),
197       Type::NonInternal(), MachineType::AnyTagged(),
198       kFullWriteBarrier};
199   return access;
200 }
201 
202 // static
ForJSGeneratorObjectRegisterFile()203 FieldAccess AccessBuilder::ForJSGeneratorObjectRegisterFile() {
204   FieldAccess access = {
205       kTaggedBase,         JSGeneratorObject::kRegisterFileOffset,
206       Handle<Name>(),      MaybeHandle<Map>(),
207       Type::Internal(),    MachineType::AnyTagged(),
208       kPointerWriteBarrier};
209   return access;
210 }
211 
212 // static
ForJSGeneratorObjectResumeMode()213 FieldAccess AccessBuilder::ForJSGeneratorObjectResumeMode() {
214   FieldAccess access = {
215       kTaggedBase,         JSGeneratorObject::kResumeModeOffset,
216       Handle<Name>(),      MaybeHandle<Map>(),
217       Type::SignedSmall(), MachineType::TaggedSigned(),
218       kNoWriteBarrier};
219   return access;
220 }
221 
222 // static
ForJSArrayLength(ElementsKind elements_kind)223 FieldAccess AccessBuilder::ForJSArrayLength(ElementsKind elements_kind) {
224   TypeCache const& type_cache = TypeCache::Get();
225   FieldAccess access = {kTaggedBase,
226                         JSArray::kLengthOffset,
227                         Handle<Name>(),
228                         MaybeHandle<Map>(),
229                         type_cache.kJSArrayLengthType,
230                         MachineType::TaggedSigned(),
231                         kFullWriteBarrier};
232   if (IsFastDoubleElementsKind(elements_kind)) {
233     access.type = type_cache.kFixedDoubleArrayLengthType;
234     access.write_barrier_kind = kNoWriteBarrier;
235   } else if (IsFastElementsKind(elements_kind)) {
236     access.type = type_cache.kFixedArrayLengthType;
237     access.write_barrier_kind = kNoWriteBarrier;
238   }
239   return access;
240 }
241 
242 
243 // static
ForJSArrayBufferBackingStore()244 FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() {
245   FieldAccess access = {
246       kTaggedBase,           JSArrayBuffer::kBackingStoreOffset,
247       MaybeHandle<Name>(),   MaybeHandle<Map>(),
248       Type::OtherInternal(), MachineType::Pointer(),
249       kNoWriteBarrier};
250   return access;
251 }
252 
253 // static
ForJSArrayBufferBitField()254 FieldAccess AccessBuilder::ForJSArrayBufferBitField() {
255   FieldAccess access = {
256       kTaggedBase,        JSArrayBuffer::kBitFieldOffset, MaybeHandle<Name>(),
257       MaybeHandle<Map>(), TypeCache::Get().kUint8,        MachineType::Uint32(),
258       kNoWriteBarrier};
259   return access;
260 }
261 
262 // static
ForJSArrayBufferViewBuffer()263 FieldAccess AccessBuilder::ForJSArrayBufferViewBuffer() {
264   FieldAccess access = {kTaggedBase,           JSArrayBufferView::kBufferOffset,
265                         MaybeHandle<Name>(),   MaybeHandle<Map>(),
266                         Type::OtherInternal(), MachineType::TaggedPointer(),
267                         kPointerWriteBarrier};
268   return access;
269 }
270 
271 // static
ForJSArrayBufferViewByteLength()272 FieldAccess AccessBuilder::ForJSArrayBufferViewByteLength() {
273   FieldAccess access = {kTaggedBase,
274                         JSArrayBufferView::kByteLengthOffset,
275                         MaybeHandle<Name>(),
276                         MaybeHandle<Map>(),
277                         TypeCache::Get().kPositiveInteger,
278                         MachineType::AnyTagged(),
279                         kFullWriteBarrier};
280   return access;
281 }
282 
283 // static
ForJSArrayBufferViewByteOffset()284 FieldAccess AccessBuilder::ForJSArrayBufferViewByteOffset() {
285   FieldAccess access = {kTaggedBase,
286                         JSArrayBufferView::kByteOffsetOffset,
287                         MaybeHandle<Name>(),
288                         MaybeHandle<Map>(),
289                         TypeCache::Get().kPositiveInteger,
290                         MachineType::AnyTagged(),
291                         kFullWriteBarrier};
292   return access;
293 }
294 
295 // static
ForJSTypedArrayLength()296 FieldAccess AccessBuilder::ForJSTypedArrayLength() {
297   FieldAccess access = {kTaggedBase,
298                         JSTypedArray::kLengthOffset,
299                         MaybeHandle<Name>(),
300                         MaybeHandle<Map>(),
301                         TypeCache::Get().kJSTypedArrayLengthType,
302                         MachineType::TaggedSigned(),
303                         kNoWriteBarrier};
304   return access;
305 }
306 
307 // static
ForJSDateValue()308 FieldAccess AccessBuilder::ForJSDateValue() {
309   FieldAccess access = {kTaggedBase,
310                         JSDate::kValueOffset,
311                         MaybeHandle<Name>(),
312                         MaybeHandle<Map>(),
313                         TypeCache::Get().kJSDateValueType,
314                         MachineType::AnyTagged(),
315                         kFullWriteBarrier};
316   return access;
317 }
318 
319 // static
ForJSDateField(JSDate::FieldIndex index)320 FieldAccess AccessBuilder::ForJSDateField(JSDate::FieldIndex index) {
321   FieldAccess access = {
322       kTaggedBase,         JSDate::kValueOffset + index * kPointerSize,
323       MaybeHandle<Name>(), MaybeHandle<Map>(),
324       Type::Number(),      MachineType::AnyTagged(),
325       kFullWriteBarrier};
326   return access;
327 }
328 
329 
330 // static
ForJSIteratorResultDone()331 FieldAccess AccessBuilder::ForJSIteratorResultDone() {
332   FieldAccess access = {kTaggedBase,         JSIteratorResult::kDoneOffset,
333                         MaybeHandle<Name>(), MaybeHandle<Map>(),
334                         Type::NonInternal(), MachineType::AnyTagged(),
335                         kFullWriteBarrier};
336   return access;
337 }
338 
339 
340 // static
ForJSIteratorResultValue()341 FieldAccess AccessBuilder::ForJSIteratorResultValue() {
342   FieldAccess access = {kTaggedBase,         JSIteratorResult::kValueOffset,
343                         MaybeHandle<Name>(), MaybeHandle<Map>(),
344                         Type::NonInternal(), MachineType::AnyTagged(),
345                         kFullWriteBarrier};
346   return access;
347 }
348 
349 
350 // static
ForJSRegExpFlags()351 FieldAccess AccessBuilder::ForJSRegExpFlags() {
352   FieldAccess access = {kTaggedBase,         JSRegExp::kFlagsOffset,
353                         MaybeHandle<Name>(), MaybeHandle<Map>(),
354                         Type::NonInternal(), MachineType::AnyTagged(),
355                         kFullWriteBarrier};
356   return access;
357 }
358 
359 
360 // static
ForJSRegExpSource()361 FieldAccess AccessBuilder::ForJSRegExpSource() {
362   FieldAccess access = {kTaggedBase,         JSRegExp::kSourceOffset,
363                         MaybeHandle<Name>(), MaybeHandle<Map>(),
364                         Type::NonInternal(), MachineType::AnyTagged(),
365                         kFullWriteBarrier};
366   return access;
367 }
368 
369 
370 // static
ForFixedArrayLength()371 FieldAccess AccessBuilder::ForFixedArrayLength() {
372   FieldAccess access = {kTaggedBase,
373                         FixedArray::kLengthOffset,
374                         MaybeHandle<Name>(),
375                         MaybeHandle<Map>(),
376                         TypeCache::Get().kFixedArrayLengthType,
377                         MachineType::TaggedSigned(),
378                         kNoWriteBarrier};
379   return access;
380 }
381 
382 // static
ForFixedTypedArrayBaseBasePointer()383 FieldAccess AccessBuilder::ForFixedTypedArrayBaseBasePointer() {
384   FieldAccess access = {
385       kTaggedBase,           FixedTypedArrayBase::kBasePointerOffset,
386       MaybeHandle<Name>(),   MaybeHandle<Map>(),
387       Type::OtherInternal(), MachineType::AnyTagged(),
388       kPointerWriteBarrier};
389   return access;
390 }
391 
392 // static
ForFixedTypedArrayBaseExternalPointer()393 FieldAccess AccessBuilder::ForFixedTypedArrayBaseExternalPointer() {
394   FieldAccess access = {kTaggedBase,
395                         FixedTypedArrayBase::kExternalPointerOffset,
396                         MaybeHandle<Name>(),
397                         MaybeHandle<Map>(),
398                         Type::ExternalPointer(),
399                         MachineType::Pointer(),
400                         kNoWriteBarrier};
401   return access;
402 }
403 
404 // static
ForDescriptorArrayEnumCache()405 FieldAccess AccessBuilder::ForDescriptorArrayEnumCache() {
406   FieldAccess access = {
407       kTaggedBase,           DescriptorArray::kEnumCacheOffset,
408       Handle<Name>(),        MaybeHandle<Map>(),
409       Type::OtherInternal(), MachineType::TaggedPointer(),
410       kPointerWriteBarrier};
411   return access;
412 }
413 
414 
415 // static
ForDescriptorArrayEnumCacheBridgeCache()416 FieldAccess AccessBuilder::ForDescriptorArrayEnumCacheBridgeCache() {
417   FieldAccess access = {
418       kTaggedBase,           DescriptorArray::kEnumCacheBridgeCacheOffset,
419       Handle<Name>(),        MaybeHandle<Map>(),
420       Type::OtherInternal(), MachineType::TaggedPointer(),
421       kPointerWriteBarrier};
422   return access;
423 }
424 
425 
426 // static
ForMapBitField()427 FieldAccess AccessBuilder::ForMapBitField() {
428   FieldAccess access = {
429       kTaggedBase,        Map::kBitFieldOffset,    Handle<Name>(),
430       MaybeHandle<Map>(), TypeCache::Get().kUint8, MachineType::Uint8(),
431       kNoWriteBarrier};
432   return access;
433 }
434 
435 
436 // static
ForMapBitField3()437 FieldAccess AccessBuilder::ForMapBitField3() {
438   FieldAccess access = {
439       kTaggedBase,        Map::kBitField3Offset,   Handle<Name>(),
440       MaybeHandle<Map>(), TypeCache::Get().kInt32, MachineType::Int32(),
441       kNoWriteBarrier};
442   return access;
443 }
444 
445 
446 // static
ForMapDescriptors()447 FieldAccess AccessBuilder::ForMapDescriptors() {
448   FieldAccess access = {kTaggedBase,           Map::kDescriptorsOffset,
449                         Handle<Name>(),        MaybeHandle<Map>(),
450                         Type::OtherInternal(), MachineType::TaggedPointer(),
451                         kPointerWriteBarrier};
452   return access;
453 }
454 
455 
456 // static
ForMapInstanceType()457 FieldAccess AccessBuilder::ForMapInstanceType() {
458   FieldAccess access = {
459       kTaggedBase,        Map::kInstanceTypeOffset, Handle<Name>(),
460       MaybeHandle<Map>(), TypeCache::Get().kUint8,  MachineType::Uint8(),
461       kNoWriteBarrier};
462   return access;
463 }
464 
465 
466 // static
ForMapPrototype()467 FieldAccess AccessBuilder::ForMapPrototype() {
468   FieldAccess access = {kTaggedBase,         Map::kPrototypeOffset,
469                         Handle<Name>(),      MaybeHandle<Map>(),
470                         Type::Any(),         MachineType::TaggedPointer(),
471                         kPointerWriteBarrier};
472   return access;
473 }
474 
475 // static
ForModuleRegularExports()476 FieldAccess AccessBuilder::ForModuleRegularExports() {
477   FieldAccess access = {kTaggedBase,           Module::kRegularExportsOffset,
478                         Handle<Name>(),        MaybeHandle<Map>(),
479                         Type::OtherInternal(), MachineType::TaggedPointer(),
480                         kPointerWriteBarrier};
481   return access;
482 }
483 
484 // static
ForModuleRegularImports()485 FieldAccess AccessBuilder::ForModuleRegularImports() {
486   FieldAccess access = {kTaggedBase,           Module::kRegularImportsOffset,
487                         Handle<Name>(),        MaybeHandle<Map>(),
488                         Type::OtherInternal(), MachineType::TaggedPointer(),
489                         kPointerWriteBarrier};
490   return access;
491 }
492 
493 // static
ForNameHashField()494 FieldAccess AccessBuilder::ForNameHashField() {
495   FieldAccess access = {kTaggedBase,        Name::kHashFieldOffset,
496                         Handle<Name>(),     MaybeHandle<Map>(),
497                         Type::Unsigned32(), MachineType::Uint32(),
498                         kNoWriteBarrier};
499   return access;
500 }
501 
502 // static
ForStringLength()503 FieldAccess AccessBuilder::ForStringLength() {
504   FieldAccess access = {kTaggedBase,
505                         String::kLengthOffset,
506                         Handle<Name>(),
507                         MaybeHandle<Map>(),
508                         TypeCache::Get().kStringLengthType,
509                         MachineType::TaggedSigned(),
510                         kNoWriteBarrier};
511   return access;
512 }
513 
514 // static
ForConsStringFirst()515 FieldAccess AccessBuilder::ForConsStringFirst() {
516   FieldAccess access = {kTaggedBase,         ConsString::kFirstOffset,
517                         Handle<Name>(),      MaybeHandle<Map>(),
518                         Type::String(),      MachineType::TaggedPointer(),
519                         kPointerWriteBarrier};
520   return access;
521 }
522 
523 // static
ForConsStringSecond()524 FieldAccess AccessBuilder::ForConsStringSecond() {
525   FieldAccess access = {kTaggedBase,         ConsString::kSecondOffset,
526                         Handle<Name>(),      MaybeHandle<Map>(),
527                         Type::String(),      MachineType::TaggedPointer(),
528                         kPointerWriteBarrier};
529   return access;
530 }
531 
532 // static
ForThinStringActual()533 FieldAccess AccessBuilder::ForThinStringActual() {
534   FieldAccess access = {kTaggedBase,         ThinString::kActualOffset,
535                         Handle<Name>(),      MaybeHandle<Map>(),
536                         Type::String(),      MachineType::TaggedPointer(),
537                         kPointerWriteBarrier};
538   return access;
539 }
540 
541 // static
ForSlicedStringOffset()542 FieldAccess AccessBuilder::ForSlicedStringOffset() {
543   FieldAccess access = {kTaggedBase,         SlicedString::kOffsetOffset,
544                         Handle<Name>(),      MaybeHandle<Map>(),
545                         Type::SignedSmall(), MachineType::TaggedSigned(),
546                         kNoWriteBarrier};
547   return access;
548 }
549 
550 // static
ForSlicedStringParent()551 FieldAccess AccessBuilder::ForSlicedStringParent() {
552   FieldAccess access = {kTaggedBase,         SlicedString::kParentOffset,
553                         Handle<Name>(),      MaybeHandle<Map>(),
554                         Type::String(),      MachineType::TaggedPointer(),
555                         kPointerWriteBarrier};
556   return access;
557 }
558 
559 // static
ForExternalStringResourceData()560 FieldAccess AccessBuilder::ForExternalStringResourceData() {
561   FieldAccess access = {kTaggedBase,
562                         ExternalString::kResourceDataOffset,
563                         Handle<Name>(),
564                         MaybeHandle<Map>(),
565                         Type::ExternalPointer(),
566                         MachineType::Pointer(),
567                         kNoWriteBarrier};
568   return access;
569 }
570 
571 // static
ForExternalOneByteStringCharacter()572 ElementAccess AccessBuilder::ForExternalOneByteStringCharacter() {
573   ElementAccess access = {kUntaggedBase, 0, TypeCache::Get().kUint8,
574                           MachineType::Uint8(), kNoWriteBarrier};
575   return access;
576 }
577 
578 // static
ForExternalTwoByteStringCharacter()579 ElementAccess AccessBuilder::ForExternalTwoByteStringCharacter() {
580   ElementAccess access = {kUntaggedBase, 0, TypeCache::Get().kUint16,
581                           MachineType::Uint16(), kNoWriteBarrier};
582   return access;
583 }
584 
585 // static
ForSeqOneByteStringCharacter()586 ElementAccess AccessBuilder::ForSeqOneByteStringCharacter() {
587   ElementAccess access = {kTaggedBase, SeqOneByteString::kHeaderSize,
588                           TypeCache::Get().kUint8, MachineType::Uint8(),
589                           kNoWriteBarrier};
590   return access;
591 }
592 
593 // static
ForSeqTwoByteStringCharacter()594 ElementAccess AccessBuilder::ForSeqTwoByteStringCharacter() {
595   ElementAccess access = {kTaggedBase, SeqTwoByteString::kHeaderSize,
596                           TypeCache::Get().kUint16, MachineType::Uint16(),
597                           kNoWriteBarrier};
598   return access;
599 }
600 
601 // static
ForJSGlobalObjectGlobalProxy()602 FieldAccess AccessBuilder::ForJSGlobalObjectGlobalProxy() {
603   FieldAccess access = {kTaggedBase,         JSGlobalObject::kGlobalProxyOffset,
604                         Handle<Name>(),      MaybeHandle<Map>(),
605                         Type::Receiver(),    MachineType::TaggedPointer(),
606                         kPointerWriteBarrier};
607   return access;
608 }
609 
610 // static
ForJSGlobalObjectNativeContext()611 FieldAccess AccessBuilder::ForJSGlobalObjectNativeContext() {
612   FieldAccess access = {
613       kTaggedBase,         JSGlobalObject::kNativeContextOffset,
614       Handle<Name>(),      MaybeHandle<Map>(),
615       Type::Internal(),    MachineType::TaggedPointer(),
616       kPointerWriteBarrier};
617   return access;
618 }
619 
620 // static
ForJSArrayIteratorObject()621 FieldAccess AccessBuilder::ForJSArrayIteratorObject() {
622   FieldAccess access = {kTaggedBase,
623                         JSArrayIterator::kIteratedObjectOffset,
624                         Handle<Name>(),
625                         MaybeHandle<Map>(),
626                         Type::ReceiverOrUndefined(),
627                         MachineType::TaggedPointer(),
628                         kPointerWriteBarrier};
629   return access;
630 }
631 
632 // static
ForJSArrayIteratorIndex(InstanceType instance_type,ElementsKind elements_kind)633 FieldAccess AccessBuilder::ForJSArrayIteratorIndex(InstanceType instance_type,
634                                                    ElementsKind elements_kind) {
635   // In generic case, cap to 2^53-1 (per ToLength() in spec) via
636   // kPositiveSafeInteger
637   FieldAccess access = {kTaggedBase,
638                         JSArrayIterator::kNextIndexOffset,
639                         Handle<Name>(),
640                         MaybeHandle<Map>(),
641                         TypeCache::Get().kPositiveSafeInteger,
642                         MachineType::AnyTagged(),
643                         kFullWriteBarrier};
644   if (instance_type == JS_ARRAY_TYPE) {
645     if (IsFastDoubleElementsKind(elements_kind)) {
646       access.type = TypeCache::Get().kFixedDoubleArrayLengthType;
647       access.machine_type = MachineType::TaggedSigned();
648       access.write_barrier_kind = kNoWriteBarrier;
649     } else if (IsFastElementsKind(elements_kind)) {
650       access.type = TypeCache::Get().kFixedArrayLengthType;
651       access.machine_type = MachineType::TaggedSigned();
652       access.write_barrier_kind = kNoWriteBarrier;
653     } else {
654       access.type = TypeCache::Get().kJSArrayLengthType;
655     }
656   } else if (instance_type == JS_TYPED_ARRAY_TYPE) {
657     access.type = TypeCache::Get().kJSTypedArrayLengthType;
658     access.machine_type = MachineType::TaggedSigned();
659     access.write_barrier_kind = kNoWriteBarrier;
660   }
661   return access;
662 }
663 
664 // static
ForJSArrayIteratorObjectMap()665 FieldAccess AccessBuilder::ForJSArrayIteratorObjectMap() {
666   FieldAccess access = {
667       kTaggedBase,           JSArrayIterator::kIteratedObjectMapOffset,
668       Handle<Name>(),        MaybeHandle<Map>(),
669       Type::OtherInternal(), MachineType::TaggedPointer(),
670       kPointerWriteBarrier};
671   return access;
672 }
673 
674 // static
ForJSStringIteratorString()675 FieldAccess AccessBuilder::ForJSStringIteratorString() {
676   FieldAccess access = {kTaggedBase,         JSStringIterator::kStringOffset,
677                         Handle<Name>(),      MaybeHandle<Map>(),
678                         Type::String(),      MachineType::TaggedPointer(),
679                         kPointerWriteBarrier};
680   return access;
681 }
682 
683 // static
ForJSStringIteratorIndex()684 FieldAccess AccessBuilder::ForJSStringIteratorIndex() {
685   FieldAccess access = {kTaggedBase,
686                         JSStringIterator::kNextIndexOffset,
687                         Handle<Name>(),
688                         MaybeHandle<Map>(),
689                         TypeCache::Get().kStringLengthType,
690                         MachineType::TaggedSigned(),
691                         kNoWriteBarrier};
692   return access;
693 }
694 
695 // static
ForValue()696 FieldAccess AccessBuilder::ForValue() {
697   FieldAccess access = {kTaggedBase,         JSValue::kValueOffset,
698                         Handle<Name>(),      MaybeHandle<Map>(),
699                         Type::NonInternal(), MachineType::AnyTagged(),
700                         kFullWriteBarrier};
701   return access;
702 }
703 
704 
705 // static
ForArgumentsLength()706 FieldAccess AccessBuilder::ForArgumentsLength() {
707   FieldAccess access = {kTaggedBase,         JSArgumentsObject::kLengthOffset,
708                         Handle<Name>(),      MaybeHandle<Map>(),
709                         Type::NonInternal(), MachineType::AnyTagged(),
710                         kFullWriteBarrier};
711   return access;
712 }
713 
714 
715 // static
ForArgumentsCallee()716 FieldAccess AccessBuilder::ForArgumentsCallee() {
717   FieldAccess access = {
718       kTaggedBase,         JSSloppyArgumentsObject::kCalleeOffset,
719       Handle<Name>(),      MaybeHandle<Map>(),
720       Type::NonInternal(), MachineType::AnyTagged(),
721       kPointerWriteBarrier};
722   return access;
723 }
724 
725 
726 // static
ForFixedArraySlot(size_t index,WriteBarrierKind write_barrier_kind)727 FieldAccess AccessBuilder::ForFixedArraySlot(
728     size_t index, WriteBarrierKind write_barrier_kind) {
729   int offset = FixedArray::OffsetOfElementAt(static_cast<int>(index));
730   FieldAccess access = {kTaggedBase,         offset,
731                         Handle<Name>(),      MaybeHandle<Map>(),
732                         Type::NonInternal(), MachineType::AnyTagged(),
733                         write_barrier_kind};
734   return access;
735 }
736 
737 
738 // static
ForCellValue()739 FieldAccess AccessBuilder::ForCellValue() {
740   FieldAccess access = {kTaggedBase,      Cell::kValueOffset,
741                         Handle<Name>(),   MaybeHandle<Map>(),
742                         Type::Any(),      MachineType::AnyTagged(),
743                         kFullWriteBarrier};
744   return access;
745 }
746 
747 // static
ForContextSlot(size_t index)748 FieldAccess AccessBuilder::ForContextSlot(size_t index) {
749   int offset = Context::kHeaderSize + static_cast<int>(index) * kPointerSize;
750   DCHECK_EQ(offset,
751             Context::SlotOffset(static_cast<int>(index)) + kHeapObjectTag);
752   FieldAccess access = {kTaggedBase,      offset,
753                         Handle<Name>(),   MaybeHandle<Map>(),
754                         Type::Any(),      MachineType::AnyTagged(),
755                         kFullWriteBarrier};
756   return access;
757 }
758 
759 // static
ForContextExtensionScopeInfo()760 FieldAccess AccessBuilder::ForContextExtensionScopeInfo() {
761   FieldAccess access = {
762       kTaggedBase,           ContextExtension::kScopeInfoOffset,
763       Handle<Name>(),        MaybeHandle<Map>(),
764       Type::OtherInternal(), MachineType::AnyTagged(),
765       kFullWriteBarrier};
766   return access;
767 }
768 
769 // static
ForContextExtensionExtension()770 FieldAccess AccessBuilder::ForContextExtensionExtension() {
771   FieldAccess access = {kTaggedBase,      ContextExtension::kExtensionOffset,
772                         Handle<Name>(),   MaybeHandle<Map>(),
773                         Type::Any(),      MachineType::AnyTagged(),
774                         kFullWriteBarrier};
775   return access;
776 }
777 
778 // static
ForFixedArrayElement()779 ElementAccess AccessBuilder::ForFixedArrayElement() {
780   ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Any(),
781                           MachineType::AnyTagged(), kFullWriteBarrier};
782   return access;
783 }
784 
785 // static
ForFixedArrayElement(ElementsKind kind)786 ElementAccess AccessBuilder::ForFixedArrayElement(ElementsKind kind) {
787   ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Any(),
788                           MachineType::AnyTagged(), kFullWriteBarrier};
789   switch (kind) {
790     case FAST_SMI_ELEMENTS:
791       access.type = Type::SignedSmall();
792       access.machine_type = MachineType::TaggedSigned();
793       access.write_barrier_kind = kNoWriteBarrier;
794       break;
795     case FAST_HOLEY_SMI_ELEMENTS:
796       access.type = TypeCache::Get().kHoleySmi;
797       break;
798     case FAST_ELEMENTS:
799       access.type = Type::NonInternal();
800       break;
801     case FAST_HOLEY_ELEMENTS:
802       break;
803     case FAST_DOUBLE_ELEMENTS:
804       access.type = Type::Number();
805       access.write_barrier_kind = kNoWriteBarrier;
806       access.machine_type = MachineType::Float64();
807       break;
808     case FAST_HOLEY_DOUBLE_ELEMENTS:
809       access.type = Type::Number();
810       access.write_barrier_kind = kNoWriteBarrier;
811       access.machine_type = MachineType::Float64();
812       break;
813     default:
814       UNREACHABLE();
815       break;
816   }
817   return access;
818 }
819 
820 // static
ForFixedDoubleArrayElement()821 ElementAccess AccessBuilder::ForFixedDoubleArrayElement() {
822   ElementAccess access = {kTaggedBase, FixedDoubleArray::kHeaderSize,
823                           TypeCache::Get().kFloat64, MachineType::Float64(),
824                           kNoWriteBarrier};
825   return access;
826 }
827 
828 
829 // static
ForTypedArrayElement(ExternalArrayType type,bool is_external)830 ElementAccess AccessBuilder::ForTypedArrayElement(ExternalArrayType type,
831                                                   bool is_external) {
832   BaseTaggedness taggedness = is_external ? kUntaggedBase : kTaggedBase;
833   int header_size = is_external ? 0 : FixedTypedArrayBase::kDataOffset;
834   switch (type) {
835     case kExternalInt8Array: {
836       ElementAccess access = {taggedness, header_size, Type::Signed32(),
837                               MachineType::Int8(), kNoWriteBarrier};
838       return access;
839     }
840     case kExternalUint8Array:
841     case kExternalUint8ClampedArray: {
842       ElementAccess access = {taggedness, header_size, Type::Unsigned32(),
843                               MachineType::Uint8(), kNoWriteBarrier};
844       return access;
845     }
846     case kExternalInt16Array: {
847       ElementAccess access = {taggedness, header_size, Type::Signed32(),
848                               MachineType::Int16(), kNoWriteBarrier};
849       return access;
850     }
851     case kExternalUint16Array: {
852       ElementAccess access = {taggedness, header_size, Type::Unsigned32(),
853                               MachineType::Uint16(), kNoWriteBarrier};
854       return access;
855     }
856     case kExternalInt32Array: {
857       ElementAccess access = {taggedness, header_size, Type::Signed32(),
858                               MachineType::Int32(), kNoWriteBarrier};
859       return access;
860     }
861     case kExternalUint32Array: {
862       ElementAccess access = {taggedness, header_size, Type::Unsigned32(),
863                               MachineType::Uint32(), kNoWriteBarrier};
864       return access;
865     }
866     case kExternalFloat32Array: {
867       ElementAccess access = {taggedness, header_size, Type::Number(),
868                               MachineType::Float32(), kNoWriteBarrier};
869       return access;
870     }
871     case kExternalFloat64Array: {
872       ElementAccess access = {taggedness, header_size, Type::Number(),
873                               MachineType::Float64(), kNoWriteBarrier};
874       return access;
875     }
876   }
877   UNREACHABLE();
878   ElementAccess access = {kUntaggedBase, 0, Type::None(), MachineType::None(),
879                           kNoWriteBarrier};
880   return access;
881 }
882 
883 // static
ForHashTableBaseNumberOfElements()884 FieldAccess AccessBuilder::ForHashTableBaseNumberOfElements() {
885   FieldAccess access = {
886       kTaggedBase,
887       FixedArray::OffsetOfElementAt(HashTableBase::kNumberOfElementsIndex),
888       MaybeHandle<Name>(),
889       MaybeHandle<Map>(),
890       Type::SignedSmall(),
891       MachineType::TaggedSigned(),
892       kNoWriteBarrier};
893   return access;
894 }
895 
896 // static
ForHashTableBaseNumberOfDeletedElement()897 FieldAccess AccessBuilder::ForHashTableBaseNumberOfDeletedElement() {
898   FieldAccess access = {
899       kTaggedBase, FixedArray::OffsetOfElementAt(
900                        HashTableBase::kNumberOfDeletedElementsIndex),
901       MaybeHandle<Name>(), MaybeHandle<Map>(), Type::SignedSmall(),
902       MachineType::TaggedSigned(), kNoWriteBarrier};
903   return access;
904 }
905 
906 // static
ForHashTableBaseCapacity()907 FieldAccess AccessBuilder::ForHashTableBaseCapacity() {
908   FieldAccess access = {
909       kTaggedBase,
910       FixedArray::OffsetOfElementAt(HashTableBase::kCapacityIndex),
911       MaybeHandle<Name>(),
912       MaybeHandle<Map>(),
913       Type::SignedSmall(),
914       MachineType::TaggedSigned(),
915       kNoWriteBarrier};
916   return access;
917 }
918 
919 // static
ForDictionaryMaxNumberKey()920 FieldAccess AccessBuilder::ForDictionaryMaxNumberKey() {
921   FieldAccess access = {
922       kTaggedBase,
923       FixedArray::OffsetOfElementAt(NameDictionary::kMaxNumberKeyIndex),
924       MaybeHandle<Name>(),
925       MaybeHandle<Map>(),
926       Type::Any(),
927       MachineType::AnyTagged(),
928       kNoWriteBarrier};
929   return access;
930 }
931 
932 // static
ForDictionaryNextEnumerationIndex()933 FieldAccess AccessBuilder::ForDictionaryNextEnumerationIndex() {
934   FieldAccess access = {
935       kTaggedBase,
936       FixedArray::OffsetOfElementAt(NameDictionary::kNextEnumerationIndexIndex),
937       MaybeHandle<Name>(),
938       MaybeHandle<Map>(),
939       Type::SignedSmall(),
940       MachineType::TaggedSigned(),
941       kNoWriteBarrier};
942   return access;
943 }
944 
945 }  // namespace compiler
946 }  // namespace internal
947 }  // namespace v8
948