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 13 matching lines...) Expand all Loading... |
24 /* Byte operands. */ \ | 24 /* Byte operands. */ \ |
25 V(Count8, OperandSize::kByte) \ | 25 V(Count8, OperandSize::kByte) \ |
26 V(Imm8, OperandSize::kByte) \ | 26 V(Imm8, OperandSize::kByte) \ |
27 V(Idx8, OperandSize::kByte) \ | 27 V(Idx8, OperandSize::kByte) \ |
28 V(Reg8, OperandSize::kByte) \ | 28 V(Reg8, OperandSize::kByte) \ |
29 \ | 29 \ |
30 /* Short operands. */ \ | 30 /* Short operands. */ \ |
31 V(Idx16, OperandSize::kShort) | 31 V(Idx16, OperandSize::kShort) |
32 | 32 |
33 // The list of bytecodes which are interpreted by the interpreter. | 33 // The list of bytecodes which are interpreted by the interpreter. |
34 #define BYTECODE_LIST(V) \ | 34 #define BYTECODE_LIST(V) \ |
35 \ | 35 \ |
36 /* Loading the accumulator */ \ | 36 /* Loading the accumulator */ \ |
37 V(LdaZero, OperandType::kNone) \ | 37 V(LdaZero, OperandType::kNone) \ |
38 V(LdaSmi8, OperandType::kImm8) \ | 38 V(LdaSmi8, OperandType::kImm8) \ |
39 V(LdaConstant, OperandType::kIdx8) \ | 39 V(LdaConstant, OperandType::kIdx8) \ |
40 V(LdaUndefined, OperandType::kNone) \ | 40 V(LdaUndefined, OperandType::kNone) \ |
41 V(LdaNull, OperandType::kNone) \ | 41 V(LdaNull, OperandType::kNone) \ |
42 V(LdaTheHole, OperandType::kNone) \ | 42 V(LdaTheHole, OperandType::kNone) \ |
43 V(LdaTrue, OperandType::kNone) \ | 43 V(LdaTrue, OperandType::kNone) \ |
44 V(LdaFalse, OperandType::kNone) \ | 44 V(LdaFalse, OperandType::kNone) \ |
45 \ | 45 \ |
46 /* Load globals */ \ | 46 /* Load globals */ \ |
47 V(LdaGlobal, OperandType::kIdx8) \ | 47 V(LdaGlobal, OperandType::kIdx8) \ |
48 \ | 48 \ |
49 /* Reg8ister-accumulator transfers */ \ | 49 /* Register-accumulator transfers */ \ |
50 V(Ldar, OperandType::kReg8) \ | 50 V(Ldar, OperandType::kReg8) \ |
51 V(Star, OperandType::kReg8) \ | 51 V(Star, OperandType::kReg8) \ |
52 \ | 52 \ |
53 /* LoadIC operations */ \ | 53 /* LoadIC operations */ \ |
54 V(LoadIC, OperandType::kReg8, OperandType::kIdx8) \ | 54 V(LoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \ |
55 V(KeyedLoadIC, OperandType::kReg8, OperandType::kIdx8) \ | 55 V(LoadICStrict, OperandType::kReg8, OperandType::kIdx8) \ |
56 \ | 56 V(KeyedLoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \ |
57 /* StoreIC operations */ \ | 57 V(KeyedLoadICStrict, OperandType::kReg8, OperandType::kIdx8) \ |
58 V(StoreIC, OperandType::kReg8, OperandType::kReg8, OperandType::kIdx8) \ | 58 \ |
59 V(KeyedStoreIC, OperandType::kReg8, OperandType::kReg8, OperandType::kIdx8) \ | 59 /* StoreIC operations */ \ |
60 \ | 60 V(StoreICSloppy, OperandType::kReg8, OperandType::kReg8, OperandType::kIdx8) \ |
61 /* Binary Operators */ \ | 61 V(StoreICStrict, OperandType::kReg8, OperandType::kReg8, OperandType::kIdx8) \ |
62 V(Add, OperandType::kReg8) \ | 62 V(KeyedStoreICSloppy, OperandType::kReg8, OperandType::kReg8, \ |
63 V(Sub, OperandType::kReg8) \ | 63 OperandType::kIdx8) \ |
64 V(Mul, OperandType::kReg8) \ | 64 V(KeyedStoreICStrict, OperandType::kReg8, OperandType::kReg8, \ |
65 V(Div, OperandType::kReg8) \ | 65 OperandType::kIdx8) \ |
66 V(Mod, OperandType::kReg8) \ | 66 \ |
67 \ | 67 /* Binary Operators */ \ |
68 /* Unary Operators */ \ | 68 V(Add, OperandType::kReg8) \ |
69 V(LogicalNot, OperandType::kNone) \ | 69 V(Sub, OperandType::kReg8) \ |
70 V(TypeOf, OperandType::kNone) \ | 70 V(Mul, OperandType::kReg8) \ |
71 \ | 71 V(Div, OperandType::kReg8) \ |
72 /* Call operations. */ \ | 72 V(Mod, OperandType::kReg8) \ |
73 V(Call, OperandType::kReg8, OperandType::kReg8, OperandType::kCount8) \ | 73 \ |
74 V(CallRuntime, OperandType::kIdx16, OperandType::kReg8, \ | 74 /* Unary Operators */ \ |
75 OperandType::kCount8) \ | 75 V(LogicalNot, OperandType::kNone) \ |
76 \ | 76 V(TypeOf, OperandType::kNone) \ |
77 /* Test Operators */ \ | 77 \ |
78 V(TestEqual, OperandType::kReg8) \ | 78 /* Call operations. */ \ |
79 V(TestNotEqual, OperandType::kReg8) \ | 79 V(Call, OperandType::kReg8, OperandType::kReg8, OperandType::kCount8) \ |
80 V(TestEqualStrict, OperandType::kReg8) \ | 80 V(CallRuntime, OperandType::kIdx16, OperandType::kReg8, \ |
81 V(TestNotEqualStrict, OperandType::kReg8) \ | 81 OperandType::kCount8) \ |
82 V(TestLessThan, OperandType::kReg8) \ | 82 \ |
83 V(TestGreaterThan, OperandType::kReg8) \ | 83 /* Test Operators */ \ |
84 V(TestLessThanOrEqual, OperandType::kReg8) \ | 84 V(TestEqual, OperandType::kReg8) \ |
85 V(TestGreaterThanOrEqual, OperandType::kReg8) \ | 85 V(TestNotEqual, OperandType::kReg8) \ |
86 V(TestInstanceOf, OperandType::kReg8) \ | 86 V(TestEqualStrict, OperandType::kReg8) \ |
87 V(TestIn, OperandType::kReg8) \ | 87 V(TestNotEqualStrict, OperandType::kReg8) \ |
88 \ | 88 V(TestLessThan, OperandType::kReg8) \ |
89 /* Cast operators */ \ | 89 V(TestGreaterThan, OperandType::kReg8) \ |
90 V(ToBoolean, OperandType::kNone) \ | 90 V(TestLessThanOrEqual, OperandType::kReg8) \ |
91 \ | 91 V(TestGreaterThanOrEqual, OperandType::kReg8) \ |
92 /* Control Flow */ \ | 92 V(TestInstanceOf, OperandType::kReg8) \ |
93 V(Jump, OperandType::kImm8) \ | 93 V(TestIn, OperandType::kReg8) \ |
94 V(JumpConstant, OperandType::kIdx8) \ | 94 \ |
95 V(JumpIfTrue, OperandType::kImm8) \ | 95 /* Cast operators */ \ |
96 V(JumpIfTrueConstant, OperandType::kIdx8) \ | 96 V(ToBoolean, OperandType::kNone) \ |
97 V(JumpIfFalse, OperandType::kImm8) \ | 97 \ |
98 V(JumpIfFalseConstant, OperandType::kIdx8) \ | 98 /* Control Flow */ \ |
| 99 V(Jump, OperandType::kImm8) \ |
| 100 V(JumpConstant, OperandType::kIdx8) \ |
| 101 V(JumpIfTrue, OperandType::kImm8) \ |
| 102 V(JumpIfTrueConstant, OperandType::kIdx8) \ |
| 103 V(JumpIfFalse, OperandType::kImm8) \ |
| 104 V(JumpIfFalseConstant, OperandType::kIdx8) \ |
99 V(Return, OperandType::kNone) | 105 V(Return, OperandType::kNone) |
100 | 106 |
101 | 107 |
102 // Enumeration of the size classes of operand types used by bytecodes. | 108 // Enumeration of the size classes of operand types used by bytecodes. |
103 enum class OperandSize : uint8_t { | 109 enum class OperandSize : uint8_t { |
104 kNone = 0, | 110 kNone = 0, |
105 kByte = 1, | 111 kByte = 1, |
106 kShort = 2, | 112 kShort = 2, |
107 }; | 113 }; |
108 | 114 |
(...skipping 17 matching lines...) Expand all Loading... |
126 BYTECODE_LIST(DECLARE_BYTECODE) | 132 BYTECODE_LIST(DECLARE_BYTECODE) |
127 #undef DECLARE_BYTECODE | 133 #undef DECLARE_BYTECODE |
128 #define COUNT_BYTECODE(x, ...) +1 | 134 #define COUNT_BYTECODE(x, ...) +1 |
129 // The COUNT_BYTECODE macro will turn this into kLast = -1 +1 +1... which will | 135 // The COUNT_BYTECODE macro will turn this into kLast = -1 +1 +1... which will |
130 // evaluate to the same value as the last real bytecode. | 136 // evaluate to the same value as the last real bytecode. |
131 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) | 137 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) |
132 #undef COUNT_BYTECODE | 138 #undef COUNT_BYTECODE |
133 }; | 139 }; |
134 | 140 |
135 | 141 |
136 // An interpreter Reg8ister which is located in the function's Reg8ister file | 142 // An interpreter Register which is located in the function's Register file |
137 // in its stack-frame. Reg8ister hold parameters, this, and expression values. | 143 // in its stack-frame. Register hold parameters, this, and expression values. |
138 class Register { | 144 class Register { |
139 public: | 145 public: |
140 static const int kMaxRegisterIndex = 127; | 146 static const int kMaxRegisterIndex = 127; |
141 static const int kMinRegisterIndex = -128; | 147 static const int kMinRegisterIndex = -128; |
142 | 148 |
143 Register() : index_(kIllegalIndex) {} | 149 Register() : index_(kIllegalIndex) {} |
144 | 150 |
145 explicit Register(int index) : index_(index) { | 151 explicit Register(int index) : index_(index) { |
146 DCHECK_LE(index_, kMaxRegisterIndex); | 152 DCHECK_LE(index_, kMaxRegisterIndex); |
147 DCHECK_GE(index_, kMinRegisterIndex); | 153 DCHECK_GE(index_, kMinRegisterIndex); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 236 |
231 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); | 237 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); |
232 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); | 238 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); |
233 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); | 239 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); |
234 | 240 |
235 } // namespace interpreter | 241 } // namespace interpreter |
236 } // namespace internal | 242 } // namespace internal |
237 } // namespace v8 | 243 } // namespace v8 |
238 | 244 |
239 #endif // V8_INTERPRETER_BYTECODES_H_ | 245 #endif // V8_INTERPRETER_BYTECODES_H_ |
OLD | NEW |