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 <cstdint> | 8 #include <cstdint> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 #include <string> | 10 #include <string> |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 V(DeletePropertySloppy, AccumulatorUse::kReadWrite, OperandType::kReg) \ | 144 V(DeletePropertySloppy, AccumulatorUse::kReadWrite, OperandType::kReg) \ |
145 \ | 145 \ |
146 /* GetSuperConstructor operator */ \ | 146 /* GetSuperConstructor operator */ \ |
147 V(GetSuperConstructor, AccumulatorUse::kRead, OperandType::kRegOut) \ | 147 V(GetSuperConstructor, AccumulatorUse::kRead, OperandType::kRegOut) \ |
148 \ | 148 \ |
149 /* Call operations */ \ | 149 /* Call operations */ \ |
150 V(Call, AccumulatorUse::kWrite, OperandType::kReg, OperandType::kRegList, \ | 150 V(Call, AccumulatorUse::kWrite, OperandType::kReg, OperandType::kRegList, \ |
151 OperandType::kRegCount, OperandType::kIdx) \ | 151 OperandType::kRegCount, OperandType::kIdx) \ |
152 V(CallProperty, AccumulatorUse::kWrite, OperandType::kReg, \ | 152 V(CallProperty, AccumulatorUse::kWrite, OperandType::kReg, \ |
153 OperandType::kRegList, OperandType::kRegCount, OperandType::kIdx) \ | 153 OperandType::kRegList, OperandType::kRegCount, OperandType::kIdx) \ |
| 154 V(Call0, AccumulatorUse::kWrite, OperandType::kReg, OperandType::kReg, \ |
| 155 OperandType::kIdx) \ |
| 156 V(Call1, AccumulatorUse::kWrite, OperandType::kReg, OperandType::kReg, \ |
| 157 OperandType::kReg, OperandType::kIdx) \ |
| 158 V(Call2, AccumulatorUse::kWrite, OperandType::kReg, OperandType::kReg, \ |
| 159 OperandType::kReg, OperandType::kReg, OperandType::kIdx) \ |
154 V(CallWithSpread, AccumulatorUse::kWrite, OperandType::kReg, \ | 160 V(CallWithSpread, AccumulatorUse::kWrite, OperandType::kReg, \ |
155 OperandType::kRegList, OperandType::kRegCount) \ | 161 OperandType::kRegList, OperandType::kRegCount) \ |
156 V(TailCall, AccumulatorUse::kWrite, OperandType::kReg, \ | 162 V(TailCall, AccumulatorUse::kWrite, OperandType::kReg, \ |
157 OperandType::kRegList, OperandType::kRegCount, OperandType::kIdx) \ | 163 OperandType::kRegList, OperandType::kRegCount, OperandType::kIdx) \ |
158 V(CallRuntime, AccumulatorUse::kWrite, OperandType::kRuntimeId, \ | 164 V(CallRuntime, AccumulatorUse::kWrite, OperandType::kRuntimeId, \ |
159 OperandType::kRegList, OperandType::kRegCount) \ | 165 OperandType::kRegList, OperandType::kRegCount) \ |
160 V(CallRuntimeForPair, AccumulatorUse::kNone, OperandType::kRuntimeId, \ | 166 V(CallRuntimeForPair, AccumulatorUse::kNone, OperandType::kRuntimeId, \ |
161 OperandType::kRegList, OperandType::kRegCount, OperandType::kRegOutPair) \ | 167 OperandType::kRegList, OperandType::kRegCount, OperandType::kRegOutPair) \ |
162 V(CallJSRuntime, AccumulatorUse::kWrite, OperandType::kIdx, \ | 168 V(CallJSRuntime, AccumulatorUse::kWrite, OperandType::kIdx, \ |
163 OperandType::kRegList, OperandType::kRegCount) \ | 169 OperandType::kRegList, OperandType::kRegCount) \ |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 #define COUNT_BYTECODE(x, ...) +1 | 401 #define COUNT_BYTECODE(x, ...) +1 |
396 // The COUNT_BYTECODE macro will turn this into kLast = -1 +1 +1... which will | 402 // The COUNT_BYTECODE macro will turn this into kLast = -1 +1 +1... which will |
397 // evaluate to the same value as the last real bytecode. | 403 // evaluate to the same value as the last real bytecode. |
398 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) | 404 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) |
399 #undef COUNT_BYTECODE | 405 #undef COUNT_BYTECODE |
400 }; | 406 }; |
401 | 407 |
402 class V8_EXPORT_PRIVATE Bytecodes final { | 408 class V8_EXPORT_PRIVATE Bytecodes final { |
403 public: | 409 public: |
404 // The maximum number of operands a bytecode may have. | 410 // The maximum number of operands a bytecode may have. |
405 static const int kMaxOperands = 4; | 411 static const int kMaxOperands = 5; |
406 | 412 |
407 // Returns string representation of |bytecode|. | 413 // Returns string representation of |bytecode|. |
408 static const char* ToString(Bytecode bytecode); | 414 static const char* ToString(Bytecode bytecode); |
409 | 415 |
410 // Returns string representation of |bytecode|. | 416 // Returns string representation of |bytecode|. |
411 static std::string ToString(Bytecode bytecode, OperandScale operand_scale); | 417 static std::string ToString(Bytecode bytecode, OperandScale operand_scale); |
412 | 418 |
413 // Returns byte value of bytecode. | 419 // Returns byte value of bytecode. |
414 static uint8_t ToByte(Bytecode bytecode) { | 420 static uint8_t ToByte(Bytecode bytecode) { |
415 DCHECK_LE(bytecode, Bytecode::kLast); | 421 DCHECK_LE(bytecode, Bytecode::kLast); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 return bytecode == Bytecode::kLdar || bytecode == Bytecode::kStar; | 612 return bytecode == Bytecode::kLdar || bytecode == Bytecode::kStar; |
607 } | 613 } |
608 | 614 |
609 // Returns true if |bytecode| puts a name in the accumulator. | 615 // Returns true if |bytecode| puts a name in the accumulator. |
610 static constexpr bool PutsNameInAccumulator(Bytecode bytecode) { | 616 static constexpr bool PutsNameInAccumulator(Bytecode bytecode) { |
611 return bytecode == Bytecode::kTypeOf; | 617 return bytecode == Bytecode::kTypeOf; |
612 } | 618 } |
613 | 619 |
614 // Returns true if the bytecode is a call or a constructor call. | 620 // Returns true if the bytecode is a call or a constructor call. |
615 static constexpr bool IsCallOrConstruct(Bytecode bytecode) { | 621 static constexpr bool IsCallOrConstruct(Bytecode bytecode) { |
616 return bytecode == Bytecode::kCall || bytecode == Bytecode::kCallProperty || | 622 return bytecode == Bytecode::kCall || bytecode == Bytecode::kCall0 || |
| 623 bytecode == Bytecode::kCall1 || bytecode == Bytecode::kCall2 || |
| 624 bytecode == Bytecode::kCallProperty || |
617 bytecode == Bytecode::kTailCall || bytecode == Bytecode::kConstruct; | 625 bytecode == Bytecode::kTailCall || bytecode == Bytecode::kConstruct; |
618 } | 626 } |
619 | 627 |
620 // Returns true if the bytecode is a call to the runtime. | 628 // Returns true if the bytecode is a call to the runtime. |
621 static constexpr bool IsCallRuntime(Bytecode bytecode) { | 629 static constexpr bool IsCallRuntime(Bytecode bytecode) { |
622 return bytecode == Bytecode::kCallRuntime || | 630 return bytecode == Bytecode::kCallRuntime || |
623 bytecode == Bytecode::kCallRuntimeForPair || | 631 bytecode == Bytecode::kCallRuntimeForPair || |
624 bytecode == Bytecode::kInvokeIntrinsic; | 632 bytecode == Bytecode::kInvokeIntrinsic; |
625 } | 633 } |
626 | 634 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 }; | 826 }; |
819 | 827 |
820 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, | 828 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, |
821 const Bytecode& bytecode); | 829 const Bytecode& bytecode); |
822 | 830 |
823 } // namespace interpreter | 831 } // namespace interpreter |
824 } // namespace internal | 832 } // namespace internal |
825 } // namespace v8 | 833 } // namespace v8 |
826 | 834 |
827 #endif // V8_INTERPRETER_BYTECODES_H_ | 835 #endif // V8_INTERPRETER_BYTECODES_H_ |
OLD | NEW |