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

Side by Side Diff: src/compiler/basic-block-instrumentor.cc

Issue 606403003: Refactor BasicBlock, no inheritance from GenericNode (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Attempt n+1 to address the size_t madness Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/basic-block-profiler.cc ('k') | src/compiler/code-generator.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/basic-block-instrumentor.h" 5 #include "src/compiler/basic-block-instrumentor.h"
6 #include "src/compiler/common-operator.h" 6 #include "src/compiler/common-operator.h"
7 #include "src/compiler/graph.h" 7 #include "src/compiler/graph.h"
8 #include "src/compiler/machine-operator.h" 8 #include "src/compiler/machine-operator.h"
9 #include "src/compiler/operator-properties-inl.h" 9 #include "src/compiler/operator-properties-inl.h"
10 #include "src/compiler/schedule.h" 10 #include "src/compiler/schedule.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 namespace compiler { 14 namespace compiler {
15 15
16 // Find the first place to insert new nodes in a block that's already been 16 // Find the first place to insert new nodes in a block that's already been
17 // scheduled that won't upset the register allocator. 17 // scheduled that won't upset the register allocator.
18 static NodeVector::iterator FindInsertionPoint(NodeVector* nodes) { 18 static NodeVector::iterator FindInsertionPoint(BasicBlock* block) {
19 NodeVector::iterator i = nodes->begin(); 19 NodeVector::iterator i = block->begin();
20 for (; i != nodes->end(); ++i) { 20 for (; i != block->end(); ++i) {
21 const Operator* op = (*i)->op(); 21 const Operator* op = (*i)->op();
22 if (OperatorProperties::IsBasicBlockBegin(op)) continue; 22 if (OperatorProperties::IsBasicBlockBegin(op)) continue;
23 switch (op->opcode()) { 23 switch (op->opcode()) {
24 case IrOpcode::kParameter: 24 case IrOpcode::kParameter:
25 case IrOpcode::kPhi: 25 case IrOpcode::kPhi:
26 case IrOpcode::kEffectPhi: 26 case IrOpcode::kEffectPhi:
27 continue; 27 continue;
28 } 28 }
29 break; 29 break;
30 } 30 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Add the increment instructions to the start of every block. 65 // Add the increment instructions to the start of every block.
66 CommonOperatorBuilder common(graph->zone()); 66 CommonOperatorBuilder common(graph->zone());
67 Node* zero = graph->NewNode(common.Int32Constant(0)); 67 Node* zero = graph->NewNode(common.Int32Constant(0));
68 Node* one = graph->NewNode(common.Int32Constant(1)); 68 Node* one = graph->NewNode(common.Int32Constant(1));
69 MachineOperatorBuilder machine; 69 MachineOperatorBuilder machine;
70 BasicBlockVector* blocks = schedule->rpo_order(); 70 BasicBlockVector* blocks = schedule->rpo_order();
71 size_t block_number = 0; 71 size_t block_number = 0;
72 for (BasicBlockVector::iterator it = blocks->begin(); block_number < n_blocks; 72 for (BasicBlockVector::iterator it = blocks->begin(); block_number < n_blocks;
73 ++it, ++block_number) { 73 ++it, ++block_number) {
74 BasicBlock* block = (*it); 74 BasicBlock* block = (*it);
75 data->SetBlockId(block_number, block->id()); 75 data->SetBlockId(block_number, block->id().ToSize());
76 // TODO(dcarney): wire effect and control deps for load and store. 76 // TODO(dcarney): wire effect and control deps for load and store.
77 // Construct increment operation. 77 // Construct increment operation.
78 Node* base = graph->NewNode( 78 Node* base = graph->NewNode(
79 PointerConstant(&common, data->GetCounterAddress(block_number))); 79 PointerConstant(&common, data->GetCounterAddress(block_number)));
80 Node* load = graph->NewNode(machine.Load(kMachUint32), base, zero); 80 Node* load = graph->NewNode(machine.Load(kMachUint32), base, zero);
81 Node* inc = graph->NewNode(machine.Int32Add(), load, one); 81 Node* inc = graph->NewNode(machine.Int32Add(), load, one);
82 Node* store = graph->NewNode( 82 Node* store = graph->NewNode(
83 machine.Store(StoreRepresentation(kMachUint32, kNoWriteBarrier)), base, 83 machine.Store(StoreRepresentation(kMachUint32, kNoWriteBarrier)), base,
84 zero, inc); 84 zero, inc);
85 // Insert the new nodes. 85 // Insert the new nodes.
86 static const int kArraySize = 6; 86 static const int kArraySize = 6;
87 Node* to_insert[kArraySize] = {zero, one, base, load, inc, store}; 87 Node* to_insert[kArraySize] = {zero, one, base, load, inc, store};
88 int insertion_start = block_number == 0 ? 0 : 2; 88 int insertion_start = block_number == 0 ? 0 : 2;
89 NodeVector* nodes = &block->nodes_; 89 NodeVector::iterator insertion_point = FindInsertionPoint(block);
90 NodeVector::iterator insertion_point = FindInsertionPoint(nodes); 90 block->InsertNodes(insertion_point, &to_insert[insertion_start],
91 nodes->insert(insertion_point, &to_insert[insertion_start], 91 &to_insert[kArraySize]);
92 &to_insert[kArraySize]);
93 // Tell the scheduler about the new nodes. 92 // Tell the scheduler about the new nodes.
94 for (int i = insertion_start; i < kArraySize; ++i) { 93 for (int i = insertion_start; i < kArraySize; ++i) {
95 schedule->SetBlockForNode(block, to_insert[i]); 94 schedule->SetBlockForNode(block, to_insert[i]);
96 } 95 }
97 } 96 }
98 return data; 97 return data;
99 } 98 }
100 99
101 } // namespace compiler 100 } // namespace compiler
102 } // namespace internal 101 } // namespace internal
103 } // namespace v8 102 } // namespace v8
OLDNEW
« no previous file with comments | « src/basic-block-profiler.cc ('k') | src/compiler/code-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698