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 #include "src/types-inl.h"
7
8 namespace v8 {
9 namespace internal {
10 namespace compiler {
11
12 // static
ForMap()13 FieldAccess AccessBuilder::ForMap() {
14 return {kTaggedBase, HeapObject::kMapOffset, Handle<Name>(), Type::Any(),
15 kMachAnyTagged};
16 }
17
18
19 // static
ForJSObjectProperties()20 FieldAccess AccessBuilder::ForJSObjectProperties() {
21 return {kTaggedBase, JSObject::kPropertiesOffset, Handle<Name>(), Type::Any(),
22 kMachAnyTagged};
23 }
24
25
26 // static
ForJSObjectElements()27 FieldAccess AccessBuilder::ForJSObjectElements() {
28 return {kTaggedBase, JSObject::kElementsOffset, Handle<Name>(),
29 Type::Internal(), kMachAnyTagged};
30 }
31
32
33 // static
ForJSFunctionContext()34 FieldAccess AccessBuilder::ForJSFunctionContext() {
35 return {kTaggedBase, JSFunction::kContextOffset, Handle<Name>(),
36 Type::Internal(), kMachAnyTagged};
37 }
38
39
40 // static
ForJSArrayBufferBackingStore()41 FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() {
42 return {kTaggedBase, JSArrayBuffer::kBackingStoreOffset, Handle<Name>(),
43 Type::UntaggedPtr(), kMachPtr};
44 }
45
46
47 // static
ForExternalArrayPointer()48 FieldAccess AccessBuilder::ForExternalArrayPointer() {
49 return {kTaggedBase, ExternalArray::kExternalPointerOffset, Handle<Name>(),
50 Type::UntaggedPtr(), kMachPtr};
51 }
52
53
54 // static
ForFixedArrayElement()55 ElementAccess AccessBuilder::ForFixedArrayElement() {
56 return {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), kMachAnyTagged};
57 }
58
59
60 // static
ForBackingStoreElement(MachineType rep)61 ElementAccess AccessBuilder::ForBackingStoreElement(MachineType rep) {
62 return {kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, Type::Any(),
63 rep};
64 }
65
66
67 // static
ForTypedArrayElement(ExternalArrayType type,bool is_external)68 ElementAccess AccessBuilder::ForTypedArrayElement(ExternalArrayType type,
69 bool is_external) {
70 BaseTaggedness taggedness = is_external ? kUntaggedBase : kTaggedBase;
71 int header_size = is_external ? 0 : FixedTypedArrayBase::kDataOffset;
72 switch (type) {
73 case kExternalInt8Array:
74 return {taggedness, header_size, Type::Signed32(), kMachInt8};
75 case kExternalUint8Array:
76 case kExternalUint8ClampedArray:
77 return {taggedness, header_size, Type::Unsigned32(), kMachUint8};
78 case kExternalInt16Array:
79 return {taggedness, header_size, Type::Signed32(), kMachInt16};
80 case kExternalUint16Array:
81 return {taggedness, header_size, Type::Unsigned32(), kMachUint16};
82 case kExternalInt32Array:
83 return {taggedness, header_size, Type::Signed32(), kMachInt32};
84 case kExternalUint32Array:
85 return {taggedness, header_size, Type::Unsigned32(), kMachUint32};
86 case kExternalFloat32Array:
87 return {taggedness, header_size, Type::Number(), kRepFloat32};
88 case kExternalFloat64Array:
89 return {taggedness, header_size, Type::Number(), kRepFloat64};
90 }
91 UNREACHABLE();
92 return {kUntaggedBase, 0, Type::None(), kMachNone};
93 }
94
95 } // namespace compiler
96 } // namespace internal
97 } // namespace v8
98