OLD | NEW |
---|---|
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...) Loading... | |
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...) Loading... | |
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...) Loading... | |
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 |
OLD | NEW |