Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: src/interpreter/bytecode-traits.h

Issue 2351763002: [Interpreter] Optimize BytecodeArrayBuilder and BytecodeArrayWriter. (Closed)
Patch Set: [Interpreter] Optimize BytecodeArrayBuilder and BytecodeArrayWriter. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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_INTERPRETER_BYTECODE_TRAITS_H_ 5 #ifndef V8_INTERPRETER_BYTECODE_TRAITS_H_
6 #define V8_INTERPRETER_BYTECODE_TRAITS_H_ 6 #define V8_INTERPRETER_BYTECODE_TRAITS_H_
7 7
8 #include "src/interpreter/bytecodes.h" 8 #include "src/interpreter/bytecode-operands.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 namespace interpreter { 12 namespace interpreter {
13 13
14 template <OperandTypeInfo> 14 template <OperandTypeInfo>
15 struct OperandTypeInfoTraits { 15 struct OperandTypeInfoTraits {
16 static const bool kIsScalable = false; 16 static const bool kIsScalable = false;
17 static const bool kIsUnsigned = false; 17 static const bool kIsUnsigned = false;
18 static const OperandSize kUnscaledSize = OperandSize::kNone; 18 static const OperandSize kUnscaledSize = OperandSize::kNone;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 static const int kSize = static_cast<int>(size) * static_cast<int>(scale); 58 static const int kSize = static_cast<int>(size) * static_cast<int>(scale);
59 }; 59 };
60 60
61 static const int kSize = 61 static const int kSize =
62 Helper<OperandTraits<operand_type>::TypeInfoTraits::kIsScalable, 62 Helper<OperandTraits<operand_type>::TypeInfoTraits::kIsScalable,
63 OperandTraits<operand_type>::TypeInfoTraits::kUnscaledSize, 63 OperandTraits<operand_type>::TypeInfoTraits::kUnscaledSize,
64 operand_scale>::kSize; 64 operand_scale>::kSize;
65 static const OperandSize kOperandSize = static_cast<OperandSize>(kSize); 65 static const OperandSize kOperandSize = static_cast<OperandSize>(kSize);
66 }; 66 };
67 67
68 template <OperandType>
69 struct RegisterOperandTraits {
70 static const int kIsRegisterOperand = 0;
71 };
72
73 #define DECLARE_REGISTER_OPERAND(Name, _) \
74 template <> \
75 struct RegisterOperandTraits<OperandType::k##Name> { \
76 static const int kIsRegisterOperand = 1; \
77 };
78 REGISTER_OPERAND_TYPE_LIST(DECLARE_REGISTER_OPERAND)
79 #undef DECLARE_REGISTER_OPERAND
80
81 template <AccumulatorUse, OperandType...> 68 template <AccumulatorUse, OperandType...>
82 struct BytecodeTraits {}; 69 struct BytecodeTraits {};
83 70
84 template <AccumulatorUse accumulator_use, OperandType operand_0, 71 template <AccumulatorUse accumulator_use, OperandType operand_0,
85 OperandType operand_1, OperandType operand_2, OperandType operand_3> 72 OperandType operand_1, OperandType operand_2, OperandType operand_3>
Leszek Swirski 2016/09/20 10:37:56 Would this code benefit from template packs? e.g.
rmcilroy 2016/09/20 16:57:25 Great suggestion! Works like a charm, thanks.
86 struct BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2, 73 struct BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2,
87 operand_3> { 74 operand_3> {
88 static const OperandType* GetOperandTypes() { 75 static constexpr OperandType kOperandTypes[] = {operand_0, operand_1,
89 static const OperandType operand_types[] = {operand_0, operand_1, operand_2, 76 operand_2, operand_3};
90 operand_3, OperandType::kNone}; 77 static constexpr OperandTypeInfo kOperandTypeInfos[] = {
91 return operand_types; 78 OperandTraits<operand_0>::kOperandTypeInfo,
92 } 79 OperandTraits<operand_1>::kOperandTypeInfo,
93 80 OperandTraits<operand_2>::kOperandTypeInfo,
94 static const OperandTypeInfo* GetOperandTypeInfos() { 81 OperandTraits<operand_3>::kOperandTypeInfo};
95 static const OperandTypeInfo operand_type_infos[] = { 82 static constexpr OperandSize kSingleScaleOperandSizes[] = {
96 OperandTraits<operand_0>::kOperandTypeInfo, 83 OperandScaler<operand_0, OperandScale::kSingle>::kOperandSize,
97 OperandTraits<operand_1>::kOperandTypeInfo, 84 OperandScaler<operand_1, OperandScale::kSingle>::kOperandSize,
98 OperandTraits<operand_2>::kOperandTypeInfo, 85 OperandScaler<operand_2, OperandScale::kSingle>::kOperandSize,
99 OperandTraits<operand_3>::kOperandTypeInfo, OperandTypeInfo::kNone}; 86 OperandScaler<operand_3, OperandScale::kSingle>::kOperandSize};
100 return operand_type_infos; 87 static constexpr OperandSize kDoubleScaleOperandSizes[] = {
101 } 88 OperandScaler<operand_0, OperandScale::kDouble>::kOperandSize,
102 89 OperandScaler<operand_1, OperandScale::kDouble>::kOperandSize,
103 template <OperandType ot> 90 OperandScaler<operand_2, OperandScale::kDouble>::kOperandSize,
104 static inline bool HasAnyOperandsOfType() { 91 OperandScaler<operand_3, OperandScale::kDouble>::kOperandSize};
105 return operand_0 == ot || operand_1 == ot || operand_2 == ot || 92 static constexpr OperandSize kQuadrupleScaleOperandSizes[] = {
106 operand_3 == ot; 93 OperandScaler<operand_0, OperandScale::kQuadruple>::kOperandSize,
107 } 94 OperandScaler<operand_1, OperandScale::kQuadruple>::kOperandSize,
108 95 OperandScaler<operand_2, OperandScale::kQuadruple>::kOperandSize,
109 static inline bool IsScalable() { 96 OperandScaler<operand_3, OperandScale::kQuadruple>::kOperandSize};
110 return (OperandTraits<operand_0>::TypeInfoTraits::kIsScalable | 97 static constexpr int kSingleScaleSize =
111 OperandTraits<operand_1>::TypeInfoTraits::kIsScalable | 98 1 + OperandScaler<operand_0, OperandScale::kSingle>::kSize +
112 OperandTraits<operand_2>::TypeInfoTraits::kIsScalable | 99 OperandScaler<operand_1, OperandScale::kSingle>::kSize +
113 OperandTraits<operand_3>::TypeInfoTraits::kIsScalable); 100 OperandScaler<operand_2, OperandScale::kSingle>::kSize +
114 } 101 OperandScaler<operand_3, OperandScale::kSingle>::kSize;
115 102 static constexpr int kDoubleScaleSize =
116 static const AccumulatorUse kAccumulatorUse = accumulator_use; 103 1 + OperandScaler<operand_0, OperandScale::kDouble>::kSize +
117 static const int kOperandCount = 4; 104 OperandScaler<operand_1, OperandScale::kDouble>::kSize +
118 static const int kRegisterOperandCount = 105 OperandScaler<operand_2, OperandScale::kDouble>::kSize +
119 RegisterOperandTraits<operand_0>::kIsRegisterOperand + 106 OperandScaler<operand_3, OperandScale::kDouble>::kSize;
120 RegisterOperandTraits<operand_1>::kIsRegisterOperand + 107 static constexpr int kQuadrupleScaleSize =
121 RegisterOperandTraits<operand_2>::kIsRegisterOperand + 108 1 + OperandScaler<operand_0, OperandScale::kQuadruple>::kSize +
122 RegisterOperandTraits<operand_3>::kIsRegisterOperand; 109 OperandScaler<operand_1, OperandScale::kQuadruple>::kSize +
123 }; 110 OperandScaler<operand_2, OperandScale::kQuadruple>::kSize +
111 OperandScaler<operand_3, OperandScale::kQuadruple>::kSize;
112 static constexpr AccumulatorUse kAccumulatorUse = accumulator_use;
113 static constexpr int kOperandCount = 4;
114 };
115
116 template <AccumulatorUse accumulator_use, OperandType operand_0,
117 OperandType operand_1, OperandType operand_2, OperandType operand_3>
118 constexpr OperandType BytecodeTraits<accumulator_use, operand_0, operand_1,
119 operand_2, operand_3>::kOperandTypes[];
120 template <AccumulatorUse accumulator_use, OperandType operand_0,
121 OperandType operand_1, OperandType operand_2, OperandType operand_3>
122 constexpr OperandTypeInfo
123 BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2,
124 operand_3>::kOperandTypeInfos[];
125 template <AccumulatorUse accumulator_use, OperandType operand_0,
126 OperandType operand_1, OperandType operand_2, OperandType operand_3>
127 constexpr OperandSize
128 BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2,
129 operand_3>::kSingleScaleOperandSizes[];
130 template <AccumulatorUse accumulator_use, OperandType operand_0,
131 OperandType operand_1, OperandType operand_2, OperandType operand_3>
132 constexpr OperandSize
133 BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2,
134 operand_3>::kDoubleScaleOperandSizes[];
135 template <AccumulatorUse accumulator_use, OperandType operand_0,
136 OperandType operand_1, OperandType operand_2, OperandType operand_3>
137 constexpr OperandSize
138 BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2,
139 operand_3>::kQuadrupleScaleOperandSizes[];
124 140
125 template <AccumulatorUse accumulator_use, OperandType operand_0, 141 template <AccumulatorUse accumulator_use, OperandType operand_0,
126 OperandType operand_1, OperandType operand_2> 142 OperandType operand_1, OperandType operand_2>
127 struct BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2> { 143 struct BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2> {
128 static const OperandType* GetOperandTypes() { 144 static constexpr OperandType kOperandTypes[] = {operand_0, operand_1,
129 static const OperandType operand_types[] = {operand_0, operand_1, operand_2, 145 operand_2};
130 OperandType::kNone}; 146 static constexpr OperandTypeInfo kOperandTypeInfos[] = {
131 return operand_types; 147 OperandTraits<operand_0>::kOperandTypeInfo,
132 } 148 OperandTraits<operand_1>::kOperandTypeInfo,
133 149 OperandTraits<operand_2>::kOperandTypeInfo};
134 static const OperandTypeInfo* GetOperandTypeInfos() { 150 static constexpr OperandSize kSingleScaleOperandSizes[] = {
135 static const OperandTypeInfo operand_type_infos[] = { 151 OperandScaler<operand_0, OperandScale::kSingle>::kOperandSize,
136 OperandTraits<operand_0>::kOperandTypeInfo, 152 OperandScaler<operand_1, OperandScale::kSingle>::kOperandSize,
137 OperandTraits<operand_1>::kOperandTypeInfo, 153 OperandScaler<operand_2, OperandScale::kSingle>::kOperandSize};
138 OperandTraits<operand_2>::kOperandTypeInfo, OperandTypeInfo::kNone}; 154 static constexpr OperandSize kDoubleScaleOperandSizes[] = {
139 return operand_type_infos; 155 OperandScaler<operand_0, OperandScale::kDouble>::kOperandSize,
140 } 156 OperandScaler<operand_1, OperandScale::kDouble>::kOperandSize,
141 157 OperandScaler<operand_2, OperandScale::kDouble>::kOperandSize};
142 template <OperandType ot> 158 static constexpr OperandSize kQuadrupleScaleOperandSizes[] = {
143 static inline bool HasAnyOperandsOfType() { 159 OperandScaler<operand_0, OperandScale::kQuadruple>::kOperandSize,
144 return operand_0 == ot || operand_1 == ot || operand_2 == ot; 160 OperandScaler<operand_1, OperandScale::kQuadruple>::kOperandSize,
145 } 161 OperandScaler<operand_2, OperandScale::kQuadruple>::kOperandSize};
146 162 static constexpr int kSingleScaleSize =
147 static inline bool IsScalable() { 163 1 + OperandScaler<operand_0, OperandScale::kSingle>::kSize +
148 return (OperandTraits<operand_0>::TypeInfoTraits::kIsScalable | 164 OperandScaler<operand_1, OperandScale::kSingle>::kSize +
149 OperandTraits<operand_1>::TypeInfoTraits::kIsScalable | 165 OperandScaler<operand_2, OperandScale::kSingle>::kSize;
150 OperandTraits<operand_2>::TypeInfoTraits::kIsScalable); 166 static constexpr int kDoubleScaleSize =
151 } 167 1 + OperandScaler<operand_0, OperandScale::kDouble>::kSize +
152 168 OperandScaler<operand_1, OperandScale::kDouble>::kSize +
169 OperandScaler<operand_2, OperandScale::kDouble>::kSize;
170 static constexpr int kQuadrupleScaleSize =
171 1 + OperandScaler<operand_0, OperandScale::kQuadruple>::kSize +
172 OperandScaler<operand_1, OperandScale::kQuadruple>::kSize +
173 OperandScaler<operand_2, OperandScale::kQuadruple>::kSize;
153 static const AccumulatorUse kAccumulatorUse = accumulator_use; 174 static const AccumulatorUse kAccumulatorUse = accumulator_use;
154 static const int kOperandCount = 3; 175 static const int kOperandCount = 3;
155 static const int kRegisterOperandCount = 176 };
156 RegisterOperandTraits<operand_0>::kIsRegisterOperand + 177
157 RegisterOperandTraits<operand_1>::kIsRegisterOperand + 178 template <AccumulatorUse accumulator_use, OperandType operand_0,
158 RegisterOperandTraits<operand_2>::kIsRegisterOperand; 179 OperandType operand_1, OperandType operand_2>
159 }; 180 constexpr OperandType BytecodeTraits<accumulator_use, operand_0, operand_1,
181 operand_2>::kOperandTypes[];
182 template <AccumulatorUse accumulator_use, OperandType operand_0,
183 OperandType operand_1, OperandType operand_2>
184 constexpr OperandTypeInfo BytecodeTraits<accumulator_use, operand_0, operand_1,
185 operand_2>::kOperandTypeInfos[];
186 template <AccumulatorUse accumulator_use, OperandType operand_0,
187 OperandType operand_1, OperandType operand_2>
188 constexpr OperandSize BytecodeTraits<accumulator_use, operand_0, operand_1,
189 operand_2>::kSingleScaleOperandSizes[];
190 template <AccumulatorUse accumulator_use, OperandType operand_0,
191 OperandType operand_1, OperandType operand_2>
192 constexpr OperandSize BytecodeTraits<accumulator_use, operand_0, operand_1,
193 operand_2>::kDoubleScaleOperandSizes[];
194 template <AccumulatorUse accumulator_use, OperandType operand_0,
195 OperandType operand_1, OperandType operand_2>
196 constexpr OperandSize BytecodeTraits<accumulator_use, operand_0, operand_1,
197 operand_2>::kQuadrupleScaleOperandSizes[];
160 198
161 template <AccumulatorUse accumulator_use, OperandType operand_0, 199 template <AccumulatorUse accumulator_use, OperandType operand_0,
162 OperandType operand_1> 200 OperandType operand_1>
163 struct BytecodeTraits<accumulator_use, operand_0, operand_1> { 201 struct BytecodeTraits<accumulator_use, operand_0, operand_1> {
164 static const OperandType* GetOperandTypes() { 202 static constexpr OperandType kOperandTypes[] = {operand_0, operand_1};
165 static const OperandType operand_types[] = {operand_0, operand_1, 203 static constexpr OperandTypeInfo kOperandTypeInfos[] = {
166 OperandType::kNone}; 204 OperandTraits<operand_0>::kOperandTypeInfo,
167 return operand_types; 205 OperandTraits<operand_1>::kOperandTypeInfo};
168 } 206 static constexpr OperandSize kSingleScaleOperandSizes[] = {
169 207 OperandScaler<operand_0, OperandScale::kSingle>::kOperandSize,
170 static const OperandTypeInfo* GetOperandTypeInfos() { 208 OperandScaler<operand_1, OperandScale::kSingle>::kOperandSize};
171 static const OperandTypeInfo operand_type_infos[] = { 209 static constexpr OperandSize kDoubleScaleOperandSizes[] = {
172 OperandTraits<operand_0>::kOperandTypeInfo, 210 OperandScaler<operand_0, OperandScale::kDouble>::kOperandSize,
173 OperandTraits<operand_1>::kOperandTypeInfo, OperandTypeInfo::kNone}; 211 OperandScaler<operand_1, OperandScale::kDouble>::kOperandSize};
174 return operand_type_infos; 212 static constexpr OperandSize kQuadrupleScaleOperandSizes[] = {
175 } 213 OperandScaler<operand_0, OperandScale::kQuadruple>::kOperandSize,
176 214 OperandScaler<operand_1, OperandScale::kQuadruple>::kOperandSize};
177 template <OperandType ot> 215 static constexpr int kSingleScaleSize =
178 static inline bool HasAnyOperandsOfType() { 216 1 + OperandScaler<operand_0, OperandScale::kSingle>::kSize +
179 return operand_0 == ot || operand_1 == ot; 217 OperandScaler<operand_1, OperandScale::kSingle>::kSize;
180 } 218 static constexpr int kDoubleScaleSize =
181 219 1 + OperandScaler<operand_0, OperandScale::kDouble>::kSize +
182 static inline bool IsScalable() { 220 OperandScaler<operand_1, OperandScale::kDouble>::kSize;
183 return (OperandTraits<operand_0>::TypeInfoTraits::kIsScalable | 221 static constexpr int kQuadrupleScaleSize =
184 OperandTraits<operand_1>::TypeInfoTraits::kIsScalable); 222 1 + OperandScaler<operand_0, OperandScale::kQuadruple>::kSize +
185 } 223 OperandScaler<operand_1, OperandScale::kQuadruple>::kSize;
186 224 static constexpr AccumulatorUse kAccumulatorUse = accumulator_use;
187 static const AccumulatorUse kAccumulatorUse = accumulator_use; 225 static constexpr int kOperandCount = 2;
188 static const int kOperandCount = 2; 226 };
189 static const int kRegisterOperandCount = 227
190 RegisterOperandTraits<operand_0>::kIsRegisterOperand + 228 template <AccumulatorUse accumulator_use, OperandType operand_0,
191 RegisterOperandTraits<operand_1>::kIsRegisterOperand; 229 OperandType operand_1>
192 }; 230 constexpr OperandType
231 BytecodeTraits<accumulator_use, operand_0, operand_1>::kOperandTypes[];
232 template <AccumulatorUse accumulator_use, OperandType operand_0,
233 OperandType operand_1>
234 constexpr OperandTypeInfo
235 BytecodeTraits<accumulator_use, operand_0, operand_1>::kOperandTypeInfos[];
236 template <AccumulatorUse accumulator_use, OperandType operand_0,
237 OperandType operand_1>
238 constexpr OperandSize BytecodeTraits<accumulator_use, operand_0,
239 operand_1>::kSingleScaleOperandSizes[];
240 template <AccumulatorUse accumulator_use, OperandType operand_0,
241 OperandType operand_1>
242 constexpr OperandSize BytecodeTraits<accumulator_use, operand_0,
243 operand_1>::kDoubleScaleOperandSizes[];
244 template <AccumulatorUse accumulator_use, OperandType operand_0,
245 OperandType operand_1>
246 constexpr OperandSize BytecodeTraits<accumulator_use, operand_0,
247 operand_1>::kQuadrupleScaleOperandSizes[];
193 248
194 template <AccumulatorUse accumulator_use, OperandType operand_0> 249 template <AccumulatorUse accumulator_use, OperandType operand_0>
195 struct BytecodeTraits<accumulator_use, operand_0> { 250 struct BytecodeTraits<accumulator_use, operand_0> {
196 static const OperandType* GetOperandTypes() { 251 static constexpr OperandType kOperandTypes[] = {operand_0};
197 static const OperandType operand_types[] = {operand_0, OperandType::kNone}; 252 static constexpr OperandTypeInfo kOperandTypeInfos[] = {
198 return operand_types; 253 OperandTraits<operand_0>::kOperandTypeInfo};
199 } 254 static constexpr OperandSize kSingleScaleOperandSizes[] = {
200 255 OperandScaler<operand_0, OperandScale::kSingle>::kOperandSize};
201 static const OperandTypeInfo* GetOperandTypeInfos() { 256 static constexpr OperandSize kDoubleScaleOperandSizes[] = {
202 static const OperandTypeInfo operand_type_infos[] = { 257 OperandScaler<operand_0, OperandScale::kDouble>::kOperandSize};
203 OperandTraits<operand_0>::kOperandTypeInfo, OperandTypeInfo::kNone}; 258 static constexpr OperandSize kQuadrupleScaleOperandSizes[] = {
204 return operand_type_infos; 259 OperandScaler<operand_0, OperandScale::kQuadruple>::kOperandSize};
205 } 260 static constexpr int kSingleScaleSize =
206 261 1 + OperandScaler<operand_0, OperandScale::kSingle>::kSize;
207 template <OperandType ot> 262 static constexpr int kDoubleScaleSize =
208 static inline bool HasAnyOperandsOfType() { 263 1 + OperandScaler<operand_0, OperandScale::kDouble>::kSize;
209 return operand_0 == ot; 264 static constexpr int kQuadrupleScaleSize =
210 } 265 1 + OperandScaler<operand_0, OperandScale::kQuadruple>::kSize;
211 266 static constexpr AccumulatorUse kAccumulatorUse = accumulator_use;
212 static inline bool IsScalable() { 267 static constexpr int kOperandCount = 1;
213 return OperandTraits<operand_0>::TypeInfoTraits::kIsScalable; 268 };
214 } 269
215 270 template <AccumulatorUse accumulator_use, OperandType operand_0>
216 static const AccumulatorUse kAccumulatorUse = accumulator_use; 271 constexpr OperandType
217 static const int kOperandCount = 1; 272 BytecodeTraits<accumulator_use, operand_0>::kOperandTypes[];
218 static const int kRegisterOperandCount = 273 template <AccumulatorUse accumulator_use, OperandType operand_0>
219 RegisterOperandTraits<operand_0>::kIsRegisterOperand; 274 constexpr OperandTypeInfo
220 }; 275 BytecodeTraits<accumulator_use, operand_0>::kOperandTypeInfos[];
276 template <AccumulatorUse accumulator_use, OperandType operand_0>
277 constexpr OperandSize
278 BytecodeTraits<accumulator_use, operand_0>::kSingleScaleOperandSizes[];
279 template <AccumulatorUse accumulator_use, OperandType operand_0>
280 constexpr OperandSize
281 BytecodeTraits<accumulator_use, operand_0>::kDoubleScaleOperandSizes[];
282 template <AccumulatorUse accumulator_use, OperandType operand_0>
283 constexpr OperandSize
284 BytecodeTraits<accumulator_use, operand_0>::kQuadrupleScaleOperandSizes[];
221 285
222 template <AccumulatorUse accumulator_use> 286 template <AccumulatorUse accumulator_use>
223 struct BytecodeTraits<accumulator_use> { 287 struct BytecodeTraits<accumulator_use> {
224 static const OperandType* GetOperandTypes() { 288 static constexpr OperandType kOperandTypes[] = {OperandType::kNone};
225 static const OperandType operand_types[] = {OperandType::kNone}; 289 static constexpr OperandTypeInfo kOperandTypeInfos[] = {
226 return operand_types; 290 OperandTypeInfo::kNone};
227 } 291 static constexpr OperandSize kSingleScaleOperandSizes[] = {
228 292 OperandSize::kNone};
229 static const OperandTypeInfo* GetOperandTypeInfos() { 293 static constexpr OperandSize kDoubleScaleOperandSizes[] = {
230 static const OperandTypeInfo operand_type_infos[] = { 294 OperandSize::kNone};
231 OperandTypeInfo::kNone}; 295 static constexpr OperandSize kQuadrupleScaleOperandSizes[] = {
232 return operand_type_infos; 296 OperandSize::kNone};
233 } 297 static constexpr int kSingleScaleSize = 1;
234 298 static constexpr int kDoubleScaleSize = 1;
235 template <OperandType ot> 299 static constexpr int kQuadrupleScaleSize = 1;
236 static inline bool HasAnyOperandsOfType() { 300 static constexpr AccumulatorUse kAccumulatorUse = accumulator_use;
237 return false; 301 static constexpr int kOperandCount = 0;
238 } 302 };
239 303
240 static inline bool IsScalable() { return false; } 304 template <AccumulatorUse accumulator_use>
241 305 constexpr OperandType BytecodeTraits<accumulator_use>::kOperandTypes[];
242 static const AccumulatorUse kAccumulatorUse = accumulator_use; 306 template <AccumulatorUse accumulator_use>
243 static const int kOperandCount = 0; 307 constexpr OperandTypeInfo BytecodeTraits<accumulator_use>::kOperandTypeInfos[];
244 static const int kRegisterOperandCount = 0; 308 template <AccumulatorUse accumulator_use>
245 }; 309 constexpr OperandSize
246 310 BytecodeTraits<accumulator_use>::kSingleScaleOperandSizes[];
247 static OperandSize ScaledOperandSize(OperandType operand_type, 311 template <AccumulatorUse accumulator_use>
248 OperandScale operand_scale) { 312 constexpr OperandSize
249 STATIC_ASSERT(static_cast<int>(OperandScale::kQuadruple) == 4 && 313 BytecodeTraits<accumulator_use>::kDoubleScaleOperandSizes[];
250 OperandScale::kLast == OperandScale::kQuadruple); 314 template <AccumulatorUse accumulator_use>
251 int index = static_cast<int>(operand_scale) >> 1; 315 constexpr OperandSize
252 switch (operand_type) { 316 BytecodeTraits<accumulator_use>::kQuadrupleScaleOperandSizes[];
253 #define CASE(Name, TypeInfo) \
254 case OperandType::k##Name: { \
255 static const OperandSize kOperandSizes[] = { \
256 OperandScaler<OperandType::k##Name, \
257 OperandScale::kSingle>::kOperandSize, \
258 OperandScaler<OperandType::k##Name, \
259 OperandScale::kDouble>::kOperandSize, \
260 OperandScaler<OperandType::k##Name, \
261 OperandScale::kQuadruple>::kOperandSize}; \
262 return kOperandSizes[index]; \
263 }
264 OPERAND_TYPE_LIST(CASE)
265 #undef CASE
266 }
267 UNREACHABLE();
268 return OperandSize::kNone;
269 }
270 317
271 } // namespace interpreter 318 } // namespace interpreter
272 } // namespace internal 319 } // namespace internal
273 } // namespace v8 320 } // namespace v8
274 321
275 #endif // V8_INTERPRETER_BYTECODE_TRAITS_H_ 322 #endif // V8_INTERPRETER_BYTECODE_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698