Index: src/interpreter/bytecode-pipeline.h |
diff --git a/src/interpreter/bytecode-pipeline.h b/src/interpreter/bytecode-pipeline.h |
index 0b1a1f1bf3afa989d4a18d34848fbcf44eb7e526..6206ae655532f9fc705a494519deb0e4935b4a3b 100644 |
--- a/src/interpreter/bytecode-pipeline.h |
+++ b/src/interpreter/bytecode-pipeline.h |
@@ -47,7 +47,7 @@ |
// Flush the pipeline and generate a bytecode array. |
virtual Handle<BytecodeArray> ToBytecodeArray( |
- Isolate* isolate, int register_count, int parameter_count, |
+ Isolate* isolate, int fixed_register_count, int parameter_count, |
Handle<FixedArray> handler_table) = 0; |
}; |
@@ -134,69 +134,21 @@ |
PositionType position_type_; |
int source_position_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BytecodeSourceInfo); |
}; |
// A container for a generated bytecode, it's operands, and source information. |
// These must be allocated by a BytecodeNodeAllocator instance. |
class BytecodeNode final : ZoneObject { |
public: |
- INLINE(BytecodeNode(const Bytecode bytecode, |
- BytecodeSourceInfo* source_info = nullptr)) |
- : bytecode_(bytecode), |
- operand_count_(0), |
- operand_scale_(OperandScale::kSingle) { |
- DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count()); |
- AttachSourceInfo(source_info); |
- } |
- |
- INLINE(BytecodeNode(const Bytecode bytecode, uint32_t operand0, |
- BytecodeSourceInfo* source_info = nullptr)) |
- : bytecode_(bytecode), |
- operand_count_(1), |
- operand_scale_(OperandScale::kSingle) { |
- DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count()); |
- SetOperand(0, operand0); |
- AttachSourceInfo(source_info); |
- } |
- |
- INLINE(BytecodeNode(const Bytecode bytecode, uint32_t operand0, |
- uint32_t operand1, |
- BytecodeSourceInfo* source_info = nullptr)) |
- : bytecode_(bytecode), |
- operand_count_(2), |
- operand_scale_(OperandScale::kSingle) { |
- DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count()); |
- SetOperand(0, operand0); |
- SetOperand(1, operand1); |
- AttachSourceInfo(source_info); |
- } |
- |
- INLINE(BytecodeNode(const Bytecode bytecode, uint32_t operand0, |
- uint32_t operand1, uint32_t operand2, |
- BytecodeSourceInfo* source_info = nullptr)) |
- : bytecode_(bytecode), |
- operand_count_(3), |
- operand_scale_(OperandScale::kSingle) { |
- DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count()); |
- SetOperand(0, operand0); |
- SetOperand(1, operand1); |
- SetOperand(2, operand2); |
- AttachSourceInfo(source_info); |
- } |
- |
- INLINE(BytecodeNode(const Bytecode bytecode, uint32_t operand0, |
- uint32_t operand1, uint32_t operand2, uint32_t operand3, |
- BytecodeSourceInfo* source_info = nullptr)) |
- : bytecode_(bytecode), |
- operand_count_(4), |
- operand_scale_(OperandScale::kSingle) { |
- DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count()); |
- SetOperand(0, operand0); |
- SetOperand(1, operand1); |
- SetOperand(2, operand2); |
- SetOperand(3, operand3); |
- AttachSourceInfo(source_info); |
- } |
+ explicit BytecodeNode(Bytecode bytecode = Bytecode::kIllegal); |
+ BytecodeNode(Bytecode bytecode, uint32_t operand0); |
+ BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1); |
+ BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
+ uint32_t operand2); |
+ BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
+ uint32_t operand2, uint32_t operand3); |
BytecodeNode(const BytecodeNode& other); |
BytecodeNode& operator=(const BytecodeNode& other); |
@@ -210,33 +162,25 @@ |
void set_bytecode(Bytecode bytecode) { |
DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0); |
bytecode_ = bytecode; |
- operand_count_ = 0; |
- operand_scale_ = OperandScale::kSingle; |
} |
void set_bytecode(Bytecode bytecode, uint32_t operand0) { |
DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 1); |
bytecode_ = bytecode; |
- operand_count_ = 1; |
- operand_scale_ = OperandScale::kSingle; |
- SetOperand(0, operand0); |
+ operands_[0] = operand0; |
} |
void set_bytecode(Bytecode bytecode, uint32_t operand0, uint32_t operand1) { |
DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 2); |
bytecode_ = bytecode; |
- operand_count_ = 2; |
- operand_scale_ = OperandScale::kSingle; |
- SetOperand(0, operand0); |
- SetOperand(1, operand1); |
+ operands_[0] = operand0; |
+ operands_[1] = operand1; |
} |
void set_bytecode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
uint32_t operand2) { |
DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 3); |
bytecode_ = bytecode; |
- operand_count_ = 3; |
- operand_scale_ = OperandScale::kSingle; |
- SetOperand(0, operand0); |
- SetOperand(1, operand1); |
- SetOperand(2, operand2); |
+ operands_[0] = operand0; |
+ operands_[1] = operand1; |
+ operands_[2] = operand2; |
} |
// Clone |other|. |
@@ -247,36 +191,7 @@ |
// Transform to a node representing |new_bytecode| which has one |
// operand more than the current bytecode. |
- void Transform(Bytecode new_bytecode, uint32_t extra_operand) { |
- DCHECK_EQ(Bytecodes::NumberOfOperands(new_bytecode), |
- Bytecodes::NumberOfOperands(bytecode()) + 1); |
- DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 1 || |
- Bytecodes::GetOperandType(new_bytecode, 0) == |
- Bytecodes::GetOperandType(bytecode(), 0)); |
- DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 2 || |
- Bytecodes::GetOperandType(new_bytecode, 1) == |
- Bytecodes::GetOperandType(bytecode(), 1)); |
- DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 3 || |
- Bytecodes::GetOperandType(new_bytecode, 2) == |
- Bytecodes::GetOperandType(bytecode(), 2)); |
- DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 4); |
- |
- bytecode_ = new_bytecode; |
- operand_count_++; |
- SetOperand(operand_count() - 1, extra_operand); |
- } |
- |
- // Updates the operand at |operand_index| to |operand|. |
- void UpdateOperand(int operand_index, uint32_t operand) { |
- DCHECK_LE(operand_index, Bytecodes::NumberOfOperands(bytecode())); |
- operands_[operand_index] = operand; |
- if ((Bytecodes::OperandIsScalableSignedByte(bytecode(), operand_index) && |
- Bytecodes::ScaleForSignedOperand(operand) != operand_scale_) || |
- (Bytecodes::OperandIsScalableUnsignedByte(bytecode(), operand_index) && |
- Bytecodes::ScaleForUnsignedOperand(operand) != operand_scale_)) { |
- UpdateScale(); |
- } |
- } |
+ void Transform(Bytecode new_bytecode, uint32_t extra_operand); |
Bytecode bytecode() const { return bytecode_; } |
@@ -284,60 +199,22 @@ |
DCHECK_LT(i, operand_count()); |
return operands_[i]; |
} |
+ uint32_t* operands() { return operands_; } |
const uint32_t* operands() const { return operands_; } |
- int operand_count() const { return operand_count_; } |
- OperandScale operand_scale() const { return operand_scale_; } |
+ int operand_count() const { return Bytecodes::NumberOfOperands(bytecode_); } |
const BytecodeSourceInfo& source_info() const { return source_info_; } |
- BytecodeSourceInfo* source_info_ptr() { return &source_info_; } |
+ BytecodeSourceInfo& source_info() { return source_info_; } |
bool operator==(const BytecodeNode& other) const; |
bool operator!=(const BytecodeNode& other) const { return !(*this == other); } |
private: |
- INLINE(void AttachSourceInfo(BytecodeSourceInfo* source_info)) { |
- if (source_info && source_info->is_valid()) { |
- // Statement positions need to be emitted immediately. Expression |
- // positions can be pushed back until a bytecode is found that can |
- // throw (if expression position filtering is turned on). We only |
- // invalidate the existing source position information if it is used. |
- if (source_info->is_statement() || |
- !FLAG_ignition_filter_expression_positions || |
- !Bytecodes::IsWithoutExternalSideEffects(bytecode())) { |
- source_info_.Clone(*source_info); |
- source_info->set_invalid(); |
- } |
- } |
- } |
- |
- INLINE(void UpdateScaleForOperand(int operand_index, uint32_t operand)) { |
- if (Bytecodes::OperandIsScalableSignedByte(bytecode(), operand_index)) { |
- operand_scale_ = |
- std::max(operand_scale_, Bytecodes::ScaleForSignedOperand(operand)); |
- } else if (Bytecodes::OperandIsScalableUnsignedByte(bytecode(), |
- operand_index)) { |
- operand_scale_ = |
- std::max(operand_scale_, Bytecodes::ScaleForUnsignedOperand(operand)); |
- } |
- } |
- |
- INLINE(void SetOperand(int operand_index, uint32_t operand)) { |
- operands_[operand_index] = operand; |
- UpdateScaleForOperand(operand_index, operand); |
- } |
- |
- void UpdateScale() { |
- operand_scale_ = OperandScale::kSingle; |
- for (int i = 0; i < operand_count(); i++) { |
- UpdateScaleForOperand(i, operands_[i]); |
- } |
- } |
+ static const int kInvalidPosition = kMinInt; |
Bytecode bytecode_; |
uint32_t operands_[Bytecodes::kMaxOperands]; |
- int operand_count_; |
- OperandScale operand_scale_; |
BytecodeSourceInfo source_info_; |
}; |