5#ifndef V8_INTERPRETER_BYTECODE_NODE_H_
6#define V8_INTERPRETER_BYTECODE_NODE_H_
15namespace interpreter {
25 source_info_(source_info) {
26 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count());
34 source_info_(source_info) {
35 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count());
36 SetOperand(0, operand0);
45 source_info_(source_info) {
46 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count());
47 SetOperand(0, operand0);
48 SetOperand(1, operand1);
52 uint32_t operand1, uint32_t operand2,
57 source_info_(source_info) {
58 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count());
59 SetOperand(0, operand0);
60 SetOperand(1, operand1);
61 SetOperand(2, operand2);
65 uint32_t operand1, uint32_t operand2,
71 source_info_(source_info) {
72 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count());
73 SetOperand(0, operand0);
74 SetOperand(1, operand1);
75 SetOperand(2, operand2);
76 SetOperand(3, operand3);
80 uint32_t operand1, uint32_t operand2,
81 uint32_t operand3, uint32_t operand4,
86 source_info_(source_info) {
87 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count());
88 SetOperand(0, operand0);
89 SetOperand(1, operand1);
90 SetOperand(2, operand2);
91 SetOperand(3, operand3);
92 SetOperand(4, operand4);
95#define DEFINE_BYTECODE_NODE_CREATOR(Name, ...) \
96 template <typename... Operands> \
97 V8_INLINE static BytecodeNode Name(BytecodeSourceInfo source_info, \
98 Operands... operands) { \
99 return Create<Bytecode::k##Name, __VA_ARGS__>(source_info, operands...); \
102#undef DEFINE_BYTECODE_NODE_CREATOR
105 void Print(std::ostream& os)
const;
113 const uint32_t*
operands()
const {
return operands_; }
122 source_info_ = source_info;
136 uint32_t operand1 = 0, uint32_t operand2 = 0,
137 uint32_t operand3 = 0, uint32_t operand4 = 0)
139 operand_count_(operand_count),
140 operand_scale_(operand_scale),
141 source_info_(source_info) {
142 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count);
143 operands_[0] = operand0;
144 operands_[1] = operand1;
145 operands_[2] = operand2;
146 operands_[3] = operand3;
147 operands_[4] = operand4;
150 template <Bytecode
bytecode, ImplicitRegisterUse accum_use>
152 return BytecodeNode(bytecode, 0, OperandScale::kSingle, source_info);
159 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 0), operand0_type);
161 scale = std::max(
scale, ScaleForOperand<operand0_type>(operand0));
168 uint32_t operand0, uint32_t operand1) {
169 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 0), operand0_type);
170 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 1), operand1_type);
172 scale = std::max(
scale, ScaleForOperand<operand0_type>(operand0));
173 scale = std::max(
scale, ScaleForOperand<operand1_type>(operand1));
181 uint32_t operand0, uint32_t operand1,
183 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 0), operand0_type);
184 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 1), operand1_type);
185 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 2), operand2_type);
187 scale = std::max(
scale, ScaleForOperand<operand0_type>(operand0));
188 scale = std::max(
scale, ScaleForOperand<operand1_type>(operand1));
189 scale = std::max(
scale, ScaleForOperand<operand2_type>(operand2));
198 uint32_t operand0, uint32_t operand1,
199 uint32_t operand2, uint32_t operand3) {
200 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 0), operand0_type);
201 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 1), operand1_type);
202 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 2), operand2_type);
203 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 3), operand3_type);
205 scale = std::max(
scale, ScaleForOperand<operand0_type>(operand0));
206 scale = std::max(
scale, ScaleForOperand<operand1_type>(operand1));
207 scale = std::max(
scale, ScaleForOperand<operand2_type>(operand2));
208 scale = std::max(
scale, ScaleForOperand<operand3_type>(operand3));
218 uint32_t operand0, uint32_t operand1,
219 uint32_t operand2, uint32_t operand3,
221 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 0), operand0_type);
222 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 1), operand1_type);
223 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 2), operand2_type);
224 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 3), operand3_type);
225 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 4), operand4_type);
227 scale = std::max(
scale, ScaleForOperand<operand0_type>(operand0));
228 scale = std::max(
scale, ScaleForOperand<operand1_type>(operand1));
229 scale = std::max(
scale, ScaleForOperand<operand2_type>(operand2));
230 scale = std::max(
scale, ScaleForOperand<operand3_type>(operand3));
231 scale = std::max(
scale, ScaleForOperand<operand4_type>(operand4));
233 operand2, operand3, operand4);
236 template <OperandType operand_type>
238 if (BytecodeOperands::IsScalableUnsignedByte(operand_type)) {
239 return Bytecodes::ScaleForUnsignedOperand(operand);
240 }
else if (BytecodeOperands::IsScalableSignedByte(operand_type)) {
241 return Bytecodes::ScaleForSignedOperand(operand);
243 return OperandScale::kSingle;
248 if (Bytecodes::OperandIsScalableSignedByte(
bytecode(), operand_index)) {
250 std::max(operand_scale_, Bytecodes::ScaleForSignedOperand(operand));
251 }
else if (Bytecodes::OperandIsScalableUnsignedByte(
bytecode(),
254 std::max(operand_scale_, Bytecodes::ScaleForUnsignedOperand(operand));
259 operands_[operand_index] = operand;
260 UpdateScaleForOperand(operand_index, operand);
264 uint32_t operands_[Bytecodes::kMaxOperands];
interpreter::Bytecode bytecode
interpreter::OperandScale scale
#define DEFINE_BYTECODE_NODE_CREATOR(Name,...)
#define BYTECODE_LIST(V, V_TSA)
V8_INLINE BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, uint32_t operand2, uint32_t operand3, BytecodeSourceInfo source_info=BytecodeSourceInfo())
Bytecode bytecode() const
OperandScale operand_scale() const
V8_INLINE BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, BytecodeSourceInfo source_info=BytecodeSourceInfo())
void update_operand0(uint32_t operand0)
static V8_INLINE OperandScale ScaleForOperand(uint32_t operand)
static V8_INLINE BytecodeNode Create(BytecodeSourceInfo source_info, uint32_t operand0, uint32_t operand1)
static V8_INLINE BytecodeNode Create(BytecodeSourceInfo source_info, uint32_t operand0)
static V8_INLINE BytecodeNode Create(BytecodeSourceInfo source_info, uint32_t operand0, uint32_t operand1, uint32_t operand2, uint32_t operand3)
uint32_t operand(int i) const
OperandScale operand_scale_
V8_INLINE BytecodeNode(Bytecode bytecode, int operand_count, OperandScale operand_scale, BytecodeSourceInfo source_info, uint32_t operand0=0, uint32_t operand1=0, uint32_t operand2=0, uint32_t operand3=0, uint32_t operand4=0)
V8_INLINE void SetOperand(int operand_index, uint32_t operand)
V8_INLINE BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, uint32_t operand2, BytecodeSourceInfo source_info=BytecodeSourceInfo())
const BytecodeSourceInfo & source_info() const
void set_source_info(BytecodeSourceInfo source_info)
static V8_INLINE BytecodeNode Create(BytecodeSourceInfo source_info, uint32_t operand0, uint32_t operand1, uint32_t operand2, uint32_t operand3, uint32_t operand4)
V8_INLINE void UpdateScaleForOperand(int operand_index, uint32_t operand)
V8_INLINE BytecodeNode(Bytecode bytecode, BytecodeSourceInfo source_info=BytecodeSourceInfo())
BytecodeSourceInfo source_info_
bool operator!=(const BytecodeNode &other) const
V8_INLINE BytecodeNode(Bytecode bytecode, uint32_t operand0, BytecodeSourceInfo source_info=BytecodeSourceInfo())
static V8_INLINE BytecodeNode Create(BytecodeSourceInfo source_info, uint32_t operand0, uint32_t operand1, uint32_t operand2)
int operand_count() const
static V8_INLINE BytecodeNode Create(BytecodeSourceInfo source_info)
V8_INLINE BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, uint32_t operand2, uint32_t operand3, uint32_t operand4, BytecodeSourceInfo source_info=BytecodeSourceInfo())
const uint32_t * operands() const
base::Vector< const RegExpInstruction > bytecode_
std::ostream & operator<<(std::ostream &os, PaddingSpace padding)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define V8_EXPORT_PRIVATE