Bug 1027897 - IonMonkey: Eliminate a few explicit CodePosition::pos() calls. r=bhackett
authorDan Gohman <sunfish@google.com>
Mon, 23 Jun 2014 13:42:06 -0700
changeset 190334 ca1cfe712eab5b6c85b661ebf5b33107527507ef
parent 190333 bb707791db4dbfd38bfd947d54dad7db33779b16
child 190335 359ba79e9b187abe4daf3836f16264440471d8d9
push id27004
push useremorley@mozilla.com
push dateTue, 24 Jun 2014 15:52:34 +0000
treeherdermozilla-central@7b174d47f3cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1027897
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1027897 - IonMonkey: Eliminate a few explicit CodePosition::pos() calls. r=bhackett
js/src/jit/BacktrackingAllocator.cpp
js/src/jit/BacktrackingAllocator.h
js/src/jit/RegisterAllocator.h
--- a/js/src/jit/BacktrackingAllocator.cpp
+++ b/js/src/jit/BacktrackingAllocator.cpp
@@ -271,17 +271,17 @@ BacktrackingAllocator::tryGroupReusedReg
         }
     }
 
     LiveInterval *preInterval = LiveInterval::New(alloc(), interval->vreg(), 0);
     for (size_t i = 0; i < interval->numRanges(); i++) {
         const LiveInterval::Range *range = interval->getRange(i);
         JS_ASSERT(range->from <= inputOf(reg.ins()));
 
-        CodePosition to = (range->to <= outputOf(reg.ins())) ? range->to : outputOf(reg.ins());
+        CodePosition to = Min(range->to, outputOf(reg.ins()));
         if (!preInterval->addRange(range->from, to))
             return false;
     }
 
     LiveInterval *postInterval = LiveInterval::New(alloc(), interval->vreg(), 0);
     if (!postInterval->addRange(inputOf(reg.ins()), interval->end()))
         return false;
 
@@ -1353,17 +1353,17 @@ BacktrackingAllocator::computePriority(c
 {
     // The priority of an interval is its total length, so that longer lived
     // intervals will be processed before shorter ones (even if the longer ones
     // have a low spill weight). See processInterval().
     size_t lifetimeTotal = 0;
 
     for (size_t i = 0; i < interval->numRanges(); i++) {
         const LiveInterval::Range *range = interval->getRange(i);
-        lifetimeTotal += range->to.pos() - range->from.pos();
+        lifetimeTotal += range->to - range->from;
     }
 
     return lifetimeTotal;
 }
 
 size_t
 BacktrackingAllocator::computePriority(const VirtualRegisterGroup *group)
 {
@@ -1620,17 +1620,17 @@ BacktrackingAllocator::splitAtAllRegiste
         if (!addLiveInterval(newIntervals, vreg, spillInterval, from, to))
             return false;
         spillStart = to;
     }
 
     if (spillIntervalIsNew) {
         for (size_t i = 0; i < interval->numRanges(); i++) {
             const LiveInterval::Range *range = interval->getRange(i);
-            CodePosition from = range->from < spillStart ? spillStart : range->from;
+            CodePosition from = Max(range->from, spillStart);
             if (!spillInterval->addRange(from, range->to))
                 return false;
         }
     }
 
     for (UsePositionIterator iter(interval->usesBegin());
          iter != interval->usesEnd();
          iter++)
@@ -1713,17 +1713,17 @@ BacktrackingAllocator::splitAt(LiveInter
     bool spillIntervalIsNew = false;
     LiveInterval *spillInterval = interval->spillInterval();
     if (!spillInterval) {
         spillInterval = LiveInterval::New(alloc(), vreg, 0);
         spillIntervalIsNew = true;
 
         for (size_t i = 0; i < interval->numRanges(); i++) {
             const LiveInterval::Range *range = interval->getRange(i);
-            CodePosition from = range->from < spillStart ? spillStart : range->from;
+            CodePosition from = Max(range->from, spillStart);
             if (!spillInterval->addRange(from, range->to))
                 return false;
         }
     }
 
     LiveIntervalVector newIntervals;
 
     CodePosition lastRegisterUse;
--- a/js/src/jit/BacktrackingAllocator.h
+++ b/js/src/jit/BacktrackingAllocator.h
@@ -146,19 +146,19 @@ class BacktrackingAllocator
         {}
 
         AllocatedRange(LiveInterval *interval, const LiveInterval::Range *range)
           : interval(interval), range(range)
         {}
 
         static int compare(const AllocatedRange &v0, const AllocatedRange &v1) {
             // LiveInterval::Range includes 'from' but excludes 'to'.
-            if (v0.range->to.pos() <= v1.range->from.pos())
+            if (v0.range->to <= v1.range->from)
                 return -1;
-            if (v0.range->from.pos() >= v1.range->to.pos())
+            if (v0.range->from >= v1.range->to)
                 return 1;
             return 0;
         }
     };
 
     typedef SplayTree<AllocatedRange, AllocatedRange> AllocatedRangeSet;
 
     // Each physical register is associated with the set of ranges over which
--- a/js/src/jit/RegisterAllocator.h
+++ b/js/src/jit/RegisterAllocator.h
@@ -197,16 +197,21 @@ class CodePosition
     bool operator >(CodePosition other) const {
         return bits_ > other.bits_;
     }
 
     bool operator >=(CodePosition other) const {
         return bits_ >= other.bits_;
     }
 
+    uint32_t operator -(CodePosition other) const {
+        JS_ASSERT(bits_ >= other.bits_);
+        return bits_ - other.bits_;
+    }
+
     CodePosition previous() const {
         JS_ASSERT(*this != MIN);
         return CodePosition(bits_ - 1);
     }
     CodePosition next() const {
         JS_ASSERT(*this != MAX);
         return CodePosition(bits_ + 1);
     }