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

Unified Diff: src/compiler/register-allocator.cc

Issue 664123002: [turbofan] cleanup InstructionSequence (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/register-allocator.h ('k') | src/compiler/x64/code-generator-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/register-allocator.cc
diff --git a/src/compiler/register-allocator.cc b/src/compiler/register-allocator.cc
index 6499554db29d103d3f049dc82445b0bf589c02d0..8f024527503a761409b58046c64999c4d76cf3b4 100644
--- a/src/compiler/register-allocator.cc
+++ b/src/compiler/register-allocator.cc
@@ -499,10 +499,13 @@ LifetimePosition LiveRange::FirstIntersection(LiveRange* other) {
}
-RegisterAllocator::RegisterAllocator(InstructionSequence* code)
+RegisterAllocator::RegisterAllocator(Frame* frame, CompilationInfo* info,
+ InstructionSequence* code)
: zone_(code->isolate()),
+ frame_(frame),
+ info_(info),
code_(code),
- live_in_sets_(code->BasicBlockCount(), zone()),
+ live_in_sets_(code->InstructionBlockCount(), zone()),
live_ranges_(code->VirtualRegisterCount() * 2, zone()),
fixed_live_ranges_(NULL),
fixed_double_live_ranges_(NULL),
@@ -517,7 +520,7 @@ RegisterAllocator::RegisterAllocator(InstructionSequence* code)
void RegisterAllocator::InitializeLivenessAnalysis() {
// Initialize the live_in sets for each block to NULL.
- int block_count = code()->BasicBlockCount();
+ int block_count = code()->InstructionBlockCount();
live_in_sets_.Initialize(block_count, zone());
live_in_sets_.AddBlock(NULL, block_count, zone());
}
@@ -1107,15 +1110,15 @@ bool RegisterAllocator::Allocate() {
PopulatePointerMaps();
ConnectRanges();
ResolveControlFlow();
- code()->frame()->SetAllocatedRegisters(assigned_registers_);
- code()->frame()->SetAllocatedDoubleRegisters(assigned_double_registers_);
+ frame()->SetAllocatedRegisters(assigned_registers_);
+ frame()->SetAllocatedDoubleRegisters(assigned_double_registers_);
return true;
}
void RegisterAllocator::MeetRegisterConstraints() {
RegisterAllocatorPhase phase("L_Register constraints", this);
- for (int i = 0; i < code()->BasicBlockCount(); ++i) {
+ for (int i = 0; i < code()->InstructionBlockCount(); ++i) {
MeetRegisterConstraints(
code()->InstructionBlockAt(BasicBlock::RpoNumber::FromInt(i)));
if (!AllocationOk()) return;
@@ -1127,7 +1130,7 @@ void RegisterAllocator::ResolvePhis() {
RegisterAllocatorPhase phase("L_Resolve phis", this);
// Process the blocks in reverse order.
- for (int i = code()->BasicBlockCount() - 1; i >= 0; --i) {
+ for (int i = code()->InstructionBlockCount() - 1; i >= 0; --i) {
ResolvePhis(code()->InstructionBlockAt(BasicBlock::RpoNumber::FromInt(i)));
}
}
@@ -1248,7 +1251,8 @@ bool RegisterAllocator::CanEagerlyResolveControlFlow(
void RegisterAllocator::ResolveControlFlow() {
RegisterAllocatorPhase phase("L_Resolve control flow", this);
- for (int block_id = 1; block_id < code()->BasicBlockCount(); ++block_id) {
+ for (int block_id = 1; block_id < code()->InstructionBlockCount();
+ ++block_id) {
const InstructionBlock* block =
code()->InstructionBlockAt(BasicBlock::RpoNumber::FromInt(block_id));
if (CanEagerlyResolveControlFlow(block)) continue;
@@ -1271,7 +1275,7 @@ void RegisterAllocator::BuildLiveRanges() {
RegisterAllocatorPhase phase("L_Build live ranges", this);
InitializeLivenessAnalysis();
// Process the blocks in reverse order.
- for (int block_id = code()->BasicBlockCount() - 1; block_id >= 0;
+ for (int block_id = code()->InstructionBlockCount() - 1; block_id >= 0;
--block_id) {
const InstructionBlock* block =
code()->InstructionBlockAt(BasicBlock::RpoNumber::FromInt(block_id));
@@ -1354,7 +1358,7 @@ void RegisterAllocator::BuildLiveRanges() {
operand_index);
LiveRange* range = LiveRangeFor(operand_index);
PrintF(" (first use is at %d)\n", range->first_pos()->pos().Value());
- CompilationInfo* info = code()->linkage()->info();
+ CompilationInfo* info = this->info();
if (info->IsStub()) {
if (info->code_stub() == NULL) {
PrintF("\n");
@@ -1944,11 +1948,19 @@ void RegisterAllocator::AllocateBlockedReg(LiveRange* current) {
}
+static const InstructionBlock* GetContainingLoop(
+ const InstructionSequence* sequence, const InstructionBlock* block) {
+ BasicBlock::RpoNumber index = block->loop_header();
+ if (!index.IsValid()) return NULL;
+ return sequence->InstructionBlockAt(index);
+}
+
+
LifetimePosition RegisterAllocator::FindOptimalSpillingPos(
LiveRange* range, LifetimePosition pos) {
const InstructionBlock* block = GetInstructionBlock(pos.InstructionStart());
const InstructionBlock* loop_header =
- block->IsLoopHeader() ? block : code()->GetContainingLoop(block);
+ block->IsLoopHeader() ? block : GetContainingLoop(code(), block);
if (loop_header == NULL) return pos;
@@ -1969,7 +1981,7 @@ LifetimePosition RegisterAllocator::FindOptimalSpillingPos(
}
// Try hoisting out to an outer loop.
- loop_header = code()->GetContainingLoop(loop_header);
+ loop_header = GetContainingLoop(code(), loop_header);
}
return pos;
@@ -2086,10 +2098,10 @@ LifetimePosition RegisterAllocator::FindOptimalSplitPos(LifetimePosition start,
const InstructionBlock* block = end_block;
// Find header of outermost loop.
// TODO(titzer): fix redundancy below.
- while (code()->GetContainingLoop(block) != NULL &&
- code()->GetContainingLoop(block)->rpo_number().ToInt() >
+ while (GetContainingLoop(code(), block) != NULL &&
+ GetContainingLoop(code(), block)->rpo_number().ToInt() >
start_block->rpo_number().ToInt()) {
- block = code()->GetContainingLoop(block);
+ block = GetContainingLoop(code(), block);
}
// We did not find any suitable outer loop. Split at the latest possible
@@ -2153,7 +2165,7 @@ void RegisterAllocator::Spill(LiveRange* range) {
if (op == NULL) {
// Allocate a new operand referring to the spill slot.
RegisterKind kind = range->Kind();
- int index = code()->frame()->AllocateSpillSlot(kind == DOUBLE_REGISTERS);
+ int index = frame()->AllocateSpillSlot(kind == DOUBLE_REGISTERS);
if (kind == DOUBLE_REGISTERS) {
op = DoubleStackSlotOperand::Create(index, zone());
} else {
@@ -2198,8 +2210,7 @@ void RegisterAllocator::SetLiveRangeAssignedRegister(LiveRange* range,
RegisterAllocatorPhase::RegisterAllocatorPhase(const char* name,
RegisterAllocator* allocator)
- : CompilationPhase(name, allocator->code()->linkage()->info()),
- allocator_(allocator) {
+ : CompilationPhase(name, allocator->info()), allocator_(allocator) {
if (FLAG_turbo_stats) {
allocator_zone_start_allocation_size_ =
allocator->zone()->allocation_size();
« no previous file with comments | « src/compiler/register-allocator.h ('k') | src/compiler/x64/code-generator-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698