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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 V(TypeOf, AccumulatorUse::kReadWrite) \ | 147 V(TypeOf, AccumulatorUse::kReadWrite) \ |
148 V(DeletePropertyStrict, AccumulatorUse::kReadWrite, OperandType::kReg) \ | 148 V(DeletePropertyStrict, AccumulatorUse::kReadWrite, OperandType::kReg) \ |
149 V(DeletePropertySloppy, AccumulatorUse::kReadWrite, OperandType::kReg) \ | 149 V(DeletePropertySloppy, AccumulatorUse::kReadWrite, OperandType::kReg) \ |
150 \ | 150 \ |
151 /* GetSuperConstructor operator */ \ | 151 /* GetSuperConstructor operator */ \ |
152 V(GetSuperConstructor, AccumulatorUse::kRead, OperandType::kRegOut) \ | 152 V(GetSuperConstructor, AccumulatorUse::kRead, OperandType::kRegOut) \ |
153 \ | 153 \ |
154 /* Call operations */ \ | 154 /* Call operations */ \ |
155 V(Call, AccumulatorUse::kWrite, OperandType::kReg, OperandType::kRegList, \ | 155 V(Call, AccumulatorUse::kWrite, OperandType::kReg, OperandType::kRegList, \ |
156 OperandType::kRegCount, OperandType::kIdx) \ | 156 OperandType::kRegCount, OperandType::kIdx) \ |
157 V(Call0, AccumulatorUse::kWrite, OperandType::kReg, OperandType::kReg, \ | |
158 OperandType::kIdx) \ | |
159 V(Call1, AccumulatorUse::kWrite, OperandType::kReg, OperandType::kReg, \ | |
160 OperandType::kReg, OperandType::kIdx) \ | |
161 V(Call2, AccumulatorUse::kWrite, OperandType::kReg, OperandType::kReg, \ | |
162 OperandType::kReg, OperandType::kReg, OperandType::kIdx) \ | |
163 V(CallProperty, AccumulatorUse::kWrite, OperandType::kReg, \ | 157 V(CallProperty, AccumulatorUse::kWrite, OperandType::kReg, \ |
164 OperandType::kRegList, OperandType::kRegCount, OperandType::kIdx) \ | 158 OperandType::kRegList, OperandType::kRegCount, OperandType::kIdx) \ |
165 V(CallProperty0, AccumulatorUse::kWrite, OperandType::kReg, \ | |
166 OperandType::kReg, OperandType::kIdx) \ | |
167 V(CallProperty1, AccumulatorUse::kWrite, OperandType::kReg, \ | |
168 OperandType::kReg, OperandType::kReg, OperandType::kIdx) \ | |
169 V(CallProperty2, AccumulatorUse::kWrite, OperandType::kReg, \ | |
170 OperandType::kReg, OperandType::kReg, OperandType::kReg, \ | |
171 OperandType::kIdx) \ | |
172 V(CallWithSpread, AccumulatorUse::kWrite, OperandType::kReg, \ | 159 V(CallWithSpread, AccumulatorUse::kWrite, OperandType::kReg, \ |
173 OperandType::kRegList, OperandType::kRegCount) \ | 160 OperandType::kRegList, OperandType::kRegCount) \ |
174 V(TailCall, AccumulatorUse::kWrite, OperandType::kReg, \ | 161 V(TailCall, AccumulatorUse::kWrite, OperandType::kReg, \ |
175 OperandType::kRegList, OperandType::kRegCount, OperandType::kIdx) \ | 162 OperandType::kRegList, OperandType::kRegCount, OperandType::kIdx) \ |
176 V(CallRuntime, AccumulatorUse::kWrite, OperandType::kRuntimeId, \ | 163 V(CallRuntime, AccumulatorUse::kWrite, OperandType::kRuntimeId, \ |
177 OperandType::kRegList, OperandType::kRegCount) \ | 164 OperandType::kRegList, OperandType::kRegCount) \ |
178 V(CallRuntimeForPair, AccumulatorUse::kNone, OperandType::kRuntimeId, \ | 165 V(CallRuntimeForPair, AccumulatorUse::kNone, OperandType::kRuntimeId, \ |
179 OperandType::kRegList, OperandType::kRegCount, OperandType::kRegOutPair) \ | 166 OperandType::kRegList, OperandType::kRegCount, OperandType::kRegOutPair) \ |
180 V(CallJSRuntime, AccumulatorUse::kWrite, OperandType::kIdx, \ | 167 V(CallJSRuntime, AccumulatorUse::kWrite, OperandType::kIdx, \ |
181 OperandType::kRegList, OperandType::kRegCount) \ | 168 OperandType::kRegList, OperandType::kRegCount) \ |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 #define COUNT_BYTECODE(x, ...) +1 | 400 #define COUNT_BYTECODE(x, ...) +1 |
414 // The COUNT_BYTECODE macro will turn this into kLast = -1 +1 +1... which will | 401 // The COUNT_BYTECODE macro will turn this into kLast = -1 +1 +1... which will |
415 // evaluate to the same value as the last real bytecode. | 402 // evaluate to the same value as the last real bytecode. |
416 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) | 403 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) |
417 #undef COUNT_BYTECODE | 404 #undef COUNT_BYTECODE |
418 }; | 405 }; |
419 | 406 |
420 class V8_EXPORT_PRIVATE Bytecodes final { | 407 class V8_EXPORT_PRIVATE Bytecodes final { |
421 public: | 408 public: |
422 // The maximum number of operands a bytecode may have. | 409 // The maximum number of operands a bytecode may have. |
423 static const int kMaxOperands = 5; | 410 static const int kMaxOperands = 4; |
424 | 411 |
425 // Returns string representation of |bytecode|. | 412 // Returns string representation of |bytecode|. |
426 static const char* ToString(Bytecode bytecode); | 413 static const char* ToString(Bytecode bytecode); |
427 | 414 |
428 // Returns string representation of |bytecode|. | 415 // Returns string representation of |bytecode|. |
429 static std::string ToString(Bytecode bytecode, OperandScale operand_scale); | 416 static std::string ToString(Bytecode bytecode, OperandScale operand_scale); |
430 | 417 |
431 // Returns byte value of bytecode. | 418 // Returns byte value of bytecode. |
432 static uint8_t ToByte(Bytecode bytecode) { | 419 static uint8_t ToByte(Bytecode bytecode) { |
433 DCHECK_LE(bytecode, Bytecode::kLast); | 420 DCHECK_LE(bytecode, Bytecode::kLast); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 } | 614 } |
628 | 615 |
629 // Returns true if |bytecode| puts a name in the accumulator. | 616 // Returns true if |bytecode| puts a name in the accumulator. |
630 static constexpr bool PutsNameInAccumulator(Bytecode bytecode) { | 617 static constexpr bool PutsNameInAccumulator(Bytecode bytecode) { |
631 return bytecode == Bytecode::kTypeOf; | 618 return bytecode == Bytecode::kTypeOf; |
632 } | 619 } |
633 | 620 |
634 // Returns true if the bytecode is a call or a constructor call. | 621 // Returns true if the bytecode is a call or a constructor call. |
635 static constexpr bool IsCallOrConstruct(Bytecode bytecode) { | 622 static constexpr bool IsCallOrConstruct(Bytecode bytecode) { |
636 return bytecode == Bytecode::kCall || bytecode == Bytecode::kCallProperty || | 623 return bytecode == Bytecode::kCall || bytecode == Bytecode::kCallProperty || |
637 bytecode == Bytecode::kCall0 || | |
638 bytecode == Bytecode::kCallProperty0 || | |
639 bytecode == Bytecode::kCall1 || | |
640 bytecode == Bytecode::kCallProperty1 || | |
641 bytecode == Bytecode::kCall2 || | |
642 bytecode == Bytecode::kCallProperty2 || | |
643 bytecode == Bytecode::kTailCall || | 624 bytecode == Bytecode::kTailCall || |
644 bytecode == Bytecode::kConstruct || | 625 bytecode == Bytecode::kConstruct || |
645 bytecode == Bytecode::kCallWithSpread || | 626 bytecode == Bytecode::kCallWithSpread || |
646 bytecode == Bytecode::kConstructWithSpread || | 627 bytecode == Bytecode::kConstructWithSpread || |
647 bytecode == Bytecode::kInvokeIntrinsic || | 628 bytecode == Bytecode::kInvokeIntrinsic || |
648 bytecode == Bytecode::kCallJSRuntime; | 629 bytecode == Bytecode::kCallJSRuntime; |
649 } | 630 } |
650 | 631 |
651 // Returns true if the bytecode is a call to the runtime. | 632 // Returns true if the bytecode is a call to the runtime. |
652 static constexpr bool IsCallRuntime(Bytecode bytecode) { | 633 static constexpr bool IsCallRuntime(Bytecode bytecode) { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 }; | 834 }; |
854 | 835 |
855 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, | 836 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, |
856 const Bytecode& bytecode); | 837 const Bytecode& bytecode); |
857 | 838 |
858 } // namespace interpreter | 839 } // namespace interpreter |
859 } // namespace internal | 840 } // namespace internal |
860 } // namespace v8 | 841 } // namespace v8 |
861 | 842 |
862 #endif // V8_INTERPRETER_BYTECODES_H_ | 843 #endif // V8_INTERPRETER_BYTECODES_H_ |
OLD | NEW |