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

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

Issue 805263003: [turbofan] move assembly order to InstructionBlock (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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/instruction.h ('k') | src/compiler/instruction-selector.h » ('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/graph.h" 6 #include "src/compiler/graph.h"
7 #include "src/compiler/instruction.h" 7 #include "src/compiler/instruction.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 return os << Brief(*constant.ToHeapObject()); 341 return os << Brief(*constant.ToHeapObject());
342 case Constant::kRpoNumber: 342 case Constant::kRpoNumber:
343 return os << "RPO" << constant.ToRpoNumber().ToInt(); 343 return os << "RPO" << constant.ToRpoNumber().ToInt();
344 } 344 }
345 UNREACHABLE(); 345 UNREACHABLE();
346 return os; 346 return os;
347 } 347 }
348 348
349 349
350 InstructionBlock::InstructionBlock(Zone* zone, BasicBlock::Id id, 350 InstructionBlock::InstructionBlock(Zone* zone, BasicBlock::Id id,
351 BasicBlock::RpoNumber ao_number,
352 BasicBlock::RpoNumber rpo_number, 351 BasicBlock::RpoNumber rpo_number,
353 BasicBlock::RpoNumber loop_header, 352 BasicBlock::RpoNumber loop_header,
354 BasicBlock::RpoNumber loop_end, 353 BasicBlock::RpoNumber loop_end,
355 bool deferred) 354 bool deferred)
356 : successors_(zone), 355 : successors_(zone),
357 predecessors_(zone), 356 predecessors_(zone),
358 phis_(zone), 357 phis_(zone),
359 id_(id), 358 id_(id),
360 ao_number_(ao_number), 359 ao_number_(rpo_number),
361 rpo_number_(rpo_number), 360 rpo_number_(rpo_number),
362 loop_header_(loop_header), 361 loop_header_(loop_header),
363 loop_end_(loop_end), 362 loop_end_(loop_end),
364 code_start_(-1), 363 code_start_(-1),
365 code_end_(-1), 364 code_end_(-1),
366 deferred_(deferred) {} 365 deferred_(deferred) {}
367 366
368 367
369 size_t InstructionBlock::PredecessorIndexOf( 368 size_t InstructionBlock::PredecessorIndexOf(
370 BasicBlock::RpoNumber rpo_number) const { 369 BasicBlock::RpoNumber rpo_number) const {
(...skipping 14 matching lines...) Expand all
385 384
386 static BasicBlock::RpoNumber GetLoopEndRpo(const BasicBlock* block) { 385 static BasicBlock::RpoNumber GetLoopEndRpo(const BasicBlock* block) {
387 if (!block->IsLoopHeader()) return BasicBlock::RpoNumber::Invalid(); 386 if (!block->IsLoopHeader()) return BasicBlock::RpoNumber::Invalid();
388 return block->loop_end()->GetRpoNumber(); 387 return block->loop_end()->GetRpoNumber();
389 } 388 }
390 389
391 390
392 static InstructionBlock* InstructionBlockFor(Zone* zone, 391 static InstructionBlock* InstructionBlockFor(Zone* zone,
393 const BasicBlock* block) { 392 const BasicBlock* block) {
394 InstructionBlock* instr_block = new (zone) InstructionBlock( 393 InstructionBlock* instr_block = new (zone) InstructionBlock(
395 zone, block->id(), block->GetAoNumber(), block->GetRpoNumber(), 394 zone, block->id(), block->GetRpoNumber(), GetRpo(block->loop_header()),
396 GetRpo(block->loop_header()), GetLoopEndRpo(block), block->deferred()); 395 GetLoopEndRpo(block), block->deferred());
397 // Map successors and precessors 396 // Map successors and precessors
398 instr_block->successors().reserve(block->SuccessorCount()); 397 instr_block->successors().reserve(block->SuccessorCount());
399 for (auto it = block->successors_begin(); it != block->successors_end(); 398 for (auto it = block->successors_begin(); it != block->successors_end();
400 ++it) { 399 ++it) {
401 instr_block->successors().push_back((*it)->GetRpoNumber()); 400 instr_block->successors().push_back((*it)->GetRpoNumber());
402 } 401 }
403 instr_block->predecessors().reserve(block->PredecessorCount()); 402 instr_block->predecessors().reserve(block->PredecessorCount());
404 for (auto it = block->predecessors_begin(); it != block->predecessors_end(); 403 for (auto it = block->predecessors_begin(); it != block->predecessors_end();
405 ++it) { 404 ++it) {
406 instr_block->predecessors().push_back((*it)->GetRpoNumber()); 405 instr_block->predecessors().push_back((*it)->GetRpoNumber());
407 } 406 }
408 return instr_block; 407 return instr_block;
409 } 408 }
410 409
411 410
412 InstructionBlocks* InstructionSequence::InstructionBlocksFor( 411 InstructionBlocks* InstructionSequence::InstructionBlocksFor(
413 Zone* zone, const Schedule* schedule) { 412 Zone* zone, const Schedule* schedule) {
414 InstructionBlocks* blocks = zone->NewArray<InstructionBlocks>(1); 413 InstructionBlocks* blocks = zone->NewArray<InstructionBlocks>(1);
415 new (blocks) InstructionBlocks( 414 new (blocks) InstructionBlocks(
416 static_cast<int>(schedule->rpo_order()->size()), NULL, zone); 415 static_cast<int>(schedule->rpo_order()->size()), NULL, zone);
417 size_t rpo_number = 0; 416 size_t rpo_number = 0;
418 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin(); 417 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin();
419 it != schedule->rpo_order()->end(); ++it, ++rpo_number) { 418 it != schedule->rpo_order()->end(); ++it, ++rpo_number) {
420 DCHECK_EQ(NULL, (*blocks)[rpo_number]); 419 DCHECK_EQ(NULL, (*blocks)[rpo_number]);
421 DCHECK((*it)->GetRpoNumber().ToSize() == rpo_number); 420 DCHECK((*it)->GetRpoNumber().ToSize() == rpo_number);
422 (*blocks)[rpo_number] = InstructionBlockFor(zone, *it); 421 (*blocks)[rpo_number] = InstructionBlockFor(zone, *it);
423 } 422 }
423 ComputeAssemblyOrder(blocks);
424 return blocks; 424 return blocks;
425 } 425 }
426 426
427 427
428 void InstructionSequence::ComputeAssemblyOrder(InstructionBlocks* blocks) {
429 int ao = 0;
430 for (auto const block : *blocks) {
431 if (!block->IsDeferred()) {
432 block->set_ao_number(BasicBlock::RpoNumber::FromInt(ao++));
433 }
434 }
435 for (auto const block : *blocks) {
436 if (block->IsDeferred()) {
437 block->set_ao_number(BasicBlock::RpoNumber::FromInt(ao++));
438 }
439 }
440 }
441
442
428 InstructionSequence::InstructionSequence(Zone* instruction_zone, 443 InstructionSequence::InstructionSequence(Zone* instruction_zone,
429 InstructionBlocks* instruction_blocks) 444 InstructionBlocks* instruction_blocks)
430 : zone_(instruction_zone), 445 : zone_(instruction_zone),
431 instruction_blocks_(instruction_blocks), 446 instruction_blocks_(instruction_blocks),
432 block_starts_(zone()), 447 block_starts_(zone()),
433 constants_(ConstantMap::key_compare(), 448 constants_(ConstantMap::key_compare(),
434 ConstantMap::allocator_type(zone())), 449 ConstantMap::allocator_type(zone())),
435 immediates_(zone()), 450 immediates_(zone()),
436 instructions_(zone()), 451 instructions_(zone()),
437 next_virtual_register_(0), 452 next_virtual_register_(0),
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 os << " B" << succ_block->id(); 694 os << " B" << succ_block->id();
680 } 695 }
681 os << "\n"; 696 os << "\n";
682 } 697 }
683 return os; 698 return os;
684 } 699 }
685 700
686 } // namespace compiler 701 } // namespace compiler
687 } // namespace internal 702 } // namespace internal
688 } // namespace v8 703 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/instruction-selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698