Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: src/interpreter/bytecode-pipeline.cc

Issue 1985753002: [interpreter] Introduce fused bytecodes for common sequences. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "src/interpreter/bytecode-pipeline.h" 5 #include "src/interpreter/bytecode-pipeline.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 #include "src/interpreter/source-position-table.h" 8 #include "src/interpreter/source-position-table.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 void BytecodeNode::set_bytecode(Bytecode bytecode, uint32_t operand0, 85 void BytecodeNode::set_bytecode(Bytecode bytecode, uint32_t operand0,
86 OperandScale operand_scale) { 86 OperandScale operand_scale) {
87 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 1); 87 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 1);
88 bytecode_ = bytecode; 88 bytecode_ = bytecode;
89 operands_[0] = operand0; 89 operands_[0] = operand0;
90 operand_scale_ = operand_scale; 90 operand_scale_ = operand_scale;
91 } 91 }
92 92
93 size_t BytecodeNode::Size() const { 93 void BytecodeNode::Clone(const BytecodeNode* const other) {
94 size_t size = Bytecodes::Size(bytecode_, operand_scale_); 94 memcpy(this, other, sizeof(*other));
95 if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale_)) {
96 size += 1;
97 }
98 return size;
99 } 95 }
100 96
101 void BytecodeNode::Print(std::ostream& os) const { 97 void BytecodeNode::Print(std::ostream& os) const {
102 #ifdef DEBUG 98 #ifdef DEBUG
103 std::ios saved_state(nullptr); 99 std::ios saved_state(nullptr);
104 saved_state.copyfmt(os); 100 saved_state.copyfmt(os);
105 101
106 os << Bytecodes::ToString(bytecode_); 102 os << Bytecodes::ToString(bytecode_);
107 if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale_)) { 103 if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale_)) {
108 Bytecode scale_prefix = 104 Bytecode scale_prefix =
109 Bytecodes::OperandScaleToPrefixBytecode(operand_scale_); 105 Bytecodes::OperandScaleToPrefixBytecode(operand_scale_);
110 os << '.' << Bytecodes::ToString(scale_prefix); 106 os << '.' << Bytecodes::ToString(scale_prefix);
111 } 107 }
112 108
113 for (int i = 0; i < operand_count(); ++i) { 109 for (int i = 0; i < operand_count(); ++i) {
114 os << ' ' << std::setw(8) << std::setfill('0') << std::hex << operands_[i]; 110 os << ' ' << std::setw(8) << std::setfill('0') << std::hex << operands_[i];
115 } 111 }
116 os.copyfmt(saved_state); 112 os.copyfmt(saved_state);
117 113
118 if (source_info_.is_valid()) { 114 if (source_info_.is_valid()) {
119 os << source_info_; 115 os << ' ' << source_info_;
120 } 116 }
121 os << '\n'; 117 os << '\n';
122 #else 118 #else
123 os << static_cast<const void*>(this); 119 os << static_cast<const void*>(this);
124 #endif // DEBUG 120 #endif // DEBUG
125 } 121 }
126 122
127 void BytecodeNode::Clone(const BytecodeNode* const other) { 123 size_t BytecodeNode::Size() const {
128 memcpy(this, other, sizeof(*other)); 124 size_t size = Bytecodes::Size(bytecode_, operand_scale_);
125 if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale_)) {
126 size += 1;
127 }
128 return size;
129 }
130
131 void BytecodeNode::Transform(Bytecode new_bytecode, uint32_t extra_operand,
132 OperandScale extra_operand_scale) {
133 DCHECK_EQ(Bytecodes::NumberOfOperands(new_bytecode),
134 Bytecodes::NumberOfOperands(bytecode()) + 1);
135 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 1 ||
136 Bytecodes::GetOperandType(new_bytecode, 0) ==
137 Bytecodes::GetOperandType(bytecode(), 0));
138 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 2 ||
139 Bytecodes::GetOperandType(new_bytecode, 1) ==
140 Bytecodes::GetOperandType(bytecode(), 1));
141 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 3 ||
142 Bytecodes::GetOperandType(new_bytecode, 2) ==
143 Bytecodes::GetOperandType(bytecode(), 2));
144 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 4);
145 operand_scale_ = std::max(extra_operand_scale, operand_scale());
146 operands_[operand_count()] = extra_operand;
147 bytecode_ = new_bytecode;
129 } 148 }
130 149
131 bool BytecodeNode::operator==(const BytecodeNode& other) const { 150 bool BytecodeNode::operator==(const BytecodeNode& other) const {
132 if (this == &other) { 151 if (this == &other) {
133 return true; 152 return true;
134 } else if (this->bytecode() != other.bytecode() || 153 } else if (this->bytecode() != other.bytecode() ||
135 this->source_info() != other.source_info()) { 154 this->source_info() != other.source_info()) {
136 return false; 155 return false;
137 } else { 156 } else {
138 for (int i = 0; i < this->operand_count(); ++i) { 157 for (int i = 0; i < this->operand_count(); ++i) {
(...skipping 14 matching lines...) Expand all
153 if (info.is_valid()) { 172 if (info.is_valid()) {
154 char description = info.is_statement() ? 'S' : 'E'; 173 char description = info.is_statement() ? 'S' : 'E';
155 os << info.source_position() << ' ' << description << '>'; 174 os << info.source_position() << ' ' << description << '>';
156 } 175 }
157 return os; 176 return os;
158 } 177 }
159 178
160 } // namespace interpreter 179 } // namespace interpreter
161 } // namespace internal 180 } // namespace internal
162 } // namespace v8 181 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698