Bug 1608791 - Harden the Rabaldr register wrappers. r=rhunt
☠☠ backed out by 06590dc45a94 ☠ ☠
authorLars T Hansen <lhansen@mozilla.com>
Tue, 14 Jan 2020 18:51:52 +0000
changeset 510237 d2457f7efd8a35a93816cbc6b47796c8cbc3b625
parent 510236 a7654938178351feeb8ec4e97994ffd9e4192214
child 510238 4cb7eb44640213b7f290bf4de4cb75e381ba1398
push id37015
push usercbrindusan@mozilla.com
push dateWed, 15 Jan 2020 04:16:28 +0000
treeherdermozilla-central@2ee6c4c25052 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhunt
bugs1608791
milestone74.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 1608791 - Harden the Rabaldr register wrappers. r=rhunt By cleaning up the register set APIs very slightly we can simplify the wrappers and make space for meaningful assertions. Differential Revision: https://phabricator.services.mozilla.com/D59673
js/src/jit/arm/Architecture-arm.h
js/src/jit/arm/Assembler-arm.cpp
js/src/jit/arm64/Architecture-arm64.h
js/src/jit/mips32/Architecture-mips32.h
js/src/wasm/WasmBaselineCompile.cpp
--- a/js/src/jit/arm/Architecture-arm.h
+++ b/js/src/jit/arm/Architecture-arm.h
@@ -381,18 +381,21 @@ class VFPRegister {
   bool isDouble() const { return kind == Double; }
   bool isSimd128() const { return false; }
   bool isFloat() const { return (kind == Double) || (kind == Single); }
   bool isInt() const { return (kind == UInt) || (kind == Int); }
   bool isSInt() const { return kind == Int; }
   bool isUInt() const { return kind == UInt; }
   bool equiv(const VFPRegister& other) const { return other.kind == kind; }
   size_t size() const { return (kind == Double) ? 8 : 4; }
-  bool isInvalid() const;
-  bool isMissing() const;
+  bool isInvalid() const { return _isInvalid; }
+  bool isMissing() const {
+    MOZ_ASSERT(!_isInvalid);
+    return _isMissing;
+  }
 
   VFPRegister doubleOverlay(unsigned int which = 0) const;
   VFPRegister singleOverlay(unsigned int which = 0) const;
   VFPRegister sintOverlay(unsigned int which = 0) const;
   VFPRegister uintOverlay(unsigned int which = 0) const;
 
   VFPRegister asSingle() const { return singleOverlay(); }
   VFPRegister asDouble() const { return doubleOverlay(); }
--- a/js/src/jit/arm/Assembler-arm.cpp
+++ b/js/src/jit/arm/Assembler-arm.cpp
@@ -1109,23 +1109,16 @@ VFPRegister VFPRegister::uintOverlay(uns
     MOZ_ASSERT(code_ < 16);
     MOZ_ASSERT(which < 2);
     return VFPRegister((code_ << 1) + which, UInt);
   }
   MOZ_ASSERT(which == 0);
   return VFPRegister(code_, UInt);
 }
 
-bool VFPRegister::isInvalid() const { return _isInvalid; }
-
-bool VFPRegister::isMissing() const {
-  MOZ_ASSERT(!_isInvalid);
-  return _isMissing;
-}
-
 bool Assembler::oom() const {
   return AssemblerShared::oom() || m_buffer.oom() || jumpRelocations_.oom() ||
          dataRelocations_.oom();
 }
 
 // Size of the instruction stream, in bytes. Including pools. This function
 // expects all pools that need to be placed have been placed. If they haven't
 // then we need to go an flush the pools :(
--- a/js/src/jit/arm64/Architecture-arm64.h
+++ b/js/src/jit/arm64/Architecture-arm64.h
@@ -489,16 +489,17 @@ struct FloatRegister {
   }
   SetType alignedOrDominatedAliasedSet() const {
     return Codes::SpreadCoefficient << code_;
   }
 
   bool isSingle() const { return k_ == FloatRegisters::Single; }
   bool isDouble() const { return k_ == FloatRegisters::Double; }
   bool isSimd128() const { return false; }
+  bool isInvalid() const { return code_ == FloatRegisters::Code(-1); }
 
   FloatRegister asSingle() const {
     return FloatRegister(code_, FloatRegisters::Single);
   }
   FloatRegister asDouble() const {
     return FloatRegister(code_, FloatRegisters::Double);
   }
   FloatRegister asSimd128() const { MOZ_CRASH(); }
