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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 V(TestNotEqualStrict, OperandType::kReg8) \ | 97 V(TestNotEqualStrict, OperandType::kReg8) \ |
98 V(TestLessThan, OperandType::kReg8) \ | 98 V(TestLessThan, OperandType::kReg8) \ |
99 V(TestGreaterThan, OperandType::kReg8) \ | 99 V(TestGreaterThan, OperandType::kReg8) \ |
100 V(TestLessThanOrEqual, OperandType::kReg8) \ | 100 V(TestLessThanOrEqual, OperandType::kReg8) \ |
101 V(TestGreaterThanOrEqual, OperandType::kReg8) \ | 101 V(TestGreaterThanOrEqual, OperandType::kReg8) \ |
102 V(TestInstanceOf, OperandType::kReg8) \ | 102 V(TestInstanceOf, OperandType::kReg8) \ |
103 V(TestIn, OperandType::kReg8) \ | 103 V(TestIn, OperandType::kReg8) \ |
104 \ | 104 \ |
105 /* Cast operators */ \ | 105 /* Cast operators */ \ |
106 V(ToBoolean, OperandType::kNone) \ | 106 V(ToBoolean, OperandType::kNone) \ |
| 107 V(ToName, OperandType::kNone) \ |
107 \ | 108 \ |
108 /* Literals */ \ | 109 /* Literals */ \ |
109 V(CreateArrayLiteral, OperandType::kIdx8, OperandType::kImm8) \ | 110 V(CreateArrayLiteral, OperandType::kIdx8, OperandType::kImm8) \ |
| 111 V(CreateObjectLiteral, OperandType::kIdx8, OperandType::kImm8) \ |
110 \ | 112 \ |
111 /* Closure allocation */ \ | 113 /* Closure allocation */ \ |
112 V(CreateClosure, OperandType::kImm8) \ | 114 V(CreateClosure, OperandType::kImm8) \ |
113 \ | 115 \ |
114 /* Control Flow */ \ | 116 /* Control Flow */ \ |
115 V(Jump, OperandType::kImm8) \ | 117 V(Jump, OperandType::kImm8) \ |
116 V(JumpConstant, OperandType::kIdx8) \ | 118 V(JumpConstant, OperandType::kIdx8) \ |
117 V(JumpIfTrue, OperandType::kImm8) \ | 119 V(JumpIfTrue, OperandType::kImm8) \ |
118 V(JumpIfTrueConstant, OperandType::kIdx8) \ | 120 V(JumpIfTrueConstant, OperandType::kIdx8) \ |
119 V(JumpIfFalse, OperandType::kImm8) \ | 121 V(JumpIfFalse, OperandType::kImm8) \ |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 explicit Register(int index) : index_(index) { | 169 explicit Register(int index) : index_(index) { |
168 DCHECK_LE(index_, kMaxRegisterIndex); | 170 DCHECK_LE(index_, kMaxRegisterIndex); |
169 DCHECK_GE(index_, kMinRegisterIndex); | 171 DCHECK_GE(index_, kMinRegisterIndex); |
170 } | 172 } |
171 | 173 |
172 int index() const { | 174 int index() const { |
173 DCHECK(index_ != kIllegalIndex); | 175 DCHECK(index_ != kIllegalIndex); |
174 return index_; | 176 return index_; |
175 } | 177 } |
176 bool is_parameter() const { return index() < 0; } | 178 bool is_parameter() const { return index() < 0; } |
| 179 bool is_valid() const { return index_ != kIllegalIndex; } |
177 | 180 |
178 static Register FromParameterIndex(int index, int parameter_count); | 181 static Register FromParameterIndex(int index, int parameter_count); |
179 int ToParameterIndex(int parameter_count) const; | 182 int ToParameterIndex(int parameter_count) const; |
180 static int MaxParameterIndex(); | 183 static int MaxParameterIndex(); |
181 | 184 |
182 // Returns the register for the function's closure object. | 185 // Returns the register for the function's closure object. |
183 static Register function_closure(); | 186 static Register function_closure(); |
184 bool is_function_closure() const; | 187 bool is_function_closure() const; |
185 | 188 |
186 // Returns the register for the function's outer context. | 189 // Returns the register for the function's outer context. |
187 static Register function_context(); | 190 static Register function_context(); |
188 bool is_function_context() const; | 191 bool is_function_context() const; |
189 | 192 |
190 static Register FromOperand(uint8_t operand); | 193 static Register FromOperand(uint8_t operand); |
191 uint8_t ToOperand() const; | 194 uint8_t ToOperand() const; |
192 | 195 |
| 196 static bool AreContiguous(Register reg1, Register reg2, |
| 197 Register reg3 = Register(), |
| 198 Register reg4 = Register(), |
| 199 Register reg5 = Register()); |
| 200 |
193 private: | 201 private: |
194 static const int kIllegalIndex = kMaxInt; | 202 static const int kIllegalIndex = kMaxInt; |
195 | 203 |
196 void* operator new(size_t size); | 204 void* operator new(size_t size); |
197 void operator delete(void* p); | 205 void operator delete(void* p); |
198 | 206 |
199 int index_; | 207 int index_; |
200 }; | 208 }; |
201 | 209 |
202 | 210 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 268 |
261 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); | 269 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); |
262 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); | 270 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); |
263 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); | 271 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); |
264 | 272 |
265 } // namespace interpreter | 273 } // namespace interpreter |
266 } // namespace internal | 274 } // namespace internal |
267 } // namespace v8 | 275 } // namespace v8 |
268 | 276 |
269 #endif // V8_INTERPRETER_BYTECODES_H_ | 277 #endif // V8_INTERPRETER_BYTECODES_H_ |
OLD | NEW |