mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-06-10 18:29:43 +00:00
#431: M1385165
This commit is contained in:
parent
8c40900ac1
commit
5b23930427
|
@ -71,11 +71,39 @@ InsertSortedList(InlineForwardList<T> &list, T* value)
|
||||||
// LiveRange
|
// LiveRange
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline void
|
||||||
|
LiveRange::noteAddedUse(UsePosition* use)
|
||||||
|
{
|
||||||
|
LUse::Policy policy = use->usePolicy();
|
||||||
|
usesSpillWeight_ += BacktrackingAllocator::SpillWeightFromUsePolicy(policy);
|
||||||
|
if (policy == LUse::FIXED)
|
||||||
|
++numFixedUses_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
LiveRange::noteRemovedUse(UsePosition* use)
|
||||||
|
{
|
||||||
|
LUse::Policy policy = use->usePolicy();
|
||||||
|
usesSpillWeight_ -= BacktrackingAllocator::SpillWeightFromUsePolicy(policy);
|
||||||
|
if (policy == LUse::FIXED)
|
||||||
|
--numFixedUses_;
|
||||||
|
MOZ_ASSERT_IF(!hasUses(), !usesSpillWeight_ && !numFixedUses_);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LiveRange::addUse(UsePosition* use)
|
LiveRange::addUse(UsePosition* use)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(covers(use->pos));
|
MOZ_ASSERT(covers(use->pos));
|
||||||
InsertSortedList(uses_, use);
|
InsertSortedList(uses_, use);
|
||||||
|
noteAddedUse(use);
|
||||||
|
}
|
||||||
|
|
||||||
|
UsePosition*
|
||||||
|
LiveRange::popUse()
|
||||||
|
{
|
||||||
|
UsePosition* ret = uses_.popFront();
|
||||||
|
noteRemovedUse(ret);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -89,6 +117,7 @@ LiveRange::distributeUses(LiveRange* other)
|
||||||
UsePosition* use = *iter;
|
UsePosition* use = *iter;
|
||||||
if (other->covers(use->pos)) {
|
if (other->covers(use->pos)) {
|
||||||
uses_.removeAndIncrement(iter);
|
uses_.removeAndIncrement(iter);
|
||||||
|
noteRemovedUse(use);
|
||||||
other->addUse(use);
|
other->addUse(use);
|
||||||
} else {
|
} else {
|
||||||
iter++;
|
iter++;
|
||||||
|
@ -2494,28 +2523,9 @@ BacktrackingAllocator::computeSpillWeight(LiveBundle* bundle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (UsePositionIterator iter = range->usesBegin(); iter; iter++) {
|
usesTotal += range->usesSpillWeight();
|
||||||
LUse* use = iter->use;
|
if (range->numFixedUses() > 0)
|
||||||
|
fixed = true;
|
||||||
switch (use->policy()) {
|
|
||||||
case LUse::ANY:
|
|
||||||
usesTotal += 1000;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LUse::FIXED:
|
|
||||||
fixed = true;
|
|
||||||
case LUse::REGISTER:
|
|
||||||
usesTotal += 2000;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LUse::KEEPALIVE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Note: RECOVERED_INPUT will not appear in UsePositionIterator.
|
|
||||||
MOZ_CRASH("Bad use");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bundles with fixed uses are given a higher spill weight, since they must
|
// Bundles with fixed uses are given a higher spill weight, since they must
|
||||||
|
|
|
@ -123,6 +123,8 @@ class Requirement
|
||||||
CodePosition position_;
|
CodePosition position_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// We may want the cache-friendlier version in
|
||||||
|
// https://hg.mozilla.org/mozilla-central/raw-file/df79199f9f0fcde01ddc2eccf2a5368cb7b801aa/js/src/jit/BacktrackingAllocator.h
|
||||||
struct UsePosition : public TempObject,
|
struct UsePosition : public TempObject,
|
||||||
public InlineForwardListNode<UsePosition>
|
public InlineForwardListNode<UsePosition>
|
||||||
{
|
{
|
||||||
|
@ -141,6 +143,9 @@ struct UsePosition : public TempObject,
|
||||||
? CodePosition::INPUT
|
? CodePosition::INPUT
|
||||||
: CodePosition::OUTPUT));
|
: CodePosition::OUTPUT));
|
||||||
}
|
}
|
||||||
|
LUse::Policy usePolicy() const {
|
||||||
|
return use->policy();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef InlineForwardListIterator<UsePosition> UsePositionIterator;
|
typedef InlineForwardListIterator<UsePosition> UsePositionIterator;
|
||||||
|
@ -231,15 +236,29 @@ class LiveRange : public TempObject
|
||||||
// All uses of the virtual register in this range, ordered by location.
|
// All uses of the virtual register in this range, ordered by location.
|
||||||
InlineForwardList<UsePosition> uses_;
|
InlineForwardList<UsePosition> uses_;
|
||||||
|
|
||||||
|
// Total spill weight that calculate from all the uses' policy. Because the
|
||||||
|
// use's policy can't be changed after initialization, we can update the
|
||||||
|
// weight whenever a use is added to or remove from this range. This way, we
|
||||||
|
// don't need to iterate all the uses every time computeSpillWeight() is
|
||||||
|
// called.
|
||||||
|
size_t usesSpillWeight_;
|
||||||
|
|
||||||
|
// Number of uses that have policy LUse::FIXED.
|
||||||
|
uint32_t numFixedUses_;
|
||||||
|
|
||||||
// Whether this range contains the virtual register's definition.
|
// Whether this range contains the virtual register's definition.
|
||||||
bool hasDefinition_;
|
bool hasDefinition_;
|
||||||
|
|
||||||
LiveRange(uint32_t vreg, Range range)
|
LiveRange(uint32_t vreg, Range range)
|
||||||
: vreg_(vreg), bundle_(nullptr), range_(range), hasDefinition_(false)
|
: vreg_(vreg), bundle_(nullptr), range_(range), usesSpillWeight_(0),
|
||||||
|
numFixedUses_(0), hasDefinition_(false)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!range.empty());
|
MOZ_ASSERT(!range.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void noteAddedUse(UsePosition* use);
|
||||||
|
void noteRemovedUse(UsePosition* use);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static LiveRange* New(TempAllocator& alloc, uint32_t vreg,
|
static LiveRange* New(TempAllocator& alloc, uint32_t vreg,
|
||||||
CodePosition from, CodePosition to) {
|
CodePosition from, CodePosition to) {
|
||||||
|
@ -287,9 +306,7 @@ class LiveRange : public TempObject
|
||||||
bool hasUses() const {
|
bool hasUses() const {
|
||||||
return !!usesBegin();
|
return !!usesBegin();
|
||||||
}
|
}
|
||||||
UsePosition* popUse() {
|
UsePosition* popUse();
|
||||||
return uses_.popFront();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasDefinition() const {
|
bool hasDefinition() const {
|
||||||
return hasDefinition_;
|
return hasDefinition_;
|
||||||
|
@ -316,6 +333,13 @@ class LiveRange : public TempObject
|
||||||
hasDefinition_ = true;
|
hasDefinition_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t usesSpillWeight() {
|
||||||
|
return usesSpillWeight_;
|
||||||
|
}
|
||||||
|
uint32_t numFixedUses() {
|
||||||
|
return numFixedUses_;
|
||||||
|
}
|
||||||
|
|
||||||
// Return a string describing this range. This is not re-entrant!
|
// Return a string describing this range. This is not re-entrant!
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
const char* toString() const;
|
const char* toString() const;
|
||||||
|
@ -636,6 +660,20 @@ class BacktrackingAllocator : protected RegisterAllocator
|
||||||
|
|
||||||
bool go();
|
bool go();
|
||||||
|
|
||||||
|
static size_t SpillWeightFromUsePolicy(LUse::Policy policy) {
|
||||||
|
switch (policy) {
|
||||||
|
case LUse::ANY:
|
||||||
|
return 1000;
|
||||||
|
|
||||||
|
case LUse::REGISTER:
|
||||||
|
case LUse::FIXED:
|
||||||
|
return 2000;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef Vector<LiveRange*, 4, SystemAllocPolicy> LiveRangeVector;
|
typedef Vector<LiveRange*, 4, SystemAllocPolicy> LiveRangeVector;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user