5#ifndef V8_INTERPRETER_BYTECODE_REGISTER_H_
6#define V8_INTERPRETER_BYTECODE_REGISTER_H_
18namespace interpreter {
35 static constexpr Register FromParameterIndex(
int index);
36 constexpr int ToParameterIndex()
const;
39 constexpr bool is_receiver()
const {
return ToParameterIndex() == 0; }
45 static constexpr Register function_closure();
46 constexpr bool is_function_closure()
const;
49 static constexpr Register current_context();
50 constexpr bool is_current_context()
const;
53 static constexpr Register bytecode_array();
54 constexpr bool is_bytecode_array()
const;
57 static constexpr Register bytecode_offset();
58 constexpr bool is_bytecode_offset()
const;
61 static constexpr Register feedback_vector();
62 constexpr bool is_feedback_vector()
const;
65 static constexpr Register argument_count();
70 static constexpr Register virtual_accumulator();
75 return kRegisterFileStartOffset -
index_;
78 return Register(kRegisterFileStartOffset - operand);
82 DCHECK(Bytecodes::IsShortStar(bytecode));
83 return Register(
static_cast<int>(Bytecode::kStar0) -
84 static_cast<int>(bytecode));
88 if (
index() >= 0 &&
index() < Bytecodes::kShortStarCount) {
90 static_cast<Bytecode>(
static_cast<int>(Bytecode::kStar0) -
index());
91 DCHECK_GE(bytecode, Bytecode::kFirstShortStar);
92 DCHECK_LE(bytecode, Bytecode::kLastShortStar);
101 return index() == other.index();
104 return index() != other.index();
107 return index() < other.index();
110 return index() <= other.index();
113 return index() > other.index();
116 return index() >= other.index();
122 static constexpr
int kInvalidIndex = kMaxInt;
124 static constexpr
int kRegisterFileStartOffset =
125 OffsetFromFPToRegisterIndex(0);
126 static constexpr
int kFirstParamRegisterIndex =
128 static constexpr
int kFunctionClosureRegisterIndex =
130 static constexpr
int kCurrentContextRegisterIndex =
132 static constexpr
int kBytecodeArrayRegisterIndex =
133 OffsetFromFPToRegisterIndex(
135 static constexpr
int kBytecodeOffsetRegisterIndex =
136 OffsetFromFPToRegisterIndex(
138 static constexpr
int kFeedbackVectorRegisterIndex =
139 OffsetFromFPToRegisterIndex(
141 static constexpr
int kCallerPCOffsetRegisterIndex =
143 static constexpr
int kArgumentCountRegisterIndex =
152 : first_reg_index_(
Register::invalid_value().index()),
153 register_count_(0) {}
165 return RegisterList(first_reg_index_ + 1, register_count_ - 1);
169 DCHECK_LT(
static_cast<int>(
i), register_count_);
170 return Register(first_reg_index_ +
static_cast<int>(
i));
174 return (register_count() == 0) ?
Register(0) : (*this)[0];
178 return (register_count() == 0) ?
Register(0) : (*this)[register_count_ - 1];
186 friend class InterpreterTester;
187 friend class BytecodeUtils;
189 friend class CallArguments;
192 : first_reg_index_(first_reg_index), register_count_(register_count) {}
201constexpr Register Register::FromParameterIndex(
int index) {
203 int register_index = kFirstParamRegisterIndex -
index;
208constexpr int Register::ToParameterIndex()
const {
210 return kFirstParamRegisterIndex -
index();
214 return Register(kFunctionClosureRegisterIndex);
217constexpr bool Register::is_function_closure()
const {
218 return index() == kFunctionClosureRegisterIndex;
222 return Register(kCurrentContextRegisterIndex);
225constexpr bool Register::is_current_context()
const {
226 return index() == kCurrentContextRegisterIndex;
230 return Register(kBytecodeArrayRegisterIndex);
233constexpr bool Register::is_bytecode_array()
const {
234 return index() == kBytecodeArrayRegisterIndex;
238 return Register(kBytecodeOffsetRegisterIndex);
241constexpr bool Register::is_bytecode_offset()
const {
242 return index() == kBytecodeOffsetRegisterIndex;
246 return Register(kFeedbackVectorRegisterIndex);
249constexpr bool Register::is_feedback_vector()
const {
250 return index() == kFeedbackVectorRegisterIndex;
254constexpr Register Register::virtual_accumulator() {
255 return Register(kCallerPCOffsetRegisterIndex);
260 return Register(kArgumentCountRegisterIndex);
264 int32_t operand = ToOperand();
266 return OperandSize::kByte;
268 return OperandSize::kShort;
270 return OperandSize::kQuad;
interpreter::Bytecode bytecode
static constexpr int kRegisterFileFromFp
void IncrementRegisterCount()
int register_count() const
const Register first_register() const
const RegisterList PopLeft() const
const Register operator[](size_t i) const
RegisterList(int first_reg_index, int register_count)
const Register last_register() const
const RegisterList Truncate(int new_count)
constexpr bool operator>=(const Register &other) const
constexpr std::optional< Bytecode > TryToShortStar() const
constexpr bool operator<=(const Register &other) const
constexpr int index() const
constexpr bool is_receiver() const
static constexpr Register FromOperand(int32_t operand)
static constexpr Register FromShortStar(Bytecode bytecode)
constexpr int32_t ToOperand() const
static constexpr Register receiver()
constexpr bool operator<(const Register &other) const
static constexpr Register invalid_value()
constexpr bool is_valid() const
constexpr bool operator!=(const Register &other) const
constexpr bool operator>(const Register &other) const
constexpr bool operator==(const Register &other) const
constexpr bool is_parameter() const
constexpr Register(int index=kInvalidIndex)
constexpr const char * ToString(DataViewOp op)
constexpr int OffsetFromFPToRegisterIndex(int offset)
constexpr int kSystemPointerSize
#define DCHECK_LE(v1, v2)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DISALLOW_NEW_AND_DELETE()
#define V8_EXPORT_PRIVATE