LUnallocated* LChunkBuilder::TempRegister() {
LUnallocated* operand =
new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
- operand->set_virtual_register(allocator_->GetVirtualRegister());
- if (!allocator_->AllocationOk()) Abort("Not enough virtual registers.");
+ int vreg = allocator_->GetVirtualRegister();
+ if (!allocator_->AllocationOk()) {
+ Abort("Out of virtual registers while trying to allocate temp register.");
+ return NULL;
+ }
+ operand->set_virtual_register(vreg);
return operand;
}
LUnallocated* LChunkBuilder::TempRegister() {
LUnallocated* operand =
new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
- operand->set_virtual_register(allocator_->GetVirtualRegister());
+ int vreg = allocator_->GetVirtualRegister();
if (!allocator_->AllocationOk()) {
- Abort("Not enough virtual registers (temps).");
+ Abort("Out of virtual registers while trying to allocate temp register.");
+ return NULL;
}
+ operand->set_virtual_register(vreg);
return operand;
}
ASSERT(!cur_input->IsUsedAtStart());
LUnallocated* input_copy = cur_input->CopyUnconstrained(zone());
- cur_input->set_virtual_register(GetVirtualRegister());
+ int vreg = GetVirtualRegister();
if (!AllocationOk()) return;
+ cur_input->set_virtual_register(vreg);
if (RequiredRegisterKind(input_copy->virtual_register()) ==
DOUBLE_REGISTERS) {
LiveRange* tail = SplitBetween(current,
current->Start(),
block_pos[reg].InstructionStart());
+ if (!AllocationOk()) return;
AddToUnhandledSorted(tail);
}
} else {
SpillBetween(range, split_pos, next_pos->pos());
}
+ if (!AllocationOk()) return;
ActiveToHandled(range);
--i;
}
next_intersection = Min(next_intersection, next_pos->pos());
SpillBetween(range, split_pos, next_intersection);
}
+ if (!AllocationOk()) return;
InactiveToHandled(range);
--i;
}
ASSERT(pos.IsInstructionStart() ||
!chunk_->instructions()->at(pos.InstructionIndex())->IsControl());
- LiveRange* result = LiveRangeFor(GetVirtualRegister());
+ int vreg = GetVirtualRegister();
if (!AllocationOk()) return NULL;
+ LiveRange* result = LiveRangeFor(vreg);
range->SplitAt(pos, result, zone_);
return result;
}
second_part,
second_part->Start().InstructionEnd(),
end.PrevInstruction().InstructionEnd());
+ if (!AllocationOk()) return;
ASSERT(third_part != second_part);
Zone* zone() const { return zone_; }
int GetVirtualRegister() {
- if (next_virtual_register_ > LUnallocated::kMaxVirtualRegisters) {
+ if (next_virtual_register_ >= LUnallocated::kMaxVirtualRegisters) {
allocation_ok_ = false;
+ // Maintain the invariant that we return something below the maximum.
+ return 0;
}
return next_virtual_register_++;
}
LUnallocated* LChunkBuilder::TempRegister() {
LUnallocated* operand =
new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
- operand->set_virtual_register(allocator_->GetVirtualRegister());
- if (!allocator_->AllocationOk()) Abort("Not enough virtual registers.");
+ int vreg = allocator_->GetVirtualRegister();
+ if (!allocator_->AllocationOk()) {
+ Abort("Out of virtual registers while trying to allocate temp register.");
+ return NULL;
+ }
+ operand->set_virtual_register(vreg);
return operand;
}
LUnallocated* LChunkBuilder::TempRegister() {
LUnallocated* operand =
new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
- operand->set_virtual_register(allocator_->GetVirtualRegister());
- if (!allocator_->AllocationOk()) Abort("Not enough virtual registers.");
+ int vreg = allocator_->GetVirtualRegister();
+ if (!allocator_->AllocationOk()) {
+ Abort("Out of virtual registers while trying to allocate temp register.");
+ return NULL;
+ }
+ operand->set_virtual_register(vreg);
return operand;
}
TEST(ManyLocalsInSharedContext) {
v8::HandleScope scope;
LocalContext env;
- int num_objects = 5000;
+ int num_objects = 6000;
CompileRun(
- "var n = 5000;"
+ "var n = 6000;"
"var result = [];"
"result.push('(function outer() {');"
"for (var i = 0; i < n; i++) {"