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

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

Issue 765983002: Clean up node iteration (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Tweaks Created 6 years 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 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/graph.h" 7 #include "src/compiler/graph.h"
8 #include "src/compiler/instruction-selector-impl.h" 8 #include "src/compiler/instruction-selector-impl.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 29 matching lines...) Expand all
40 BasicBlock* block = *i; 40 BasicBlock* block = *i;
41 if (!block->IsLoopHeader()) continue; 41 if (!block->IsLoopHeader()) continue;
42 DCHECK_NE(0, static_cast<int>(block->PredecessorCount())); 42 DCHECK_NE(0, static_cast<int>(block->PredecessorCount()));
43 DCHECK_NE(1, static_cast<int>(block->PredecessorCount())); 43 DCHECK_NE(1, static_cast<int>(block->PredecessorCount()));
44 for (BasicBlock::const_iterator j = block->begin(); j != block->end(); 44 for (BasicBlock::const_iterator j = block->begin(); j != block->end();
45 ++j) { 45 ++j) {
46 Node* phi = *j; 46 Node* phi = *j;
47 if (phi->opcode() != IrOpcode::kPhi) continue; 47 if (phi->opcode() != IrOpcode::kPhi) continue;
48 48
49 // Mark all inputs as used. 49 // Mark all inputs as used.
50 Node::Inputs inputs = phi->inputs(); 50 for (Node* const k : phi->inputs()) {
51 for (InputIter k = inputs.begin(); k != inputs.end(); ++k) { 51 MarkAsUsed(k);
52 MarkAsUsed(*k);
53 } 52 }
54 } 53 }
55 } 54 }
56 55
57 // Visit each basic block in post order. 56 // Visit each basic block in post order.
58 for (BasicBlockVectorRIter i = blocks->rbegin(); i != blocks->rend(); ++i) { 57 for (BasicBlockVectorRIter i = blocks->rbegin(); i != blocks->rend(); ++i) {
59 VisitBlock(*i); 58 VisitBlock(*i);
60 } 59 }
61 60
62 // Schedule the selected instructions. 61 // Schedule the selected instructions.
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 376 }
378 DCHECK(1 + buffer->frame_state_value_count() == 377 DCHECK(1 + buffer->frame_state_value_count() ==
379 buffer->instruction_args.size()); 378 buffer->instruction_args.size());
380 379
381 size_t input_count = static_cast<size_t>(buffer->input_count()); 380 size_t input_count = static_cast<size_t>(buffer->input_count());
382 381
383 // Split the arguments into pushed_nodes and instruction_args. Pushed 382 // Split the arguments into pushed_nodes and instruction_args. Pushed
384 // arguments require an explicit push instruction before the call and do 383 // arguments require an explicit push instruction before the call and do
385 // not appear as arguments to the call. Everything else ends up 384 // not appear as arguments to the call. Everything else ends up
386 // as an InstructionOperand argument to the call. 385 // as an InstructionOperand argument to the call.
387 InputIter iter(call->inputs().begin()); 386 auto iter(call->inputs().begin());
388 int pushed_count = 0; 387 int pushed_count = 0;
389 for (size_t index = 0; index < input_count; ++iter, ++index) { 388 for (size_t index = 0; index < input_count; ++iter, ++index) {
390 DCHECK(iter != call->inputs().end()); 389 DCHECK(iter != call->inputs().end());
391 DCHECK(index == static_cast<size_t>(iter.index()));
392 DCHECK((*iter)->op()->opcode() != IrOpcode::kFrameState); 390 DCHECK((*iter)->op()->opcode() != IrOpcode::kFrameState);
393 if (index == 0) continue; // The first argument (callee) is already done. 391 if (index == 0) continue; // The first argument (callee) is already done.
394 InstructionOperand* op = 392 InstructionOperand* op =
395 g.UseLocation(*iter, buffer->descriptor->GetInputLocation(index), 393 g.UseLocation(*iter, buffer->descriptor->GetInputLocation(index),
396 buffer->descriptor->GetInputType(index)); 394 buffer->descriptor->GetInputType(index));
397 if (UnallocatedOperand::cast(op)->HasFixedSlotPolicy()) { 395 if (UnallocatedOperand::cast(op)->HasFixedSlotPolicy()) {
398 int stack_index = -UnallocatedOperand::cast(op)->fixed_slot_index() - 1; 396 int stack_index = -UnallocatedOperand::cast(op)->fixed_slot_index() - 1;
399 if (static_cast<size_t>(stack_index) >= buffer->pushed_nodes.size()) { 397 if (static_cast<size_t>(stack_index) >= buffer->pushed_nodes.size()) {
400 buffer->pushed_nodes.resize(stack_index + 1, NULL); 398 buffer->pushed_nodes.resize(stack_index + 1, NULL);
401 } 399 }
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 MachineOperatorBuilder::Flags 1106 MachineOperatorBuilder::Flags
1109 InstructionSelector::SupportedMachineOperatorFlags() { 1107 InstructionSelector::SupportedMachineOperatorFlags() {
1110 return MachineOperatorBuilder::Flag::kNoFlags; 1108 return MachineOperatorBuilder::Flag::kNoFlags;
1111 } 1109 }
1112 1110
1113 #endif // !V8_TURBOFAN_BACKEND 1111 #endif // !V8_TURBOFAN_BACKEND
1114 1112
1115 } // namespace compiler 1113 } // namespace compiler
1116 } // namespace internal 1114 } // namespace internal
1117 } // namespace v8 1115 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698