Bug 1112164 part 3 - Add {Float,}Register::Encoding to represent what can be decoded from the assembly. r=jandem
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Thu, 26 Feb 2015 12:18:21 +0100
changeset 231021 9a3fd2e8ec2e73d33d9eb057903ccb8d16bf783a
parent 231020 037b0e802178659daeb2dbd1ce1bf4990274b391
child 231022 660504e5426fa1e693525908c39827e01369765e
push id14145
push userkwierso@gmail.com
push dateFri, 27 Feb 2015 02:54:23 +0000
treeherderb2g-inbound@c4f764ed8795 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1112164
milestone39.0a1
Bug 1112164 part 3 - Add {Float,}Register::Encoding to represent what can be decoded from the assembly. r=jandem
js/src/jit/Disassembler.h
js/src/jit/RegisterSets.h
js/src/jit/Registers.h
js/src/jit/arm/Architecture-arm.h
js/src/jit/mips/Architecture-mips.h
js/src/jit/none/Architecture-none.h
js/src/jit/shared/Assembler-x86-shared.h
js/src/jit/x64/Architecture-x64.h
js/src/jit/x86/Architecture-x86.h
--- a/js/src/jit/Disassembler.h
+++ b/js/src/jit/Disassembler.h
@@ -12,45 +12,45 @@
 
 namespace js {
 namespace jit {
 
 namespace Disassembler {
 
 class ComplexAddress {
     int32_t disp_;
-    Register::Code base_ : 8;
-    Register::Code index_ : 8;
+    Register::Encoding base_ : 8;
+    Register::Encoding index_ : 8;
     int8_t scale_; // log2 encoding
     bool isPCRelative_;
 
   public:
     ComplexAddress()
       : disp_(0),
         base_(Registers::Invalid),
         index_(Registers::Invalid),
         scale_(0),
         isPCRelative_(false)
     {
         MOZ_ASSERT(*this == *this);
     }
 
-    ComplexAddress(int32_t disp, Register::Code base)
+    ComplexAddress(int32_t disp, Register::Encoding base)
       : disp_(disp),
         base_(base),
         index_(Registers::Invalid),
         scale_(0),
         isPCRelative_(false)
     {
         MOZ_ASSERT(*this == *this);
         MOZ_ASSERT(base != Registers::Invalid);
         MOZ_ASSERT(base_ == base);
     }
 
-    ComplexAddress(int32_t disp, Register::Code base, Register::Code index, int scale)
+    ComplexAddress(int32_t disp, Register::Encoding base, Register::Encoding index, int scale)
       : disp_(disp),
         base_(base),
         index_(index),
         scale_(scale),
         isPCRelative_(false)
     {
         MOZ_ASSERT(scale >= 0 && scale < 4);
         MOZ_ASSERT_IF(index == Registers::Invalid, scale == 0);
@@ -92,21 +92,21 @@ class ComplexAddress {
     bool isPCRelative() const {
         return isPCRelative_;
     }
 
     int32_t disp() const {
         return disp_;
     }
 
-    Register::Code base() const {
+    Register::Encoding base() const {
         return base_;
     }
 
-    Register::Code index() const {
+    Register::Encoding index() const {
         return index_;
     }
 
     uint32_t scale() const {
         return scale_;
     }
 
 #ifdef DEBUG
@@ -123,18 +123,18 @@ class OtherOperand {
         GPR,
         FPR,
     };
 
   private:
     Kind kind_;
     union {
         int32_t imm;
-        Register::Code gpr;
-        FloatRegister::Code fpr;
+        Register::Encoding gpr;
+        FloatRegister::Encoding fpr;
     } u_;
 
   public:
     OtherOperand()
       : kind_(Imm)
     {
         u_.imm = 0;
         MOZ_ASSERT(*this == *this);
@@ -142,45 +142,45 @@ class OtherOperand {
 
     explicit OtherOperand(int32_t imm)
       : kind_(Imm)
     {
         u_.imm = imm;
         MOZ_ASSERT(*this == *this);
     }
 
-    explicit OtherOperand(Register::Code gpr)
+    explicit OtherOperand(Register::Encoding gpr)
       : kind_(GPR)
     {
         u_.gpr = gpr;
         MOZ_ASSERT(*this == *this);
     }
 
-    explicit OtherOperand(FloatRegister::Code fpr)
+    explicit OtherOperand(FloatRegister::Encoding fpr)
       : kind_(FPR)
     {
         u_.fpr = fpr;
         MOZ_ASSERT(*this == *this);
     }
 
     Kind kind() const {
         return kind_;
     }
 
     int32_t imm() const {
         MOZ_ASSERT(kind_ == Imm);
         return u_.imm;
     }
 
-    Register::Code gpr() const {
+    Register::Encoding gpr() const {
         MOZ_ASSERT(kind_ == GPR);
         return u_.gpr;
     }
 
-    FloatRegister::Code fpr() const {
+    FloatRegister::Encoding fpr() const {
         MOZ_ASSERT(kind_ == FPR);
         return u_.fpr;
     }
 
 #ifdef DEBUG
     bool operator==(const OtherOperand &other) const;
     bool operator!=(const OtherOperand &other) const;
 #endif
--- a/js/src/jit/RegisterSets.h
+++ b/js/src/jit/RegisterSets.h
@@ -848,18 +848,18 @@ class AnyRegisterIterator
 class ABIArg
 {
   public:
     enum Kind { GPR, FPU, Stack };
 
   private:
     Kind kind_;
     union {
-        Registers::Code gpr_;
-        FloatRegisters::Code fpu_;
+        Register::Code gpr_;
+        FloatRegister::Code fpu_;
         uint32_t offset_;
     } u;
 
   public:
     ABIArg() : kind_(Kind(-1)) { u.offset_ = -1; }
     explicit ABIArg(Register gpr) : kind_(GPR) { u.gpr_ = gpr.code(); }
     explicit ABIArg(FloatRegister fpu) : kind_(FPU) { u.fpu_ = fpu.code(); }
     explicit ABIArg(uint32_t offset) : kind_(Stack) { u.offset_ = offset; }
--- a/js/src/jit/Registers.h
+++ b/js/src/jit/Registers.h
@@ -24,26 +24,27 @@
 # error "Unknown architecture!"
 #endif
 
 namespace js {
 namespace jit {
 
 struct Register {
     typedef Registers Codes;
+    typedef Codes::Encoding Encoding;
     typedef Codes::Code Code;
     typedef Codes::SetType SetType;
     Code code_;
     static Register FromCode(uint32_t i) {
         MOZ_ASSERT(i < Registers::Total);
-        Register r = { (Registers::Code)i };
+        Register r = { Code(i) };
         return r;
     }
     static Register FromName(const char *name) {
-        Registers::Code code = Registers::FromName(name);
+        Code code = Registers::FromName(name);
         Register r = { code };
         return r;
     }
     Code code() const {
         MOZ_ASSERT((uint32_t)code_ < Registers::Total);
         return code_;
     }
     const char *name() const {
--- a/js/src/jit/arm/Architecture-arm.h
+++ b/js/src/jit/arm/Architecture-arm.h
@@ -70,16 +70,17 @@ class Registers
         sp = r13,
         r14,
         lr = r14,
         r15,
         pc = r15,
         invalid_reg
     };
     typedef RegisterID Code;
+    typedef RegisterID Encoding;
 
     static const char *GetName(Code code) {
         static const char * const Names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
                                               "r8", "r9", "r10", "r11", "r12", "sp", "r14", "pc"};
         return Names[code];
     }
     static const char *GetName(uint32_t i) {
         MOZ_ASSERT(i < Total);
@@ -227,16 +228,17 @@ class FloatRegisters
         d28,
         d29,
         d30,
         d31,
         invalid_freg
     };
 
     typedef FPRegisterID Code;
+    typedef FPRegisterID Encoding;
 
 
     static const char *GetDoubleName(Code code) {
         static const char * const Names[] = { "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
                                               "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15",
                                               "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23",
                                               "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31"};
         return Names[code];
@@ -326,16 +328,17 @@ class VFPRegister
         Single = 0x0,
         Double = 0x1,
         UInt   = 0x2,
         Int    = 0x3
     };
 
     typedef FloatRegisters Codes;
     typedef Codes::Code Code;
+    typedef Codes::Encoding Encoding;
 
   protected:
     RegType kind : 2;
     // ARM doesn't have more than 32 registers. Don't take more bits than we'll
     // need. Presently, we don't have plans to address the upper and lower
     // halves of the double registers seprately, so 5 bits should suffice. If we
     // do decide to address them seprately (vmov, I'm looking at you), we will
     // likely specify it as a separate field.
--- a/js/src/jit/mips/Architecture-mips.h
+++ b/js/src/jit/mips/Architecture-mips.h
@@ -108,16 +108,17 @@ class Registers
         k1 = r27,
         gp = r28,
         sp = r29,
         fp = r30,
         ra = r31,
         invalid_reg
     };
     typedef RegisterID Code;
+    typedef RegisterID Encoding;
 
     static const char *GetName(Code code) {
         static const char * const Names[] = { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
                                               "t0",   "t1", "t2", "t3", "t4", "t5", "t6", "t7",
                                               "s0",   "s1", "s2", "s3", "s4", "s5", "s6", "s7",
                                               "t8",   "t9", "k0", "k1", "gp", "sp", "fp", "ra"};
         return Names[code];
     }
@@ -259,16 +260,17 @@ class FloatRegisters
         f27,
         f28,
         f29,
         f30,
         f31,
         invalid_freg
     };
     typedef FPRegisterID Code;
+    typedef FPRegisterID Encoding;
 
     static const char *GetName(Code code) {
         static const char * const Names[] = { "f0", "f1", "f2", "f3",  "f4", "f5",  "f6", "f7",
                                               "f8", "f9",  "f10", "f11", "f12", "f13",
                                               "f14", "f15", "f16", "f17", "f18", "f19",
                                               "f20", "f21", "f22", "f23", "f24", "f25",
                                               "f26", "f27", "f28", "f29", "f30", "f31"};
         return Names[code];
@@ -347,16 +349,17 @@ class FloatRegister
   public:
     enum RegType {
         Single = 0x0,
         Double = 0x1,
     };
 
     typedef FloatRegisters Codes;
     typedef Codes::Code Code;
+    typedef Codes::Encoding Encoding;
 
     uint32_t code_ : 6;
   protected:
     RegType kind_ : 1;
 
   public:
     MOZ_CONSTEXPR FloatRegister(uint32_t code, RegType kind = Double)
       : code_ (Code(code)), kind_(kind)
--- a/js/src/jit/none/Architecture-none.h
+++ b/js/src/jit/none/Architecture-none.h
@@ -21,16 +21,17 @@ static const uint32_t AsmJSStackAlignmen
 class Registers
 {
   public:
     enum RegisterID {
         r0 = 0,
         invalid_reg
     };
     typedef RegisterID Code;
+    typedef RegisterID Encoding;
     typedef uint8_t SetType;
 
     static uint32_t SetSize(SetType) { MOZ_CRASH(); }
     static uint32_t FirstBit(SetType) { MOZ_CRASH(); }
     static uint32_t LastBit(SetType) { MOZ_CRASH(); }
     static const char *GetName(Code) { MOZ_CRASH(); }
     static Code FromName(const char *) { MOZ_CRASH(); }
 
@@ -55,16 +56,17 @@ typedef uint8_t PackedRegisterMask;
 class FloatRegisters
 {
   public:
     enum FPRegisterID {
         f0 = 0,
         invalid_reg
     };
     typedef FPRegisterID  Code;
+    typedef FPRegisterID Encoding;
     typedef uint32_t SetType;
 
     static const char *GetName(Code) { MOZ_CRASH(); }
     static Code FromName(const char *) { MOZ_CRASH(); }
 
     static const Code Invalid = invalid_reg;
     static const uint32_t Total = 0;
     static const uint32_t TotalPhys = 0;
@@ -79,16 +81,17 @@ class FloatRegisters
 
 template <typename T>
 class TypedRegisterSet;
 
 struct FloatRegister
 {
     typedef FloatRegisters Codes;
     typedef Codes::Code Code;
+    typedef Codes::Encoding Encoding;
     typedef Codes::SetType SetType;
 
     Code _;
 
     static uint32_t FirstBit(SetType) { MOZ_CRASH(); }
     static uint32_t LastBit(SetType) { MOZ_CRASH(); }
     static FloatRegister FromCode(uint32_t) { MOZ_CRASH(); }
     Code code() const { MOZ_CRASH(); }
--- a/js/src/jit/shared/Assembler-x86-shared.h
+++ b/js/src/jit/shared/Assembler-x86-shared.h
@@ -83,35 +83,35 @@ class Operand
     BaseIndex toBaseIndex() const {
         MOZ_ASSERT(kind() == MEM_SCALE);
         return BaseIndex(Register::FromCode(base()), Register::FromCode(index()), scale(), disp());
     }
 
     Kind kind() const {
         return kind_;
     }
-    Registers::Code reg() const {
+    Register::Code reg() const {
         MOZ_ASSERT(kind() == REG);
-        return (Registers::Code)base_;
+        return Register::Code(base_);
     }
-    Registers::Code base() const {
+    Register::Code base() const {
         MOZ_ASSERT(kind() == MEM_REG_DISP || kind() == MEM_SCALE);
-        return (Registers::Code)base_;
+        return Register::Code(base_);
     }
-    Registers::Code index() const {
+    Register::Code index() const {
         MOZ_ASSERT(kind() == MEM_SCALE);
-        return (Registers::Code)index_;
+        return Register::Code(index_);
     }
     Scale scale() const {
         MOZ_ASSERT(kind() == MEM_SCALE);
         return scale_;
     }
-    FloatRegisters::Code fpu() const {
+    FloatRegister::Code fpu() const {
         MOZ_ASSERT(kind() == FPREG);
-        return (FloatRegisters::Code)base_;
+        return FloatRegister::Code(base_);
     }
     int32_t disp() const {
         MOZ_ASSERT(kind() == MEM_REG_DISP || kind() == MEM_SCALE);
         return disp_;
     }
     void *address() const {
         MOZ_ASSERT(kind() == MEM_ADDRESS32);
         return reinterpret_cast<void *>(disp_);
--- a/js/src/jit/x64/Architecture-x64.h
+++ b/js/src/jit/x64/Architecture-x64.h
@@ -22,16 +22,17 @@ static const uint32_t ION_FRAME_SLACK_SI
 static const uint32_t ShadowStackSpace = 32;
 #else
 static const uint32_t ShadowStackSpace = 0;
 #endif
 
 class Registers {
   public:
     typedef X86Encoding::RegisterID Code;
+    typedef X86Encoding::RegisterID Encoding;
     typedef uint32_t SetType;
     static uint32_t SetSize(SetType x) {
         static_assert(sizeof(SetType) == 4, "SetType must be 32 bits");
         return mozilla::CountPopulation32(x);
     }
     static uint32_t FirstBit(SetType x) {
         return mozilla::CountTrailingZeroes32(x);
     }
@@ -121,16 +122,17 @@ class Registers {
 };
 
 // Smallest integer type that can hold a register bitmask.
 typedef uint16_t PackedRegisterMask;
 
 class FloatRegisters {
   public:
     typedef X86Encoding::XMMRegisterID Code;
+    typedef X86Encoding::XMMRegisterID Encoding;
     typedef uint32_t SetType;
     static const char *GetName(Code code) {
         return X86Encoding::XMMRegName(code);
     }
 
     static Code FromName(const char *name) {
         for (size_t i = 0; i < Total; i++) {
             if (strcmp(GetName(Code(i)), name) == 0)
@@ -171,16 +173,17 @@ class FloatRegisters {
 };
 
 template <typename T>
 class TypedRegisterSet;
 
 struct FloatRegister {
     typedef FloatRegisters Codes;
     typedef Codes::Code Code;
+    typedef Codes::Encoding Encoding;
     typedef Codes::SetType SetType;
     static uint32_t SetSize(SetType x) {
         static_assert(sizeof(SetType) == 4, "SetType must be 32 bits");
         return mozilla::CountPopulation32(x);
     }
     static uint32_t FirstBit(SetType x) {
         return mozilla::CountTrailingZeroes32(x);
     }
--- a/js/src/jit/x86/Architecture-x86.h
+++ b/js/src/jit/x86/Architecture-x86.h
@@ -31,16 +31,17 @@ static const int32_t NUNBOX32_PAYLOAD_OF
 ////
 
 // Size of each bailout table entry. On x86 this is a 5-byte relative call.
 static const uint32_t BAILOUT_TABLE_ENTRY_SIZE    = 5;
 
 class Registers {
   public:
     typedef X86Encoding::RegisterID Code;
+    typedef X86Encoding::RegisterID Encoding;
     typedef uint8_t SetType;
     static uint32_t SetSize(SetType x) {
         static_assert(sizeof(SetType) == 1, "SetType must be 8 bits");
         return mozilla::CountPopulation32(x);
     }
     static uint32_t FirstBit(SetType x) {
         return mozilla::CountTrailingZeroes32(x);
     }
@@ -110,16 +111,17 @@ class Registers {
 };
 
 // Smallest integer type that can hold a register bitmask.
 typedef uint8_t PackedRegisterMask;
 
 class FloatRegisters {
   public:
     typedef X86Encoding::XMMRegisterID Code;
+    typedef X86Encoding::XMMRegisterID Encoding;
     typedef uint32_t SetType;
     static const char *GetName(Code code) {
         return X86Encoding::XMMRegName(code);
     }
 
     static Code FromName(const char *name) {
         for (size_t i = 0; i < Total; i++) {
             if (strcmp(GetName(Code(i)), name) == 0)
@@ -148,16 +150,17 @@ class FloatRegisters {
 };
 
 template <typename T>
 class TypedRegisterSet;
 
 struct FloatRegister {
     typedef FloatRegisters Codes;
     typedef Codes::Code Code;
+    typedef Codes::Encoding Encoding;
     typedef Codes::SetType SetType;
     static uint32_t SetSize(SetType x) {
         static_assert(sizeof(SetType) == 4, "SetType must be 32 bits");
         return mozilla::CountPopulation32(x);
     }
     static uint32_t FirstBit(SetType x) {
         return mozilla::CountTrailingZeroes32(x);
     }