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

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

Issue 2041913002: [interpreter] Remove OperandScale from front stages of pipeline. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 6 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/bytecode-register-optimizer.cc » ('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 16 matching lines...) Expand all
27 // may end up with later statement positions being added during bytecode 27 // may end up with later statement positions being added during bytecode
28 // generation. 28 // generation.
29 source_position_ = entry.source_position_; 29 source_position_ = entry.source_position_;
30 is_statement_ = entry.is_statement_; 30 is_statement_ = entry.is_statement_;
31 } 31 }
32 } 32 }
33 33
34 BytecodeNode::BytecodeNode(Bytecode bytecode) { 34 BytecodeNode::BytecodeNode(Bytecode bytecode) {
35 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0); 35 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0);
36 bytecode_ = bytecode; 36 bytecode_ = bytecode;
37 operand_scale_ = OperandScale::kSingle; 37 }
38
39 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0) {
40 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 1);
41 bytecode_ = bytecode;
42 operands_[0] = operand0;
38 } 43 }
39 44
40 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0, 45 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0,
41 OperandScale operand_scale) { 46 uint32_t operand1) {
42 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 1);
43 bytecode_ = bytecode;
44 operands_[0] = operand0;
45 operand_scale_ = operand_scale;
46 }
47
48 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0,
49 uint32_t operand1, OperandScale operand_scale) {
50 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 2); 47 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 2);
51 bytecode_ = bytecode; 48 bytecode_ = bytecode;
52 operands_[0] = operand0; 49 operands_[0] = operand0;
53 operands_[1] = operand1; 50 operands_[1] = operand1;
54 operand_scale_ = operand_scale;
55 } 51 }
56 52
57 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0, 53 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0,
58 uint32_t operand1, uint32_t operand2, 54 uint32_t operand1, uint32_t operand2) {
59 OperandScale operand_scale) {
60 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 3); 55 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 3);
61 bytecode_ = bytecode; 56 bytecode_ = bytecode;
62 operands_[0] = operand0; 57 operands_[0] = operand0;
63 operands_[1] = operand1; 58 operands_[1] = operand1;
64 operands_[2] = operand2; 59 operands_[2] = operand2;
65 operand_scale_ = operand_scale;
66 } 60 }
67 61
68 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0, 62 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0,
69 uint32_t operand1, uint32_t operand2, 63 uint32_t operand1, uint32_t operand2,
70 uint32_t operand3, OperandScale operand_scale) { 64 uint32_t operand3) {
71 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 4); 65 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 4);
72 bytecode_ = bytecode; 66 bytecode_ = bytecode;
73 operands_[0] = operand0; 67 operands_[0] = operand0;
74 operands_[1] = operand1; 68 operands_[1] = operand1;
75 operands_[2] = operand2; 69 operands_[2] = operand2;
76 operands_[3] = operand3; 70 operands_[3] = operand3;
77 operand_scale_ = operand_scale;
78 } 71 }
79 72
80 BytecodeNode::BytecodeNode(const BytecodeNode& other) { 73 BytecodeNode::BytecodeNode(const BytecodeNode& other) {
81 memcpy(this, &other, sizeof(other)); 74 memcpy(this, &other, sizeof(other));
82 } 75 }
83 76
84 BytecodeNode& BytecodeNode::operator=(const BytecodeNode& other) { 77 BytecodeNode& BytecodeNode::operator=(const BytecodeNode& other) {
85 memcpy(this, &other, sizeof(other)); 78 memcpy(this, &other, sizeof(other));
86 return *this; 79 return *this;
87 } 80 }
88 81
89 void BytecodeNode::set_bytecode(Bytecode bytecode) { 82 void BytecodeNode::set_bytecode(Bytecode bytecode) {
90 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0); 83 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0);
91 bytecode_ = bytecode; 84 bytecode_ = bytecode;
92 operand_scale_ = OperandScale::kSingle;
93 } 85 }
94 86
95 void BytecodeNode::set_bytecode(Bytecode bytecode, uint32_t operand0, 87 void BytecodeNode::set_bytecode(Bytecode bytecode, uint32_t operand0) {
96 OperandScale operand_scale) {
97 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 1); 88 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 1);
98 bytecode_ = bytecode; 89 bytecode_ = bytecode;
99 operands_[0] = operand0; 90 operands_[0] = operand0;
100 operand_scale_ = operand_scale;
101 } 91 }
102 92
103 void BytecodeNode::Clone(const BytecodeNode* const other) { 93 void BytecodeNode::Clone(const BytecodeNode* const other) {
104 memcpy(this, other, sizeof(*other)); 94 memcpy(this, other, sizeof(*other));
105 } 95 }
106 96
107 void BytecodeNode::Print(std::ostream& os) const { 97 void BytecodeNode::Print(std::ostream& os) const {
108 #ifdef DEBUG 98 #ifdef DEBUG
109 std::ios saved_state(nullptr); 99 std::ios saved_state(nullptr);
110 saved_state.copyfmt(os); 100 saved_state.copyfmt(os);
111
112 os << Bytecodes::ToString(bytecode_); 101 os << Bytecodes::ToString(bytecode_);
113 if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale_)) {
114 Bytecode scale_prefix =
115 Bytecodes::OperandScaleToPrefixBytecode(operand_scale_);
116 os << '.' << Bytecodes::ToString(scale_prefix);
117 }
118 102
119 for (int i = 0; i < operand_count(); ++i) { 103 for (int i = 0; i < operand_count(); ++i) {
120 os << ' ' << std::setw(8) << std::setfill('0') << std::hex << operands_[i]; 104 os << ' ' << std::setw(8) << std::setfill('0') << std::hex << operands_[i];
121 } 105 }
122 os.copyfmt(saved_state); 106 os.copyfmt(saved_state);
123 107
124 if (source_info_.is_valid()) { 108 if (source_info_.is_valid()) {
125 os << ' ' << source_info_; 109 os << ' ' << source_info_;
126 } 110 }
127 os << '\n'; 111 os << '\n';
128 #else 112 #else
129 os << static_cast<const void*>(this); 113 os << static_cast<const void*>(this);
130 #endif // DEBUG 114 #endif // DEBUG
131 } 115 }
132 116
133 size_t BytecodeNode::Size() const { 117 void BytecodeNode::Transform(Bytecode new_bytecode, uint32_t extra_operand) {
134 size_t size = Bytecodes::Size(bytecode_, operand_scale_);
135 if (Bytecodes::OperandScaleRequiresPrefixBytecode(operand_scale_)) {
136 size += 1;
137 }
138 return size;
139 }
140
141 void BytecodeNode::Transform(Bytecode new_bytecode, uint32_t extra_operand,
142 OperandScale extra_operand_scale) {
143 DCHECK_EQ(Bytecodes::NumberOfOperands(new_bytecode), 118 DCHECK_EQ(Bytecodes::NumberOfOperands(new_bytecode),
144 Bytecodes::NumberOfOperands(bytecode()) + 1); 119 Bytecodes::NumberOfOperands(bytecode()) + 1);
145 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 1 || 120 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 1 ||
146 Bytecodes::GetOperandType(new_bytecode, 0) == 121 Bytecodes::GetOperandType(new_bytecode, 0) ==
147 Bytecodes::GetOperandType(bytecode(), 0)); 122 Bytecodes::GetOperandType(bytecode(), 0));
148 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 2 || 123 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 2 ||
149 Bytecodes::GetOperandType(new_bytecode, 1) == 124 Bytecodes::GetOperandType(new_bytecode, 1) ==
150 Bytecodes::GetOperandType(bytecode(), 1)); 125 Bytecodes::GetOperandType(bytecode(), 1));
151 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 3 || 126 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 3 ||
152 Bytecodes::GetOperandType(new_bytecode, 2) == 127 Bytecodes::GetOperandType(new_bytecode, 2) ==
153 Bytecodes::GetOperandType(bytecode(), 2)); 128 Bytecodes::GetOperandType(bytecode(), 2));
154 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 4); 129 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 4);
155 operand_scale_ = std::max(extra_operand_scale, operand_scale());
156 operands_[operand_count()] = extra_operand; 130 operands_[operand_count()] = extra_operand;
157 bytecode_ = new_bytecode; 131 bytecode_ = new_bytecode;
158 } 132 }
159 133
160 bool BytecodeNode::operator==(const BytecodeNode& other) const { 134 bool BytecodeNode::operator==(const BytecodeNode& other) const {
161 if (this == &other) { 135 if (this == &other) {
162 return true; 136 return true;
163 } else if (this->bytecode() != other.bytecode() || 137 } else if (this->bytecode() != other.bytecode() ||
164 this->source_info() != other.source_info()) { 138 this->source_info() != other.source_info()) {
165 return false; 139 return false;
166 } else { 140 } else {
167 for (int i = 0; i < this->operand_count(); ++i) { 141 for (int i = 0; i < this->operand_count(); ++i) {
168 if (this->operand(i) != other.operand(i)) { 142 if (this->operand(i) != other.operand(i)) {
169 return false; 143 return false;
170 } 144 }
171 } 145 }
172 } 146 }
173 return true; 147 return true;
174 } 148 }
175 149
176 std::ostream& operator<<(std::ostream& os, const BytecodeNode& node) {
177 node.Print(os);
178 return os;
179 }
180
181 std::ostream& operator<<(std::ostream& os, const BytecodeSourceInfo& info) { 150 std::ostream& operator<<(std::ostream& os, const BytecodeSourceInfo& info) {
182 if (info.is_valid()) { 151 if (info.is_valid()) {
183 char description = info.is_statement() ? 'S' : 'E'; 152 char description = info.is_statement() ? 'S' : 'E';
184 os << info.source_position() << ' ' << description << '>'; 153 os << info.source_position() << ' ' << description << '>';
185 } 154 }
186 return os; 155 return os;
187 } 156 }
188 157
158 std::ostream& operator<<(std::ostream& os, const BytecodeNode& node) {
159 node.Print(os);
160 return os;
161 }
162
189 } // namespace interpreter 163 } // namespace interpreter
190 } // namespace internal 164 } // namespace internal
191 } // namespace v8 165 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-pipeline.h ('k') | src/interpreter/bytecode-register-optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698