Bug 1229396: Templatize Float/Double/SimdData in MacroAssembler-x86-shared.h; r=jandem
authorBenjamin Bouvier <benj@benj.me>
Tue, 01 Dec 2015 19:24:49 +0100
changeset 309682 54c0681d35b05e2c333d22667b7490fdb24711cb
parent 309681 b7a7fcf24c4904f2c687eebfba067685a0e3699a
child 309683 904fe1ab68b9f538346b0f83d1d546f440a8d8d1
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1229396
milestone45.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 1229396: Templatize Float/Double/SimdData in MacroAssembler-x86-shared.h; r=jandem
js/src/jit/x86-shared/MacroAssembler-x86-shared.h
--- a/js/src/jit/x86-shared/MacroAssembler-x86-shared.h
+++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared.h
@@ -47,56 +47,45 @@ class MacroAssemblerX86Shared : public A
 
   public:
     typedef Vector<CodeOffset, 0, SystemAllocPolicy> UsesVector;
 
   protected:
 
     // For Double, Float and SimdData, make the move ctors explicit so that MSVC
     // knows what to use instead of copying these data structures.
-    struct Double {
-        typedef double Pod;
-        double value;
+    template<class T>
+    struct Constant {
+        typedef T Pod;
+
+        T value;
         UsesVector uses;
 
-        explicit Double(double value) : value(value) {}
-        Double(Double&& other) : value(other.value), uses(mozilla::Move(other.uses)) {}
-        explicit Double(const Double&) = delete;
+        explicit Constant(const T& value) : value(value) {}
+        Constant(Constant<T>&& other) : value(other.value), uses(mozilla::Move(other.uses)) {}
+        explicit Constant(const Constant<T>&) = delete;
     };
 
-    // These use SystemAllocPolicy since asm.js releases memory after each
+    // Containers use SystemAllocPolicy since asm.js releases memory after each
     // function is compiled, and these need to live until after all functions
     // are compiled.
+    using Double = Constant<double>;
     Vector<Double, 0, SystemAllocPolicy> doubles_;
     typedef HashMap<double, size_t, DefaultHasher<double>, SystemAllocPolicy> DoubleMap;
     DoubleMap doubleMap_;
 
-    struct Float {
-        typedef float Pod;
-        float value;
-        UsesVector uses;
-
-        explicit Float(float value) : value(value) {}
-        Float(Float&& other) : value(other.value), uses(mozilla::Move(other.uses)) {}
-        explicit Float(const Float&) = delete;
-    };
-
+    using Float = Constant<float>;
     Vector<Float, 0, SystemAllocPolicy> floats_;
     typedef HashMap<float, size_t, DefaultHasher<float>, SystemAllocPolicy> FloatMap;
     FloatMap floatMap_;
 
-    struct SimdData {
-        typedef SimdConstant Pod;
-        SimdConstant value;
-        UsesVector uses;
-
-        explicit SimdData(const SimdConstant& v) : value(v) {}
-        SimdData(SimdData&& other) : value(other.value), uses(mozilla::Move(other.uses)) {}
+    struct SimdData : public Constant<SimdConstant> {
+        explicit SimdData(SimdConstant d) : Constant<SimdConstant>(d) {}
+        SimdData(SimdData&& d) : Constant<SimdConstant>(mozilla::Move(d)) {}
         explicit SimdData(const SimdData&) = delete;
-
         SimdConstant::Type type() const { return value.type(); }
     };
 
     Vector<SimdData, 0, SystemAllocPolicy> simds_;
     typedef HashMap<SimdConstant, size_t, SimdConstant, SystemAllocPolicy> SimdMap;
     SimdMap simdMap_;
 
     template<class T, class Map>