Author: [email protected]
Date: Wed Mar 25 03:00:52 2009
New Revision: 1605
Modified:
branches/bleeding_edge/src/codegen-ia32.cc
branches/bleeding_edge/src/jump-target.cc
branches/bleeding_edge/src/register-allocator.cc
branches/bleeding_edge/src/virtual-frame-arm.h
branches/bleeding_edge/src/virtual-frame-ia32.cc
branches/bleeding_edge/src/virtual-frame-ia32.h
branches/bleeding_edge/src/virtual-frame.cc
Log:
Remove register counts from VirtualFrame, use register indices instead.
Review URL: http://codereview.chromium.org/42565
Modified: branches/bleeding_edge/src/codegen-ia32.cc
==============================================================================
--- branches/bleeding_edge/src/codegen-ia32.cc (original)
+++ branches/bleeding_edge/src/codegen-ia32.cc Wed Mar 25 03:00:52 2009
@@ -5163,11 +5163,11 @@
#ifdef DEBUG
bool CodeGenerator::HasValidEntryRegisters() {
- return (allocator()->count(eax) == frame()->register_count(eax))
- && (allocator()->count(ebx) == frame()->register_count(ebx))
- && (allocator()->count(ecx) == frame()->register_count(ecx))
- && (allocator()->count(edx) == frame()->register_count(edx))
- && (allocator()->count(edi) == frame()->register_count(edi));
+ return (allocator()->count(eax) == (frame()->is_used(eax) ? 1 : 0))
+ && (allocator()->count(ebx) == (frame()->is_used(ebx) ? 1 : 0))
+ && (allocator()->count(ecx) == (frame()->is_used(ecx) ? 1 : 0))
+ && (allocator()->count(edx) == (frame()->is_used(edx) ? 1 : 0))
+ && (allocator()->count(edi) == (frame()->is_used(edi) ? 1 : 0));
}
#endif
Modified: branches/bleeding_edge/src/jump-target.cc
==============================================================================
--- branches/bleeding_edge/src/jump-target.cc (original)
+++ branches/bleeding_edge/src/jump-target.cc Wed Mar 25 03:00:52 2009
@@ -272,14 +272,13 @@
// Set the copied flags in the frame to be exact. This assumes that
// the backing store of copies is always lower in the frame.
- // Set the register counts and indices.
+ // Set the register locations to their index in the frame.
for (int i = 0; i < length; i++) {
FrameElement current = entry_frame_->elements_[i];
entry_frame_->elements_[i].clear_copied();
if (current.is_copy()) {
entry_frame_->elements_[current.index()].set_copied();
} else if (current.is_register()) {
- entry_frame_->frame_registers_.Use(current.reg());
entry_frame_->register_locations_[current.reg().code()] = i;
}
}
Modified: branches/bleeding_edge/src/register-allocator.cc
==============================================================================
--- branches/bleeding_edge/src/register-allocator.cc (original)
+++ branches/bleeding_edge/src/register-allocator.cc Wed Mar 25 03:00:52
2009
@@ -107,7 +107,7 @@
// If the target is only referenced in the frame, it can be spilled and
// then allocated.
ASSERT(cgen_->has_valid_frame());
- if (count(target) == cgen_->frame()->register_count(target)) {
+ if (cgen_->frame()->is_used(target) && count(target) == 1) {
cgen_->frame()->Spill(target);
ASSERT(!is_used(target));
return Result(target, cgen_);
Modified: branches/bleeding_edge/src/virtual-frame-arm.h
==============================================================================
--- branches/bleeding_edge/src/virtual-frame-arm.h (original)
+++ branches/bleeding_edge/src/virtual-frame-arm.h Wed Mar 25 03:00:52 2009
@@ -76,8 +76,16 @@
return elements_.length() - expression_base_index();
}
- int register_count(Register reg) {
- return frame_registers_.count(reg);
+ int register_index(Register reg) {
+ return register_locations_[reg.code()];
+ }
+
+ bool is_used(int reg_code) {
+ return register_locations_[reg_code] != kIllegalIndex;
+ }
+
+ bool is_used(Register reg) {
+ return is_used(reg.code()) != kIllegalIndex;
}
// Add extra in-memory elements to the top of the frame to match an
actual
@@ -341,10 +349,6 @@
// The index of the register frame element using each register, or
// kIllegalIndex if a register is not on the frame.
int register_locations_[kNumRegisters];
-
- // The frame has an embedded register file that it uses to track
registers
- // used in the frame.
- RegisterFile frame_registers_;
// The index of the first parameter. The receiver lies below the first
// parameter.
Modified: branches/bleeding_edge/src/virtual-frame-ia32.cc
==============================================================================
--- branches/bleeding_edge/src/virtual-frame-ia32.cc (original)
+++ branches/bleeding_edge/src/virtual-frame-ia32.cc Wed Mar 25 03:00:52
2009
@@ -308,7 +308,7 @@
elements_[i] = target;
} else {
// We need to move source to target.
- if (frame_registers_.is_used(target.reg())) {
+ if (is_used(target.reg())) {
// The move is blocked because the target contains valid data.
// If we are stuck with only cycles remaining, then we spill
source.
// Otherwise, we just need more iterations.
Modified: branches/bleeding_edge/src/virtual-frame-ia32.h
==============================================================================
--- branches/bleeding_edge/src/virtual-frame-ia32.h (original)
+++ branches/bleeding_edge/src/virtual-frame-ia32.h Wed Mar 25 03:00:52 2009
@@ -76,8 +76,16 @@
return elements_.length() - expression_base_index();
}
- int register_count(Register reg) {
- return frame_registers_.count(reg);
+ int register_index(Register reg) {
+ return register_locations_[reg.code()];
+ }
+
+ bool is_used(int reg_code) {
+ return register_locations_[reg_code] != kIllegalIndex;
+ }
+
+ bool is_used(Register reg) {
+ return is_used(reg.code());
}
// Add extra in-memory elements to the top of the frame to match an
actual
@@ -332,10 +340,6 @@
// The index of the element that is at the processor's frame pointer
// (the ebp register).
int frame_pointer_;
-
- // The frame has an embedded register file that it uses to track
registers
- // used in the frame.
- RegisterFile frame_registers_;
// The index of the register frame element using each register, or
// kIllegalIndex if a register is not on the frame.
Modified: branches/bleeding_edge/src/virtual-frame.cc
==============================================================================
--- branches/bleeding_edge/src/virtual-frame.cc (original)
+++ branches/bleeding_edge/src/virtual-frame.cc Wed Mar 25 03:00:52 2009
@@ -57,8 +57,7 @@
parameter_count_(original->parameter_count_),
local_count_(original->local_count_),
stack_pointer_(original->stack_pointer_),
- frame_pointer_(original->frame_pointer_),
- frame_registers_(original->frame_registers_) {
+ frame_pointer_(original->frame_pointer_) {
// Copy all the elements from the original.
for (int i = 0; i < original->elements_.length(); i++) {
elements_.Add(original->elements_[i]);
@@ -152,7 +151,6 @@
if (cgen_->frame() == this) {
Unuse(last.reg());
} else {
- frame_registers_.Unuse(last.reg());
register_locations_[last.reg().code()] = kIllegalIndex;
}
}
@@ -161,29 +159,22 @@
void VirtualFrame::Use(Register reg, int index) {
- ASSERT(frame_registers_.count(reg) == 0);
ASSERT(register_locations_[reg.code()] == kIllegalIndex);
register_locations_[reg.code()] = index;
- frame_registers_.Use(reg);
cgen_->allocator()->Use(reg);
}
void VirtualFrame::Unuse(Register reg) {
- ASSERT(frame_registers_.count(reg) == 1);
ASSERT(register_locations_[reg.code()] != kIllegalIndex);
register_locations_[reg.code()] = kIllegalIndex;
- frame_registers_.Unuse(reg);
cgen_->allocator()->Unuse(reg);
}
void VirtualFrame::Spill(Register target) {
- if (!frame_registers_.is_used(target)) return;
- for (int i = 0; i < elements_.length(); i++) {
- if (elements_[i].is_register() && elements_[i].reg().is(target)) {
- SpillElementAt(i);
- }
+ if (is_used(target)) {
+ SpillElementAt(register_index(target));
}
}
@@ -194,23 +185,15 @@
// internally-referenced register whose internal reference count matches
// its external reference count (so that spilling it from the frame frees
// it for use).
- int min_count = kMaxInt;
- int best_register_code = no_reg.code_;
-
for (int i = 0; i < kNumRegisters; i++) {
- int count = frame_registers_.count(i);
- if (count < min_count && count == cgen_->allocator()->count(i)) {
- min_count = count;
- best_register_code = i;
+ if (is_used(i) && cgen_->allocator()->count(i) == 1) {
+ Register result = { i };
+ Spill(result);
+ ASSERT(!cgen_->allocator()->is_used(result));
+ return result;
}
}
-
- Register result = { best_register_code };
- if (result.is_valid()) {
- Spill(result);
- ASSERT(!cgen_->allocator()->is_used(result));
- }
- return result;
+ return no_reg;
}
@@ -279,7 +262,6 @@
if (cgen_->frame() == this) {
Unuse(source.reg());
} else {
- frame_registers_.Unuse(source.reg());
register_locations_[source.reg().code()] = kIllegalIndex;
}
}
@@ -390,24 +372,13 @@
FrameElement new_element;
if (value->is_register()) {
- // There are two cases depending no whether the register already
- // occurs in the frame or not.
- if (register_count(value->reg()) == 0) {
- Use(value->reg(), frame_index);
- elements_[frame_index] =
- FrameElement::RegisterElement(value->reg(),
- FrameElement::NOT_SYNCED);
- } else {
- int i = 0;
- for (; i < elements_.length(); i++) {
- if (elements_[i].is_register() &&
elements_[i].reg().is(value->reg())) {
- break;
- }
- }
- ASSERT(i < elements_.length());
-
+ if (is_used(value->reg())) {
+ // 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());
if (i < frame_index) {
- // The register backing store is lower in the frame than its copy.
+ // The register FrameElement is lower in the frame than the new
copy.
elements_[frame_index] = CopyElementAt(i);
} else {
// There was an early bailout for the case of setting a
@@ -426,6 +397,12 @@
}
}
}
+ } else {
+ // The register value->reg() was not already used on the frame.
+ Use(value->reg(), frame_index);
+ elements_[frame_index] =
+ FrameElement::RegisterElement(value->reg(),
+ FrameElement::NOT_SYNCED);
}
} else {
ASSERT(value->is_constant());
@@ -497,21 +474,12 @@
void VirtualFrame::Push(Register reg) {
- FrameElement new_element;
- if (register_count(reg) == 0) {
- Use(reg, elements_.length());
- new_element =
- FrameElement::RegisterElement(reg, FrameElement::NOT_SYNCED);
+ if (is_used(reg)) {
+ elements_.Add(CopyElementAt(register_index(reg)));
} else {
- for (int i = 0; i < elements_.length(); i++) {
- FrameElement element = elements_[i];
- if (element.is_register() && element.reg().is(reg)) {
- new_element = CopyElementAt(i);
- break;
- }
- }
+ Use(reg, elements_.length());
+ elements_.Add(FrameElement::RegisterElement(reg,
FrameElement::NOT_SYNCED));
}
- elements_.Add(new_element);
}
@@ -569,9 +537,6 @@
if (frame_pointer_ != other->frame_pointer_) return false;
for (int i = 0; i < kNumRegisters; i++) {
- if (frame_registers_.count(i) != other->frame_registers_.count(i)) {
- return false;
- }
if (register_locations_[i] != other->register_locations_[i]) {
return false;
}
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---