| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_ACCESS_BUILDER_H_ | 5 #ifndef V8_COMPILER_ACCESS_BUILDER_H_ |
| 6 #define V8_COMPILER_ACCESS_BUILDER_H_ | 6 #define V8_COMPILER_ACCESS_BUILDER_H_ |
| 7 | 7 |
| 8 #include "src/compiler/simplified-operator.h" | 8 #include "src/compiler/simplified-operator.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 namespace compiler { | 12 namespace compiler { |
| 13 | 13 |
| 14 // This access builder provides a set of static methods constructing commonly | 14 // This access builder provides a set of static methods constructing commonly |
| 15 // used FieldAccess and ElementAccess descriptors. These descriptors server as | 15 // used FieldAccess and ElementAccess descriptors. These descriptors server as |
| 16 // parameters to simplified load/store operators. | 16 // parameters to simplified load/store operators. |
| 17 class AccessBuilder : public AllStatic { | 17 class AccessBuilder FINAL : public AllStatic { |
| 18 public: | 18 public: |
| 19 // Provides access to HeapObject::map() field. | 19 // Provides access to HeapObject::map() field. |
| 20 static FieldAccess ForMap() { | 20 static FieldAccess ForMap(); |
| 21 return {kTaggedBase, HeapObject::kMapOffset, Handle<Name>(), Type::Any(), | |
| 22 kMachAnyTagged}; | |
| 23 } | |
| 24 | 21 |
| 25 // Provides access to JSObject::properties() field. | 22 // Provides access to JSObject::properties() field. |
| 26 static FieldAccess ForJSObjectProperties() { | 23 static FieldAccess ForJSObjectProperties(); |
| 27 return {kTaggedBase, JSObject::kPropertiesOffset, Handle<Name>(), | |
| 28 Type::Any(), kMachAnyTagged}; | |
| 29 } | |
| 30 | 24 |
| 31 // Provides access to JSObject::elements() field. | 25 // Provides access to JSObject::elements() field. |
| 32 static FieldAccess ForJSObjectElements() { | 26 static FieldAccess ForJSObjectElements(); |
| 33 return {kTaggedBase, JSObject::kElementsOffset, Handle<Name>(), | |
| 34 Type::Internal(), kMachAnyTagged}; | |
| 35 } | |
| 36 | 27 |
| 37 // Provides access to JSArrayBuffer::backing_store() field. | 28 // Provides access to JSArrayBuffer::backing_store() field. |
| 38 static FieldAccess ForJSArrayBufferBackingStore() { | 29 static FieldAccess ForJSArrayBufferBackingStore(); |
| 39 return {kTaggedBase, JSArrayBuffer::kBackingStoreOffset, Handle<Name>(), | |
| 40 Type::UntaggedPtr(), kMachPtr}; | |
| 41 } | |
| 42 | 30 |
| 43 // Provides access to ExternalArray::external_pointer() field. | 31 // Provides access to ExternalArray::external_pointer() field. |
| 44 static FieldAccess ForExternalArrayPointer() { | 32 static FieldAccess ForExternalArrayPointer(); |
| 45 return {kTaggedBase, ExternalArray::kExternalPointerOffset, Handle<Name>(), | |
| 46 Type::UntaggedPtr(), kMachPtr}; | |
| 47 } | |
| 48 | 33 |
| 49 // Provides access to FixedArray elements. | 34 // Provides access to FixedArray elements. |
| 50 static ElementAccess ForFixedArrayElement() { | 35 static ElementAccess ForFixedArrayElement(); |
| 51 return {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), kMachAnyTagged}; | |
| 52 } | |
| 53 | 36 |
| 54 // TODO(mstarzinger): Raw access only for testing, drop me. | 37 // TODO(mstarzinger): Raw access only for testing, drop me. |
| 55 static ElementAccess ForBackingStoreElement(MachineType rep) { | 38 static ElementAccess ForBackingStoreElement(MachineType rep); |
| 56 return {kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, | |
| 57 Type::Any(), rep}; | |
| 58 } | |
| 59 | 39 |
| 60 // Provides access to Fixed{type}TypedArray and External{type}Array elements. | 40 // Provides access to Fixed{type}TypedArray and External{type}Array elements. |
| 61 static ElementAccess ForTypedArrayElement(ExternalArrayType type, | 41 static ElementAccess ForTypedArrayElement(ExternalArrayType type, |
| 62 bool is_external) { | 42 bool is_external); |
| 63 BaseTaggedness taggedness = is_external ? kUntaggedBase : kTaggedBase; | |
| 64 int header_size = is_external ? 0 : FixedTypedArrayBase::kDataOffset; | |
| 65 switch (type) { | |
| 66 case kExternalInt8Array: | |
| 67 return {taggedness, header_size, Type::Signed32(), kMachInt8}; | |
| 68 case kExternalUint8Array: | |
| 69 case kExternalUint8ClampedArray: | |
| 70 return {taggedness, header_size, Type::Unsigned32(), kMachUint8}; | |
| 71 case kExternalInt16Array: | |
| 72 return {taggedness, header_size, Type::Signed32(), kMachInt16}; | |
| 73 case kExternalUint16Array: | |
| 74 return {taggedness, header_size, Type::Unsigned32(), kMachUint16}; | |
| 75 case kExternalInt32Array: | |
| 76 return {taggedness, header_size, Type::Signed32(), kMachInt32}; | |
| 77 case kExternalUint32Array: | |
| 78 return {taggedness, header_size, Type::Unsigned32(), kMachUint32}; | |
| 79 case kExternalFloat32Array: | |
| 80 return {taggedness, header_size, Type::Number(), kRepFloat32}; | |
| 81 case kExternalFloat64Array: | |
| 82 return {taggedness, header_size, Type::Number(), kRepFloat64}; | |
| 83 } | |
| 84 UNREACHABLE(); | |
| 85 return {kUntaggedBase, 0, Type::None(), kMachNone}; | |
| 86 } | |
| 87 | 43 |
| 88 private: | 44 private: |
| 89 DISALLOW_COPY_AND_ASSIGN(AccessBuilder); | 45 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessBuilder); |
| 90 }; | 46 }; |
| 91 | 47 |
| 92 } // namespace compiler | 48 } // namespace compiler |
| 93 } // namespace internal | 49 } // namespace internal |
| 94 } // namespace v8 | 50 } // namespace v8 |
| 95 | 51 |
| 96 #endif // V8_COMPILER_ACCESS_BUILDER_H_ | 52 #endif // V8_COMPILER_ACCESS_BUILDER_H_ |
| OLD | NEW |