Bug 1011045 - SpiderMonkey: Shrink and simplify AnyRegister r=jandem
authorDan Gohman <sunfish@mozilla.com>
Thu, 15 May 2014 09:58:03 -0700
changeset 183289 9a2447888dae00eacc34e6990b5fcd607d859151
parent 183288 a0d2fc4bb0534eed6e8678b3963c1a0282acc0e5
child 183290 122366d4eeb843f789dd68232d8f504713d6ce0c
push id43521
push userdgohman@mozilla.com
push dateThu, 15 May 2014 16:57:57 +0000
treeherdermozilla-inbound@122366d4eeb8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1011045
milestone32.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 1011045 - SpiderMonkey: Shrink and simplify AnyRegister r=jandem
js/src/jit/RegisterSets.h
--- a/js/src/jit/RegisterSets.h
+++ b/js/src/jit/RegisterSets.h
@@ -17,74 +17,56 @@ namespace js {
 namespace jit {
 
 struct AnyRegister {
     typedef uint32_t Code;
 
     static const uint32_t Total = Registers::Total + FloatRegisters::Total;
     static const uint32_t Invalid = UINT_MAX;
 
-    union {
-        Registers::Code gpr_;
-        FloatRegisters::Code fpu_;
-    };
-    bool isFloat_;
+  private:
+    Code code_;
 
+  public:
     AnyRegister()
     { }
     explicit AnyRegister(Register gpr) {
-        gpr_ = gpr.code();
-        isFloat_ = false;
+        code_ = gpr.code();
     }
     explicit AnyRegister(FloatRegister fpu) {
-        fpu_ = fpu.code();
-        isFloat_ = true;
+        code_ = fpu.code() + Registers::Total;
     }
     static AnyRegister FromCode(uint32_t i) {
         JS_ASSERT(i < Total);
         AnyRegister r;
-        if (i < Registers::Total) {
-            r.gpr_ = Register::Code(i);
-            r.isFloat_ = false;
-        } else {
-            r.fpu_ = FloatRegister::Code(i - Registers::Total);
-            r.isFloat_ = true;
-        }
+        r.code_ = i;
         return r;
     }
     bool isFloat() const {
-        return isFloat_;
+        return code_ >= Registers::Total;
     }
     Register gpr() const {
         JS_ASSERT(!isFloat());
-        return Register::FromCode(gpr_);
+        return Register::FromCode(code_);
     }
     FloatRegister fpu() const {
         JS_ASSERT(isFloat());
-        return FloatRegister::FromCode(fpu_);
+        return FloatRegister::FromCode(code_ - Registers::Total);
     }
     bool operator ==(const AnyRegister &other) const {
-        return isFloat()
-               ? (other.isFloat() && fpu_ == other.fpu_)
-               : (!other.isFloat() && gpr_ == other.gpr_);
+        return code_ == other.code_;
     }
     bool operator !=(const AnyRegister &other) const {
-        return isFloat()
-               ? (!other.isFloat() || fpu_ != other.fpu_)
-               : (other.isFloat() || gpr_ != other.gpr_);
+        return code_ != other.code_;
     }
     const char *name() const {
-        return isFloat()
-               ? FloatRegister::FromCode(fpu_).name()
-               : Register::FromCode(gpr_).name();
+        return isFloat() ? fpu().name() : gpr().name();
     }
     const Code code() const {
-        return isFloat()
-               ? fpu_ + Registers::Total
-               : gpr_;
+        return code_;
     }
     bool volatile_() const {
         return isFloat() ? fpu().volatile_() : gpr().volatile_();
     }
 };
 
 // Registers to hold a boxed value. Uses one register on 64 bit
 // platforms, two registers on 32 bit platforms.