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 \ | 97 \ |
98 /* Register-register transfers */ \ | 98 /* Register-register transfers */ \ |
99 V(Mov, OperandType::kReg8, OperandType::kReg8) \ | 99 V(Mov, OperandType::kReg8, OperandType::kReg8) \ |
100 V(MovWide, OperandType::kReg16, OperandType::kReg16) \ | 100 V(MovWide, OperandType::kReg16, OperandType::kReg16) \ |
101 \ | 101 \ |
102 /* LoadIC operations */ \ | 102 /* LoadIC operations */ \ |
103 V(LoadICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ | 103 V(LoadICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ |
104 V(LoadICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ | 104 V(LoadICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ |
105 V(KeyedLoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \ | 105 V(KeyedLoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \ |
106 V(KeyedLoadICStrict, OperandType::kReg8, OperandType::kIdx8) \ | 106 V(KeyedLoadICStrict, OperandType::kReg8, OperandType::kIdx8) \ |
107 /* TODO(rmcilroy): Wide register operands too? */ \ | |
108 V(LoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ | 107 V(LoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ |
109 OperandType::kIdx16) \ | 108 OperandType::kIdx16) \ |
110 V(LoadICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ | 109 V(LoadICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ |
111 OperandType::kIdx16) \ | 110 OperandType::kIdx16) \ |
112 V(KeyedLoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16) \ | 111 V(KeyedLoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16) \ |
113 V(KeyedLoadICStrictWide, OperandType::kReg8, OperandType::kIdx16) \ | 112 V(KeyedLoadICStrictWide, OperandType::kReg8, OperandType::kIdx16) \ |
114 \ | 113 \ |
115 /* StoreIC operations */ \ | 114 /* StoreIC operations */ \ |
116 V(StoreICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ | 115 V(StoreICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ |
117 V(StoreICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ | 116 V(StoreICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ |
118 V(KeyedStoreICSloppy, OperandType::kReg8, OperandType::kReg8, \ | 117 V(KeyedStoreICSloppy, OperandType::kReg8, OperandType::kReg8, \ |
119 OperandType::kIdx8) \ | 118 OperandType::kIdx8) \ |
120 V(KeyedStoreICStrict, OperandType::kReg8, OperandType::kReg8, \ | 119 V(KeyedStoreICStrict, OperandType::kReg8, OperandType::kReg8, \ |
121 OperandType::kIdx8) \ | 120 OperandType::kIdx8) \ |
122 /* TODO(rmcilroy): Wide register operands too? */ \ | |
123 V(StoreICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ | 121 V(StoreICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ |
124 OperandType::kIdx16) \ | 122 OperandType::kIdx16) \ |
125 V(StoreICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ | 123 V(StoreICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ |
126 OperandType::kIdx16) \ | 124 OperandType::kIdx16) \ |
127 V(KeyedStoreICSloppyWide, OperandType::kReg8, OperandType::kReg8, \ | 125 V(KeyedStoreICSloppyWide, OperandType::kReg8, OperandType::kReg8, \ |
128 OperandType::kIdx16) \ | 126 OperandType::kIdx16) \ |
129 V(KeyedStoreICStrictWide, OperandType::kReg8, OperandType::kReg8, \ | 127 V(KeyedStoreICStrictWide, OperandType::kReg8, OperandType::kReg8, \ |
130 OperandType::kIdx16) \ | 128 OperandType::kIdx16) \ |
131 \ | 129 \ |
132 /* Binary Operators */ \ | 130 /* Binary Operators */ \ |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 Register() : index_(kIllegalIndex) {} | 289 Register() : index_(kIllegalIndex) {} |
292 | 290 |
293 explicit Register(int index) : index_(index) {} | 291 explicit Register(int index) : index_(index) {} |
294 | 292 |
295 int index() const { | 293 int index() const { |
296 DCHECK(index_ != kIllegalIndex); | 294 DCHECK(index_ != kIllegalIndex); |
297 return index_; | 295 return index_; |
298 } | 296 } |
299 bool is_parameter() const { return index() < 0; } | 297 bool is_parameter() const { return index() < 0; } |
300 bool is_valid() const { return index_ != kIllegalIndex; } | 298 bool is_valid() const { return index_ != kIllegalIndex; } |
299 bool is_byte_operand() const; | |
300 bool is_short_operand() const; | |
301 | 301 |
302 static Register FromParameterIndex(int index, int parameter_count); | 302 static Register FromParameterIndex(int index, int parameter_count); |
303 int ToParameterIndex(int parameter_count) const; | 303 int ToParameterIndex(int parameter_count) const; |
304 static int MaxParameterIndex(); | 304 static int MaxParameterIndex(); |
305 static int MaxRegisterIndex(); | |
305 | 306 |
306 // Returns the register for the function's closure object. | 307 // Returns the register for the function's closure object. |
307 static Register function_closure(); | 308 static Register function_closure(); |
308 bool is_function_closure() const; | 309 bool is_function_closure() const; |
309 | 310 |
310 // Returns the register for the function's outer context. | 311 // Returns the register for the function's outer context. |
311 static Register function_context(); | 312 static Register function_context(); |
312 bool is_function_context() const; | 313 bool is_function_context() const; |
313 | 314 |
314 // Returns the register for the incoming new target value. | 315 // Returns the register for the incoming new target value. |
315 static Register new_target(); | 316 static Register new_target(); |
316 bool is_new_target() const; | 317 bool is_new_target() const; |
317 | 318 |
318 static Register FromOperand(uint8_t operand); | 319 static Register FromOperand(uint8_t operand); |
319 uint8_t ToOperand() const; | 320 uint8_t ToOperand() const; |
320 | 321 |
321 static Register FromWideOperand(uint16_t operand); | 322 static Register FromWideOperand(uint16_t operand); |
322 uint16_t ToWideOperand() const; | 323 uint16_t ToWideOperand() const; |
323 | 324 |
324 static Register FromRawOperand(uint32_t raw_operand); | 325 static Register FromRawOperand(uint32_t raw_operand); |
325 uint32_t ToRawOperand() const; | 326 uint32_t ToRawOperand() const; |
326 | 327 |
328 static Register IllegalRegister() { return Register(kIllegalIndex); } | |
rmcilroy
2016/01/22 17:50:56
This is just the same as Register(); I'm fine with
| |
329 | |
327 static bool AreContiguous(Register reg1, Register reg2, | 330 static bool AreContiguous(Register reg1, Register reg2, |
328 Register reg3 = Register(), | 331 Register reg3 = Register(), |
329 Register reg4 = Register(), | 332 Register reg4 = Register(), |
330 Register reg5 = Register()); | 333 Register reg5 = Register()); |
331 | 334 |
332 bool operator==(const Register& other) const { | 335 bool operator==(const Register& other) const { |
333 return index() == other.index(); | 336 return index() == other.index(); |
334 } | 337 } |
335 bool operator!=(const Register& other) const { | 338 bool operator!=(const Register& other) const { |
336 return index() != other.index(); | 339 return index() != other.index(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 | 374 |
372 // Returns byte value of bytecode. | 375 // Returns byte value of bytecode. |
373 static uint8_t ToByte(Bytecode bytecode); | 376 static uint8_t ToByte(Bytecode bytecode); |
374 | 377 |
375 // Returns bytecode for |value|. | 378 // Returns bytecode for |value|. |
376 static Bytecode FromByte(uint8_t value); | 379 static Bytecode FromByte(uint8_t value); |
377 | 380 |
378 // Returns the number of operands expected by |bytecode|. | 381 // Returns the number of operands expected by |bytecode|. |
379 static int NumberOfOperands(Bytecode bytecode); | 382 static int NumberOfOperands(Bytecode bytecode); |
380 | 383 |
384 // Returns the number of register operands expected by |bytecode|. | |
385 static int NumberOfRegisterOperands(Bytecode bytecode); | |
386 | |
381 // Return the i-th operand of |bytecode|. | 387 // Return the i-th operand of |bytecode|. |
382 static OperandType GetOperandType(Bytecode bytecode, int i); | 388 static OperandType GetOperandType(Bytecode bytecode, int i); |
383 | 389 |
384 // Return the size of the i-th operand of |bytecode|. | 390 // Return the size of the i-th operand of |bytecode|. |
385 static OperandSize GetOperandSize(Bytecode bytecode, int i); | 391 static OperandSize GetOperandSize(Bytecode bytecode, int i); |
386 | 392 |
387 // Returns the offset of the i-th operand of |bytecode| relative to the start | 393 // Returns the offset of the i-th operand of |bytecode| relative to the start |
388 // of the bytecode. | 394 // of the bytecode. |
389 static int GetOperandOffset(Bytecode bytecode, int i); | 395 static int GetOperandOffset(Bytecode bytecode, int i); |
390 | 396 |
391 // Returns the size of the bytecode including its operands. | 397 // Returns the size of the bytecode including its operands. |
392 static int Size(Bytecode bytecode); | 398 static int Size(Bytecode bytecode); |
393 | 399 |
394 // Returns the size of |operand|. | 400 // Returns the size of |operand|. |
395 static OperandSize SizeOfOperand(OperandType operand); | 401 static OperandSize SizeOfOperand(OperandType operand); |
396 | 402 |
397 // Return true if the bytecode is a conditional jump taking | 403 // Returns true if the bytecode is a conditional jump taking |
398 // an immediate byte operand (OperandType::kImm8). | 404 // an immediate byte operand (OperandType::kImm8). |
399 static bool IsConditionalJumpImmediate(Bytecode bytecode); | 405 static bool IsConditionalJumpImmediate(Bytecode bytecode); |
400 | 406 |
401 // Return true if the bytecode is a conditional jump taking | 407 // Returns true if the bytecode is a conditional jump taking |
402 // a constant pool entry (OperandType::kIdx8). | 408 // a constant pool entry (OperandType::kIdx8). |
403 static bool IsConditionalJumpConstant(Bytecode bytecode); | 409 static bool IsConditionalJumpConstant(Bytecode bytecode); |
404 | 410 |
405 // Return true if the bytecode is a conditional jump taking | 411 // Returns true if the bytecode is a conditional jump taking |
406 // a constant pool entry (OperandType::kIdx16). | 412 // a constant pool entry (OperandType::kIdx16). |
407 static bool IsConditionalJumpConstantWide(Bytecode bytecode); | 413 static bool IsConditionalJumpConstantWide(Bytecode bytecode); |
408 | 414 |
409 // Return true if the bytecode is a conditional jump taking | 415 // Returns true if the bytecode is a conditional jump taking |
410 // any kind of operand. | 416 // any kind of operand. |
411 static bool IsConditionalJump(Bytecode bytecode); | 417 static bool IsConditionalJump(Bytecode bytecode); |
412 | 418 |
413 // Return true if the bytecode is a jump or a conditional jump taking | 419 // Returns true if the bytecode is a jump or a conditional jump taking |
414 // an immediate byte operand (OperandType::kImm8). | 420 // an immediate byte operand (OperandType::kImm8). |
415 static bool IsJumpImmediate(Bytecode bytecode); | 421 static bool IsJumpImmediate(Bytecode bytecode); |
416 | 422 |
417 // Return true if the bytecode is a jump or conditional jump taking a | 423 // Returns true if the bytecode is a jump or conditional jump taking a |
418 // constant pool entry (OperandType::kIdx8). | 424 // constant pool entry (OperandType::kIdx8). |
419 static bool IsJumpConstant(Bytecode bytecode); | 425 static bool IsJumpConstant(Bytecode bytecode); |
420 | 426 |
421 // Return true if the bytecode is a jump or conditional jump taking a | 427 // Returns true if the bytecode is a jump or conditional jump taking a |
422 // constant pool entry (OperandType::kIdx16). | 428 // constant pool entry (OperandType::kIdx16). |
423 static bool IsJumpConstantWide(Bytecode bytecode); | 429 static bool IsJumpConstantWide(Bytecode bytecode); |
424 | 430 |
425 // Return true if the bytecode is a jump or conditional jump taking | 431 // Return true if the bytecode is a jump or conditional jump taking |
426 // any kind of operand. | 432 // any kind of operand. |
427 static bool IsJump(Bytecode bytecode); | 433 static bool IsJump(Bytecode bytecode); |
428 | 434 |
429 // Return true if the bytecode is a conditional jump, a jump, or a return. | 435 // Return true if the bytecode is a conditional jump, a jump, or a return. |
430 static bool IsJumpOrReturn(Bytecode bytecode); | 436 static bool IsJumpOrReturn(Bytecode bytecode); |
431 | 437 |
432 // Decode a single bytecode and operands to |os|. | 438 // Decode a single bytecode and operands to |os|. |
433 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start, | 439 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start, |
434 int number_of_parameters); | 440 int number_of_parameters); |
435 | 441 |
436 private: | 442 private: |
437 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes); | 443 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes); |
438 }; | 444 }; |
439 | 445 |
440 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); | 446 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); |
441 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); | 447 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); |
442 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); | 448 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); |
443 | 449 |
444 } // namespace interpreter | 450 } // namespace interpreter |
445 } // namespace internal | 451 } // namespace internal |
446 } // namespace v8 | 452 } // namespace v8 |
447 | 453 |
448 #endif // V8_INTERPRETER_BYTECODES_H_ | 454 #endif // V8_INTERPRETER_BYTECODES_H_ |
OLD | NEW |