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