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

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

Issue 1997653002: [interpreter] Bytecode register optimizer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Decouple a test from implementation. Created 4 years, 6 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
« no previous file with comments | « src/interpreter/bytecode-register-optimizer.cc ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/bytecodes.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 template <AccumulatorUse accumulator_use, OperandType operand_0, 82 template <AccumulatorUse accumulator_use, OperandType operand_0,
83 OperandType operand_1, OperandType operand_2, OperandType operand_3> 83 OperandType operand_1, OperandType operand_2, OperandType operand_3>
84 struct BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2, 84 struct BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2,
85 operand_3> { 85 operand_3> {
86 static const OperandType* GetOperandTypes() { 86 static const OperandType* GetOperandTypes() {
87 static const OperandType operand_types[] = {operand_0, operand_1, operand_2, 87 static const OperandType operand_types[] = {operand_0, operand_1, operand_2,
88 operand_3, OperandType::kNone}; 88 operand_3, OperandType::kNone};
89 return operand_types; 89 return operand_types;
90 } 90 }
91 91
92 static OperandSize GetOperandSize(int i, OperandScale operand_scale) { 92 static const OperandSize* GetOperandSizes(OperandScale operand_scale) {
93 switch (operand_scale) { 93 switch (operand_scale) {
94 #define CASE(Name, _) \ 94 #define CASE(Name, _) \
95 case OperandScale::k##Name: { \ 95 case OperandScale::k##Name: { \
96 static const OperandSize kOperandSizes[] = { \ 96 static const OperandSize kOperandSizes[] = { \
97 OperandScaler<operand_0, OperandScale::k##Name>::kOperandSize, \ 97 OperandScaler<operand_0, OperandScale::k##Name>::kOperandSize, \
98 OperandScaler<operand_1, OperandScale::k##Name>::kOperandSize, \ 98 OperandScaler<operand_1, OperandScale::k##Name>::kOperandSize, \
99 OperandScaler<operand_2, OperandScale::k##Name>::kOperandSize, \ 99 OperandScaler<operand_2, OperandScale::k##Name>::kOperandSize, \
100 OperandScaler<operand_3, OperandScale::k##Name>::kOperandSize, \ 100 OperandScaler<operand_3, OperandScale::k##Name>::kOperandSize, \
101 }; \ 101 }; \
102 DCHECK_LT(static_cast<size_t>(i), arraysize(kOperandSizes)); \ 102 return kOperandSizes; \
103 return kOperandSizes[i]; \
104 } 103 }
105 OPERAND_SCALE_LIST(CASE) 104 OPERAND_SCALE_LIST(CASE)
106 #undef CASE 105 #undef CASE
107 } 106 }
108 UNREACHABLE(); 107 UNREACHABLE();
109 return OperandSize::kNone; 108 return nullptr;
110 } 109 }
111 110
112 template <OperandType ot> 111 template <OperandType ot>
113 static inline bool HasAnyOperandsOfType() { 112 static inline bool HasAnyOperandsOfType() {
114 return operand_0 == ot || operand_1 == ot || operand_2 == ot || 113 return operand_0 == ot || operand_1 == ot || operand_2 == ot ||
115 operand_3 == ot; 114 operand_3 == ot;
116 } 115 }
117 116
118 static inline bool IsScalable() { 117 static inline bool IsScalable() {
119 return (OperandTraits<operand_0>::TypeInfo::kIsScalable | 118 return (OperandTraits<operand_0>::TypeInfo::kIsScalable |
(...skipping 18 matching lines...) Expand all
138 137
139 template <AccumulatorUse accumulator_use, OperandType operand_0, 138 template <AccumulatorUse accumulator_use, OperandType operand_0,
140 OperandType operand_1, OperandType operand_2> 139 OperandType operand_1, OperandType operand_2>
141 struct BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2> { 140 struct BytecodeTraits<accumulator_use, operand_0, operand_1, operand_2> {
142 static const OperandType* GetOperandTypes() { 141 static const OperandType* GetOperandTypes() {
143 static const OperandType operand_types[] = {operand_0, operand_1, operand_2, 142 static const OperandType operand_types[] = {operand_0, operand_1, operand_2,
144 OperandType::kNone}; 143 OperandType::kNone};
145 return operand_types; 144 return operand_types;
146 } 145 }
147 146
148 static OperandSize GetOperandSize(int i, OperandScale operand_scale) { 147 static const OperandSize* GetOperandSizes(OperandScale operand_scale) {
149 switch (operand_scale) { 148 switch (operand_scale) {
150 #define CASE(Name, _) \ 149 #define CASE(Name, _) \
151 case OperandScale::k##Name: { \ 150 case OperandScale::k##Name: { \
152 static const OperandSize kOperandSizes[] = { \ 151 static const OperandSize kOperandSizes[] = { \
153 OperandScaler<operand_0, OperandScale::k##Name>::kOperandSize, \ 152 OperandScaler<operand_0, OperandScale::k##Name>::kOperandSize, \
154 OperandScaler<operand_1, OperandScale::k##Name>::kOperandSize, \ 153 OperandScaler<operand_1, OperandScale::k##Name>::kOperandSize, \
155 OperandScaler<operand_2, OperandScale::k##Name>::kOperandSize, \ 154 OperandScaler<operand_2, OperandScale::k##Name>::kOperandSize, \
156 }; \ 155 }; \
157 DCHECK_LT(static_cast<size_t>(i), arraysize(kOperandSizes)); \ 156 return kOperandSizes; \
158 return kOperandSizes[i]; \
159 } 157 }
160 OPERAND_SCALE_LIST(CASE) 158 OPERAND_SCALE_LIST(CASE)
161 #undef CASE 159 #undef CASE
162 } 160 }
163 UNREACHABLE(); 161 UNREACHABLE();
164 return OperandSize::kNone; 162 return nullptr;
165 } 163 }
166 164
167 template <OperandType ot> 165 template <OperandType ot>
168 static inline bool HasAnyOperandsOfType() { 166 static inline bool HasAnyOperandsOfType() {
169 return operand_0 == ot || operand_1 == ot || operand_2 == ot; 167 return operand_0 == ot || operand_1 == ot || operand_2 == ot;
170 } 168 }
171 169
172 static inline bool IsScalable() { 170 static inline bool IsScalable() {
173 return (OperandTraits<operand_0>::TypeInfo::kIsScalable | 171 return (OperandTraits<operand_0>::TypeInfo::kIsScalable |
174 OperandTraits<operand_1>::TypeInfo::kIsScalable | 172 OperandTraits<operand_1>::TypeInfo::kIsScalable |
(...skipping 14 matching lines...) Expand all
189 187
190 template <AccumulatorUse accumulator_use, OperandType operand_0, 188 template <AccumulatorUse accumulator_use, OperandType operand_0,
191 OperandType operand_1> 189 OperandType operand_1>
192 struct BytecodeTraits<accumulator_use, operand_0, operand_1> { 190 struct BytecodeTraits<accumulator_use, operand_0, operand_1> {
193 static const OperandType* GetOperandTypes() { 191 static const OperandType* GetOperandTypes() {
194 static const OperandType operand_types[] = {operand_0, operand_1, 192 static const OperandType operand_types[] = {operand_0, operand_1,
195 OperandType::kNone}; 193 OperandType::kNone};
196 return operand_types; 194 return operand_types;
197 } 195 }
198 196
199 static OperandSize GetOperandSize(int i, OperandScale operand_scale) { 197 static const OperandSize* GetOperandSizes(OperandScale operand_scale) {
200 switch (operand_scale) { 198 switch (operand_scale) {
201 #define CASE(Name, _) \ 199 #define CASE(Name, _) \
202 case OperandScale::k##Name: { \ 200 case OperandScale::k##Name: { \
203 static const OperandSize kOperandSizes[] = { \ 201 static const OperandSize kOperandSizes[] = { \
204 OperandScaler<operand_0, OperandScale::k##Name>::kOperandSize, \ 202 OperandScaler<operand_0, OperandScale::k##Name>::kOperandSize, \
205 OperandScaler<operand_1, OperandScale::k##Name>::kOperandSize, \ 203 OperandScaler<operand_1, OperandScale::k##Name>::kOperandSize, \
206 }; \ 204 }; \
207 DCHECK_LT(static_cast<size_t>(i), arraysize(kOperandSizes)); \ 205 return kOperandSizes; \
208 return kOperandSizes[i]; \
209 } 206 }
210 OPERAND_SCALE_LIST(CASE) 207 OPERAND_SCALE_LIST(CASE)
211 #undef CASE 208 #undef CASE
212 } 209 }
213 UNREACHABLE(); 210 UNREACHABLE();
214 return OperandSize::kNone; 211 return nullptr;
215 } 212 }
216 213
217 template <OperandType ot> 214 template <OperandType ot>
218 static inline bool HasAnyOperandsOfType() { 215 static inline bool HasAnyOperandsOfType() {
219 return operand_0 == ot || operand_1 == ot; 216 return operand_0 == ot || operand_1 == ot;
220 } 217 }
221 218
222 static inline bool IsScalable() { 219 static inline bool IsScalable() {
223 return (OperandTraits<operand_0>::TypeInfo::kIsScalable | 220 return (OperandTraits<operand_0>::TypeInfo::kIsScalable |
224 OperandTraits<operand_1>::TypeInfo::kIsScalable); 221 OperandTraits<operand_1>::TypeInfo::kIsScalable);
225 } 222 }
226 223
227 static const AccumulatorUse kAccumulatorUse = accumulator_use; 224 static const AccumulatorUse kAccumulatorUse = accumulator_use;
228 static const int kOperandCount = 2; 225 static const int kOperandCount = 2;
229 static const int kRegisterOperandCount = 226 static const int kRegisterOperandCount =
230 RegisterOperandTraits<operand_0>::kIsRegisterOperand + 227 RegisterOperandTraits<operand_0>::kIsRegisterOperand +
231 RegisterOperandTraits<operand_1>::kIsRegisterOperand; 228 RegisterOperandTraits<operand_1>::kIsRegisterOperand;
232 static const int kRegisterOperandBitmap = 229 static const int kRegisterOperandBitmap =
233 RegisterOperandTraits<operand_0>::kIsRegisterOperand + 230 RegisterOperandTraits<operand_0>::kIsRegisterOperand +
234 (RegisterOperandTraits<operand_1>::kIsRegisterOperand << 1); 231 (RegisterOperandTraits<operand_1>::kIsRegisterOperand << 1);
235 }; 232 };
236 233
237 template <AccumulatorUse accumulator_use, OperandType operand_0> 234 template <AccumulatorUse accumulator_use, OperandType operand_0>
238 struct BytecodeTraits<accumulator_use, operand_0> { 235 struct BytecodeTraits<accumulator_use, operand_0> {
239 static const OperandType* GetOperandTypes() { 236 static const OperandType* GetOperandTypes() {
240 static const OperandType operand_types[] = {operand_0, OperandType::kNone}; 237 static const OperandType operand_types[] = {operand_0, OperandType::kNone};
241 return operand_types; 238 return operand_types;
242 } 239 }
243 240
244 static OperandSize GetOperandSize(int i, OperandScale operand_scale) { 241 static const OperandSize* GetOperandSizes(OperandScale operand_scale) {
245 switch (operand_scale) { 242 switch (operand_scale) {
246 #define CASE(Name, _) \ 243 #define CASE(Name, _) \
247 case OperandScale::k##Name: { \ 244 case OperandScale::k##Name: { \
248 static const OperandSize kOperandSizes[] = { \ 245 static const OperandSize kOperandSizes[] = { \
249 OperandScaler<operand_0, OperandScale::k##Name>::kOperandSize, \ 246 OperandScaler<operand_0, OperandScale::k##Name>::kOperandSize, \
250 }; \ 247 }; \
251 DCHECK_LT(static_cast<size_t>(i), arraysize(kOperandSizes)); \ 248 return kOperandSizes; \
252 return kOperandSizes[i]; \
253 } 249 }
254 OPERAND_SCALE_LIST(CASE) 250 OPERAND_SCALE_LIST(CASE)
255 #undef CASE 251 #undef CASE
256 } 252 }
257 UNREACHABLE(); 253 UNREACHABLE();
258 return OperandSize::kNone; 254 return nullptr;
259 } 255 }
260 256
261 template <OperandType ot> 257 template <OperandType ot>
262 static inline bool HasAnyOperandsOfType() { 258 static inline bool HasAnyOperandsOfType() {
263 return operand_0 == ot; 259 return operand_0 == ot;
264 } 260 }
265 261
266 static inline bool IsScalable() { 262 static inline bool IsScalable() {
267 return OperandTraits<operand_0>::TypeInfo::kIsScalable; 263 return OperandTraits<operand_0>::TypeInfo::kIsScalable;
268 } 264 }
269 265
270 static const AccumulatorUse kAccumulatorUse = accumulator_use; 266 static const AccumulatorUse kAccumulatorUse = accumulator_use;
271 static const int kOperandCount = 1; 267 static const int kOperandCount = 1;
272 static const int kRegisterOperandCount = 268 static const int kRegisterOperandCount =
273 RegisterOperandTraits<operand_0>::kIsRegisterOperand; 269 RegisterOperandTraits<operand_0>::kIsRegisterOperand;
274 static const int kRegisterOperandBitmap = 270 static const int kRegisterOperandBitmap =
275 RegisterOperandTraits<operand_0>::kIsRegisterOperand; 271 RegisterOperandTraits<operand_0>::kIsRegisterOperand;
276 }; 272 };
277 273
278 template <AccumulatorUse accumulator_use> 274 template <AccumulatorUse accumulator_use>
279 struct BytecodeTraits<accumulator_use> { 275 struct BytecodeTraits<accumulator_use> {
280 static const OperandType* GetOperandTypes() { 276 static const OperandType* GetOperandTypes() {
281 static const OperandType operand_types[] = {OperandType::kNone}; 277 static const OperandType operand_types[] = {OperandType::kNone};
282 return operand_types; 278 return operand_types;
283 } 279 }
284 280
285 static OperandSize GetOperandSize(int i, OperandScale operand_scale) { 281 static const OperandSize* GetOperandSizes(OperandScale operand_scale) {
286 UNREACHABLE(); 282 return nullptr;
287 return OperandSize::kNone;
288 } 283 }
289 284
290 template <OperandType ot> 285 template <OperandType ot>
291 static inline bool HasAnyOperandsOfType() { 286 static inline bool HasAnyOperandsOfType() {
292 return false; 287 return false;
293 } 288 }
294 289
295 static inline bool IsScalable() { return false; } 290 static inline bool IsScalable() { return false; }
296 291
297 static const AccumulatorUse kAccumulatorUse = accumulator_use; 292 static const AccumulatorUse kAccumulatorUse = accumulator_use;
(...skipping 24 matching lines...) Expand all
322 } 317 }
323 UNREACHABLE(); 318 UNREACHABLE();
324 return OperandSize::kNone; 319 return OperandSize::kNone;
325 } 320 }
326 321
327 } // namespace interpreter 322 } // namespace interpreter
328 } // namespace internal 323 } // namespace internal
329 } // namespace v8 324 } // namespace v8
330 325
331 #endif // V8_INTERPRETER_BYTECODE_TRAITS_H_ 326 #endif // V8_INTERPRETER_BYTECODE_TRAITS_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-register-optimizer.cc ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698