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

Unified Diff: src/lithium-allocator.cc

Issue 9430002: Use placement-new operator in the register allocator. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/lithium-allocator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lithium-allocator.cc
===================================================================
--- src/lithium-allocator.cc (revision 10782)
+++ src/lithium-allocator.cc (working copy)
@@ -110,9 +110,9 @@
}
-void UseInterval::SplitAt(LifetimePosition pos) {
+void UseInterval::SplitAt(LifetimePosition pos, Zone* zone) {
ASSERT(Contains(pos) && pos.Value() != start().Value());
- UseInterval* after = new UseInterval(pos, end_);
+ UseInterval* after = new(zone) UseInterval(pos, end_);
after->next_ = next_;
next_ = after;
end_ = pos;
@@ -149,7 +149,7 @@
#endif
-LiveRange::LiveRange(int id)
+LiveRange::LiveRange(int id, Zone* zone)
: id_(id),
spilled_(false),
is_double_(false),
@@ -161,24 +161,26 @@
next_(NULL),
current_interval_(NULL),
last_processed_use_(NULL),
- spill_operand_(new LOperand()),
+ spill_operand_(new(zone) LOperand()),
spill_start_index_(kMaxInt) { }
-void LiveRange::set_assigned_register(int reg, RegisterKind register_kind) {
+void LiveRange::set_assigned_register(int reg,
+ RegisterKind register_kind,
+ Zone* zone) {
ASSERT(!HasRegisterAssigned() && !IsSpilled());
assigned_register_ = reg;
is_double_ = (register_kind == DOUBLE_REGISTERS);
- ConvertOperands();
+ ConvertOperands(zone);
}
-void LiveRange::MakeSpilled() {
+void LiveRange::MakeSpilled(Zone* zone) {
ASSERT(!IsSpilled());
ASSERT(TopLevel()->HasAllocatedSpillOperand());
spilled_ = true;
assigned_register_ = kInvalidAssignment;
- ConvertOperands();
+ ConvertOperands(zone);
}
@@ -246,7 +248,7 @@
}
-LOperand* LiveRange::CreateAssignedOperand() {
+LOperand* LiveRange::CreateAssignedOperand(Zone* zone) {
LOperand* op = NULL;
if (HasRegisterAssigned()) {
ASSERT(!IsSpilled());
@@ -260,7 +262,7 @@
op = TopLevel()->GetSpillOperand();
ASSERT(!op->IsUnallocated());
} else {
- LUnallocated* unalloc = new LUnallocated(LUnallocated::NONE);
+ LUnallocated* unalloc = new(zone) LUnallocated(LUnallocated::NONE);
unalloc->set_virtual_register(id_);
op = unalloc;
}
@@ -292,7 +294,9 @@
}
-void LiveRange::SplitAt(LifetimePosition position, LiveRange* result) {
+void LiveRange::SplitAt(LifetimePosition position,
+ LiveRange* result,
+ Zone* zone) {
ASSERT(Start().Value() < position.Value());
ASSERT(result->IsEmpty());
// Find the last interval that ends before the position. If the
@@ -311,7 +315,7 @@
while (current != NULL) {
if (current->Contains(position)) {
- current->SplitAt(position);
+ current->SplitAt(position, zone);
break;
}
UseInterval* next = current->next();
@@ -404,7 +408,9 @@
}
-void LiveRange::EnsureInterval(LifetimePosition start, LifetimePosition end) {
+void LiveRange::EnsureInterval(LifetimePosition start,
+ LifetimePosition end,
+ Zone* zone) {
LAllocator::TraceAlloc("Ensure live range %d in interval [%d %d[\n",
id_,
start.Value(),
@@ -418,7 +424,7 @@
first_interval_ = first_interval_->next();
}
- UseInterval* new_interval = new UseInterval(start, new_end);
+ UseInterval* new_interval = new(zone) UseInterval(start, new_end);
new_interval->next_ = first_interval_;
first_interval_ = new_interval;
if (new_interval->next() == NULL) {
@@ -427,20 +433,22 @@
}
-void LiveRange::AddUseInterval(LifetimePosition start, LifetimePosition end) {
+void LiveRange::AddUseInterval(LifetimePosition start,
+ LifetimePosition end,
+ Zone* zone) {
LAllocator::TraceAlloc("Add to live range %d interval [%d %d[\n",
id_,
start.Value(),
end.Value());
if (first_interval_ == NULL) {
- UseInterval* interval = new UseInterval(start, end);
+ UseInterval* interval = new(zone) UseInterval(start, end);
first_interval_ = interval;
last_interval_ = interval;
} else {
if (end.Value() == first_interval_->start().Value()) {
first_interval_->set_start(start);
} else if (end.Value() < first_interval_->start().Value()) {
- UseInterval* interval = new UseInterval(start, end);
+ UseInterval* interval = new(zone) UseInterval(start, end);
interval->set_next(first_interval_);
first_interval_ = interval;
} else {
@@ -456,11 +464,12 @@
UsePosition* LiveRange::AddUsePosition(LifetimePosition pos,
- LOperand* operand) {
+ LOperand* operand,
+ Zone* zone) {
LAllocator::TraceAlloc("Add to live range %d use position %d\n",
id_,
pos.Value());
- UsePosition* use_pos = new UsePosition(pos, operand);
+ UsePosition* use_pos = new(zone) UsePosition(pos, operand);
UsePosition* prev = NULL;
UsePosition* current = first_pos_;
while (current != NULL && current->pos().Value() < pos.Value()) {
@@ -480,8 +489,8 @@
}
-void LiveRange::ConvertOperands() {
- LOperand* op = CreateAssignedOperand();
+void LiveRange::ConvertOperands(Zone* zone) {
+ LOperand* op = CreateAssignedOperand(zone);
UsePosition* use_pos = first_pos();
while (use_pos != NULL) {
ASSERT(Start().Value() <= use_pos->pos().Value() &&
@@ -545,8 +554,8 @@
LAllocator::LAllocator(int num_values, HGraph* graph)
- : chunk_(NULL),
- allocation_ok_(true),
+ : zone_(graph->zone()),
+ chunk_(NULL),
live_in_sets_(graph->blocks()->length()),
live_ranges_(num_values * 2),
fixed_live_ranges_(NULL),
@@ -560,7 +569,8 @@
mode_(GENERAL_REGISTERS),
num_registers_(-1),
graph_(graph),
- has_osr_entry_(false) {}
+ has_osr_entry_(false),
+ allocation_ok_(true) { }
void LAllocator::InitializeLivenessAnalysis() {
@@ -574,7 +584,7 @@
BitVector* LAllocator::ComputeLiveOut(HBasicBlock* block) {
// Compute live out for the given block, except not including backward
// successor edges.
- BitVector* live_out = new BitVector(next_virtual_register_);
+ BitVector* live_out = new(zone_) BitVector(next_virtual_register_);
// Process all successor blocks.
for (HSuccessorIterator it(block->end()); !it.Done(); it.Advance()) {
@@ -612,7 +622,7 @@
while (!iterator.Done()) {
int operand_index = iterator.Current();
LiveRange* range = LiveRangeFor(operand_index);
- range->AddUseInterval(start, end);
+ range->AddUseInterval(start, end, zone_);
iterator.Advance();
}
}
@@ -654,9 +664,9 @@
ASSERT(index < Register::kNumAllocatableRegisters);
LiveRange* result = fixed_live_ranges_[index];
if (result == NULL) {
- result = new LiveRange(FixedLiveRangeID(index));
+ result = new(zone_) LiveRange(FixedLiveRangeID(index), zone_);
ASSERT(result->IsFixed());
- result->set_assigned_register(index, GENERAL_REGISTERS);
+ result->set_assigned_register(index, GENERAL_REGISTERS, zone_);
fixed_live_ranges_[index] = result;
}
return result;
@@ -667,9 +677,9 @@
ASSERT(index < DoubleRegister::kNumAllocatableRegisters);
LiveRange* result = fixed_double_live_ranges_[index];
if (result == NULL) {
- result = new LiveRange(FixedDoubleLiveRangeID(index));
+ result = new(zone_) LiveRange(FixedDoubleLiveRangeID(index), zone_);
ASSERT(result->IsFixed());
- result->set_assigned_register(index, DOUBLE_REGISTERS);
+ result->set_assigned_register(index, DOUBLE_REGISTERS, zone_);
fixed_double_live_ranges_[index] = result;
}
return result;
@@ -682,7 +692,7 @@
}
LiveRange* result = live_ranges_[index];
if (result == NULL) {
- result = new LiveRange(index);
+ result = new(zone_) LiveRange(index, zone_);
live_ranges_[index] = result;
}
return result;
@@ -728,15 +738,15 @@
if (range->IsEmpty() || range->Start().Value() > position.Value()) {
// Can happen if there is a definition without use.
- range->AddUseInterval(position, position.NextInstruction());
- range->AddUsePosition(position.NextInstruction(), NULL);
+ range->AddUseInterval(position, position.NextInstruction(), zone_);
+ range->AddUsePosition(position.NextInstruction(), NULL, zone_);
} else {
range->ShortenTo(position);
}
if (operand->IsUnallocated()) {
LUnallocated* unalloc_operand = LUnallocated::cast(operand);
- range->AddUsePosition(position, unalloc_operand)->set_hint(hint);
+ range->AddUsePosition(position, unalloc_operand, zone_)->set_hint(hint);
}
}
@@ -749,9 +759,9 @@
if (range == NULL) return;
if (operand->IsUnallocated()) {
LUnallocated* unalloc_operand = LUnallocated::cast(operand);
- range->AddUsePosition(position, unalloc_operand)->set_hint(hint);
+ range->AddUsePosition(position, unalloc_operand, zone_)->set_hint(hint);
}
- range->AddUseInterval(block_start, position);
+ range->AddUseInterval(block_start, position, zone_);
}
@@ -860,7 +870,8 @@
if (RequiredRegisterKind(input_copy->virtual_register()) ==
DOUBLE_REGISTERS) {
double_artificial_registers_.Add(
- cur_input->virtual_register() - first_artificial_register_);
+ cur_input->virtual_register() - first_artificial_register_,
+ zone_);
}
AddConstraintsGapMove(gap_index, input_copy, cur_input);
@@ -964,7 +975,8 @@
output->index() != i) {
LiveRange* range = FixedLiveRangeFor(i);
range->AddUseInterval(curr_position,
- curr_position.InstructionEnd());
+ curr_position.InstructionEnd(),
+ zone_);
}
}
}
@@ -975,7 +987,8 @@
output->index() != i) {
LiveRange* range = FixedDoubleLiveRangeFor(i);
range->AddUseInterval(curr_position,
- curr_position.InstructionEnd());
+ curr_position.InstructionEnd(),
+ zone_);
}
}
}
@@ -1023,7 +1036,7 @@
const ZoneList<HPhi*>* phis = block->phis();
for (int i = 0; i < phis->length(); ++i) {
HPhi* phi = phis->at(i);
- LUnallocated* phi_operand = new LUnallocated(LUnallocated::NONE);
+ LUnallocated* phi_operand = new(zone_) LUnallocated(LUnallocated::NONE);
phi_operand->set_virtual_register(phi->id());
for (int j = 0; j < phi->OperandCount(); ++j) {
HValue* op = phi->OperandAt(j);
@@ -1033,7 +1046,7 @@
operand = chunk_->DefineConstantOperand(constant);
} else {
ASSERT(!op->EmitAtUses());
- LUnallocated* unalloc = new LUnallocated(LUnallocated::ANY);
+ LUnallocated* unalloc = new(zone_) LUnallocated(LUnallocated::ANY);
unalloc->set_virtual_register(op->id());
operand = unalloc;
}
@@ -1140,8 +1153,8 @@
if (cur_cover->IsSpilled()) return;
ASSERT(pred_cover != NULL && cur_cover != NULL);
if (pred_cover != cur_cover) {
- LOperand* pred_op = pred_cover->CreateAssignedOperand();
- LOperand* cur_op = cur_cover->CreateAssignedOperand();
+ LOperand* pred_op = pred_cover->CreateAssignedOperand(zone_);
+ LOperand* cur_op = cur_cover->CreateAssignedOperand(zone_);
if (!pred_op->Equals(cur_op)) {
LGap* gap = NULL;
if (block->predecessors()->length() == 1) {
@@ -1213,8 +1226,8 @@
}
if (should_insert) {
LParallelMove* move = GetConnectingParallelMove(pos);
- LOperand* prev_operand = first_range->CreateAssignedOperand();
- LOperand* cur_operand = second_range->CreateAssignedOperand();
+ LOperand* prev_operand = first_range->CreateAssignedOperand(zone_);
+ LOperand* cur_operand = second_range->CreateAssignedOperand(zone_);
move->AddMove(prev_operand, cur_operand);
}
}
@@ -1317,7 +1330,7 @@
while (!iterator.Done()) {
int operand_index = iterator.Current();
LiveRange* range = LiveRangeFor(operand_index);
- range->EnsureInterval(start, end);
+ range->EnsureInterval(start, end, zone_);
iterator.Advance();
}
@@ -1438,7 +1451,7 @@
TraceAlloc("Pointer in register for range %d (start at %d) "
"at safe point %d\n",
cur->id(), cur->Start().Value(), safe_point);
- LOperand* operand = cur->CreateAssignedOperand();
+ LOperand* operand = cur->CreateAssignedOperand(zone_);
ASSERT(!operand->IsStackSlot());
map->RecordPointer(operand);
}
@@ -1810,7 +1823,7 @@
TraceAlloc("Assigning preferred reg %s to live range %d\n",
RegisterName(register_index),
current->id());
- current->set_assigned_register(register_index, mode_);
+ current->set_assigned_register(register_index, mode_, zone_);
return true;
}
}
@@ -1846,7 +1859,7 @@
TraceAlloc("Assigning free reg %s to live range %d\n",
RegisterName(reg),
current->id());
- current->set_assigned_register(reg, mode_);
+ current->set_assigned_register(reg, mode_, zone_);
return true;
}
@@ -1936,7 +1949,7 @@
TraceAlloc("Assigning blocked reg %s to live range %d\n",
RegisterName(reg),
current->id());
- current->set_assigned_register(reg, mode_);
+ current->set_assigned_register(reg, mode_, zone_);
// This register was not free. Thus we need to find and spill
// parts of active and inactive live regions that use the same register
@@ -2003,7 +2016,7 @@
LiveRange* result = LiveRangeFor(GetVirtualRegister());
if (!AllocationOk()) return NULL;
- range->SplitAt(pos, result);
+ range->SplitAt(pos, result, zone_);
return result;
}
@@ -2102,7 +2115,7 @@
if (op == NULL) op = chunk_->GetNextSpillSlot(mode_ == DOUBLE_REGISTERS);
first->SetSpillOperand(op);
}
- range->MakeSpilled();
+ range->MakeSpilled(zone_);
}
« no previous file with comments | « src/lithium-allocator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698