| 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_BYTECODE_PIPELINE_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_PIPELINE_H_ |
| 6 #define V8_INTERPRETER_BYTECODE_PIPELINE_H_ | 6 #define V8_INTERPRETER_BYTECODE_PIPELINE_H_ |
| 7 | 7 |
| 8 #include "src/interpreter/bytecode-register-allocator.h" | 8 #include "src/interpreter/bytecode-register-allocator.h" |
| 9 #include "src/interpreter/bytecodes.h" | 9 #include "src/interpreter/bytecodes.h" |
| 10 #include "src/zone-containers.h" | 10 #include "src/zone-containers.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 private: | 84 private: |
| 85 int source_position_; | 85 int source_position_; |
| 86 bool is_statement_; | 86 bool is_statement_; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 // A container for a generated bytecode, it's operands, and source information. | 89 // A container for a generated bytecode, it's operands, and source information. |
| 90 // These must be allocated by a BytecodeNodeAllocator instance. | 90 // These must be allocated by a BytecodeNodeAllocator instance. |
| 91 class BytecodeNode final : ZoneObject { | 91 class BytecodeNode final : ZoneObject { |
| 92 public: | 92 public: |
| 93 explicit BytecodeNode(Bytecode bytecode = Bytecode::kIllegal); | 93 explicit BytecodeNode(Bytecode bytecode = Bytecode::kIllegal); |
| 94 BytecodeNode(Bytecode bytecode, uint32_t operand0, | 94 BytecodeNode(Bytecode bytecode, uint32_t operand0); |
| 95 OperandScale operand_scale); | 95 BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1); |
| 96 BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, | 96 BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
| 97 OperandScale operand_scale); | 97 uint32_t operand2); |
| 98 BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, | 98 BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
| 99 uint32_t operand2, OperandScale operand_scale); | 99 uint32_t operand2, uint32_t operand3); |
| 100 BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, | |
| 101 uint32_t operand2, uint32_t operand3, | |
| 102 OperandScale operand_scale); | |
| 103 | 100 |
| 104 BytecodeNode(const BytecodeNode& other); | 101 BytecodeNode(const BytecodeNode& other); |
| 105 BytecodeNode& operator=(const BytecodeNode& other); | 102 BytecodeNode& operator=(const BytecodeNode& other); |
| 106 | 103 |
| 107 void set_bytecode(Bytecode bytecode); | 104 void set_bytecode(Bytecode bytecode); |
| 108 void set_bytecode(Bytecode bytecode, uint32_t operand0, | 105 void set_bytecode(Bytecode bytecode, uint32_t operand0); |
| 109 OperandScale operand_scale); | |
| 110 | 106 |
| 111 // Clone |other|. | 107 // Clone |other|. |
| 112 void Clone(const BytecodeNode* const other); | 108 void Clone(const BytecodeNode* const other); |
| 113 | 109 |
| 114 // Print to stream |os|. | 110 // Print to stream |os|. |
| 115 void Print(std::ostream& os) const; | 111 void Print(std::ostream& os) const; |
| 116 | 112 |
| 117 // Return the size when this node is serialized to a bytecode array. | |
| 118 size_t Size() const; | |
| 119 | |
| 120 // Transform to a node representing |new_bytecode| which has one | 113 // Transform to a node representing |new_bytecode| which has one |
| 121 // operand more than the current bytecode. | 114 // operand more than the current bytecode. |
| 122 void Transform(Bytecode new_bytecode, uint32_t extra_operand, | 115 void Transform(Bytecode new_bytecode, uint32_t extra_operand); |
| 123 OperandScale extra_operand_scale); | |
| 124 | 116 |
| 125 Bytecode bytecode() const { return bytecode_; } | 117 Bytecode bytecode() const { return bytecode_; } |
| 126 | 118 |
| 127 uint32_t operand(int i) const { | 119 uint32_t operand(int i) const { |
| 128 DCHECK_LT(i, operand_count()); | 120 DCHECK_LT(i, operand_count()); |
| 129 return operands_[i]; | 121 return operands_[i]; |
| 130 } | 122 } |
| 131 uint32_t* operands() { return operands_; } | 123 uint32_t* operands() { return operands_; } |
| 132 const uint32_t* operands() const { return operands_; } | 124 const uint32_t* operands() const { return operands_; } |
| 133 | 125 |
| 134 int operand_count() const { return Bytecodes::NumberOfOperands(bytecode_); } | 126 int operand_count() const { return Bytecodes::NumberOfOperands(bytecode_); } |
| 135 OperandScale operand_scale() const { return operand_scale_; } | |
| 136 void set_operand_scale(OperandScale operand_scale) { | |
| 137 operand_scale_ = operand_scale; | |
| 138 } | |
| 139 | 127 |
| 140 const BytecodeSourceInfo& source_info() const { return source_info_; } | 128 const BytecodeSourceInfo& source_info() const { return source_info_; } |
| 141 BytecodeSourceInfo& source_info() { return source_info_; } | 129 BytecodeSourceInfo& source_info() { return source_info_; } |
| 142 | 130 |
| 143 bool operator==(const BytecodeNode& other) const; | 131 bool operator==(const BytecodeNode& other) const; |
| 144 bool operator!=(const BytecodeNode& other) const { return !(*this == other); } | 132 bool operator!=(const BytecodeNode& other) const { return !(*this == other); } |
| 145 | 133 |
| 146 private: | 134 private: |
| 147 static const int kInvalidPosition = kMinInt; | 135 static const int kInvalidPosition = kMinInt; |
| 148 static const size_t kMaxOperands = 4; | 136 static const size_t kMaxOperands = 4; |
| 149 | 137 |
| 150 Bytecode bytecode_; | 138 Bytecode bytecode_; |
| 151 uint32_t operands_[kMaxOperands]; | 139 uint32_t operands_[kMaxOperands]; |
| 152 OperandScale operand_scale_; | |
| 153 BytecodeSourceInfo source_info_; | 140 BytecodeSourceInfo source_info_; |
| 154 }; | 141 }; |
| 155 | 142 |
| 156 std::ostream& operator<<(std::ostream& os, const BytecodeSourceInfo& info); | 143 std::ostream& operator<<(std::ostream& os, const BytecodeSourceInfo& info); |
| 157 std::ostream& operator<<(std::ostream& os, const BytecodeNode& node); | 144 std::ostream& operator<<(std::ostream& os, const BytecodeNode& node); |
| 158 | 145 |
| 159 } // namespace interpreter | 146 } // namespace interpreter |
| 160 } // namespace internal | 147 } // namespace internal |
| 161 } // namespace v8 | 148 } // namespace v8 |
| 162 | 149 |
| 163 #endif // V8_INTERPRETER_BYTECODE_PIPELINE_H_ | 150 #endif // V8_INTERPRETER_BYTECODE_PIPELINE_H_ |
| OLD | NEW |