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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) | 71 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) |
72 #undef COUNT_BYTECODE | 72 #undef COUNT_BYTECODE |
73 }; | 73 }; |
74 | 74 |
75 | 75 |
76 class Bytecodes { | 76 class Bytecodes { |
77 public: | 77 public: |
78 // Returns string representation of |bytecode|. | 78 // Returns string representation of |bytecode|. |
79 static const char* ToString(Bytecode bytecode); | 79 static const char* ToString(Bytecode bytecode); |
80 | 80 |
| 81 // Returns string representation of |operand_type|. |
| 82 static const char* OperandTypeToString(OperandType operand_type); |
| 83 |
81 // Returns byte value of bytecode. | 84 // Returns byte value of bytecode. |
82 static uint8_t ToByte(Bytecode bytecode); | 85 static uint8_t ToByte(Bytecode bytecode); |
83 | 86 |
84 // Returns bytecode for |value|. | 87 // Returns bytecode for |value|. |
85 static Bytecode FromByte(uint8_t value); | 88 static Bytecode FromByte(uint8_t value); |
86 | 89 |
87 // Returns the number of operands expected by |bytecode|. | 90 // Returns the number of operands expected by |bytecode|. |
88 static int NumberOfOperands(Bytecode bytecode); | 91 static int NumberOfOperands(Bytecode bytecode); |
89 | 92 |
90 // Return the i-th operand of |bytecode|. | 93 // Return the i-th operand of |bytecode|. |
91 static OperandType GetOperandType(Bytecode bytecode, int i); | 94 static OperandType GetOperandType(Bytecode bytecode, int i); |
92 | 95 |
93 // Returns the size of the bytecode including its operands. | 96 // Returns the size of the bytecode including its operands. |
94 static int Size(Bytecode bytecode); | 97 static int Size(Bytecode bytecode); |
95 | 98 |
96 // The maximum number of operands across all bytecodes. | 99 // The maximum number of operands across all bytecodes. |
97 static int MaximumNumberOfOperands(); | 100 static int MaximumNumberOfOperands(); |
98 | 101 |
99 // Maximum size of a bytecode and its operands. | 102 // Maximum size of a bytecode and its operands. |
100 static int MaximumSize(); | 103 static int MaximumSize(); |
101 | 104 |
102 // Decode a single bytecode and operands to |os|. | 105 // Decode a single bytecode and operands to |os|. |
103 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start); | 106 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start); |
104 | 107 |
105 private: | 108 private: |
106 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes); | 109 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes); |
107 }; | 110 }; |
108 | 111 |
109 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); | 112 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); |
| 113 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); |
110 | 114 |
111 } // namespace interpreter | 115 } // namespace interpreter |
112 } // namespace internal | 116 } // namespace internal |
113 } // namespace v8 | 117 } // namespace v8 |
114 | 118 |
115 #endif // V8_INTERPRETER_BYTECODES_H_ | 119 #endif // V8_INTERPRETER_BYTECODES_H_ |
OLD | NEW |