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

Unified Diff: src/jump-target.cc

Issue 114018: Simplify JumpTarget::ComputeEntryFrame. Eliminate a separate pass... (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
« no previous file with comments | « src/ia32/register-allocator-ia32.cc ('k') | src/register-allocator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/jump-target.cc
===================================================================
--- src/jump-target.cc (revision 1905)
+++ src/jump-target.cc (working copy)
@@ -189,28 +189,37 @@
}
}
- // Compute the registers already reserved by values in the frame.
- // Count the reserved registers to avoid using them.
- RegisterFile frame_registers = RegisterAllocator::Reserved();
- for (int i = 0; i < length; i++) {
- FrameElement* element = elements[i];
- if (element != NULL && element->is_register()) {
- frame_registers.Use(element->reg());
+ // Build the new frame. Initially it has memory elements for the
+ // parameters and some platform-dependent elements (e.g., return
+ // address). Fill those in first.
William Hesse 2009/05/11 13:47:34 The new frame does not "have" memory elements for
Kevin Millikin (Chromium) 2009/05/11 13:57:15 Replaced with: // Build the new frame. A freshl
+ entry_frame_ = new VirtualFrame(cgen_);
+ int index = 0;
+ for (; index < entry_frame_->elements_.length(); index++) {
+ // If the element is determined, set it now and count registers.
+ // Undetermined elements are initially recorded as if in memory.
+ if (elements[index] != NULL) {
+ entry_frame_->elements_[index] = *elements[index];
+ if (elements[index]->is_register()) {
+ entry_frame_->register_locations_[elements[index]->reg().code()] =
+ index;
+ }
}
}
-
- // Build the new frame. The frame already has memory elements for
- // the parameters (including the receiver) and the return address.
- // We will fill it up with memory elements.
- entry_frame_ = new VirtualFrame(cgen_);
- while (entry_frame_->elements_.length() < length) {
- entry_frame_->elements_.Add(FrameElement::MemoryElement());
+ // Fill in the rest of the frame with new elements.
+ for (; index < length; index++) {
+ if (elements[index] == NULL) {
+ entry_frame_->elements_.Add(FrameElement::MemoryElement());
+ } else {
+ entry_frame_->elements_.Add(*elements[index]);
+ if (elements[index]->is_register()) {
+ entry_frame_->register_locations_[elements[index]->reg().code()] =
+ index;
+ }
+ }
}
-
- // Copy the already-determined frame elements to the entry frame,
- // and allocate any still-undetermined frame elements to registers
- // or memory, from the top down.
+ // Allocate any still-undetermined frame elements to registers or
+ // memory, from the top down.
for (int i = length - 1; i >= 0; i--) {
if (elements[i] == NULL) {
// If the value is synced on all frames, put it in memory. This
@@ -234,7 +243,7 @@
for (int j = 0; j < reaching_frames_.length(); j++) {
FrameElement element = reaching_frames_[j]->elements_[i];
if (element.is_register() &&
- !frame_registers.is_used(element.reg())) {
+ !entry_frame_->is_used(element.reg())) {
candidate_registers.Use(element.reg());
if (candidate_registers.count(element.reg()) > max_count) {
max_count = candidate_registers.count(element.reg());
@@ -245,7 +254,7 @@
// If there was no preferred choice consider any free register.
if (best_reg_code == no_reg.code_) {
for (int j = 0; j < kNumRegisters; j++) {
- if (!frame_registers.is_used(j)) {
+ if (!entry_frame_->is_used(j) && !RegisterAllocator::IsReserved(j)) {
best_reg_code = j;
break;
}
@@ -256,27 +265,21 @@
// (the element is already recorded as in memory)
if (best_reg_code != no_reg.code_) {
Register reg = { best_reg_code };
- frame_registers.Use(reg);
entry_frame_->elements_[i] =
FrameElement::RegisterElement(reg,
FrameElement::NOT_SYNCED);
+ entry_frame_->register_locations_[best_reg_code] = i;
}
- } else {
- // The element is already determined.
- entry_frame_->elements_[i] = *elements[i];
}
}
// 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 locations to their index in the frame.
for (int i = 0; i < length; i++) {
FrameElement* current = &entry_frame_->elements_[i];
current->clear_copied();
if (current->is_copy()) {
entry_frame_->elements_[current->index()].set_copied();
- } else if (current->is_register()) {
- entry_frame_->register_locations_[current->reg().code()] = i;
}
if (direction_ == BIDIRECTIONAL && i >= high_water_mark) {
« no previous file with comments | « src/ia32/register-allocator-ia32.cc ('k') | src/register-allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698