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

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

Issue 699083003: [turbofan] extend register allocator testing with control flow (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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/compiler/instruction.h ('k') | src/compiler/instruction-selector.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/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 #include "src/compiler/generic-node-inl.h" 6 #include "src/compiler/generic-node-inl.h"
7 #include "src/compiler/graph.h" 7 #include "src/compiler/graph.h"
8 #include "src/compiler/instruction.h" 8 #include "src/compiler/instruction.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 return os << static_cast<const void*>( 331 return os << static_cast<const void*>(
332 constant.ToExternalReference().address()); 332 constant.ToExternalReference().address());
333 case Constant::kHeapObject: 333 case Constant::kHeapObject:
334 return os << Brief(*constant.ToHeapObject()); 334 return os << Brief(*constant.ToHeapObject());
335 } 335 }
336 UNREACHABLE(); 336 UNREACHABLE();
337 return os; 337 return os;
338 } 338 }
339 339
340 340
341 InstructionBlock::InstructionBlock(Zone* zone, BasicBlock::Id id,
342 BasicBlock::RpoNumber ao_number,
343 BasicBlock::RpoNumber rpo_number,
344 BasicBlock::RpoNumber loop_header,
345 BasicBlock::RpoNumber loop_end,
346 bool deferred)
347 : successors_(zone),
348 predecessors_(zone),
349 phis_(zone),
350 id_(id),
351 ao_number_(ao_number),
352 rpo_number_(rpo_number),
353 loop_header_(loop_header),
354 loop_end_(loop_end),
355 code_start_(-1),
356 code_end_(-1),
357 deferred_(deferred) {}
358
359
360 size_t InstructionBlock::PredecessorIndexOf(
361 BasicBlock::RpoNumber rpo_number) const {
362 size_t j = 0;
363 for (InstructionBlock::Predecessors::const_iterator i = predecessors_.begin();
364 i != predecessors_.end(); ++i, ++j) {
365 if (*i == rpo_number) break;
366 }
367 return j;
368 }
369
370
341 static BasicBlock::RpoNumber GetRpo(BasicBlock* block) { 371 static BasicBlock::RpoNumber GetRpo(BasicBlock* block) {
342 if (block == NULL) return BasicBlock::RpoNumber::Invalid(); 372 if (block == NULL) return BasicBlock::RpoNumber::Invalid();
343 return block->GetRpoNumber(); 373 return block->GetRpoNumber();
344 } 374 }
345 375
346 376
347 static BasicBlock::RpoNumber GetLoopEndRpo(const BasicBlock* block) { 377 static BasicBlock::RpoNumber GetLoopEndRpo(const BasicBlock* block) {
348 if (!block->IsLoopHeader()) return BasicBlock::RpoNumber::Invalid(); 378 if (!block->IsLoopHeader()) return BasicBlock::RpoNumber::Invalid();
349 return block->loop_end()->GetRpoNumber(); 379 return block->loop_end()->GetRpoNumber();
350 } 380 }
351 381
352 382
353 InstructionBlock::InstructionBlock(Zone* zone, const BasicBlock* block) 383 static InstructionBlock* InstructionBlockFor(Zone* zone,
354 : successors_(static_cast<int>(block->SuccessorCount()), 384 const BasicBlock* block) {
355 BasicBlock::RpoNumber::Invalid(), zone), 385 InstructionBlock* instr_block = new (zone) InstructionBlock(
356 predecessors_(static_cast<int>(block->PredecessorCount()), 386 zone, block->id(), block->GetAoNumber(), block->GetRpoNumber(),
357 BasicBlock::RpoNumber::Invalid(), zone), 387 GetRpo(block->loop_header()), GetLoopEndRpo(block), block->deferred());
358 phis_(zone),
359 id_(block->id()),
360 ao_number_(block->GetAoNumber()),
361 rpo_number_(block->GetRpoNumber()),
362 loop_header_(GetRpo(block->loop_header())),
363 loop_end_(GetLoopEndRpo(block)),
364 code_start_(-1),
365 code_end_(-1),
366 deferred_(block->deferred()) {
367 // Map successors and precessors 388 // Map successors and precessors
368 size_t index = 0; 389 instr_block->successors().reserve(block->SuccessorCount());
369 for (BasicBlock::Successors::const_iterator it = block->successors_begin(); 390 for (auto it = block->successors_begin(); it != block->successors_end();
370 it != block->successors_end(); ++it, ++index) { 391 ++it) {
371 successors_[index] = (*it)->GetRpoNumber(); 392 instr_block->successors().push_back((*it)->GetRpoNumber());
372 } 393 }
373 index = 0; 394 instr_block->predecessors().reserve(block->PredecessorCount());
374 for (BasicBlock::Predecessors::const_iterator 395 for (auto it = block->predecessors_begin(); it != block->predecessors_end();
375 it = block->predecessors_begin(); 396 ++it) {
376 it != block->predecessors_end(); ++it, ++index) { 397 instr_block->predecessors().push_back((*it)->GetRpoNumber());
377 predecessors_[index] = (*it)->GetRpoNumber();
378 } 398 }
399 return instr_block;
379 } 400 }
380 401
381 402
382 size_t InstructionBlock::PredecessorIndexOf(
383 BasicBlock::RpoNumber rpo_number) const {
384 size_t j = 0;
385 for (InstructionBlock::Predecessors::const_iterator i = predecessors_.begin();
386 i != predecessors_.end(); ++i, ++j) {
387 if (*i == rpo_number) break;
388 }
389 return j;
390 }
391
392
393 InstructionBlocks* InstructionSequence::InstructionBlocksFor( 403 InstructionBlocks* InstructionSequence::InstructionBlocksFor(
394 Zone* zone, const Schedule* schedule) { 404 Zone* zone, const Schedule* schedule) {
395 InstructionBlocks* blocks = zone->NewArray<InstructionBlocks>(1); 405 InstructionBlocks* blocks = zone->NewArray<InstructionBlocks>(1);
396 new (blocks) InstructionBlocks( 406 new (blocks) InstructionBlocks(
397 static_cast<int>(schedule->rpo_order()->size()), NULL, zone); 407 static_cast<int>(schedule->rpo_order()->size()), NULL, zone);
398 size_t rpo_number = 0; 408 size_t rpo_number = 0;
399 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin(); 409 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin();
400 it != schedule->rpo_order()->end(); ++it, ++rpo_number) { 410 it != schedule->rpo_order()->end(); ++it, ++rpo_number) {
401 DCHECK_EQ(NULL, (*blocks)[rpo_number]); 411 DCHECK_EQ(NULL, (*blocks)[rpo_number]);
402 DCHECK((*it)->GetRpoNumber().ToSize() == rpo_number); 412 DCHECK((*it)->GetRpoNumber().ToSize() == rpo_number);
403 (*blocks)[rpo_number] = new (zone) InstructionBlock(zone, *it); 413 (*blocks)[rpo_number] = InstructionBlockFor(zone, *it);
404 } 414 }
405 return blocks; 415 return blocks;
406 } 416 }
407 417
408 418
409 InstructionSequence::InstructionSequence(Zone* instruction_zone, 419 InstructionSequence::InstructionSequence(Zone* instruction_zone,
410 InstructionBlocks* instruction_blocks) 420 InstructionBlocks* instruction_blocks)
411 : zone_(instruction_zone), 421 : zone_(instruction_zone),
412 instruction_blocks_(instruction_blocks), 422 instruction_blocks_(instruction_blocks),
413 constants_(ConstantMap::key_compare(), 423 constants_(ConstantMap::key_compare(),
(...skipping 15 matching lines...) Expand all
429 BlockStartInstruction* InstructionSequence::GetBlockStart( 439 BlockStartInstruction* InstructionSequence::GetBlockStart(
430 BasicBlock::RpoNumber rpo) { 440 BasicBlock::RpoNumber rpo) {
431 InstructionBlock* block = InstructionBlockAt(rpo); 441 InstructionBlock* block = InstructionBlockAt(rpo);
432 BlockStartInstruction* block_start = 442 BlockStartInstruction* block_start =
433 BlockStartInstruction::cast(InstructionAt(block->code_start())); 443 BlockStartInstruction::cast(InstructionAt(block->code_start()));
434 DCHECK_EQ(rpo.ToInt(), block_start->rpo_number().ToInt()); 444 DCHECK_EQ(rpo.ToInt(), block_start->rpo_number().ToInt());
435 return block_start; 445 return block_start;
436 } 446 }
437 447
438 448
439 void InstructionSequence::StartBlock(BasicBlock* basic_block) { 449 void InstructionSequence::StartBlock(BasicBlock::RpoNumber rpo) {
440 InstructionBlock* block = InstructionBlockAt(basic_block->GetRpoNumber()); 450 InstructionBlock* block = InstructionBlockAt(rpo);
441 block->set_code_start(static_cast<int>(instructions_.size())); 451 block->set_code_start(static_cast<int>(instructions_.size()));
442 BlockStartInstruction* block_start = 452 BlockStartInstruction* block_start =
443 BlockStartInstruction::New(zone(), basic_block); 453 BlockStartInstruction::New(zone(), block->id(), rpo);
444 AddInstruction(block_start); 454 AddInstruction(block_start);
445 } 455 }
446 456
447 457
448 void InstructionSequence::EndBlock(BasicBlock* basic_block) { 458 void InstructionSequence::EndBlock(BasicBlock::RpoNumber rpo) {
449 int end = static_cast<int>(instructions_.size()); 459 int end = static_cast<int>(instructions_.size());
450 InstructionBlock* block = InstructionBlockAt(basic_block->GetRpoNumber()); 460 InstructionBlock* block = InstructionBlockAt(rpo);
451 DCHECK(block->code_start() >= 0 && block->code_start() < end); 461 DCHECK(block->code_start() >= 0 && block->code_start() < end);
452 block->set_code_end(end); 462 block->set_code_end(end);
453 } 463 }
454 464
455 465
456 int InstructionSequence::AddInstruction(Instruction* instr) { 466 int InstructionSequence::AddInstruction(Instruction* instr) {
457 // TODO(titzer): the order of these gaps is a holdover from Lithium. 467 // TODO(titzer): the order of these gaps is a holdover from Lithium.
458 GapInstruction* gap = GapInstruction::New(zone()); 468 GapInstruction* gap = GapInstruction::New(zone());
459 if (instr->IsControl()) instructions_.push_back(gap); 469 if (instr->IsControl()) instructions_.push_back(gap);
460 int index = static_cast<int>(instructions_.size()); 470 int index = static_cast<int>(instructions_.size());
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 os << " B" << succ_block->id(); 670 os << " B" << succ_block->id();
661 } 671 }
662 os << "\n"; 672 os << "\n";
663 } 673 }
664 return os; 674 return os;
665 } 675 }
666 676
667 } // namespace compiler 677 } // namespace compiler
668 } // namespace internal 678 } // namespace internal
669 } // namespace v8 679 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/instruction-selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698