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_SIMPLIFIED_OPERATOR_H_ | 5 #ifndef V8_COMPILER_SIMPLIFIED_OPERATOR_H_ |
6 #define V8_COMPILER_SIMPLIFIED_OPERATOR_H_ | 6 #define V8_COMPILER_SIMPLIFIED_OPERATOR_H_ |
7 | 7 |
8 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
9 #include "src/compiler/opcodes.h" | 9 #include "src/compiler/opcodes.h" |
10 #include "src/zone.h" | 10 #include "src/zone.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 87 } |
88 | 88 |
89 | 89 |
90 inline const ElementAccess ElementAccessOf(Operator* op) { | 90 inline const ElementAccess ElementAccessOf(Operator* op) { |
91 DCHECK(op->opcode() == IrOpcode::kLoadElement || | 91 DCHECK(op->opcode() == IrOpcode::kLoadElement || |
92 op->opcode() == IrOpcode::kStoreElement); | 92 op->opcode() == IrOpcode::kStoreElement); |
93 return static_cast<Operator1<ElementAccess>*>(op)->parameter(); | 93 return static_cast<Operator1<ElementAccess>*>(op)->parameter(); |
94 } | 94 } |
95 | 95 |
96 | 96 |
| 97 // This access helper provides a set of static methods constructing commonly |
| 98 // used FieldAccess and ElementAccess descriptors. |
| 99 class Access : public AllStatic { |
| 100 public: |
| 101 // Provides access to JSObject::elements() field. |
| 102 static FieldAccess ForJSObjectElements() { |
| 103 return {kTaggedBase, JSObject::kElementsOffset, Handle<Name>(), |
| 104 Type::Internal(), kMachAnyTagged}; |
| 105 } |
| 106 |
| 107 // Provides access to ExternalArray::external_pointer() field. |
| 108 static FieldAccess ForExternalArrayPointer() { |
| 109 return {kTaggedBase, ExternalArray::kExternalPointerOffset, Handle<Name>(), |
| 110 Type::UntaggedPtr(), kMachPtr}; |
| 111 } |
| 112 |
| 113 // Provides access to Fixed{type}TypedArray and External{type}Array elements. |
| 114 static ElementAccess ForTypedArrayElement(ExternalArrayType type, |
| 115 bool is_external) { |
| 116 BaseTaggedness taggedness = is_external ? kUntaggedBase : kTaggedBase; |
| 117 int header_size = is_external ? 0 : FixedTypedArrayBase::kDataOffset; |
| 118 switch (type) { |
| 119 case kExternalInt8Array: |
| 120 return {taggedness, header_size, Type::Signed32(), kMachInt8}; |
| 121 case kExternalUint8Array: |
| 122 case kExternalUint8ClampedArray: |
| 123 return {taggedness, header_size, Type::Unsigned32(), kMachUint8}; |
| 124 case kExternalInt16Array: |
| 125 return {taggedness, header_size, Type::Signed32(), kMachInt16}; |
| 126 case kExternalUint16Array: |
| 127 return {taggedness, header_size, Type::Unsigned32(), kMachUint16}; |
| 128 case kExternalInt32Array: |
| 129 return {taggedness, header_size, Type::Signed32(), kMachInt32}; |
| 130 case kExternalUint32Array: |
| 131 return {taggedness, header_size, Type::Unsigned32(), kMachUint32}; |
| 132 case kExternalFloat32Array: |
| 133 return {taggedness, header_size, Type::Number(), kRepFloat32}; |
| 134 case kExternalFloat64Array: |
| 135 return {taggedness, header_size, Type::Number(), kRepFloat64}; |
| 136 } |
| 137 UNREACHABLE(); |
| 138 return {kUntaggedBase, 0, Type::None(), kMachNone}; |
| 139 } |
| 140 |
| 141 private: |
| 142 DISALLOW_COPY_AND_ASSIGN(Access); |
| 143 }; |
| 144 |
| 145 |
97 // Interface for building simplified operators, which represent the | 146 // Interface for building simplified operators, which represent the |
98 // medium-level operations of V8, including adding numbers, allocating objects, | 147 // medium-level operations of V8, including adding numbers, allocating objects, |
99 // indexing into objects and arrays, etc. | 148 // indexing into objects and arrays, etc. |
100 // All operators are typed but many are representation independent. | 149 // All operators are typed but many are representation independent. |
101 | 150 |
102 // Number values from JS can be in one of these representations: | 151 // Number values from JS can be in one of these representations: |
103 // - Tagged: word-sized integer that is either | 152 // - Tagged: word-sized integer that is either |
104 // - a signed small integer (31 or 32 bits plus a tag) | 153 // - a signed small integer (31 or 32 bits plus a tag) |
105 // - a tagged pointer to a HeapNumber object that has a float64 field | 154 // - a tagged pointer to a HeapNumber object that has a float64 field |
106 // - Int32: an untagged signed 32-bit integer | 155 // - Int32: an untagged signed 32-bit integer |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 #undef SIMPLE | 229 #undef SIMPLE |
181 | 230 |
182 private: | 231 private: |
183 Zone* zone_; | 232 Zone* zone_; |
184 }; | 233 }; |
185 } | 234 } |
186 } | 235 } |
187 } // namespace v8::internal::compiler | 236 } // namespace v8::internal::compiler |
188 | 237 |
189 #endif // V8_COMPILER_SIMPLIFIED_OPERATOR_H_ | 238 #endif // V8_COMPILER_SIMPLIFIED_OPERATOR_H_ |
OLD | NEW |