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. |
11 // Do not include anything from src/interpreter here! | 11 // Do not include anything from src/interpreter here! |
12 #include "src/utils.h" | 12 #include "src/utils.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 namespace interpreter { | 16 namespace interpreter { |
17 | 17 |
18 // The list of operand types used by bytecodes. | 18 // The list of operand types used by bytecodes. |
19 #define OPERAND_TYPE_LIST(V) \ | 19 #define OPERAND_TYPE_LIST(V) \ |
20 V(None) \ | 20 V(None) \ |
21 V(Imm8) \ | 21 V(Imm8) \ |
22 V(Idx) \ | 22 V(Idx) \ |
23 V(Reg) | 23 V(Reg) |
24 | 24 |
25 // The list of bytecodes which are interpreted by the interpreter. | 25 // The list of bytecodes which are interpreted by the interpreter. |
26 #define BYTECODE_LIST(V) \ | 26 #define BYTECODE_LIST(V) \ |
27 \ | 27 \ |
28 /* Loading the accumulator */ \ | 28 /* Loading the accumulator */ \ |
29 V(LdaZero, OperandType::kNone) \ | 29 V(LdaZero, OperandType::kNone) \ |
30 V(LdaSmi8, OperandType::kImm8) \ | 30 V(LdaSmi8, OperandType::kImm8) \ |
31 V(LdaConstant, OperandType::kIdx) \ | 31 V(LdaConstant, OperandType::kIdx) \ |
32 V(LdaUndefined, OperandType::kNone) \ | 32 V(LdaUndefined, OperandType::kNone) \ |
33 V(LdaNull, OperandType::kNone) \ | 33 V(LdaNull, OperandType::kNone) \ |
34 V(LdaTheHole, OperandType::kNone) \ | 34 V(LdaTheHole, OperandType::kNone) \ |
35 V(LdaTrue, OperandType::kNone) \ | 35 V(LdaTrue, OperandType::kNone) \ |
36 V(LdaFalse, OperandType::kNone) \ | 36 V(LdaFalse, OperandType::kNone) \ |
37 \ | 37 \ |
38 /* Register-accumulator transfers */ \ | 38 /* Register-accumulator transfers */ \ |
39 V(Ldar, OperandType::kReg) \ | 39 V(Ldar, OperandType::kReg) \ |
40 V(Star, OperandType::kReg) \ | 40 V(Star, OperandType::kReg) \ |
41 \ | 41 \ |
42 /* Binary Operators */ \ | 42 /* LoadIC operations */ \ |
43 V(Add, OperandType::kReg) \ | 43 V(LoadIC, OperandType::kReg, OperandType::kIdx) \ |
44 V(Sub, OperandType::kReg) \ | 44 V(KeyedLoadIC, OperandType::kReg, OperandType::kIdx) \ |
45 V(Mul, OperandType::kReg) \ | 45 \ |
46 V(Div, OperandType::kReg) \ | 46 /* Binary Operators */ \ |
47 V(Mod, OperandType::kReg) \ | 47 V(Add, OperandType::kReg) \ |
48 \ | 48 V(Sub, OperandType::kReg) \ |
49 /* Control Flow */ \ | 49 V(Mul, OperandType::kReg) \ |
| 50 V(Div, OperandType::kReg) \ |
| 51 V(Mod, OperandType::kReg) \ |
| 52 \ |
| 53 /* Control Flow */ \ |
50 V(Return, OperandType::kNone) | 54 V(Return, OperandType::kNone) |
51 | 55 |
52 | 56 |
53 // Enumeration of operand types used by bytecodes. | 57 // Enumeration of operand types used by bytecodes. |
54 enum class OperandType : uint8_t { | 58 enum class OperandType : uint8_t { |
55 #define DECLARE_OPERAND_TYPE(Name) k##Name, | 59 #define DECLARE_OPERAND_TYPE(Name) k##Name, |
56 OPERAND_TYPE_LIST(DECLARE_OPERAND_TYPE) | 60 OPERAND_TYPE_LIST(DECLARE_OPERAND_TYPE) |
57 #undef DECLARE_OPERAND_TYPE | 61 #undef DECLARE_OPERAND_TYPE |
58 #define COUNT_OPERAND_TYPES(x) +1 | 62 #define COUNT_OPERAND_TYPES(x) +1 |
59 // The COUNT_OPERAND macro will turn this into kLast = -1 +1 +1... which will | 63 // The COUNT_OPERAND macro will turn this into kLast = -1 +1 +1... which will |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 }; | 117 }; |
114 | 118 |
115 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); | 119 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); |
116 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); | 120 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); |
117 | 121 |
118 } // namespace interpreter | 122 } // namespace interpreter |
119 } // namespace internal | 123 } // namespace internal |
120 } // namespace v8 | 124 } // namespace v8 |
121 | 125 |
122 #endif // V8_INTERPRETER_BYTECODES_H_ | 126 #endif // V8_INTERPRETER_BYTECODES_H_ |
OLD | NEW |