Cache first hint operand while building live ranges.

R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/14771015

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14546 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2aad7805
...@@ -140,6 +140,7 @@ LiveRange::LiveRange(int id, Zone* zone) ...@@ -140,6 +140,7 @@ LiveRange::LiveRange(int id, Zone* zone)
next_(NULL), next_(NULL),
current_interval_(NULL), current_interval_(NULL),
last_processed_use_(NULL), last_processed_use_(NULL),
current_hint_operand_(NULL),
spill_operand_(new(zone) LOperand()), spill_operand_(new(zone) LOperand()),
spill_start_index_(kMaxInt) { } spill_start_index_(kMaxInt) { }
...@@ -452,9 +453,11 @@ void LiveRange::AddUsePosition(LifetimePosition pos, ...@@ -452,9 +453,11 @@ void LiveRange::AddUsePosition(LifetimePosition pos,
id_, id_,
pos.Value()); pos.Value());
UsePosition* use_pos = new(zone) UsePosition(pos, operand, hint); UsePosition* use_pos = new(zone) UsePosition(pos, operand, hint);
UsePosition* prev_hint = NULL;
UsePosition* prev = NULL; UsePosition* prev = NULL;
UsePosition* current = first_pos_; UsePosition* current = first_pos_;
while (current != NULL && current->pos().Value() < pos.Value()) { while (current != NULL && current->pos().Value() < pos.Value()) {
prev_hint = current->HasHint() ? current : prev_hint;
prev = current; prev = current;
current = current->next(); current = current->next();
} }
...@@ -466,6 +469,10 @@ void LiveRange::AddUsePosition(LifetimePosition pos, ...@@ -466,6 +469,10 @@ void LiveRange::AddUsePosition(LifetimePosition pos,
use_pos->next_ = prev->next_; use_pos->next_ = prev->next_;
prev->next_ = use_pos; prev->next_ = use_pos;
} }
if (prev_hint == NULL && use_pos->HasHint()) {
current_hint_operand_ = hint;
}
} }
...@@ -918,7 +925,7 @@ void LAllocator::ProcessInstructions(HBasicBlock* block, BitVector* live) { ...@@ -918,7 +925,7 @@ void LAllocator::ProcessInstructions(HBasicBlock* block, BitVector* live) {
if (phi != NULL) { if (phi != NULL) {
// This is a phi resolving move. // This is a phi resolving move.
if (!phi->block()->IsLoopHeader()) { if (!phi->block()->IsLoopHeader()) {
hint = LiveRangeFor(phi->id())->FirstHint(); hint = LiveRangeFor(phi->id())->current_hint_operand();
} }
} else { } else {
if (to->IsUnallocated()) { if (to->IsUnallocated()) {
......
...@@ -329,6 +329,10 @@ class LiveRange: public ZoneObject { ...@@ -329,6 +329,10 @@ class LiveRange: public ZoneObject {
} }
bool IsSpilled() const { return spilled_; } bool IsSpilled() const { return spilled_; }
LOperand* current_hint_operand() const {
ASSERT(current_hint_operand_ == FirstHint());
return current_hint_operand_;
}
LOperand* FirstHint() const { LOperand* FirstHint() const {
UsePosition* pos = first_pos_; UsePosition* pos = first_pos_;
while (pos != NULL && !pos->HasHint()) pos = pos->next(); while (pos != NULL && !pos->HasHint()) pos = pos->next();
...@@ -398,6 +402,8 @@ class LiveRange: public ZoneObject { ...@@ -398,6 +402,8 @@ class LiveRange: public ZoneObject {
// This is used as a cache, it doesn't affect correctness. // This is used as a cache, it doesn't affect correctness.
mutable UseInterval* current_interval_; mutable UseInterval* current_interval_;
UsePosition* last_processed_use_; UsePosition* last_processed_use_;
// This is used as a cache, it's invalid outside of BuildLiveRanges.
LOperand* current_hint_operand_;
LOperand* spill_operand_; LOperand* spill_operand_;
int spill_start_index_; int spill_start_index_;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment