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

Side by Side Diff: src/compiler/jump-threading.cc

Issue 951553005: [turbofan] remove dependence of InstructionBlock on BasicBlock (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
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/jump-threading.h" 5 #include "src/compiler/jump-threading.h"
6 #include "src/compiler/code-generator-impl.h" 6 #include "src/compiler/code-generator-impl.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 namespace compiler { 10 namespace compiler {
11 11
12 typedef BasicBlock::RpoNumber RpoNumber; 12 typedef RpoNumber RpoNumber;
Michael Starzinger 2015/02/25 14:59:37 nit: Redundant typedef is redundant.
dcarney 2015/02/25 16:08:25 Done.
13 13
14 #define TRACE(x) \ 14 #define TRACE(x) \
15 if (FLAG_trace_turbo_jt) PrintF x 15 if (FLAG_trace_turbo_jt) PrintF x
16 16
17 struct JumpThreadingState { 17 struct JumpThreadingState {
18 bool forwarded; 18 bool forwarded;
19 ZoneVector<RpoNumber>& result; 19 ZoneVector<RpoNumber>& result;
20 ZoneStack<RpoNumber>& stack; 20 ZoneStack<RpoNumber>& stack;
21 21
22 void Clear(size_t count) { result.assign(count, unvisited()); } 22 void Clear(size_t count) { result.assign(count, unvisited()); }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 // Iterate over the blocks forward, pushing the blocks onto the stack. 64 // Iterate over the blocks forward, pushing the blocks onto the stack.
65 for (auto const block : code->instruction_blocks()) { 65 for (auto const block : code->instruction_blocks()) {
66 RpoNumber current = block->rpo_number(); 66 RpoNumber current = block->rpo_number();
67 state.PushIfUnvisited(current); 67 state.PushIfUnvisited(current);
68 68
69 // Process the stack, which implements DFS through empty blocks. 69 // Process the stack, which implements DFS through empty blocks.
70 while (!state.stack.empty()) { 70 while (!state.stack.empty()) {
71 InstructionBlock* block = code->InstructionBlockAt(state.stack.top()); 71 InstructionBlock* block = code->InstructionBlockAt(state.stack.top());
72 // Process the instructions in a block up to a non-empty instruction. 72 // Process the instructions in a block up to a non-empty instruction.
73 TRACE(("jt [%d] B%d RPO%d\n", static_cast<int>(stack.size()), 73 TRACE(("jt [%d] B%d\n", static_cast<int>(stack.size()),
74 block->id().ToInt(), block->rpo_number().ToInt())); 74 block->rpo_number().ToInt()));
75 bool fallthru = true; 75 bool fallthru = true;
76 RpoNumber fw = block->rpo_number(); 76 RpoNumber fw = block->rpo_number();
77 for (int i = block->code_start(); i < block->code_end(); ++i) { 77 for (int i = block->code_start(); i < block->code_end(); ++i) {
78 Instruction* instr = code->InstructionAt(i); 78 Instruction* instr = code->InstructionAt(i);
79 if (instr->IsGapMoves() && GapInstruction::cast(instr)->IsRedundant()) { 79 if (instr->IsGapMoves() && GapInstruction::cast(instr)->IsRedundant()) {
80 // skip redundant gap moves. 80 // skip redundant gap moves.
81 TRACE((" nop gap\n")); 81 TRACE((" nop gap\n"));
82 continue; 82 continue;
83 } else if (instr->IsSourcePosition()) { 83 } else if (instr->IsSourcePosition()) {
84 // skip source positions. 84 // skip source positions.
(...skipping 28 matching lines...) Expand all
113 } 113 }
114 114
115 #ifdef DEBUG 115 #ifdef DEBUG
116 for (RpoNumber num : result) { 116 for (RpoNumber num : result) {
117 CHECK(num.IsValid()); 117 CHECK(num.IsValid());
118 } 118 }
119 #endif 119 #endif
120 120
121 if (FLAG_trace_turbo_jt) { 121 if (FLAG_trace_turbo_jt) {
122 for (int i = 0; i < static_cast<int>(result.size()); i++) { 122 for (int i = 0; i < static_cast<int>(result.size()); i++) {
123 TRACE(("RPO%d B%d ", i, 123 TRACE(("B%d ", i));
124 code->InstructionBlockAt(RpoNumber::FromInt(i))->id().ToInt()));
125 int to = result[i].ToInt(); 124 int to = result[i].ToInt();
126 if (i != to) { 125 if (i != to) {
127 TRACE(("-> B%d\n", 126 TRACE(("-> B%d\n", to));
128 code->InstructionBlockAt(RpoNumber::FromInt(to))->id().ToInt()));
129 } else { 127 } else {
130 TRACE(("\n")); 128 TRACE(("\n"));
131 } 129 }
132 } 130 }
133 } 131 }
134 132
135 return state.forwarded; 133 return state.forwarded;
136 } 134 }
137 135
138 136
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (block->IsDeferred()) { 187 if (block->IsDeferred()) {
190 block->set_ao_number(RpoNumber::FromInt(ao)); 188 block->set_ao_number(RpoNumber::FromInt(ao));
191 if (!skip[block->rpo_number().ToInt()]) ao++; 189 if (!skip[block->rpo_number().ToInt()]) ao++;
192 } 190 }
193 } 191 }
194 } 192 }
195 193
196 } // namespace compiler 194 } // namespace compiler
197 } // namespace internal 195 } // namespace internal
198 } // namespace v8 196 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698