Chromium Code Reviews| Index: src/interpreter/bytecodes.h |
| diff --git a/src/interpreter/bytecodes.h b/src/interpreter/bytecodes.h |
| index 05c0afe8f6bacd2ea33142eeee53d78c38762f6f..68de71a1fa6694143eb905cf076a432a1d1ae2f4 100644 |
| --- a/src/interpreter/bytecodes.h |
| +++ b/src/interpreter/bytecodes.h |
| @@ -213,24 +213,33 @@ namespace interpreter { |
| V(CreateUnmappedArguments, AccumulatorUse::kWrite) \ |
| V(CreateRestParameter, AccumulatorUse::kWrite) \ |
| \ |
| - /* Control Flow */ \ |
| + /* Control Flow -- carefully ordered for efficient checks */ \ |
| + /* - [Unconditional jumps] */ \ |
| + V(JumpLoop, AccumulatorUse::kNone, OperandType::kImm, OperandType::kImm) \ |
| + /* - [Forward jumps] */ \ |
| V(Jump, AccumulatorUse::kNone, OperandType::kImm) \ |
| + /* - [Start constant jumps] */ \ |
| V(JumpConstant, AccumulatorUse::kNone, OperandType::kIdx) \ |
| - V(JumpIfTrue, AccumulatorUse::kRead, OperandType::kImm) \ |
| + /* - [Conditional jumps] */ \ |
| + /* - [Conditional constant jumps] */ \ |
| + V(JumpIfNullConstant, AccumulatorUse::kRead, OperandType::kIdx) \ |
| + V(JumpIfUndefinedConstant, AccumulatorUse::kRead, OperandType::kIdx) \ |
| V(JumpIfTrueConstant, AccumulatorUse::kRead, OperandType::kIdx) \ |
| - V(JumpIfFalse, AccumulatorUse::kRead, OperandType::kImm) \ |
| V(JumpIfFalseConstant, AccumulatorUse::kRead, OperandType::kIdx) \ |
| - V(JumpIfToBooleanTrue, AccumulatorUse::kRead, OperandType::kImm) \ |
| + V(JumpIfNotHoleConstant, AccumulatorUse::kRead, OperandType::kIdx) \ |
| + /* - [Start ToBoolean jumps] */ \ |
| V(JumpIfToBooleanTrueConstant, AccumulatorUse::kRead, OperandType::kIdx) \ |
| - V(JumpIfToBooleanFalse, AccumulatorUse::kRead, OperandType::kImm) \ |
| V(JumpIfToBooleanFalseConstant, AccumulatorUse::kRead, OperandType::kIdx) \ |
| + /* - [End constant jumps] */ \ |
| + /* - [Conditional immediate jumps] */ \ |
| + V(JumpIfToBooleanTrue, AccumulatorUse::kRead, OperandType::kImm) \ |
| + V(JumpIfToBooleanFalse, AccumulatorUse::kRead, OperandType::kImm) \ |
| + /* - [End ToBoolean jumps] */ \ |
| + V(JumpIfTrue, AccumulatorUse::kRead, OperandType::kImm) \ |
| + V(JumpIfFalse, AccumulatorUse::kRead, OperandType::kImm) \ |
| V(JumpIfNull, AccumulatorUse::kRead, OperandType::kImm) \ |
| - V(JumpIfNullConstant, AccumulatorUse::kRead, OperandType::kIdx) \ |
| V(JumpIfUndefined, AccumulatorUse::kRead, OperandType::kImm) \ |
| - V(JumpIfUndefinedConstant, AccumulatorUse::kRead, OperandType::kIdx) \ |
| V(JumpIfNotHole, AccumulatorUse::kRead, OperandType::kImm) \ |
| - V(JumpIfNotHoleConstant, AccumulatorUse::kRead, OperandType::kIdx) \ |
| - V(JumpLoop, AccumulatorUse::kNone, OperandType::kImm, OperandType::kImm) \ |
| \ |
| /* Complex flow control For..in */ \ |
| V(ForInPrepare, AccumulatorUse::kNone, OperandType::kReg, \ |
| @@ -300,6 +309,77 @@ namespace interpreter { |
| DEBUG_BREAK_PLAIN_BYTECODE_LIST(V) \ |
| DEBUG_BREAK_PREFIX_BYTECODE_LIST(V) |
| +// List of jump bytecodes. |
| +#define JUMP_FORWARD_BYTECODE_LIST(V) \ |
| + V(Jump) \ |
| + V(JumpConstant) \ |
| + V(JumpIfNullConstant) \ |
| + V(JumpIfUndefinedConstant) \ |
| + V(JumpIfTrueConstant) \ |
| + V(JumpIfFalseConstant) \ |
| + V(JumpIfNotHoleConstant) \ |
| + V(JumpIfToBooleanTrueConstant) \ |
| + V(JumpIfToBooleanFalseConstant) \ |
| + V(JumpIfToBooleanTrue) \ |
| + V(JumpIfToBooleanFalse) \ |
| + V(JumpIfTrue) \ |
| + V(JumpIfFalse) \ |
| + V(JumpIfNull) \ |
| + V(JumpIfUndefined) \ |
| + V(JumpIfNotHole) |
| + |
| +#define JUMP_CONSTANT_BYTECODE_LIST(V) \ |
| + V(JumpConstant) \ |
| + V(JumpIfNullConstant) \ |
| + V(JumpIfUndefinedConstant) \ |
| + V(JumpIfTrueConstant) \ |
| + V(JumpIfFalseConstant) \ |
| + V(JumpIfNotHoleConstant) \ |
| + V(JumpIfToBooleanTrueConstant) \ |
| + V(JumpIfToBooleanFalseConstant) |
| + |
| +#define JUMP_IMMEDIATE_BYTECODE_LIST(V) \ |
| + V(JumpLoop) \ |
| + V(Jump) \ |
| + V(JumpIfToBooleanTrue) \ |
| + V(JumpIfToBooleanFalse) \ |
| + V(JumpIfTrue) \ |
| + V(JumpIfFalse) \ |
| + V(JumpIfNull) \ |
| + V(JumpIfUndefined) \ |
| + V(JumpIfNotHole) |
| + |
| +#define JUMP_TO_BOOLEAN_BYTECODE_LIST(V) \ |
| + V(JumpIfToBooleanTrueConstant) \ |
| + V(JumpIfToBooleanFalseConstant) \ |
| + V(JumpIfToBooleanTrue) \ |
| + V(JumpIfToBooleanFalse) |
| + |
| +#define JUMP_UNCONDITIONAL_BYTECODE_LIST(V) \ |
| + V(JumpLoop) \ |
| + V(Jump) \ |
| + V(JumpConstant) |
| + |
| +#define JUMP_CONDITIONAL_BYTECODE_LIST(V) \ |
| + V(JumpIfNullConstant) \ |
| + V(JumpIfUndefinedConstant) \ |
| + V(JumpIfTrueConstant) \ |
| + V(JumpIfFalseConstant) \ |
| + V(JumpIfNotHoleConstant) \ |
| + V(JumpIfToBooleanTrueConstant) \ |
| + V(JumpIfToBooleanFalseConstant) \ |
| + V(JumpIfToBooleanTrue) \ |
| + V(JumpIfToBooleanFalse) \ |
| + V(JumpIfTrue) \ |
| + V(JumpIfFalse) \ |
| + V(JumpIfNull) \ |
| + V(JumpIfUndefined) \ |
| + V(JumpIfNotHole) |
|
rmcilroy
2016/12/05 14:33:40
nit - could you build these up so there aren't rep
Leszek Swirski
2016/12/05 17:53:11
Done, except for some duplication in JumpForward c
|
| + |
| +#define JUMP_BYTECODE_LIST(V) \ |
| + V(JumpLoop) \ |
| + JUMP_FORWARD_BYTECODE_LIST(V) |
| + |
| // Enumeration of interpreter bytecodes. |
| enum class Bytecode : uint8_t { |
| #define DECLARE_BYTECODE(Name, ...) k##Name, |
| @@ -443,38 +523,28 @@ class V8_EXPORT_PRIVATE Bytecodes final { |
| // Returns true if the bytecode is a conditional jump taking |
| // an immediate byte operand (OperandType::kImm). |
| static CONSTEXPR bool IsConditionalJumpImmediate(Bytecode bytecode) { |
| - return bytecode == Bytecode::kJumpIfTrue || |
| - bytecode == Bytecode::kJumpIfFalse || |
| - bytecode == Bytecode::kJumpIfToBooleanTrue || |
| - bytecode == Bytecode::kJumpIfToBooleanFalse || |
| - bytecode == Bytecode::kJumpIfNotHole || |
| - bytecode == Bytecode::kJumpIfNull || |
| - bytecode == Bytecode::kJumpIfUndefined; |
| + return bytecode >= Bytecode::kJumpIfToBooleanTrue && |
| + bytecode <= Bytecode::kJumpIfNotHole; |
| } |
| // Returns true if the bytecode is a conditional jump taking |
| // a constant pool entry (OperandType::kIdx). |
| static CONSTEXPR bool IsConditionalJumpConstant(Bytecode bytecode) { |
| - return bytecode == Bytecode::kJumpIfTrueConstant || |
| - bytecode == Bytecode::kJumpIfFalseConstant || |
| - bytecode == Bytecode::kJumpIfToBooleanTrueConstant || |
| - bytecode == Bytecode::kJumpIfToBooleanFalseConstant || |
| - bytecode == Bytecode::kJumpIfNotHoleConstant || |
| - bytecode == Bytecode::kJumpIfNullConstant || |
| - bytecode == Bytecode::kJumpIfUndefinedConstant; |
| + return bytecode >= Bytecode::kJumpIfNullConstant && |
| + bytecode <= Bytecode::kJumpIfToBooleanFalseConstant; |
| } |
| // Returns true if the bytecode is a conditional jump taking |
| // any kind of operand. |
| static CONSTEXPR bool IsConditionalJump(Bytecode bytecode) { |
| - return IsConditionalJumpImmediate(bytecode) || |
| - IsConditionalJumpConstant(bytecode); |
| + return bytecode >= Bytecode::kJumpIfNullConstant && |
| + bytecode <= Bytecode::kJumpIfNotHole; |
| } |
| // Returns true if the bytecode is an unconditional jump. |
| static CONSTEXPR bool IsUnconditionalJump(Bytecode bytecode) { |
| - return bytecode == Bytecode::kJump || bytecode == Bytecode::kJumpConstant || |
| - bytecode == Bytecode::kJumpLoop; |
| + return bytecode >= Bytecode::kJumpLoop && |
| + bytecode <= Bytecode::kJumpConstant; |
| } |
| // Returns true if the bytecode is a jump or a conditional jump taking |
| @@ -487,29 +557,28 @@ class V8_EXPORT_PRIVATE Bytecodes final { |
| // Returns true if the bytecode is a jump or conditional jump taking a |
| // constant pool entry (OperandType::kIdx). |
| static CONSTEXPR bool IsJumpConstant(Bytecode bytecode) { |
| - return bytecode == Bytecode::kJumpConstant || |
| - IsConditionalJumpConstant(bytecode); |
| + return bytecode >= Bytecode::kJumpConstant && |
| + bytecode <= Bytecode::kJumpIfToBooleanFalseConstant; |
| } |
| // Returns true if the bytecode is a jump that internally coerces the |
| // accumulator to a boolean. |
| static CONSTEXPR bool IsJumpIfToBoolean(Bytecode bytecode) { |
| - return bytecode == Bytecode::kJumpIfToBooleanTrue || |
| - bytecode == Bytecode::kJumpIfToBooleanFalse || |
| - bytecode == Bytecode::kJumpIfToBooleanTrueConstant || |
| - bytecode == Bytecode::kJumpIfToBooleanFalseConstant; |
| + return bytecode >= Bytecode::kJumpIfToBooleanTrueConstant && |
| + bytecode <= Bytecode::kJumpIfToBooleanFalse; |
| } |
| // Returns true if the bytecode is a jump or conditional jump taking |
| // any kind of operand. |
| static CONSTEXPR bool IsJump(Bytecode bytecode) { |
| - return IsJumpImmediate(bytecode) || IsJumpConstant(bytecode); |
| + return bytecode >= Bytecode::kJumpLoop && |
| + bytecode <= Bytecode::kJumpIfNotHole; |
| } |
| // Returns true if the bytecode is a forward jump or conditional jump taking |
| // any kind of operand. |
| static CONSTEXPR bool IsForwardJump(Bytecode bytecode) { |
| - return bytecode != Bytecode::kJumpLoop && IsJump(bytecode); |
| + return bytecode >= Bytecode::kJump && bytecode <= Bytecode::kJumpIfNotHole; |
| } |
| // Returns true if the bytecode is a conditional jump, a jump, or a return. |