OLD | NEW |
(Empty) | |
| 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 #ifndef V8_COMPILER_ACCESS_BUILDER_H_ |
| 6 #define V8_COMPILER_ACCESS_BUILDER_H_ |
| 7 |
| 8 #include "src/compiler/simplified-operator.h" |
| 9 |
| 10 namespace v8 { |
| 11 namespace internal { |
| 12 namespace compiler { |
| 13 |
| 14 // This access builder provides a set of static methods constructing commonly |
| 15 // used FieldAccess and ElementAccess descriptors. These descriptors server as |
| 16 // parameters to simplified load/store operators. |
| 17 class AccessBuilder : public AllStatic { |
| 18 public: |
| 19 // Provides access to JSObject::elements() field. |
| 20 static FieldAccess ForJSObjectElements() { |
| 21 return {kTaggedBase, JSObject::kElementsOffset, Handle<Name>(), |
| 22 Type::Internal(), kMachAnyTagged}; |
| 23 } |
| 24 |
| 25 // Provides access to ExternalArray::external_pointer() field. |
| 26 static FieldAccess ForExternalArrayPointer() { |
| 27 return {kTaggedBase, ExternalArray::kExternalPointerOffset, Handle<Name>(), |
| 28 Type::UntaggedPtr(), kMachPtr}; |
| 29 } |
| 30 |
| 31 // Provides access to Fixed{type}TypedArray and External{type}Array elements. |
| 32 static ElementAccess ForTypedArrayElement(ExternalArrayType type, |
| 33 bool is_external) { |
| 34 BaseTaggedness taggedness = is_external ? kUntaggedBase : kTaggedBase; |
| 35 int header_size = is_external ? 0 : FixedTypedArrayBase::kDataOffset; |
| 36 switch (type) { |
| 37 case kExternalInt8Array: |
| 38 return {taggedness, header_size, Type::Signed32(), kMachInt8}; |
| 39 case kExternalUint8Array: |
| 40 case kExternalUint8ClampedArray: |
| 41 return {taggedness, header_size, Type::Unsigned32(), kMachUint8}; |
| 42 case kExternalInt16Array: |
| 43 return {taggedness, header_size, Type::Signed32(), kMachInt16}; |
| 44 case kExternalUint16Array: |
| 45 return {taggedness, header_size, Type::Unsigned32(), kMachUint16}; |
| 46 case kExternalInt32Array: |
| 47 return {taggedness, header_size, Type::Signed32(), kMachInt32}; |
| 48 case kExternalUint32Array: |
| 49 return {taggedness, header_size, Type::Unsigned32(), kMachUint32}; |
| 50 case kExternalFloat32Array: |
| 51 return {taggedness, header_size, Type::Number(), kRepFloat32}; |
| 52 case kExternalFloat64Array: |
| 53 return {taggedness, header_size, Type::Number(), kRepFloat64}; |
| 54 } |
| 55 UNREACHABLE(); |
| 56 return {kUntaggedBase, 0, Type::None(), kMachNone}; |
| 57 } |
| 58 |
| 59 private: |
| 60 DISALLOW_COPY_AND_ASSIGN(AccessBuilder); |
| 61 }; |
| 62 |
| 63 } // namespace compiler |
| 64 } // namespace internal |
| 65 } // namespace v8 |
| 66 |
| 67 #endif // V8_COMPILER_ACCESS_BUILDER_H_ |
OLD | NEW |