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

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: Rebase. 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
« no previous file with comments | « src/interpreter/bytecode-pipeline.h ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 83
84 void BytecodeNode::set_bytecode(Bytecode bytecode, uint32_t operand0, 84 void BytecodeNode::set_bytecode(Bytecode bytecode, uint32_t operand0,
85 OperandScale operand_scale) { 85 OperandScale operand_scale) {
86 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 1); 86 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 1);
87 bytecode_ = bytecode; 87 bytecode_ = bytecode;
88 operands_[0] = operand0; 88 operands_[0] = operand0;
89 operand_scale_ = operand_scale; 89 operand_scale_ = operand_scale;
90 } 90 }
91 91
92 size_t BytecodeNode::Size() const { 92 void BytecodeNode::Clone(const BytecodeNode* const other) {
93 size_t size = Bytecodes::Size(bytecode_, operand_scale_); 93 memcpy(this, other, sizeof(*other));
94 if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale_)) {
95 size += 1;
96 }
97 return size;
98 } 94 }
99 95
100 void BytecodeNode::Print(std::ostream& os) const { 96 void BytecodeNode::Print(std::ostream& os) const {
101 #ifdef DEBUG 97 #ifdef DEBUG
102 std::ios saved_state(nullptr); 98 std::ios saved_state(nullptr);
103 saved_state.copyfmt(os); 99 saved_state.copyfmt(os);
104 100
105 os << Bytecodes::ToString(bytecode_); 101 os << Bytecodes::ToString(bytecode_);
106 if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale_)) { 102 if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale_)) {
107 Bytecode scale_prefix = 103 Bytecode scale_prefix =
108 Bytecodes::OperandScaleToPrefixBytecode(operand_scale_); 104 Bytecodes::OperandScaleToPrefixBytecode(operand_scale_);
109 os << '.' << Bytecodes::ToString(scale_prefix); 105 os << '.' << Bytecodes::ToString(scale_prefix);
110 } 106 }
111 107
112 for (int i = 0; i < operand_count(); ++i) { 108 for (int i = 0; i < operand_count(); ++i) {
113 os << ' ' << std::setw(8) << std::setfill('0') << std::hex << operands_[i]; 109 os << ' ' << std::setw(8) << std::setfill('0') << std::hex << operands_[i];
114 } 110 }
115 os.copyfmt(saved_state); 111 os.copyfmt(saved_state);
116 112
117 if (source_info_.is_valid()) { 113 if (source_info_.is_valid()) {
118 os << ' ' << source_info_; 114 os << ' ' << source_info_;
119 } 115 }
120 os << '\n'; 116 os << '\n';
121 #else 117 #else
122 os << static_cast<const void*>(this); 118 os << static_cast<const void*>(this);
123 #endif // DEBUG 119 #endif // DEBUG
124 } 120 }
125 121
126 void BytecodeNode::Clone(const BytecodeNode* const other) { 122 size_t BytecodeNode::Size() const {
127 memcpy(this, other, sizeof(*other)); 123 size_t size = Bytecodes::Size(bytecode_, operand_scale_);
124 if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale_)) {
125 size += 1;
126 }
127 return size;
128 }
129
130 void BytecodeNode::Transform(Bytecode new_bytecode, uint32_t extra_operand,
131 OperandScale extra_operand_scale) {
132 DCHECK_EQ(Bytecodes::NumberOfOperands(new_bytecode),
133 Bytecodes::NumberOfOperands(bytecode()) + 1);
134 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 1 ||
135 Bytecodes::GetOperandType(new_bytecode, 0) ==
136 Bytecodes::GetOperandType(bytecode(), 0));
137 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 2 ||
138 Bytecodes::GetOperandType(new_bytecode, 1) ==
139 Bytecodes::GetOperandType(bytecode(), 1));
140 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 3 ||
141 Bytecodes::GetOperandType(new_bytecode, 2) ==
142 Bytecodes::GetOperandType(bytecode(), 2));
143 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 4);
144 operand_scale_ = std::max(extra_operand_scale, operand_scale());
145 operands_[operand_count()] = extra_operand;
146 bytecode_ = new_bytecode;
128 } 147 }
129 148
130 bool BytecodeNode::operator==(const BytecodeNode& other) const { 149 bool BytecodeNode::operator==(const BytecodeNode& other) const {
131 if (this == &other) { 150 if (this == &other) {
132 return true; 151 return true;
133 } else if (this->bytecode() != other.bytecode() || 152 } else if (this->bytecode() != other.bytecode() ||
134 this->source_info() != other.source_info()) { 153 this->source_info() != other.source_info()) {
135 return false; 154 return false;
136 } else { 155 } else {
137 for (int i = 0; i < this->operand_count(); ++i) { 156 for (int i = 0; i < this->operand_count(); ++i) {
(...skipping 14 matching lines...) Expand all
152 if (info.is_valid()) { 171 if (info.is_valid()) {
153 char description = info.is_statement() ? 'S' : 'E'; 172 char description = info.is_statement() ? 'S' : 'E';
154 os << info.source_position() << ' ' << description << '>'; 173 os << info.source_position() << ' ' << description << '>';
155 } 174 }
156 return os; 175 return os;
157 } 176 }
158 177
159 } // namespace interpreter 178 } // namespace interpreter
160 } // namespace internal 179 } // namespace internal
161 } // namespace v8 180 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-pipeline.h ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698