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

Side by Side Diff: src/compiler/instruction-selector.cc

Issue 904693002: [turbofan] Remove global InstructionOperand caches. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/compiler/instruction.cc ('k') | src/compiler/instruction-selector-impl.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/instruction-selector.h" 5 #include "src/compiler/instruction-selector.h"
6 6
7 #include "src/compiler/instruction-selector-impl.h" 7 #include "src/compiler/instruction-selector-impl.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 #include "src/compiler/pipeline.h" 10 #include "src/compiler/pipeline.h"
(...skipping 12 matching lines...) Expand all
23 linkage_(linkage), 23 linkage_(linkage),
24 sequence_(sequence), 24 sequence_(sequence),
25 source_positions_(source_positions), 25 source_positions_(source_positions),
26 features_(features), 26 features_(features),
27 schedule_(schedule), 27 schedule_(schedule),
28 current_block_(NULL), 28 current_block_(NULL),
29 instructions_(zone), 29 instructions_(zone),
30 defined_(node_count, false, zone), 30 defined_(node_count, false, zone),
31 used_(node_count, false, zone), 31 used_(node_count, false, zone),
32 virtual_registers_(node_count, 32 virtual_registers_(node_count,
33 UnallocatedOperand::kInvalidVirtualRegister, zone) { 33 InstructionOperand::kInvalidVirtualRegister, zone) {
34 instructions_.reserve(node_count); 34 instructions_.reserve(node_count);
35 } 35 }
36 36
37 37
38 void InstructionSelector::SelectInstructions() { 38 void InstructionSelector::SelectInstructions() {
39 // Mark the inputs of all phis in loop headers as used. 39 // Mark the inputs of all phis in loop headers as used.
40 BasicBlockVector* blocks = schedule()->rpo_order(); 40 BasicBlockVector* blocks = schedule()->rpo_order();
41 for (auto const block : *blocks) { 41 for (auto const block : *blocks) {
42 if (!block->IsLoopHeader()) continue; 42 if (!block->IsLoopHeader()) continue;
43 DCHECK_LE(2u, block->PredecessorCount()); 43 DCHECK_LE(2u, block->PredecessorCount());
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 return node->OwnedBy(user) && 175 return node->OwnedBy(user) &&
176 schedule()->block(node) == schedule()->block(user); 176 schedule()->block(node) == schedule()->block(user);
177 } 177 }
178 178
179 179
180 int InstructionSelector::GetVirtualRegister(const Node* node) { 180 int InstructionSelector::GetVirtualRegister(const Node* node) {
181 DCHECK_NOT_NULL(node); 181 DCHECK_NOT_NULL(node);
182 size_t const id = node->id(); 182 size_t const id = node->id();
183 DCHECK_LT(id, virtual_registers_.size()); 183 DCHECK_LT(id, virtual_registers_.size());
184 int virtual_register = virtual_registers_[id]; 184 int virtual_register = virtual_registers_[id];
185 if (virtual_register == UnallocatedOperand::kInvalidVirtualRegister) { 185 if (virtual_register == InstructionOperand::kInvalidVirtualRegister) {
186 virtual_register = sequence()->NextVirtualRegister(); 186 virtual_register = sequence()->NextVirtualRegister();
187 virtual_registers_[id] = virtual_register; 187 virtual_registers_[id] = virtual_register;
188 } 188 }
189 return virtual_register; 189 return virtual_register;
190 } 190 }
191 191
192 192
193 const std::map<NodeId, int> InstructionSelector::GetVirtualRegistersForTesting() 193 const std::map<NodeId, int> InstructionSelector::GetVirtualRegistersForTesting()
194 const { 194 const {
195 std::map<NodeId, int> virtual_registers; 195 std::map<NodeId, int> virtual_registers;
196 for (size_t n = 0; n < virtual_registers_.size(); ++n) { 196 for (size_t n = 0; n < virtual_registers_.size(); ++n) {
197 if (virtual_registers_[n] != UnallocatedOperand::kInvalidVirtualRegister) { 197 if (virtual_registers_[n] != InstructionOperand::kInvalidVirtualRegister) {
198 NodeId const id = static_cast<NodeId>(n); 198 NodeId const id = static_cast<NodeId>(n);
199 virtual_registers.insert(std::make_pair(id, virtual_registers_[n])); 199 virtual_registers.insert(std::make_pair(id, virtual_registers_[n]));
200 } 200 }
201 } 201 }
202 return virtual_registers; 202 return virtual_registers;
203 } 203 }
204 204
205 205
206 bool InstructionSelector::IsDefined(Node* node) const { 206 bool InstructionSelector::IsDefined(Node* node) const {
207 DCHECK_NOT_NULL(node); 207 DCHECK_NOT_NULL(node);
(...skipping 24 matching lines...) Expand all
232 DCHECK_NOT_NULL(node); 232 DCHECK_NOT_NULL(node);
233 size_t const id = node->id(); 233 size_t const id = node->id();
234 DCHECK_LT(id, used_.size()); 234 DCHECK_LT(id, used_.size());
235 used_[id] = true; 235 used_[id] = true;
236 } 236 }
237 237
238 238
239 bool InstructionSelector::IsDouble(const Node* node) const { 239 bool InstructionSelector::IsDouble(const Node* node) const {
240 DCHECK_NOT_NULL(node); 240 DCHECK_NOT_NULL(node);
241 int const virtual_register = virtual_registers_[node->id()]; 241 int const virtual_register = virtual_registers_[node->id()];
242 if (virtual_register == UnallocatedOperand::kInvalidVirtualRegister) { 242 if (virtual_register == InstructionOperand::kInvalidVirtualRegister) {
243 return false; 243 return false;
244 } 244 }
245 return sequence()->IsDouble(virtual_register); 245 return sequence()->IsDouble(virtual_register);
246 } 246 }
247 247
248 248
249 void InstructionSelector::MarkAsDouble(Node* node) { 249 void InstructionSelector::MarkAsDouble(Node* node) {
250 DCHECK_NOT_NULL(node); 250 DCHECK_NOT_NULL(node);
251 DCHECK(!IsReference(node)); 251 DCHECK(!IsReference(node));
252 sequence()->MarkAsDouble(GetVirtualRegister(node)); 252 sequence()->MarkAsDouble(GetVirtualRegister(node));
253 } 253 }
254 254
255 255
256 bool InstructionSelector::IsReference(const Node* node) const { 256 bool InstructionSelector::IsReference(const Node* node) const {
257 DCHECK_NOT_NULL(node); 257 DCHECK_NOT_NULL(node);
258 int const virtual_register = virtual_registers_[node->id()]; 258 int const virtual_register = virtual_registers_[node->id()];
259 if (virtual_register == UnallocatedOperand::kInvalidVirtualRegister) { 259 if (virtual_register == InstructionOperand::kInvalidVirtualRegister) {
260 return false; 260 return false;
261 } 261 }
262 return sequence()->IsReference(virtual_register); 262 return sequence()->IsReference(virtual_register);
263 } 263 }
264 264
265 265
266 void InstructionSelector::MarkAsReference(Node* node) { 266 void InstructionSelector::MarkAsReference(Node* node) {
267 DCHECK_NOT_NULL(node); 267 DCHECK_NOT_NULL(node);
268 DCHECK(!IsDouble(node)); 268 DCHECK(!IsDouble(node));
269 sequence()->MarkAsReference(GetVirtualRegister(node)); 269 sequence()->MarkAsReference(GetVirtualRegister(node));
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 MachineOperatorBuilder::Flags 1176 MachineOperatorBuilder::Flags
1177 InstructionSelector::SupportedMachineOperatorFlags() { 1177 InstructionSelector::SupportedMachineOperatorFlags() {
1178 return MachineOperatorBuilder::Flag::kNoFlags; 1178 return MachineOperatorBuilder::Flag::kNoFlags;
1179 } 1179 }
1180 1180
1181 #endif // !V8_TURBOFAN_BACKEND 1181 #endif // !V8_TURBOFAN_BACKEND
1182 1182
1183 } // namespace compiler 1183 } // namespace compiler
1184 } // namespace internal 1184 } // namespace internal
1185 } // namespace v8 1185 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction.cc ('k') | src/compiler/instruction-selector-impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698