--- a/js/src/jit/mips32/Architecture-mips32.h
+++ b/js/src/jit/mips32/Architecture-mips32.h
@@ -132,16 +132,17 @@ class FloatRegister : public FloatRegist
   size_t size() const { return (kind_ == Double) ? 8 : 4; }
   size_t pushSize() const { return size(); }
   bool isInvalid() const { return code_ == FloatRegisters::invalid_freg; }
 
   bool isNotOdd() const { return !isInvalid() && ((code_ & 1) == 0); }
 
   bool isSingle() const { return kind_ == Single; }
   bool isDouble() const { return kind_ == Double; }
+  bool isInvalid() const { return code_ == FloatRegisters::invalid_freg; }
 
   FloatRegister doubleOverlay() const;
   FloatRegister singleOverlay() const;
 
   FloatRegister asSingle() const { return singleOverlay(); }
   FloatRegister asDouble() const { return doubleOverlay(); }
   FloatRegister asSimd128() const { MOZ_CRASH("NYI"); }
 
--- a/js/src/wasm/WasmBaselineCompile.cpp
+++ b/js/src/wasm/WasmBaselineCompile.cpp
@@ -294,52 +294,60 @@ struct RegTypeOf<MIRType::Double> {
 };
 
 // The strongly typed register wrappers are especially useful to distinguish
 // float registers from double registers, but they also clearly distinguish
 // 32-bit registers from 64-bit register pairs on 32-bit systems.
 
 struct RegI32 : public Register {
   RegI32() : Register(Register::Invalid()) {}
-  explicit RegI32(Register reg) : Register(reg) {}
-  bool isValid() const { return *this != Invalid(); }
-  bool isInvalid() const { return !isValid(); }
-  static RegI32 Invalid() { return RegI32(Register::Invalid()); }
+  explicit RegI32(Register reg) : Register(reg) {
+    MOZ_ASSERT(reg != Invalid());
+  }
+  bool isInvalid() const { return *this == Invalid(); }
+  bool isValid() const { return !isInvalid(); }
+  static RegI32 Invalid() { return RegI32(); }
 };
 
 struct RegI64 : public Register64 {
   RegI64() : Register64(Register64::Invalid()) {}
-  explicit RegI64(Register64 reg) : Register64(reg) {}
-  bool isValid() const { return *this != Invalid(); }
-  bool isInvalid() const { return !isValid(); }
-  static RegI64 Invalid() { return RegI64(Register64::Invalid()); }
+  explicit RegI64(Register64 reg) : Register64(reg) {
+    MOZ_ASSERT(reg != Invalid());
+  }
+  bool isInvalid() const { return *this == Invalid(); }
+  bool isValid() const { return !isInvalid(); }
+  static RegI64 Invalid() { return RegI64(); }
 };
 
 struct RegPtr : public Register {
   RegPtr() : Register(Register::Invalid()) {}
-  explicit RegPtr(Register reg) : Register(reg) {}
-  bool isValid() const { return *this != Invalid(); }
-  bool isInvalid() const { return !isValid(); }
-  static RegPtr Invalid() { return RegPtr(Register::Invalid()); }
+  explicit RegPtr(Register reg) : Register(reg) {
+    MOZ_ASSERT(reg != Invalid());
+  }
+  bool isInvalid() const { return *this == Invalid(); }
+  bool isValid() const { return !isInvalid(); }
+  static RegPtr Invalid() { return RegPtr(); }
 };
 
 struct RegF32 : public FloatRegister {
   RegF32() : FloatRegister() {}
-  explicit RegF32(FloatRegister reg) : FloatRegister(reg) {}
-  bool isValid() const { return *this != Invalid(); }
-  bool isInvalid() const { return !isValid(); }
-  static RegF32 Invalid() { return RegF32(InvalidFloatReg); }
+  explicit RegF32(FloatRegister reg) : FloatRegister(reg) {
+    MOZ_ASSERT(isSingle());
+  }
+  bool isValid() const { return !isInvalid(); }
+  static RegF32 Invalid() { return RegF32(); }
 };
 
 struct RegF64 : public FloatRegister {
   RegF64() : FloatRegister() {}
-  explicit RegF64(FloatRegister reg) : FloatRegister(reg) {}
-  bool isValid() const { return *this != Invalid(); }
-  bool isInvalid() const { return !isValid(); }
-  static RegF64 Invalid() { return RegF64(InvalidFloatReg); }
+  explicit RegF64(FloatRegister reg) : FloatRegister(reg) {
+    MOZ_ASSERT(isDouble());
+  }
+  bool isValid() const { return !isInvalid(); }
+  static RegF64 Invalid() { return RegF64(); }
 };
 
 struct AnyReg {
   union {
     RegI32 i32_;
     RegI64 i64_;
     RegPtr ref_;
     RegF32 f32_;