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

Side by Side Diff: src/compiler/schedule.cc

Issue 892513003: [turbofan] Initial support for Switch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Wuschelstudio build. 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
« no previous file with comments | « src/compiler/schedule.h ('k') | src/compiler/scheduler.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/schedule.h" 5 #include "src/compiler/schedule.h"
6 6
7 #include "src/compiler/node.h" 7 #include "src/compiler/node.h"
8 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 #include "src/ostreams.h" 9 #include "src/ostreams.h"
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 96
97 std::ostream& operator<<(std::ostream& os, const BasicBlock::Control& c) { 97 std::ostream& operator<<(std::ostream& os, const BasicBlock::Control& c) {
98 switch (c) { 98 switch (c) {
99 case BasicBlock::kNone: 99 case BasicBlock::kNone:
100 return os << "none"; 100 return os << "none";
101 case BasicBlock::kGoto: 101 case BasicBlock::kGoto:
102 return os << "goto"; 102 return os << "goto";
103 case BasicBlock::kBranch: 103 case BasicBlock::kBranch:
104 return os << "branch"; 104 return os << "branch";
105 case BasicBlock::kSwitch:
106 return os << "switch";
105 case BasicBlock::kReturn: 107 case BasicBlock::kReturn:
106 return os << "return"; 108 return os << "return";
107 case BasicBlock::kThrow: 109 case BasicBlock::kThrow:
108 return os << "throw"; 110 return os << "throw";
109 } 111 }
110 UNREACHABLE(); 112 UNREACHABLE();
111 return os; 113 return os;
112 } 114 }
113 115
114 116
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 BasicBlock* fblock) { 204 BasicBlock* fblock) {
203 DCHECK(block->control() == BasicBlock::kNone); 205 DCHECK(block->control() == BasicBlock::kNone);
204 DCHECK(branch->opcode() == IrOpcode::kBranch); 206 DCHECK(branch->opcode() == IrOpcode::kBranch);
205 block->set_control(BasicBlock::kBranch); 207 block->set_control(BasicBlock::kBranch);
206 AddSuccessor(block, tblock); 208 AddSuccessor(block, tblock);
207 AddSuccessor(block, fblock); 209 AddSuccessor(block, fblock);
208 SetControlInput(block, branch); 210 SetControlInput(block, branch);
209 } 211 }
210 212
211 213
214 void Schedule::AddSwitch(BasicBlock* block, Node* sw, BasicBlock** succ_blocks,
215 size_t succ_count) {
216 DCHECK_EQ(BasicBlock::kNone, block->control());
217 DCHECK_EQ(IrOpcode::kSwitch, sw->opcode());
218 block->set_control(BasicBlock::kSwitch);
219 for (size_t index = 0; index < succ_count; ++index) {
220 AddSuccessor(block, succ_blocks[index]);
221 }
222 SetControlInput(block, sw);
223 }
224
225
212 void Schedule::AddReturn(BasicBlock* block, Node* input) { 226 void Schedule::AddReturn(BasicBlock* block, Node* input) {
213 DCHECK(block->control() == BasicBlock::kNone); 227 DCHECK(block->control() == BasicBlock::kNone);
214 block->set_control(BasicBlock::kReturn); 228 block->set_control(BasicBlock::kReturn);
215 SetControlInput(block, input); 229 SetControlInput(block, input);
216 if (block != end()) AddSuccessor(block, end()); 230 if (block != end()) AddSuccessor(block, end());
217 } 231 }
218 232
219 233
220 void Schedule::AddThrow(BasicBlock* block, Node* input) { 234 void Schedule::AddThrow(BasicBlock* block, Node* input) {
221 DCHECK(block->control() == BasicBlock::kNone); 235 DCHECK(block->control() == BasicBlock::kNone);
222 block->set_control(BasicBlock::kThrow); 236 block->set_control(BasicBlock::kThrow);
223 SetControlInput(block, input); 237 SetControlInput(block, input);
224 if (block != end()) AddSuccessor(block, end()); 238 if (block != end()) AddSuccessor(block, end());
225 } 239 }
226 240
227 241
228 void Schedule::InsertBranch(BasicBlock* block, BasicBlock* end, Node* branch, 242 void Schedule::InsertBranch(BasicBlock* block, BasicBlock* end, Node* branch,
229 BasicBlock* tblock, BasicBlock* fblock) { 243 BasicBlock* tblock, BasicBlock* fblock) {
230 DCHECK(block->control() != BasicBlock::kNone); 244 DCHECK(block->control() != BasicBlock::kNone);
231 DCHECK(end->control() == BasicBlock::kNone); 245 DCHECK(end->control() == BasicBlock::kNone);
232 end->set_control(block->control()); 246 end->set_control(block->control());
233 block->set_control(BasicBlock::kBranch); 247 block->set_control(BasicBlock::kBranch);
234 MoveSuccessors(block, end); 248 MoveSuccessors(block, end);
235 AddSuccessor(block, tblock); 249 AddSuccessor(block, tblock);
236 AddSuccessor(block, fblock); 250 AddSuccessor(block, fblock);
237 if (block->control_input() != NULL) { 251 if (block->control_input() != nullptr) {
238 SetControlInput(end, block->control_input()); 252 SetControlInput(end, block->control_input());
239 } 253 }
240 SetControlInput(block, branch); 254 SetControlInput(block, branch);
241 } 255 }
242 256
243 257
258 void Schedule::InsertSwitch(BasicBlock* block, BasicBlock* end, Node* sw,
259 BasicBlock** succ_blocks, size_t succ_count) {
260 DCHECK_NE(BasicBlock::kNone, block->control());
261 DCHECK_EQ(BasicBlock::kNone, end->control());
262 end->set_control(block->control());
263 block->set_control(BasicBlock::kSwitch);
264 MoveSuccessors(block, end);
265 for (size_t index = 0; index < succ_count; ++index) {
266 AddSuccessor(block, succ_blocks[index]);
267 }
268 if (block->control_input() != nullptr) {
269 SetControlInput(end, block->control_input());
270 }
271 SetControlInput(block, sw);
272 }
273
274
244 void Schedule::AddSuccessor(BasicBlock* block, BasicBlock* succ) { 275 void Schedule::AddSuccessor(BasicBlock* block, BasicBlock* succ) {
245 block->AddSuccessor(succ); 276 block->AddSuccessor(succ);
246 succ->AddPredecessor(block); 277 succ->AddPredecessor(block);
247 } 278 }
248 279
249 280
250 void Schedule::MoveSuccessors(BasicBlock* from, BasicBlock* to) { 281 void Schedule::MoveSuccessors(BasicBlock* from, BasicBlock* to) {
251 for (BasicBlock* const successor : from->successors()) { 282 for (BasicBlock* const successor : from->successors()) {
252 to->AddSuccessor(successor); 283 to->AddSuccessor(successor);
253 for (BasicBlock*& predecessor : successor->predecessors()) { 284 for (BasicBlock*& predecessor : successor->predecessors()) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 346 }
316 os << "\n"; 347 os << "\n";
317 } 348 }
318 } 349 }
319 return os; 350 return os;
320 } 351 }
321 352
322 } // namespace compiler 353 } // namespace compiler
323 } // namespace internal 354 } // namespace internal
324 } // namespace v8 355 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/schedule.h ('k') | src/compiler/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698