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

Unified Diff: src/virtual-frame.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/virtual-frame.cc
===================================================================
--- src/virtual-frame.cc (revision 2055)
+++ src/virtual-frame.cc (working copy)
@@ -38,7 +38,7 @@
// When cloned, a frame is a deep copy of the original.
VirtualFrame::VirtualFrame(VirtualFrame* original)
- : elements_(original->elements_.length()),
+ : elements_(original->element_count()),
stack_pointer_(original->stack_pointer_) {
elements_.AddAll(original->elements_);
// Copy register locations from original.
@@ -50,7 +50,7 @@
FrameElement VirtualFrame::CopyElementAt(int index) {
ASSERT(index >= 0);
- ASSERT(index < elements_.length());
+ ASSERT(index < element_count());
FrameElement target = elements_[index];
FrameElement result;
@@ -96,7 +96,7 @@
// pushing an exception handler). No code is emitted.
void VirtualFrame::Adjust(int count) {
ASSERT(count >= 0);
- ASSERT(stack_pointer_ == elements_.length() - 1);
+ ASSERT(stack_pointer_ == element_count() - 1);
for (int i = 0; i < count; i++) {
elements_.Add(FrameElement::MemoryElement());
@@ -107,7 +107,7 @@
void VirtualFrame::ForgetElements(int count) {
ASSERT(count >= 0);
- ASSERT(elements_.length() >= count);
+ ASSERT(element_count() >= count);
for (int i = 0; i < count; i++) {
FrameElement last = elements_.RemoveLast();
@@ -118,7 +118,7 @@
if (cgen()->frame() == this) {
Unuse(last.reg());
} else {
- register_locations_[last.reg().code()] = kIllegalIndex;
+ set_register_location(last.reg(), kIllegalIndex);
}
}
}
@@ -127,14 +127,13 @@
// If there are any registers referenced only by the frame, spill one.
Register VirtualFrame::SpillAnyRegister() {
- // Find the leftmost (ordered by register code) register whose only
+ // Find the leftmost (ordered by register number) register whose only
// reference is in the frame.
- for (int i = 0; i < kNumRegisters; i++) {
+ for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
if (is_used(i) && cgen()->allocator()->count(i) == 1) {
- Register result = { i };
- Spill(result);
- ASSERT(!cgen()->allocator()->is_used(result));
- return result;
+ SpillElementAt(register_location(i));
+ ASSERT(!cgen()->allocator()->is_used(i));
+ return RegisterAllocator::ToRegister(i);
}
}
return no_reg;
@@ -173,7 +172,7 @@
// Make the type of all elements be MEMORY.
void VirtualFrame::SpillAll() {
- for (int i = 0; i < elements_.length(); i++) {
+ for (int i = 0; i < element_count(); i++) {
SpillElementAt(i);
}
}
@@ -183,7 +182,7 @@
// Perform state changes on this frame that will make merge to the
// expected frame simpler or else increase the likelihood that his
// frame will match another.
- for (int i = 0; i < elements_.length(); i++) {
+ for (int i = 0; i < element_count(); i++) {
FrameElement source = elements_[i];
FrameElement target = expected->elements_[i];
@@ -200,7 +199,7 @@
if (cgen()->frame() == this) {
Unuse(source.reg());
} else {
- register_locations_[source.reg().code()] = kIllegalIndex;
+ set_register_location(source.reg(), kIllegalIndex);
}
}
elements_[i] = target;
@@ -224,16 +223,16 @@
ASSERT(height() >= spilled_args);
ASSERT(dropped_args <= spilled_args);
- SyncRange(0, elements_.length() - 1);
+ SyncRange(0, element_count() - 1);
// Spill registers.
- for (int i = 0; i < kNumRegisters; i++) {
+ for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
if (is_used(i)) {
- SpillElementAt(register_locations_[i]);
+ SpillElementAt(register_location(i));
}
}
// Spill the arguments.
- for (int i = elements_.length() - spilled_args; i < elements_.length(); i++) {
+ for (int i = element_count() - spilled_args; i < element_count(); i++) {
if (!elements_[i].is_memory()) {
SpillElementAt(i);
}
@@ -257,9 +256,9 @@
void VirtualFrame::SetElementAt(int index, Result* value) {
- int frame_index = elements_.length() - index - 1;
+ int frame_index = element_count() - index - 1;
ASSERT(frame_index >= 0);
- ASSERT(frame_index < elements_.length());
+ ASSERT(frame_index < element_count());
ASSERT(value->is_valid());
FrameElement original = elements_[frame_index];
@@ -283,7 +282,7 @@
// The register already appears on the frame. Either the existing
// register element, or the new element at frame_index, must be made
// a copy.
- int i = register_index(value->reg());
+ int i = register_location(value->reg());
ASSERT(value->static_type() == elements_[i].static_type());
if (i < frame_index) {
@@ -299,8 +298,8 @@
elements_[i].set_sync();
}
elements_[frame_index].clear_sync();
- register_locations_[value->reg().code()] = frame_index;
- for (int j = i + 1; j < elements_.length(); j++) {
+ set_register_location(value->reg(), frame_index);
+ for (int j = i + 1; j < element_count(); j++) {
if (elements_[j].is_copy() && elements_[j].index() == i) {
elements_[j].set_index(frame_index);
}
@@ -331,12 +330,12 @@
void VirtualFrame::Push(Register reg, StaticType static_type) {
if (is_used(reg)) {
- int index = register_index(reg);
+ int index = register_location(reg);
FrameElement element = CopyElementAt(index);
ASSERT(static_type.merge(element.static_type()) == element.static_type());
elements_.Add(element);
} else {
- Use(reg, elements_.length());
+ Use(reg, element_count());
FrameElement element =
FrameElement::RegisterElement(reg,
FrameElement::NOT_SYNCED,
@@ -366,15 +365,15 @@
bool VirtualFrame::Equals(VirtualFrame* other) {
#ifdef DEBUG
- for (int i = 0; i < kNumRegisters; i++) {
- if (register_locations_[i] != other->register_locations_[i]) {
+ for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
+ if (register_location(i) != other->register_location(i)) {
return false;
}
}
- if (elements_.length() != other->elements_.length()) return false;
+ if (element_count() != other->element_count()) return false;
#endif
if (stack_pointer_ != other->stack_pointer_) return false;
- for (int i = 0; i < elements_.length(); i++) {
+ for (int i = 0; i < element_count(); i++) {
if (!elements_[i].Equals(other->elements_[i])) return false;
}

Powered by Google App Engine
This is Rietveld 408576698