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

Side by Side Diff: src/interpreter/bytecodes.h

Issue 1633153002: [interpreter] Reduce move operations for wide register support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove RegisterOperandIsMovable from RegisterMover interface Created 4 years, 11 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-array-iterator.cc ('k') | src/interpreter/bytecodes.cc » ('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_BYTECODES_H_ 5 #ifndef V8_INTERPRETER_BYTECODES_H_
6 #define V8_INTERPRETER_BYTECODES_H_ 6 #define V8_INTERPRETER_BYTECODES_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 // Clients of this interface shouldn't depend on lots of interpreter internals. 10 // Clients of this interface shouldn't depend on lots of interpreter internals.
11 // Do not include anything from src/interpreter here! 11 // Do not include anything from src/interpreter here!
12 #include "src/utils.h" 12 #include "src/utils.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 namespace interpreter { 16 namespace interpreter {
17 17
18 #define INVALID_OPERAND_TYPE_LIST(V) \ 18 #define INVALID_OPERAND_TYPE_LIST(V) \
19 V(None, OperandSize::kNone) 19 V(None, OperandSize::kNone)
20 20
21 #define REGISTER_OPERAND_TYPE_LIST(V) \ 21 #define REGISTER_INPUT_OPERAND_TYPE_LIST(V) \
22 /* Byte operands. */ \ 22 /* Byte operands. */ \
23 V(MaybeReg8, OperandSize::kByte) \ 23 V(MaybeReg8, OperandSize::kByte) \
24 V(Reg8, OperandSize::kByte) \ 24 V(Reg8, OperandSize::kByte) \
25 V(RegPair8, OperandSize::kByte) \ 25 V(RegPair8, OperandSize::kByte) \
26 V(RegTriple8, OperandSize::kByte) \ 26 /* Short operands. */ \
27 /* Short operands. */ \ 27 V(MaybeReg16, OperandSize::kShort) \
28 V(MaybeReg16, OperandSize::kShort) \ 28 V(Reg16, OperandSize::kShort) \
29 V(Reg16, OperandSize::kShort) \ 29 V(RegPair16, OperandSize::kShort)
30 V(RegPair16, OperandSize::kShort) \ 30
31 V(RegTriple16, OperandSize::kShort) 31 #define REGISTER_OUTPUT_OPERAND_TYPE_LIST(V) \
32 /* Byte operands. */ \
33 V(RegOut8, OperandSize::kByte) \
34 V(RegOutPair8, OperandSize::kByte) \
35 V(RegOutTriple8, OperandSize::kByte) \
36 /* Short operands. */ \
37 V(RegOut16, OperandSize::kShort) \
38 V(RegOutPair16, OperandSize::kShort) \
39 V(RegOutTriple16, OperandSize::kShort)
32 40
33 #define SCALAR_OPERAND_TYPE_LIST(V) \ 41 #define SCALAR_OPERAND_TYPE_LIST(V) \
34 /* Byte operands. */ \ 42 /* Byte operands. */ \
35 V(Idx8, OperandSize::kByte) \ 43 V(Idx8, OperandSize::kByte) \
36 V(Imm8, OperandSize::kByte) \ 44 V(Imm8, OperandSize::kByte) \
37 V(RegCount8, OperandSize::kByte) \ 45 V(RegCount8, OperandSize::kByte) \
38 /* Short operands. */ \ 46 /* Short operands. */ \
39 V(Idx16, OperandSize::kShort) \ 47 V(Idx16, OperandSize::kShort) \
40 V(RegCount16, OperandSize::kShort) 48 V(RegCount16, OperandSize::kShort)
41 49
50 #define REGISTER_OPERAND_TYPE_LIST(V) \
51 REGISTER_INPUT_OPERAND_TYPE_LIST(V) \
52 REGISTER_OUTPUT_OPERAND_TYPE_LIST(V)
53
54 #define NON_REGISTER_OPERAND_TYPE_LIST(V) \
55 INVALID_OPERAND_TYPE_LIST(V) \
56 SCALAR_OPERAND_TYPE_LIST(V)
57
42 // The list of operand types used by bytecodes. 58 // The list of operand types used by bytecodes.
43 #define OPERAND_TYPE_LIST(V) \ 59 #define OPERAND_TYPE_LIST(V) \
44 INVALID_OPERAND_TYPE_LIST(V) \ 60 NON_REGISTER_OPERAND_TYPE_LIST(V) \
45 REGISTER_OPERAND_TYPE_LIST(V) \ 61 REGISTER_OPERAND_TYPE_LIST(V)
46 SCALAR_OPERAND_TYPE_LIST(V)
47 62
48 // The list of bytecodes which are interpreted by the interpreter. 63 // The list of bytecodes which are interpreted by the interpreter.
49 #define BYTECODE_LIST(V) \ 64 #define BYTECODE_LIST(V) \
50 \ 65 \
51 /* Loading the accumulator */ \ 66 /* Loading the accumulator */ \
52 V(LdaZero, OperandType::kNone) \ 67 V(LdaZero, OperandType::kNone) \
53 V(LdaSmi8, OperandType::kImm8) \ 68 V(LdaSmi8, OperandType::kImm8) \
54 V(LdaUndefined, OperandType::kNone) \ 69 V(LdaUndefined, OperandType::kNone) \
55 V(LdaNull, OperandType::kNone) \ 70 V(LdaNull, OperandType::kNone) \
56 V(LdaTheHole, OperandType::kNone) \ 71 V(LdaTheHole, OperandType::kNone) \
(...skipping 29 matching lines...) Expand all
86 V(LdaLookupSlotInsideTypeof, OperandType::kIdx8) \ 101 V(LdaLookupSlotInsideTypeof, OperandType::kIdx8) \
87 V(LdaLookupSlotWide, OperandType::kIdx16) \ 102 V(LdaLookupSlotWide, OperandType::kIdx16) \
88 V(LdaLookupSlotInsideTypeofWide, OperandType::kIdx16) \ 103 V(LdaLookupSlotInsideTypeofWide, OperandType::kIdx16) \
89 V(StaLookupSlotSloppy, OperandType::kIdx8) \ 104 V(StaLookupSlotSloppy, OperandType::kIdx8) \
90 V(StaLookupSlotStrict, OperandType::kIdx8) \ 105 V(StaLookupSlotStrict, OperandType::kIdx8) \
91 V(StaLookupSlotSloppyWide, OperandType::kIdx16) \ 106 V(StaLookupSlotSloppyWide, OperandType::kIdx16) \
92 V(StaLookupSlotStrictWide, OperandType::kIdx16) \ 107 V(StaLookupSlotStrictWide, OperandType::kIdx16) \
93 \ 108 \
94 /* Register-accumulator transfers */ \ 109 /* Register-accumulator transfers */ \
95 V(Ldar, OperandType::kReg8) \ 110 V(Ldar, OperandType::kReg8) \
96 V(Star, OperandType::kReg8) \ 111 V(Star, OperandType::kRegOut8) \
97 \ 112 \
98 /* Register-register transfers */ \ 113 /* Register-register transfers */ \
99 V(Mov, OperandType::kReg8, OperandType::kReg8) \ 114 V(Mov, OperandType::kReg8, OperandType::kRegOut8) \
100 V(MovWide, OperandType::kReg16, OperandType::kReg16) \ 115 V(MovWide, OperandType::kReg16, OperandType::kRegOut16) \
101 \ 116 \
102 /* LoadIC operations */ \ 117 /* LoadIC operations */ \
103 V(LoadICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 118 V(LoadICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \
104 V(LoadICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 119 V(LoadICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \
105 V(KeyedLoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \ 120 V(KeyedLoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \
106 V(KeyedLoadICStrict, OperandType::kReg8, OperandType::kIdx8) \ 121 V(KeyedLoadICStrict, OperandType::kReg8, OperandType::kIdx8) \
107 V(LoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ 122 V(LoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \
108 OperandType::kIdx16) \ 123 OperandType::kIdx16) \
109 V(LoadICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ 124 V(LoadICStrictWide, OperandType::kReg8, OperandType::kIdx16, \
110 OperandType::kIdx16) \ 125 OperandType::kIdx16) \
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 /* Call operations */ \ 167 /* Call operations */ \
153 V(Call, OperandType::kReg8, OperandType::kReg8, OperandType::kRegCount8, \ 168 V(Call, OperandType::kReg8, OperandType::kReg8, OperandType::kRegCount8, \
154 OperandType::kIdx8) \ 169 OperandType::kIdx8) \
155 V(CallWide, OperandType::kReg16, OperandType::kReg16, \ 170 V(CallWide, OperandType::kReg16, OperandType::kReg16, \
156 OperandType::kRegCount16, OperandType::kIdx16) \ 171 OperandType::kRegCount16, OperandType::kIdx16) \
157 V(CallRuntime, OperandType::kIdx16, OperandType::kMaybeReg8, \ 172 V(CallRuntime, OperandType::kIdx16, OperandType::kMaybeReg8, \
158 OperandType::kRegCount8) \ 173 OperandType::kRegCount8) \
159 V(CallRuntimeWide, OperandType::kIdx16, OperandType::kMaybeReg16, \ 174 V(CallRuntimeWide, OperandType::kIdx16, OperandType::kMaybeReg16, \
160 OperandType::kRegCount8) \ 175 OperandType::kRegCount8) \
161 V(CallRuntimeForPair, OperandType::kIdx16, OperandType::kMaybeReg8, \ 176 V(CallRuntimeForPair, OperandType::kIdx16, OperandType::kMaybeReg8, \
162 OperandType::kRegCount8, OperandType::kRegPair8) \ 177 OperandType::kRegCount8, OperandType::kRegOutPair8) \
163 V(CallRuntimeForPairWide, OperandType::kIdx16, OperandType::kMaybeReg16, \ 178 V(CallRuntimeForPairWide, OperandType::kIdx16, OperandType::kMaybeReg16, \
164 OperandType::kRegCount8, OperandType::kRegPair16) \ 179 OperandType::kRegCount8, OperandType::kRegOutPair16) \
165 V(CallJSRuntime, OperandType::kIdx16, OperandType::kReg8, \ 180 V(CallJSRuntime, OperandType::kIdx16, OperandType::kReg8, \
166 OperandType::kRegCount8) \ 181 OperandType::kRegCount8) \
167 V(CallJSRuntimeWide, OperandType::kIdx16, OperandType::kReg16, \ 182 V(CallJSRuntimeWide, OperandType::kIdx16, OperandType::kReg16, \
168 OperandType::kRegCount16) \ 183 OperandType::kRegCount16) \
169 \ 184 \
170 /* New operator */ \ 185 /* New operator */ \
171 V(New, OperandType::kReg8, OperandType::kMaybeReg8, OperandType::kRegCount8) \ 186 V(New, OperandType::kReg8, OperandType::kMaybeReg8, OperandType::kRegCount8) \
172 V(NewWide, OperandType::kReg16, OperandType::kMaybeReg16, \ 187 V(NewWide, OperandType::kReg16, OperandType::kMaybeReg16, \
173 OperandType::kRegCount16) \ 188 OperandType::kRegCount16) \
174 \ 189 \
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 V(JumpIfToBooleanFalseConstant, OperandType::kIdx8) \ 243 V(JumpIfToBooleanFalseConstant, OperandType::kIdx8) \
229 V(JumpIfToBooleanFalseConstantWide, OperandType::kIdx16) \ 244 V(JumpIfToBooleanFalseConstantWide, OperandType::kIdx16) \
230 V(JumpIfNull, OperandType::kImm8) \ 245 V(JumpIfNull, OperandType::kImm8) \
231 V(JumpIfNullConstant, OperandType::kIdx8) \ 246 V(JumpIfNullConstant, OperandType::kIdx8) \
232 V(JumpIfNullConstantWide, OperandType::kIdx16) \ 247 V(JumpIfNullConstantWide, OperandType::kIdx16) \
233 V(JumpIfUndefined, OperandType::kImm8) \ 248 V(JumpIfUndefined, OperandType::kImm8) \
234 V(JumpIfUndefinedConstant, OperandType::kIdx8) \ 249 V(JumpIfUndefinedConstant, OperandType::kIdx8) \
235 V(JumpIfUndefinedConstantWide, OperandType::kIdx16) \ 250 V(JumpIfUndefinedConstantWide, OperandType::kIdx16) \
236 \ 251 \
237 /* Complex flow control For..in */ \ 252 /* Complex flow control For..in */ \
238 V(ForInPrepare, OperandType::kRegTriple8) \ 253 V(ForInPrepare, OperandType::kRegOutTriple8) \
239 V(ForInPrepareWide, OperandType::kRegTriple16) \ 254 V(ForInPrepareWide, OperandType::kRegOutTriple16) \
240 V(ForInDone, OperandType::kReg8, OperandType::kReg8) \ 255 V(ForInDone, OperandType::kReg8, OperandType::kReg8) \
241 V(ForInNext, OperandType::kReg8, OperandType::kReg8, OperandType::kRegPair8) \ 256 V(ForInNext, OperandType::kReg8, OperandType::kReg8, OperandType::kRegPair8) \
242 V(ForInNextWide, OperandType::kReg16, OperandType::kReg16, \ 257 V(ForInNextWide, OperandType::kReg16, OperandType::kReg16, \
243 OperandType::kRegPair16) \ 258 OperandType::kRegPair16) \
244 V(ForInStep, OperandType::kReg8) \ 259 V(ForInStep, OperandType::kReg8) \
245 \ 260 \
246 /* Non-local flow control */ \ 261 /* Non-local flow control */ \
247 V(Throw, OperandType::kNone) \ 262 V(Throw, OperandType::kNone) \
248 V(ReThrow, OperandType::kNone) \ 263 V(ReThrow, OperandType::kNone) \
249 V(Return, OperandType::kNone) 264 V(Return, OperandType::kNone)
250 265
251
252 // Enumeration of the size classes of operand types used by bytecodes. 266 // Enumeration of the size classes of operand types used by bytecodes.
253 enum class OperandSize : uint8_t { 267 enum class OperandSize : uint8_t {
254 kNone = 0, 268 kNone = 0,
255 kByte = 1, 269 kByte = 1,
256 kShort = 2, 270 kShort = 2,
257 }; 271 };
258 272
259 273
260 // Enumeration of operand types used by bytecodes. 274 // Enumeration of operand types used by bytecodes.
261 enum class OperandType : uint8_t { 275 enum class OperandType : uint8_t {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 389
376 // Returns bytecode for |value|. 390 // Returns bytecode for |value|.
377 static Bytecode FromByte(uint8_t value); 391 static Bytecode FromByte(uint8_t value);
378 392
379 // Returns the number of operands expected by |bytecode|. 393 // Returns the number of operands expected by |bytecode|.
380 static int NumberOfOperands(Bytecode bytecode); 394 static int NumberOfOperands(Bytecode bytecode);
381 395
382 // Returns the number of register operands expected by |bytecode|. 396 // Returns the number of register operands expected by |bytecode|.
383 static int NumberOfRegisterOperands(Bytecode bytecode); 397 static int NumberOfRegisterOperands(Bytecode bytecode);
384 398
385 // Return the i-th operand of |bytecode|. 399 // Returns the i-th operand of |bytecode|.
386 static OperandType GetOperandType(Bytecode bytecode, int i); 400 static OperandType GetOperandType(Bytecode bytecode, int i);
387 401
388 // Return the size of the i-th operand of |bytecode|. 402 // Returns the size of the i-th operand of |bytecode|.
389 static OperandSize GetOperandSize(Bytecode bytecode, int i); 403 static OperandSize GetOperandSize(Bytecode bytecode, int i);
390 404
391 // Returns the offset of the i-th operand of |bytecode| relative to the start 405 // Returns the offset of the i-th operand of |bytecode| relative to the start
392 // of the bytecode. 406 // of the bytecode.
393 static int GetOperandOffset(Bytecode bytecode, int i); 407 static int GetOperandOffset(Bytecode bytecode, int i);
394 408
395 // Returns a zero-based bitmap of the register operand positions of 409 // Returns a zero-based bitmap of the register operand positions of
396 // |bytecode|. 410 // |bytecode|.
397 static int GetRegisterOperandBitmap(Bytecode bytecode); 411 static int GetRegisterOperandBitmap(Bytecode bytecode);
398 412
(...skipping 24 matching lines...) Expand all
423 static bool IsJumpImmediate(Bytecode bytecode); 437 static bool IsJumpImmediate(Bytecode bytecode);
424 438
425 // Returns true if the bytecode is a jump or conditional jump taking a 439 // Returns true if the bytecode is a jump or conditional jump taking a
426 // constant pool entry (OperandType::kIdx8). 440 // constant pool entry (OperandType::kIdx8).
427 static bool IsJumpConstant(Bytecode bytecode); 441 static bool IsJumpConstant(Bytecode bytecode);
428 442
429 // Returns true if the bytecode is a jump or conditional jump taking a 443 // Returns true if the bytecode is a jump or conditional jump taking a
430 // constant pool entry (OperandType::kIdx16). 444 // constant pool entry (OperandType::kIdx16).
431 static bool IsJumpConstantWide(Bytecode bytecode); 445 static bool IsJumpConstantWide(Bytecode bytecode);
432 446
433 // Return true if the bytecode is a jump or conditional jump taking 447 // Returns true if the bytecode is a jump or conditional jump taking
434 // any kind of operand. 448 // any kind of operand.
435 static bool IsJump(Bytecode bytecode); 449 static bool IsJump(Bytecode bytecode);
436 450
437 // Return true if the bytecode is a conditional jump, a jump, or a return. 451 // Returns true if the bytecode is a conditional jump, a jump, or a return.
438 static bool IsJumpOrReturn(Bytecode bytecode); 452 static bool IsJumpOrReturn(Bytecode bytecode);
439 453
454 // Returns true if |operand_type| is any type of register operand.
455 static bool IsRegisterOperandType(OperandType operand_type);
456
457 // Returns true if |operand_type| represents a register used as an input.
458 static bool IsRegisterInputOperandType(OperandType operand_type);
459
460 // Returns true if |operand_type| represents a register used as an output.
461 static bool IsRegisterOutputOperandType(OperandType operand_type);
462
440 // Decode a single bytecode and operands to |os|. 463 // Decode a single bytecode and operands to |os|.
441 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start, 464 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start,
442 int number_of_parameters); 465 int number_of_parameters);
443 466
444 private: 467 private:
445 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes); 468 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes);
446 }; 469 };
447 470
448 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); 471 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode);
449 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); 472 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type);
450 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); 473 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type);
451 474
452 } // namespace interpreter 475 } // namespace interpreter
453 } // namespace internal 476 } // namespace internal
454 } // namespace v8 477 } // namespace v8
455 478
456 #endif // V8_INTERPRETER_BYTECODES_H_ 479 #endif // V8_INTERPRETER_BYTECODES_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-iterator.cc ('k') | src/interpreter/bytecodes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698