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

Unified Diff: src/ia32/virtual-frame-ia32.cc

Issue 113837: Change the register allocator so that it no longer tracks references... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 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
Index: src/ia32/virtual-frame-ia32.cc
===================================================================
--- src/ia32/virtual-frame-ia32.cc (revision 2055)
+++ src/ia32/virtual-frame-ia32.cc (working copy)
@@ -47,7 +47,7 @@
for (int i = 0; i <= stack_pointer_; i++) {
elements_.Add(FrameElement::MemoryElement());
}
- for (int i = 0; i < kNumRegisters; i++) {
+ for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
register_locations_[i] = kIllegalIndex;
}
}
@@ -156,7 +156,7 @@
// [min(stack_pointer_ + 1,begin), end].
void VirtualFrame::SyncRange(int begin, int end) {
ASSERT(begin >= 0);
- ASSERT(end < elements_.length());
+ ASSERT(end < element_count());
// Sync elements below the range if they have not been materialized
// on the stack.
int start = Min(begin, stack_pointer_ + 1);
@@ -176,12 +176,12 @@
void VirtualFrame::MakeMergable(int mergable_elements) {
if (mergable_elements == JumpTarget::kAllElements) {
- mergable_elements = elements_.length();
+ mergable_elements = element_count();
}
- ASSERT(mergable_elements <= elements_.length());
+ ASSERT(mergable_elements <= element_count());
- int start_index = elements_.length() - mergable_elements;
- for (int i = start_index; i < elements_.length(); i++) {
+ int start_index = element_count() - mergable_elements;
+ for (int i = start_index; i < element_count(); i++) {
FrameElement element = elements_[i];
if (element.is_constant() || element.is_copy()) {
@@ -281,7 +281,7 @@
// of the index of the frame element esi is caching or kIllegalIndex
// if esi has not been disturbed.
int esi_caches = kIllegalIndex;
- for (int i = elements_.length() - 1; i >= 0; i--) {
+ for (int i = element_count() - 1; i >= 0; i--) {
FrameElement target = expected->elements_[i];
if (target.is_register()) continue; // Handle registers later.
if (target.is_memory()) {
@@ -347,17 +347,16 @@
// We have already done X-to-memory moves.
ASSERT(stack_pointer_ >= expected->stack_pointer_);
- for (int i = 0; i < kNumRegisters; i++) {
+ for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
// Move the right value into register i if it is currently in a register.
- int index = expected->register_locations_[i];
- int use_index = register_locations_[i];
+ int index = expected->register_location(i);
+ int use_index = register_location(i);
// Skip if register i is unused in the target or else if source is
// not a register (this is not a register-to-register move).
if (index == kIllegalIndex || !elements_[index].is_register()) continue;
- Register target = { i };
+ Register target = RegisterAllocator::ToRegister(i);
Register source = elements_[index].reg();
-
if (index != use_index) {
if (use_index == kIllegalIndex) { // Target is currently unused.
// Copy contents of source from source to target.
@@ -369,8 +368,8 @@
// Exchange contents of registers source and target.
// Nothing except the register backing use_index has changed.
elements_[use_index].set_reg(source);
- register_locations_[target.code()] = index;
- register_locations_[source.code()] = use_index;
+ set_register_location(target, index);
+ set_register_location(source, use_index);
__ xchg(source, target);
}
}
@@ -390,20 +389,24 @@
// register code order, we have special code to ensure that the backing
// elements of copies are in their correct locations when we
// encounter the copies.
- for (int i = 0; i < kNumRegisters; i++) {
- int index = expected->register_locations_[i];
+ for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
+ int index = expected->register_location(i);
if (index != kIllegalIndex) {
FrameElement source = elements_[index];
FrameElement target = expected->elements_[index];
- Register target_reg = { i };
+ Register target_reg = RegisterAllocator::ToRegister(i);
ASSERT(target.reg().is(target_reg));
switch (source.type()) {
case FrameElement::INVALID: // Fall through.
UNREACHABLE();
break;
case FrameElement::REGISTER:
- ASSERT(source.reg().is(target_reg));
- continue; // Go to next iteration. Skips Use(target_reg) below.
+ ASSERT(source.Equals(target));
+ // Go to next iteration. Skips Use(target_reg) and syncing
+ // below. It is safe to skip syncing because a target
+ // register frame element would only be synced if all source
+ // elements were.
+ continue;
break;
case FrameElement::MEMORY:
ASSERT(index <= stack_pointer_);
@@ -443,8 +446,7 @@
}
}
}
- // Ensure the proper sync state. If the source was memory no
- // code needs to be emitted.
+ // Ensure the proper sync state.
if (target.is_synced() && !source.is_synced()) {
__ mov(Operand(ebp, fp_relative(index)), target_reg);
}
@@ -482,7 +484,7 @@
// Store the function in the frame. The frame owns the register
// reference now (ie, it can keep it in edi or spill it later).
Push(edi);
- SyncElementAt(elements_.length() - 1);
+ SyncElementAt(element_count() - 1);
cgen()->allocator()->Unuse(edi);
}
@@ -499,7 +501,7 @@
// debugger. See VisitReturnStatement for the full return sequence.
__ mov(esp, Operand(ebp));
stack_pointer_ = frame_pointer();
- for (int i = elements_.length() - 1; i > stack_pointer_; i--) {
+ for (int i = element_count() - 1; i > stack_pointer_; i--) {
FrameElement last = elements_.RemoveLast();
if (last.is_register()) {
Unuse(last.reg());
@@ -518,7 +520,7 @@
// we sync them with the actual frame to allocate space for spilling
// them later. First sync everything above the stack pointer so we can
// use pushes to allocate and initialize the locals.
- SyncRange(stack_pointer_ + 1, elements_.length() - 1);
+ SyncRange(stack_pointer_ + 1, element_count() - 1);
Handle<Object> undefined = Factory::undefined_value();
FrameElement initial_value =
FrameElement::ConstantElement(undefined, FrameElement::SYNCED);
@@ -561,7 +563,7 @@
int new_backing_index = kIllegalIndex;
if (original.is_copied()) {
// Verify it is copied, and find first copy.
- for (int i = index + 1; i < elements_.length(); i++) {
+ for (int i = index + 1; i < element_count(); i++) {
if (elements_[i].is_copy() && elements_[i].index() == index) {
new_backing_index = i;
break;
@@ -589,7 +591,7 @@
} else {
// The original was in a register.
backing_reg = original.reg();
- register_locations_[backing_reg.code()] = new_backing_index;
+ set_register_location(backing_reg, new_backing_index);
}
// Invalidate the element at index.
elements_[index] = FrameElement::InvalidElement();
@@ -602,7 +604,7 @@
FrameElement::RegisterElement(backing_reg, FrameElement::NOT_SYNCED);
}
// Update the other copies.
- for (int i = new_backing_index + 1; i < elements_.length(); i++) {
+ for (int i = new_backing_index + 1; i < element_count(); i++) {
if (elements_[i].is_copy() && elements_[i].index() == index) {
elements_[i].set_index(new_backing_index);
elements_[new_backing_index].set_copied();
@@ -614,7 +616,7 @@
void VirtualFrame::TakeFrameSlotAt(int index) {
ASSERT(index >= 0);
- ASSERT(index <= elements_.length());
+ ASSERT(index <= element_count());
FrameElement original = elements_[index];
int new_backing_store_index = InvalidateFrameSlotAt(index);
if (new_backing_store_index != kIllegalIndex) {
@@ -631,13 +633,13 @@
FrameElement new_element =
FrameElement::RegisterElement(fresh.reg(),
FrameElement::NOT_SYNCED);
- Use(fresh.reg(), elements_.length());
+ Use(fresh.reg(), element_count());
elements_.Add(new_element);
__ mov(fresh.reg(), Operand(ebp, fp_relative(index)));
break;
}
case FrameElement::REGISTER:
- Use(original.reg(), elements_.length());
+ Use(original.reg(), element_count());
// Fall through.
case FrameElement::CONSTANT:
case FrameElement::COPY:
@@ -656,9 +658,9 @@
// a given index. The value on top of the frame is left in place.
// This is a duplicating operation, so it can create copies.
ASSERT(index >= 0);
- ASSERT(index < elements_.length());
+ ASSERT(index < element_count());
- int top_index = elements_.length() - 1;
+ int top_index = element_count() - 1;
FrameElement top = elements_[top_index];
FrameElement original = elements_[index];
if (top.is_copy() && top.index() == index) return;
@@ -705,7 +707,7 @@
__ mov(temp.reg(), Operand(ebp, fp_relative(backing_index)));
__ mov(Operand(ebp, fp_relative(index)), temp.reg());
} else {
- register_locations_[backing_element.reg().code()] = index;
+ set_register_location(backing_element.reg(), index);
if (backing_element.is_synced()) {
// If the element is a register, we will not actually move
// anything on the stack but only update the virtual frame
@@ -725,7 +727,7 @@
// All the copies of the old backing element (including the top
// element) become copies of the new backing element.
- for (int i = backing_index + 1; i < elements_.length(); i++) {
+ for (int i = backing_index + 1; i < element_count(); i++) {
if (elements_[i].is_copy() && elements_[i].index() == backing_index) {
elements_[i].set_index(index);
}
@@ -752,7 +754,7 @@
__ mov(temp.reg(), Operand(esp, 0));
__ mov(Operand(ebp, fp_relative(index)), temp.reg());
} else if (top.is_register()) {
- register_locations_[top.reg().code()] = index;
+ set_register_location(top.reg(), index);
// The stored-to slot has the (unsynced) register reference and
// the top element becomes a copy. The sync state of the top is
// preserved.
@@ -976,7 +978,7 @@
void VirtualFrame::Drop(int count) {
ASSERT(height() >= count);
- int num_virtual_elements = (elements_.length() - 1) - stack_pointer_;
+ int num_virtual_elements = (element_count() - 1) - stack_pointer_;
// Emit code to lower the stack pointer if necessary.
if (num_virtual_elements < count) {
@@ -997,7 +999,7 @@
Result VirtualFrame::Pop() {
FrameElement element = elements_.RemoveLast();
- int index = elements_.length();
+ int index = element_count();
ASSERT(element.is_valid());
bool pop_needed = (stack_pointer_ == index);
@@ -1052,7 +1054,7 @@
void VirtualFrame::EmitPop(Register reg) {
- ASSERT(stack_pointer_ == elements_.length() - 1);
+ ASSERT(stack_pointer_ == element_count() - 1);
stack_pointer_--;
elements_.RemoveLast();
__ pop(reg);
@@ -1060,7 +1062,7 @@
void VirtualFrame::EmitPop(Operand operand) {
- ASSERT(stack_pointer_ == elements_.length() - 1);
+ ASSERT(stack_pointer_ == element_count() - 1);
stack_pointer_--;
elements_.RemoveLast();
__ pop(operand);
@@ -1068,7 +1070,7 @@
void VirtualFrame::EmitPush(Register reg) {
- ASSERT(stack_pointer_ == elements_.length() - 1);
+ ASSERT(stack_pointer_ == element_count() - 1);
elements_.Add(FrameElement::MemoryElement());
stack_pointer_++;
__ push(reg);
@@ -1076,7 +1078,7 @@
void VirtualFrame::EmitPush(Operand operand) {
- ASSERT(stack_pointer_ == elements_.length() - 1);
+ ASSERT(stack_pointer_ == element_count() - 1);
elements_.Add(FrameElement::MemoryElement());
stack_pointer_++;
__ push(operand);
@@ -1084,7 +1086,7 @@
void VirtualFrame::EmitPush(Immediate immediate) {
- ASSERT(stack_pointer_ == elements_.length() - 1);
+ ASSERT(stack_pointer_ == element_count() - 1);
elements_.Add(FrameElement::MemoryElement());
stack_pointer_++;
__ push(immediate);

Powered by Google App Engine
This is Rietveld 408576698