Chromium Code Reviews| 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 size. | |
| 64 #define DEBUG_BREAK_BYTECODE_LIST(V) \ | |
| 65 V(DebugBreak1, OperandType::kNone) \ | |
| 66 V(DebugBreak2, OperandType::kReg8) \ | |
| 67 V(DebugBreak3, OperandType::kReg16) \ | |
| 68 V(DebugBreak4, OperandType::kReg16, OperandType::kReg8) \ | |
| 69 V(DebugBreak5, OperandType::kReg16, OperandType::kReg16) \ | |
| 70 V(DebugBreak6, OperandType::kReg16, OperandType::kReg16, OperandType::kReg8) \ | |
| 71 V(DebugBreak7, OperandType::kReg16, OperandType::kReg16, \ | |
| 72 OperandType::kReg16) \ | |
| 73 V(DebugBreak8, OperandType::kReg16, OperandType::kReg16, \ | |
| 74 OperandType::kReg16, OperandType::kReg8) \ | |
| 75 V(DebugBreak9, OperandType::kReg16, OperandType::kReg16, \ | |
| 76 OperandType::kReg16, OperandType::kReg16) | |
|
Yang
2016/02/16 09:22:20
These are more than I originally thought. But we d
rmcilroy
2016/02/16 10:46:38
Yeah, I realized this yesterday after leaving work
Yang
2016/02/19 13:09:18
Done.
| |
| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 \ | 278 \ |
| 264 /* Perform a stack guard check */ \ | 279 /* Perform a stack guard check */ \ |
| 265 V(StackCheck, OperandType::kNone) \ | 280 V(StackCheck, OperandType::kNone) \ |
| 266 \ | 281 \ |
| 267 /* Non-local flow control */ \ | 282 /* Non-local flow control */ \ |
| 268 V(Throw, OperandType::kNone) \ | 283 V(Throw, OperandType::kNone) \ |
| 269 V(ReThrow, OperandType::kNone) \ | 284 V(ReThrow, OperandType::kNone) \ |
| 270 V(Return, OperandType::kNone) \ | 285 V(Return, OperandType::kNone) \ |
| 271 \ | 286 \ |
| 272 /* Debugger */ \ | 287 /* Debugger */ \ |
| 273 V(Debugger, OperandType::kNone) | 288 V(Debugger, OperandType::kNone) \ |
| 289 DEBUG_BREAK_BYTECODE_LIST(V) | |
| 274 | 290 |
| 275 // Enumeration of the size classes of operand types used by bytecodes. | 291 // Enumeration of the size classes of operand types used by bytecodes. |
| 276 enum class OperandSize : uint8_t { | 292 enum class OperandSize : uint8_t { |
| 277 kNone = 0, | 293 kNone = 0, |
| 278 kByte = 1, | 294 kByte = 1, |
| 279 kShort = 2, | 295 kShort = 2, |
| 280 }; | 296 }; |
| 281 | 297 |
| 282 | 298 |
| 283 // Enumeration of operand types used by bytecodes. | 299 // Enumeration of operand types used by bytecodes. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 static OperandSize GetOperandSize(Bytecode bytecode, int i); | 430 static OperandSize GetOperandSize(Bytecode bytecode, int i); |
| 415 | 431 |
| 416 // Returns the offset of the i-th operand of |bytecode| relative to the start | 432 // Returns the offset of the i-th operand of |bytecode| relative to the start |
| 417 // of the bytecode. | 433 // of the bytecode. |
| 418 static int GetOperandOffset(Bytecode bytecode, int i); | 434 static int GetOperandOffset(Bytecode bytecode, int i); |
| 419 | 435 |
| 420 // Returns a zero-based bitmap of the register operand positions of | 436 // Returns a zero-based bitmap of the register operand positions of |
| 421 // |bytecode|. | 437 // |bytecode|. |
| 422 static int GetRegisterOperandBitmap(Bytecode bytecode); | 438 static int GetRegisterOperandBitmap(Bytecode bytecode); |
| 423 | 439 |
| 440 // Returns a debug break bytecode with a matching operand size. | |
| 441 static Bytecode GetDebugBreak(Bytecode bytecode); | |
| 442 | |
| 424 // Returns the size of the bytecode including its operands. | 443 // Returns the size of the bytecode including its operands. |
| 425 static int Size(Bytecode bytecode); | 444 static int Size(Bytecode bytecode); |
| 426 | 445 |
| 427 // Returns the size of |operand|. | 446 // Returns the size of |operand|. |
| 428 static OperandSize SizeOfOperand(OperandType operand); | 447 static OperandSize SizeOfOperand(OperandType operand); |
| 429 | 448 |
| 430 // Returns true if the bytecode is a conditional jump taking | 449 // Returns true if the bytecode is a conditional jump taking |
| 431 // an immediate byte operand (OperandType::kImm8). | 450 // an immediate byte operand (OperandType::kImm8). |
| 432 static bool IsConditionalJumpImmediate(Bytecode bytecode); | 451 static bool IsConditionalJumpImmediate(Bytecode bytecode); |
| 433 | 452 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 458 // Returns true if the bytecode is a jump or conditional jump taking | 477 // Returns true if the bytecode is a jump or conditional jump taking |
| 459 // any kind of operand. | 478 // any kind of operand. |
| 460 static bool IsJump(Bytecode bytecode); | 479 static bool IsJump(Bytecode bytecode); |
| 461 | 480 |
| 462 // Returns true if the bytecode is a conditional jump, a jump, or a return. | 481 // Returns true if the bytecode is a conditional jump, a jump, or a return. |
| 463 static bool IsJumpOrReturn(Bytecode bytecode); | 482 static bool IsJumpOrReturn(Bytecode bytecode); |
| 464 | 483 |
| 465 // Returns true if the bytecode is a call or a constructor call. | 484 // Returns true if the bytecode is a call or a constructor call. |
| 466 static bool IsCallOrNew(Bytecode bytecode); | 485 static bool IsCallOrNew(Bytecode bytecode); |
| 467 | 486 |
| 487 // Returns true if the bytecode is a debug break. | |
| 488 static bool IsDebugBreak(Bytecode bytecode); | |
| 489 | |
| 468 // Returns true if |operand_type| is a register index operand (kIdx8/kIdx16). | 490 // Returns true if |operand_type| is a register index operand (kIdx8/kIdx16). |
| 469 static bool IsIndexOperandType(OperandType operand_type); | 491 static bool IsIndexOperandType(OperandType operand_type); |
| 470 | 492 |
| 471 // Returns true if |operand_type| represents an immediate. | 493 // Returns true if |operand_type| represents an immediate. |
| 472 static bool IsImmediateOperandType(OperandType operand_type); | 494 static bool IsImmediateOperandType(OperandType operand_type); |
| 473 | 495 |
| 474 // Returns true if |operand_type| is a register count operand | 496 // Returns true if |operand_type| is a register count operand |
| 475 // (kRegCount8/kRegCount16). | 497 // (kRegCount8/kRegCount16). |
| 476 static bool IsRegisterCountOperandType(OperandType operand_type); | 498 static bool IsRegisterCountOperandType(OperandType operand_type); |
| 477 | 499 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 498 | 520 |
| 499 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); | 521 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); |
| 500 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); | 522 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); |
| 501 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); | 523 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); |
| 502 | 524 |
| 503 } // namespace interpreter | 525 } // namespace interpreter |
| 504 } // namespace internal | 526 } // namespace internal |
| 505 } // namespace v8 | 527 } // namespace v8 |
| 506 | 528 |
| 507 #endif // V8_INTERPRETER_BYTECODES_H_ | 529 #endif // V8_INTERPRETER_BYTECODES_H_ |
| OLD | NEW |