OLD | NEW |
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. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 #define NON_REGISTER_OPERAND_TYPE_LIST(V) \ | 54 #define NON_REGISTER_OPERAND_TYPE_LIST(V) \ |
55 INVALID_OPERAND_TYPE_LIST(V) \ | 55 INVALID_OPERAND_TYPE_LIST(V) \ |
56 SCALAR_OPERAND_TYPE_LIST(V) | 56 SCALAR_OPERAND_TYPE_LIST(V) |
57 | 57 |
58 // The list of operand types used by bytecodes. | 58 // The list of operand types used by bytecodes. |
59 #define OPERAND_TYPE_LIST(V) \ | 59 #define OPERAND_TYPE_LIST(V) \ |
60 NON_REGISTER_OPERAND_TYPE_LIST(V) \ | 60 NON_REGISTER_OPERAND_TYPE_LIST(V) \ |
61 REGISTER_OPERAND_TYPE_LIST(V) | 61 REGISTER_OPERAND_TYPE_LIST(V) |
62 | 62 |
| 63 // Define one debug break bytecode for each operands size. |
| 64 #define DEBUG_BREAK_BYTECODE_LIST(V) \ |
| 65 V(DebugBreak0, OperandType::kNone) \ |
| 66 V(DebugBreak1, OperandType::kReg8) \ |
| 67 V(DebugBreak2, OperandType::kReg16) \ |
| 68 V(DebugBreak3, OperandType::kReg16, OperandType::kReg8) \ |
| 69 V(DebugBreak4, OperandType::kReg16, OperandType::kReg16) \ |
| 70 V(DebugBreak5, OperandType::kReg16, OperandType::kReg16, OperandType::kReg8) \ |
| 71 V(DebugBreak6, OperandType::kReg16, OperandType::kReg16, \ |
| 72 OperandType::kReg16) \ |
| 73 V(DebugBreak7, OperandType::kReg16, OperandType::kReg16, \ |
| 74 OperandType::kReg16, OperandType::kReg8) \ |
| 75 V(DebugBreak8, OperandType::kReg16, OperandType::kReg16, \ |
| 76 OperandType::kReg16, OperandType::kReg16) |
| 77 |
63 // The list of bytecodes which are interpreted by the interpreter. | 78 // The list of bytecodes which are interpreted by the interpreter. |
64 #define BYTECODE_LIST(V) \ | 79 #define BYTECODE_LIST(V) \ |
65 \ | 80 \ |
66 /* Loading the accumulator */ \ | 81 /* Loading the accumulator */ \ |
67 V(LdaZero, OperandType::kNone) \ | 82 V(LdaZero, OperandType::kNone) \ |
68 V(LdaSmi8, OperandType::kImm8) \ | 83 V(LdaSmi8, OperandType::kImm8) \ |
69 V(LdaUndefined, OperandType::kNone) \ | 84 V(LdaUndefined, OperandType::kNone) \ |
70 V(LdaNull, OperandType::kNone) \ | 85 V(LdaNull, OperandType::kNone) \ |
71 V(LdaTheHole, OperandType::kNone) \ | 86 V(LdaTheHole, OperandType::kNone) \ |
72 V(LdaTrue, OperandType::kNone) \ | 87 V(LdaTrue, OperandType::kNone) \ |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 \ | 272 \ |
258 /* Perform a stack guard check */ \ | 273 /* Perform a stack guard check */ \ |
259 V(StackCheck, OperandType::kNone) \ | 274 V(StackCheck, OperandType::kNone) \ |
260 \ | 275 \ |
261 /* Non-local flow control */ \ | 276 /* Non-local flow control */ \ |
262 V(Throw, OperandType::kNone) \ | 277 V(Throw, OperandType::kNone) \ |
263 V(ReThrow, OperandType::kNone) \ | 278 V(ReThrow, OperandType::kNone) \ |
264 V(Return, OperandType::kNone) \ | 279 V(Return, OperandType::kNone) \ |
265 \ | 280 \ |
266 /* Debugger */ \ | 281 /* Debugger */ \ |
267 V(Debugger, OperandType::kNone) | 282 V(Debugger, OperandType::kNone) \ |
| 283 DEBUG_BREAK_BYTECODE_LIST(V) |
268 | 284 |
269 // Enumeration of the size classes of operand types used by bytecodes. | 285 // Enumeration of the size classes of operand types used by bytecodes. |
270 enum class OperandSize : uint8_t { | 286 enum class OperandSize : uint8_t { |
271 kNone = 0, | 287 kNone = 0, |
272 kByte = 1, | 288 kByte = 1, |
273 kShort = 2, | 289 kShort = 2, |
274 }; | 290 }; |
275 | 291 |
276 | 292 |
277 // Enumeration of operand types used by bytecodes. | 293 // Enumeration of operand types used by bytecodes. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 static OperandSize GetOperandSize(Bytecode bytecode, int i); | 424 static OperandSize GetOperandSize(Bytecode bytecode, int i); |
409 | 425 |
410 // Returns the offset of the i-th operand of |bytecode| relative to the start | 426 // Returns the offset of the i-th operand of |bytecode| relative to the start |
411 // of the bytecode. | 427 // of the bytecode. |
412 static int GetOperandOffset(Bytecode bytecode, int i); | 428 static int GetOperandOffset(Bytecode bytecode, int i); |
413 | 429 |
414 // Returns a zero-based bitmap of the register operand positions of | 430 // Returns a zero-based bitmap of the register operand positions of |
415 // |bytecode|. | 431 // |bytecode|. |
416 static int GetRegisterOperandBitmap(Bytecode bytecode); | 432 static int GetRegisterOperandBitmap(Bytecode bytecode); |
417 | 433 |
| 434 // Returns a debug break bytecode with a matching operand size. |
| 435 static Bytecode GetDebugBreak(Bytecode bytecode); |
| 436 |
418 // Returns the size of the bytecode including its operands. | 437 // Returns the size of the bytecode including its operands. |
419 static int Size(Bytecode bytecode); | 438 static int Size(Bytecode bytecode); |
420 | 439 |
421 // Returns the size of |operand|. | 440 // Returns the size of |operand|. |
422 static OperandSize SizeOfOperand(OperandType operand); | 441 static OperandSize SizeOfOperand(OperandType operand); |
423 | 442 |
424 // Returns true if the bytecode is a conditional jump taking | 443 // Returns true if the bytecode is a conditional jump taking |
425 // an immediate byte operand (OperandType::kImm8). | 444 // an immediate byte operand (OperandType::kImm8). |
426 static bool IsConditionalJumpImmediate(Bytecode bytecode); | 445 static bool IsConditionalJumpImmediate(Bytecode bytecode); |
427 | 446 |
(...skipping 24 matching lines...) Expand all Loading... |
452 // Returns true if the bytecode is a jump or conditional jump taking | 471 // Returns true if the bytecode is a jump or conditional jump taking |
453 // any kind of operand. | 472 // any kind of operand. |
454 static bool IsJump(Bytecode bytecode); | 473 static bool IsJump(Bytecode bytecode); |
455 | 474 |
456 // Returns true if the bytecode is a conditional jump, a jump, or a return. | 475 // Returns true if the bytecode is a conditional jump, a jump, or a return. |
457 static bool IsJumpOrReturn(Bytecode bytecode); | 476 static bool IsJumpOrReturn(Bytecode bytecode); |
458 | 477 |
459 // Returns true if the bytecode is a call or a constructor call. | 478 // Returns true if the bytecode is a call or a constructor call. |
460 static bool IsCallOrNew(Bytecode bytecode); | 479 static bool IsCallOrNew(Bytecode bytecode); |
461 | 480 |
| 481 // Returns true if the bytecode is a debug break. |
| 482 static bool IsDebugBreak(Bytecode bytecode); |
| 483 |
462 // Returns true if |operand_type| is a register index operand (kIdx8/kIdx16). | 484 // Returns true if |operand_type| is a register index operand (kIdx8/kIdx16). |
463 static bool IsIndexOperandType(OperandType operand_type); | 485 static bool IsIndexOperandType(OperandType operand_type); |
464 | 486 |
465 // Returns true if |operand_type| represents an immediate. | 487 // Returns true if |operand_type| represents an immediate. |
466 static bool IsImmediateOperandType(OperandType operand_type); | 488 static bool IsImmediateOperandType(OperandType operand_type); |
467 | 489 |
468 // Returns true if |operand_type| is a register count operand | 490 // Returns true if |operand_type| is a register count operand |
469 // (kRegCount8/kRegCount16). | 491 // (kRegCount8/kRegCount16). |
470 static bool IsRegisterCountOperandType(OperandType operand_type); | 492 static bool IsRegisterCountOperandType(OperandType operand_type); |
471 | 493 |
(...skipping 20 matching lines...) Expand all Loading... |
492 | 514 |
493 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); | 515 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); |
494 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); | 516 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); |
495 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); | 517 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); |
496 | 518 |
497 } // namespace interpreter | 519 } // namespace interpreter |
498 } // namespace internal | 520 } // namespace internal |
499 } // namespace v8 | 521 } // namespace v8 |
500 | 522 |
501 #endif // V8_INTERPRETER_BYTECODES_H_ | 523 #endif // V8_INTERPRETER_BYTECODES_H_ |
OLD | NEW |