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 <cstdint> | 8 #include <cstdint> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 #include <string> | 10 #include <string> |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 bytecode == Bytecode::kJumpIfUndefinedConstant; | 464 bytecode == Bytecode::kJumpIfUndefinedConstant; |
465 } | 465 } |
466 | 466 |
467 // Returns true if the bytecode is a conditional jump taking | 467 // Returns true if the bytecode is a conditional jump taking |
468 // any kind of operand. | 468 // any kind of operand. |
469 static CONSTEXPR bool IsConditionalJump(Bytecode bytecode) { | 469 static CONSTEXPR bool IsConditionalJump(Bytecode bytecode) { |
470 return IsConditionalJumpImmediate(bytecode) || | 470 return IsConditionalJumpImmediate(bytecode) || |
471 IsConditionalJumpConstant(bytecode); | 471 IsConditionalJumpConstant(bytecode); |
472 } | 472 } |
473 | 473 |
| 474 // Returns true if the bytecode is an unconditional jump. |
| 475 static CONSTEXPR bool IsUnconditionalJump(Bytecode bytecode) { |
| 476 return bytecode == Bytecode::kJump || bytecode == Bytecode::kJumpConstant || |
| 477 bytecode == Bytecode::kJumpLoop; |
| 478 } |
| 479 |
474 // Returns true if the bytecode is a jump or a conditional jump taking | 480 // Returns true if the bytecode is a jump or a conditional jump taking |
475 // an immediate byte operand (OperandType::kImm). | 481 // an immediate byte operand (OperandType::kImm). |
476 static CONSTEXPR bool IsJumpImmediate(Bytecode bytecode) { | 482 static CONSTEXPR bool IsJumpImmediate(Bytecode bytecode) { |
477 return bytecode == Bytecode::kJump || bytecode == Bytecode::kJumpLoop || | 483 return bytecode == Bytecode::kJump || bytecode == Bytecode::kJumpLoop || |
478 IsConditionalJumpImmediate(bytecode); | 484 IsConditionalJumpImmediate(bytecode); |
479 } | 485 } |
480 | 486 |
481 // Returns true if the bytecode is a jump or conditional jump taking a | 487 // Returns true if the bytecode is a jump or conditional jump taking a |
482 // constant pool entry (OperandType::kIdx). | 488 // constant pool entry (OperandType::kIdx). |
483 static CONSTEXPR bool IsJumpConstant(Bytecode bytecode) { | 489 static CONSTEXPR bool IsJumpConstant(Bytecode bytecode) { |
484 return bytecode == Bytecode::kJumpConstant || | 490 return bytecode == Bytecode::kJumpConstant || |
485 IsConditionalJumpConstant(bytecode); | 491 IsConditionalJumpConstant(bytecode); |
486 } | 492 } |
487 | 493 |
488 // Returns true if the bytecode is a jump that internally coerces the | 494 // Returns true if the bytecode is a jump that internally coerces the |
489 // accumulator to a boolean. | 495 // accumulator to a boolean. |
490 static CONSTEXPR bool IsJumpIfToBoolean(Bytecode bytecode) { | 496 static CONSTEXPR bool IsJumpIfToBoolean(Bytecode bytecode) { |
491 return bytecode == Bytecode::kJumpIfToBooleanTrue || | 497 return bytecode == Bytecode::kJumpIfToBooleanTrue || |
492 bytecode == Bytecode::kJumpIfToBooleanFalse || | 498 bytecode == Bytecode::kJumpIfToBooleanFalse || |
493 bytecode == Bytecode::kJumpIfToBooleanTrueConstant || | 499 bytecode == Bytecode::kJumpIfToBooleanTrueConstant || |
494 bytecode == Bytecode::kJumpIfToBooleanFalseConstant; | 500 bytecode == Bytecode::kJumpIfToBooleanFalseConstant; |
495 } | 501 } |
496 | 502 |
497 // Returns true if the bytecode is a jump or conditional jump taking | 503 // Returns true if the bytecode is a jump or conditional jump taking |
498 // any kind of operand. | 504 // any kind of operand. |
499 static CONSTEXPR bool IsJump(Bytecode bytecode) { | 505 static CONSTEXPR bool IsJump(Bytecode bytecode) { |
500 return IsJumpImmediate(bytecode) || IsJumpConstant(bytecode); | 506 return IsJumpImmediate(bytecode) || IsJumpConstant(bytecode); |
501 } | 507 } |
502 | 508 |
| 509 // Returns true if the bytecode is a forward jump or conditional jump taking |
| 510 // any kind of operand. |
| 511 static CONSTEXPR bool IsForwardJump(Bytecode bytecode) { |
| 512 return bytecode != Bytecode::kJumpLoop && IsJump(bytecode); |
| 513 } |
| 514 |
503 // Returns true if the bytecode is a conditional jump, a jump, or a return. | 515 // Returns true if the bytecode is a conditional jump, a jump, or a return. |
504 static CONSTEXPR bool IsJumpOrReturn(Bytecode bytecode) { | 516 static CONSTEXPR bool IsJumpOrReturn(Bytecode bytecode) { |
505 return bytecode == Bytecode::kReturn || IsJump(bytecode); | 517 return bytecode == Bytecode::kReturn || IsJump(bytecode); |
506 } | 518 } |
507 | 519 |
508 // Return true if |bytecode| is a jump without effects, | 520 // Return true if |bytecode| is a jump without effects, |
509 // e.g. any jump excluding those that include type coercion like | 521 // e.g. any jump excluding those that include type coercion like |
510 // JumpIfTrueToBoolean. | 522 // JumpIfTrueToBoolean. |
511 static CONSTEXPR bool IsJumpWithoutEffects(Bytecode bytecode) { | 523 static CONSTEXPR bool IsJumpWithoutEffects(Bytecode bytecode) { |
512 return IsJump(bytecode) && !IsJumpIfToBoolean(bytecode); | 524 return IsJump(bytecode) && !IsJumpIfToBoolean(bytecode); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 #undef CONSTEXPR | 753 #undef CONSTEXPR |
742 | 754 |
743 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, | 755 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, |
744 const Bytecode& bytecode); | 756 const Bytecode& bytecode); |
745 | 757 |
746 } // namespace interpreter | 758 } // namespace interpreter |
747 } // namespace internal | 759 } // namespace internal |
748 } // namespace v8 | 760 } // namespace v8 |
749 | 761 |
750 #endif // V8_INTERPRETER_BYTECODES_H_ | 762 #endif // V8_INTERPRETER_BYTECODES_H_ |
OLD | NEW |