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

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: Fix windows build 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
« no previous file with comments | « src/compiler/graph-visualizer.cc ('k') | src/compiler/js-inlining.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 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 401 }
403 DCHECK(1 + buffer->frame_state_value_count() == 402 DCHECK(1 + buffer->frame_state_value_count() ==
404 buffer->instruction_args.size()); 403 buffer->instruction_args.size());
405 404
406 size_t input_count = static_cast<size_t>(buffer->input_count()); 405 size_t input_count = static_cast<size_t>(buffer->input_count());
407 406
408 // Split the arguments into pushed_nodes and instruction_args. Pushed 407 // Split the arguments into pushed_nodes and instruction_args. Pushed
409 // arguments require an explicit push instruction before the call and do 408 // arguments require an explicit push instruction before the call and do
410 // not appear as arguments to the call. Everything else ends up 409 // not appear as arguments to the call. Everything else ends up
411 // as an InstructionOperand argument to the call. 410 // as an InstructionOperand argument to the call.
412 InputIter iter(call->inputs().begin()); 411 auto iter(call->inputs().begin());
413 int pushed_count = 0; 412 int pushed_count = 0;
414 for (size_t index = 0; index < input_count; ++iter, ++index) { 413 for (size_t index = 0; index < input_count; ++iter, ++index) {
415 DCHECK(iter != call->inputs().end()); 414 DCHECK(iter != call->inputs().end());
416 DCHECK(index == static_cast<size_t>(iter.index()));
417 DCHECK((*iter)->op()->opcode() != IrOpcode::kFrameState); 415 DCHECK((*iter)->op()->opcode() != IrOpcode::kFrameState);
418 if (index == 0) continue; // The first argument (callee) is already done. 416 if (index == 0) continue; // The first argument (callee) is already done.
419 InstructionOperand* op = 417 InstructionOperand* op =
420 g.UseLocation(*iter, buffer->descriptor->GetInputLocation(index), 418 g.UseLocation(*iter, buffer->descriptor->GetInputLocation(index),
421 buffer->descriptor->GetInputType(index)); 419 buffer->descriptor->GetInputType(index));
422 if (UnallocatedOperand::cast(op)->HasFixedSlotPolicy()) { 420 if (UnallocatedOperand::cast(op)->HasFixedSlotPolicy()) {
423 int stack_index = -UnallocatedOperand::cast(op)->fixed_slot_index() - 1; 421 int stack_index = -UnallocatedOperand::cast(op)->fixed_slot_index() - 1;
424 if (static_cast<size_t>(stack_index) >= buffer->pushed_nodes.size()) { 422 if (static_cast<size_t>(stack_index) >= buffer->pushed_nodes.size()) {
425 buffer->pushed_nodes.resize(stack_index + 1, NULL); 423 buffer->pushed_nodes.resize(stack_index + 1, NULL);
426 } 424 }
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 MachineOperatorBuilder::Flags 1142 MachineOperatorBuilder::Flags
1145 InstructionSelector::SupportedMachineOperatorFlags() { 1143 InstructionSelector::SupportedMachineOperatorFlags() {
1146 return MachineOperatorBuilder::Flag::kNoFlags; 1144 return MachineOperatorBuilder::Flag::kNoFlags;
1147 } 1145 }
1148 1146
1149 #endif // !V8_TURBOFAN_BACKEND 1147 #endif // !V8_TURBOFAN_BACKEND
1150 1148
1151 } // namespace compiler 1149 } // namespace compiler
1152 } // namespace internal 1150 } // namespace internal
1153 } // namespace v8 1151 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/graph-visualizer.cc ('k') | src/compiler/js-inlining.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698