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

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

Issue 683133005: [turbofan] initial framework for unittesting of register allocator (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase 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/pipeline.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 #include "src/macro-assembler.h" 9 #include "src/macro-assembler.h"
10 10
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 BasicBlock::RpoNumber rpo_number) const { 366 BasicBlock::RpoNumber rpo_number) const {
367 size_t j = 0; 367 size_t j = 0;
368 for (InstructionBlock::Predecessors::const_iterator i = predecessors_.begin(); 368 for (InstructionBlock::Predecessors::const_iterator i = predecessors_.begin();
369 i != predecessors_.end(); ++i, ++j) { 369 i != predecessors_.end(); ++i, ++j) {
370 if (*i == rpo_number) break; 370 if (*i == rpo_number) break;
371 } 371 }
372 return j; 372 return j;
373 } 373 }
374 374
375 375
376 static void InitializeInstructionBlocks(Zone* zone, const Schedule* schedule, 376 InstructionBlocks* InstructionSequence::InstructionBlocksFor(
377 InstructionBlocks* blocks) { 377 Zone* zone, const Schedule* schedule) {
378 DCHECK(blocks->size() == schedule->rpo_order()->size()); 378 InstructionBlocks* blocks = zone->NewArray<InstructionBlocks>(1);
379 new (blocks) InstructionBlocks(
380 static_cast<int>(schedule->rpo_order()->size()), NULL, zone);
379 size_t rpo_number = 0; 381 size_t rpo_number = 0;
380 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin(); 382 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin();
381 it != schedule->rpo_order()->end(); ++it, ++rpo_number) { 383 it != schedule->rpo_order()->end(); ++it, ++rpo_number) {
382 DCHECK_EQ(NULL, (*blocks)[rpo_number]); 384 DCHECK_EQ(NULL, (*blocks)[rpo_number]);
383 DCHECK((*it)->GetRpoNumber().ToSize() == rpo_number); 385 DCHECK((*it)->GetRpoNumber().ToSize() == rpo_number);
384 (*blocks)[rpo_number] = new (zone) InstructionBlock(zone, *it); 386 (*blocks)[rpo_number] = new (zone) InstructionBlock(zone, *it);
385 } 387 }
388 return blocks;
386 } 389 }
387 390
388 391
389 InstructionSequence::InstructionSequence(Zone* instruction_zone, 392 InstructionSequence::InstructionSequence(Zone* instruction_zone,
390 const Schedule* schedule) 393 InstructionBlocks* instruction_blocks)
391 : zone_(instruction_zone), 394 : zone_(instruction_zone),
392 instruction_blocks_(static_cast<int>(schedule->rpo_order()->size()), NULL, 395 instruction_blocks_(instruction_blocks),
393 zone()),
394 constants_(ConstantMap::key_compare(), 396 constants_(ConstantMap::key_compare(),
395 ConstantMap::allocator_type(zone())), 397 ConstantMap::allocator_type(zone())),
396 immediates_(zone()), 398 immediates_(zone()),
397 instructions_(zone()), 399 instructions_(zone()),
398 next_virtual_register_(0), 400 next_virtual_register_(0),
399 pointer_maps_(zone()), 401 pointer_maps_(zone()),
400 doubles_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())), 402 doubles_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())),
401 references_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())), 403 references_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())),
402 deoptimization_entries_(zone()) { 404 deoptimization_entries_(zone()) {}
403 InitializeInstructionBlocks(zone(), schedule, &instruction_blocks_);
404 }
405 405
406 406
407 Label* InstructionSequence::GetLabel(BasicBlock::RpoNumber rpo) { 407 Label* InstructionSequence::GetLabel(BasicBlock::RpoNumber rpo) {
408 return GetBlockStart(rpo)->label(); 408 return GetBlockStart(rpo)->label();
409 } 409 }
410 410
411 411
412 BlockStartInstruction* InstructionSequence::GetBlockStart( 412 BlockStartInstruction* InstructionSequence::GetBlockStart(
413 BasicBlock::RpoNumber rpo) { 413 BasicBlock::RpoNumber rpo) {
414 InstructionBlock* block = InstructionBlockAt(rpo); 414 InstructionBlock* block = InstructionBlockAt(rpo);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 454 }
455 455
456 456
457 const InstructionBlock* InstructionSequence::GetInstructionBlock( 457 const InstructionBlock* InstructionSequence::GetInstructionBlock(
458 int instruction_index) const { 458 int instruction_index) const {
459 // TODO(turbofan): Optimize this. 459 // TODO(turbofan): Optimize this.
460 for (;;) { 460 for (;;) {
461 DCHECK_LE(0, instruction_index); 461 DCHECK_LE(0, instruction_index);
462 Instruction* instruction = InstructionAt(instruction_index--); 462 Instruction* instruction = InstructionAt(instruction_index--);
463 if (instruction->IsBlockStart()) { 463 if (instruction->IsBlockStart()) {
464 return instruction_blocks_ 464 return instruction_blocks_->at(
465 [BlockStartInstruction::cast(instruction)->rpo_number().ToSize()]; 465 BlockStartInstruction::cast(instruction)->rpo_number().ToSize());
466 } 466 }
467 } 467 }
468 } 468 }
469 469
470 470
471 bool InstructionSequence::IsReference(int virtual_register) const { 471 bool InstructionSequence::IsReference(int virtual_register) const {
472 return references_.find(virtual_register) != references_.end(); 472 return references_.find(virtual_register) != references_.end();
473 } 473 }
474 474
475 475
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 os << " B" << succ_block->id(); 645 os << " B" << succ_block->id();
646 } 646 }
647 os << "\n"; 647 os << "\n";
648 } 648 }
649 return os; 649 return os;
650 } 650 }
651 651
652 } // namespace compiler 652 } // namespace compiler
653 } // namespace internal 653 } // namespace internal
654 } // namespace v8 654 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698