Bug 1302401 - Revert: "With move semantics added to the language and the standard library updated with move constructors added for many types it is now interesting to take an argument directly by value, instead of by const-reference, and then copy. This check allows the compiler to take care of choosing the best way to construct the copy." draft
authorSylvestre Ledru <sledru@mozilla.com>
Wed, 14 Sep 2016 16:15:34 +0200
changeset 413624 30fe3411d82421b4a8a3970222978c2967e89dcd
parent 413623 d4fdfbe4c4a55919eaa5049c375917ae7a0d4424
child 413625 2cb43ce2d0b47bb8507bd309b2eb8d8a3bc161ab
push id29456
push usersledru@mozilla.com
push dateWed, 14 Sep 2016 14:17:25 +0000
bugs1302401, 0
milestone51.0a1
Bug 1302401 - Revert: "With move semantics added to the language and the standard library updated with move constructors added for many types it is now interesting to take an argument directly by value, instead of by const-reference, and then copy. This check allows the compiler to take care of choosing the best way to construct the copy." Caused: 06:24:19 INFO - /builds/slave/try-and-api-15-000000000000000/build/src/js/src/jit/RegisterSets.h:602:85: error: call to non-constexpr function 'typename std::__ndk1::remove_reference<_Tp>::type&& std::__ndk1::move(_Tp&&) [with _Tp = js::jit::RegisterSet&; typename std::__ndk1::remove_reference<_Tp>::type = js::jit::RegisterSet]' on Android 4.0 MozReview-Commit-ID: FJxnyvhYAwm
js/src/ds/OrderedHashTable.h
js/src/frontend/ParseNode.h
js/src/gc/Barrier.h
js/src/gc/GCRuntime.h
js/src/jit/Disassembler.h
js/src/jit/LIR.h
js/src/jit/MIR.h
js/src/jit/RegisterSets.h
js/src/jit/shared/Assembler-shared.h
js/src/jit/x86-shared/MacroAssembler-x86-shared.h
js/src/jsapi.h
--- a/js/src/ds/OrderedHashTable.h
+++ b/js/src/ds/OrderedHashTable.h
@@ -30,18 +30,16 @@
  * See the comment about "Hash policy" in HashTable.h for general features that
  * hash policy classes must provide. Hash policies for OrderedHashMaps and Sets
  * must additionally provide a distinguished "empty" key value and the
  * following static member functions:
  *     bool isEmpty(const Key&);
  *     void makeEmpty(Key*);
  */
 
-#include <utility>
-
 #include "mozilla/Move.h"
 
 using mozilla::Forward;
 using mozilla::Move;
 
 namespace js {
 
 namespace detail {
@@ -701,17 +699,17 @@ class OrderedHashMap
             MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited");
             const_cast<Key&>(key) = Move(rhs.key);
             value = Move(rhs.value);
         }
 
       public:
         Entry() : key(), value() {}
         template <typename V>
-        Entry(Key  k, V&& v) : key(std::move(k)), value(Forward<V>(v)) {}
+        Entry(const Key& k, V&& v) : key(k), value(Forward<V>(v)) {}
         Entry(Entry&& rhs) : key(Move(rhs.key)), value(Move(rhs.value)) {}
 
         const Key key;
         Value value;
 
         static size_t offsetOfKey() {
             return offsetof(Entry, key);
         }
--- a/js/src/frontend/ParseNode.h
+++ b/js/src/frontend/ParseNode.h
@@ -2,18 +2,16 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef frontend_ParseNode_h
 #define frontend_ParseNode_h
 
-#include <utility>
-
 #include "mozilla/Attributes.h"
 
 #include "builtin/ModuleObject.h"
 #include "frontend/TokenStream.h"
 
 namespace js {
 namespace frontend {
 
@@ -457,22 +455,22 @@ class ParseNode
         pn_parens(false),
         pn_pos(0, 0),
         pn_next(nullptr)
     {
         MOZ_ASSERT(kind < PNK_LIMIT);
         memset(&pn_u, 0, sizeof pn_u);
     }
 
-    ParseNode(ParseNodeKind kind, JSOp op, ParseNodeArity arity, TokenPos  pos)
+    ParseNode(ParseNodeKind kind, JSOp op, ParseNodeArity arity, const TokenPos& pos)
       : pn_type(kind),
         pn_op(op),
         pn_arity(arity),
         pn_parens(false),
-        pn_pos(std::move(pos)),
+        pn_pos(pos),
         pn_next(nullptr)
     {
         MOZ_ASSERT(kind < PNK_LIMIT);
         memset(&pn_u, 0, sizeof pn_u);
     }
 
     JSOp getOp() const                     { return JSOp(pn_op); }
     void setOp(JSOp op)                    { pn_op = op; }
--- a/js/src/gc/Barrier.h
+++ b/js/src/gc/Barrier.h
@@ -2,18 +2,16 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef gc_Barrier_h
 #define gc_Barrier_h
 
-#include <utility>
-
 #include "NamespaceImports.h"
 
 #include "gc/Heap.h"
 #include "gc/StoreBuffer.h"
 #include "js/HeapAPI.h"
 #include "js/Id.h"
 #include "js/RootingAPI.h"
 #include "js/Value.h"
@@ -511,17 +509,17 @@ class HeapPtr : public WriteBarrieredBas
     }
 
     /*
      * For HeapPtr, move semantics are equivalent to copy semantics. In
      * C++, a copy constructor taking const-ref is the way to get a single
      * function that will be used for both lvalue and rvalue copies, so we can
      * simply omit the rvalue variant.
      */
-    MOZ_IMPLICIT HeapPtr(HeapPtr<T>  const &v) : WriteBarrieredBase<T>(std::move(v)) {
+    MOZ_IMPLICIT HeapPtr(const HeapPtr<T>& v) : WriteBarrieredBase<T>(v) {
         this->post(JS::GCPolicy<T>::initial(), this->value);
     }
 
     ~HeapPtr() {
         this->pre();
         this->post(this->value, JS::GCPolicy<T>::initial());
     }
 
--- a/js/src/gc/GCRuntime.h
+++ b/js/src/gc/GCRuntime.h
@@ -2,18 +2,16 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef gc_GCRuntime_h
 #define gc_GCRuntime_h
 
-#include <utility>
-
 #include "mozilla/Atomics.h"
 #include "mozilla/EnumSet.h"
 
 #include "jsfriendapi.h"
 #include "jsgc.h"
 
 #include "gc/Heap.h"
 #include "gc/Nursery.h"
@@ -558,18 +556,18 @@ using CallbackVector = Vector<Callback<F
 
 template <typename T, typename Iter0, typename Iter1>
 class ChainedIter
 {
     Iter0 iter0_;
     Iter1 iter1_;
 
   public:
-    ChainedIter(Iter0  iter0, Iter1  iter1)
-      : iter0_(std::move(iter0)), iter1_(std::move(iter1))
+    ChainedIter(const Iter0& iter0, const Iter1& iter1)
+      : iter0_(iter0), iter1_(iter1)
     {}
 
     bool done() const { return iter0_.done() && iter1_.done(); }
     void next() {
         MOZ_ASSERT(!done());
         if (!iter0_.done()) {
             iter0_.next();
         } else {
--- a/js/src/jit/Disassembler.h
+++ b/js/src/jit/Disassembler.h
@@ -2,18 +2,16 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jit_Disassembler_h
 #define jit_Disassembler_h
 
-#include <utility>
-
 #include "jit/MacroAssembler.h"
 #include "jit/Registers.h"
 
 namespace js {
 namespace jit {
 
 namespace Disassembler {
 
@@ -217,21 +215,21 @@ class HeapAccess {
   public:
     HeapAccess()
       : kind_(Unknown),
         size_(0)
     {
         MOZ_ASSERT(*this == *this);
     }
 
-    HeapAccess(Kind kind, size_t size, ComplexAddress  address, OtherOperand  otherOperand)
+    HeapAccess(Kind kind, size_t size, const ComplexAddress& address, const OtherOperand& otherOperand)
       : kind_(kind),
         size_(size),
-        address_(std::move(address)),
-        otherOperand_(std::move(otherOperand))
+        address_(address),
+        otherOperand_(otherOperand)
     {
         MOZ_ASSERT(kind != Unknown);
         MOZ_ASSERT_IF(kind == LoadSext32, otherOperand.kind() != OtherOperand::FPR);
         MOZ_ASSERT_IF(kind == Load || kind == LoadSext32, otherOperand.kind() != OtherOperand::Imm);
         MOZ_ASSERT(*this == *this);
     }
 
     Kind kind() const {
--- a/js/src/jit/LIR.h
+++ b/js/src/jit/LIR.h
@@ -5,18 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jit_LIR_h
 #define jit_LIR_h
 
 // This file declares the core data structures for LIR: storage allocations for
 // inputs and outputs, as well as the interface instructions must conform to.
 
-#include <utility>
-
 #include "mozilla/Array.h"
 
 #include "jit/Bailouts.h"
 #include "jit/FixedList.h"
 #include "jit/InlineList.h"
 #include "jit/JitAllocPolicy.h"
 #include "jit/LOpcodes.h"
 #include "jit/MIR.h"
@@ -496,24 +494,24 @@ class LDefinition
     LDefinition(uint32_t index, Type type, Policy policy = REGISTER) {
         set(index, type, policy);
     }
 
     explicit LDefinition(Type type, Policy policy = REGISTER) {
         set(0, type, policy);
     }
 
-    LDefinition(Type type, LAllocation  a)
-      : output_(std::move(a))
+    LDefinition(Type type, const LAllocation& a)
+      : output_(a)
     {
         set(0, type, FIXED);
     }
 
-    LDefinition(uint32_t index, Type type, LAllocation  a)
-      : output_(std::move(a))
+    LDefinition(uint32_t index, Type type, const LAllocation& a)
+      : output_(a)
     {
         set(index, type, FIXED);
     }
 
     LDefinition() : bits_(0)
     {
         MOZ_ASSERT(isBogusTemp());
     }
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -7,18 +7,16 @@
 /*
  * Everything needed to build actual MIR instructions: the actual opcodes and
  * instructions, the instruction interface, and use chains.
  */
 
 #ifndef jit_MIR_h
 #define jit_MIR_h
 
-#include <utility>
-
 #include "mozilla/Array.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/MacroForEach.h"
 
 #include "builtin/SIMD.h"
 #include "jit/AtomicOp.h"
 #include "jit/BaselineIC.h"
 #include "jit/FixedList.h"
@@ -1689,17 +1687,17 @@ class MSimdSplat
 
 // A constant SIMD value.
 class MSimdConstant
   : public MNullaryInstruction
 {
     SimdConstant value_;
 
   protected:
-    MSimdConstant(SimdConstant  v, MIRType type) : value_(std::move(v)) {
+    MSimdConstant(const SimdConstant& v, MIRType type) : value_(v) {
         MOZ_ASSERT(IsSimdType(type));
         setMovable();
         setResultType(type);
     }
 
   public:
     INSTRUCTION_HEADER(SimdConstant)
     TRIVIAL_NEW_WRAPPERS
@@ -13329,19 +13327,19 @@ class MWasmMemoryAccess
     void clearOffset() { offset_ = 0; }
 };
 
 class MWasmLoad
   : public MUnaryInstruction,
     public MWasmMemoryAccess,
     public NoTypePolicy::Data
 {
-    MWasmLoad(MDefinition* base, MWasmMemoryAccess  access, MIRType resultType)
+    MWasmLoad(MDefinition* base, const MWasmMemoryAccess& access, MIRType resultType)
       : MUnaryInstruction(base),
-        MWasmMemoryAccess(std::move(access))
+        MWasmMemoryAccess(access)
     {
         setGuard();
         setResultType(resultType);
     }
 
   public:
     INSTRUCTION_HEADER(WasmLoad)
     TRIVIAL_NEW_WRAPPERS
@@ -13356,19 +13354,19 @@ class MWasmLoad
     }
 };
 
 class MWasmStore
   : public MBinaryInstruction,
     public MWasmMemoryAccess,
     public NoTypePolicy::Data
 {
-    MWasmStore(MDefinition* base, MWasmMemoryAccess  access, MDefinition* value)
+    MWasmStore(MDefinition* base, const MWasmMemoryAccess& access, MDefinition* value)
       : MBinaryInstruction(base, value),
-        MWasmMemoryAccess(std::move(access))
+        MWasmMemoryAccess(access)
     {
         setGuard();
     }
 
   public:
     INSTRUCTION_HEADER(WasmStore)
     TRIVIAL_NEW_WRAPPERS
     NAMED_OPERANDS((0, base), (1, value))
@@ -13453,20 +13451,20 @@ class MAsmJSStoreHeap
     }
 };
 
 class MAsmJSCompareExchangeHeap
   : public MQuaternaryInstruction,
     public MWasmMemoryAccess,
     public NoTypePolicy::Data
 {
-    MAsmJSCompareExchangeHeap(MDefinition* base, MWasmMemoryAccess  access,
+    MAsmJSCompareExchangeHeap(MDefinition* base, const MWasmMemoryAccess& access,
                               MDefinition* oldv, MDefinition* newv, MDefinition* tls)
         : MQuaternaryInstruction(base, oldv, newv, tls),
-          MWasmMemoryAccess(std::move(access))
+          MWasmMemoryAccess(access)
     {
         setGuard();             // Not removable
         setResultType(MIRType::Int32);
     }
 
   public:
     INSTRUCTION_HEADER(AsmJSCompareExchangeHeap)
     TRIVIAL_NEW_WRAPPERS
@@ -13481,20 +13479,20 @@ class MAsmJSCompareExchangeHeap
     }
 };
 
 class MAsmJSAtomicExchangeHeap
   : public MTernaryInstruction,
     public MWasmMemoryAccess,
     public NoTypePolicy::Data
 {
-    MAsmJSAtomicExchangeHeap(MDefinition* base, MWasmMemoryAccess  access,
+    MAsmJSAtomicExchangeHeap(MDefinition* base, const MWasmMemoryAccess& access,
                              MDefinition* value, MDefinition* tls)
         : MTernaryInstruction(base, value, tls),
-          MWasmMemoryAccess(std::move(access))
+          MWasmMemoryAccess(access)
     {
         setGuard();             // Not removable
         setResultType(MIRType::Int32);
     }
 
   public:
     INSTRUCTION_HEADER(AsmJSAtomicExchangeHeap)
     TRIVIAL_NEW_WRAPPERS
@@ -13510,20 +13508,20 @@ class MAsmJSAtomicExchangeHeap
 
 class MAsmJSAtomicBinopHeap
   : public MTernaryInstruction,
     public MWasmMemoryAccess,
     public NoTypePolicy::Data
 {
     AtomicOp op_;
 
-    MAsmJSAtomicBinopHeap(AtomicOp op, MDefinition* base, MWasmMemoryAccess  access,
+    MAsmJSAtomicBinopHeap(AtomicOp op, MDefinition* base, const MWasmMemoryAccess& access,
                           MDefinition* v, MDefinition* tls)
         : MTernaryInstruction(base, v, tls),
-          MWasmMemoryAccess(std::move(access)),
+          MWasmMemoryAccess(access),
           op_(op)
     {
         setGuard();         // Not removable
         setResultType(MIRType::Int32);
     }
 
   public:
     INSTRUCTION_HEADER(AsmJSAtomicBinopHeap)
@@ -13665,20 +13663,20 @@ class MWasmCall final
 {
     wasm::CallSiteDesc desc_;
     wasm::CalleeDesc callee_;
     FixedList<AnyRegister> argRegs_;
     uint32_t spIncrement_;
     uint32_t tlsStackOffset_;
     ABIArg instanceArg_;
 
-    MWasmCall(wasm::CallSiteDesc  desc, wasm::CalleeDesc  callee, uint32_t spIncrement,
+    MWasmCall(const wasm::CallSiteDesc& desc, const wasm::CalleeDesc& callee, uint32_t spIncrement,
               uint32_t tlsStackOffset)
-      : desc_(std::move(desc)),
-        callee_(std::move(callee)),
+      : desc_(desc),
+        callee_(callee),
         spIncrement_(spIncrement),
         tlsStackOffset_(tlsStackOffset)
     { }
 
   public:
     INSTRUCTION_HEADER(WasmCall)
 
     struct Arg {
--- a/js/src/jit/RegisterSets.h
+++ b/js/src/jit/RegisterSets.h
@@ -2,18 +2,16 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jit_RegisterSets_h
 #define jit_RegisterSets_h
 
-#include <utility>
-
 #include "mozilla/MathAlgorithms.h"
 
 #include "jit/JitAllocPolicy.h"
 #include "jit/Registers.h"
 
 namespace js {
 namespace jit {
 
@@ -594,17 +592,17 @@ class AllocatableSetAccessors<RegisterSe
     typedef char SetType;
 
   protected:
     RegisterSet set_;
 
   public:
     AllocatableSetAccessors() : set_() {}
     explicit constexpr AllocatableSetAccessors(SetType) = delete;
-    explicit constexpr AllocatableSetAccessors(RegisterSet set) : set_(std::move(set)) {}
+    explicit constexpr AllocatableSetAccessors(RegisterSet set) : set_(set) {}
 
     bool has(Register reg) const {
         return set_.gprs().hasAllocatable(reg);
     }
     bool has(FloatRegister reg) const {
         return set_.fpus().hasAllocatable(reg);
     }
 
@@ -676,17 +674,17 @@ class LiveSetAccessors<RegisterSet>
     typedef char SetType;
 
   protected:
     RegisterSet set_;
 
   public:
     LiveSetAccessors() : set_() {}
     explicit constexpr LiveSetAccessors(SetType) = delete;
-    explicit constexpr LiveSetAccessors(RegisterSet set) : set_(std::move(set)) {}
+    explicit constexpr LiveSetAccessors(RegisterSet set) : set_(set) {}
 
     bool has(Register reg) const {
         return set_.gprs().hasRegisterIndex(reg);
     }
     bool has(FloatRegister reg) const {
         return set_.fpus().hasRegisterIndex(reg);
     }
 
--- a/js/src/jit/shared/Assembler-shared.h
+++ b/js/src/jit/shared/Assembler-shared.h
@@ -6,18 +6,16 @@
 
 #ifndef jit_shared_Assembler_shared_h
 #define jit_shared_Assembler_shared_h
 
 #include "mozilla/PodOperations.h"
 
 #include <limits.h>
 
-#include <utility>
-
 #include "asmjs/WasmTypes.h"
 #include "jit/JitAllocPolicy.h"
 #include "jit/Label.h"
 #include "jit/Registers.h"
 #include "jit/RegisterSets.h"
 #include "vm/HelperThreads.h"
 
 #if defined(JS_CODEGEN_ARM) || defined(JS_CODEGEN_ARM64) || \
@@ -462,22 +460,22 @@ class CodeLabel
 
     // The source label (relative) in the code to where the destination should
     // get patched to.
     CodeOffset target_;
 
   public:
     CodeLabel()
     { }
-    explicit CodeLabel(CodeOffset  patchAt)
-      : patchAt_(std::move(patchAt))
+    explicit CodeLabel(const CodeOffset& patchAt)
+      : patchAt_(patchAt)
     { }
-    CodeLabel(CodeOffset  patchAt, CodeOffset  target)
-      : patchAt_(std::move(patchAt)),
-        target_(std::move(target))
+    CodeLabel(const CodeOffset& patchAt, const CodeOffset& target)
+      : patchAt_(patchAt),
+        target_(target)
     { }
     CodeOffset* patchAt() {
         return &patchAt_;
     }
     CodeOffset* target() {
         return &target_;
     }
     void offsetBy(size_t delta) {
--- a/js/src/jit/x86-shared/MacroAssembler-x86-shared.h
+++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared.h
@@ -2,18 +2,16 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jit_x86_shared_MacroAssembler_x86_shared_h
 #define jit_x86_shared_MacroAssembler_x86_shared_h
 
-#include <utility>
-
 #include "mozilla/Casting.h"
 
 #if defined(JS_CODEGEN_X86)
 # include "jit/x86/Assembler-x86.h"
 #elif defined(JS_CODEGEN_X64)
 # include "jit/x64/Assembler-x64.h"
 #endif
 
@@ -55,17 +53,17 @@ class MacroAssemblerX86Shared : public A
     // knows what to use instead of copying these data structures.
     template<class T>
     struct Constant {
         typedef T Pod;
 
         T value;
         UsesVector uses;
 
-        explicit Constant(T  value) : value(std::move(value)) {}
+        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;
     };
 
     // 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>;
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -18,18 +18,16 @@
 #include "mozilla/RefPtr.h"
 #include "mozilla/Variant.h"
 
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
 
-#include <utility>
-
 #include "jsalloc.h"
 #include "jspubtd.h"
 
 #include "js/CallArgs.h"
 #include "js/CharacterEncoding.h"
 #include "js/Class.h"
 #include "js/GCVector.h"
 #include "js/HashTable.h"
@@ -2335,20 +2333,20 @@ class JS_PUBLIC_API(CompartmentBehaviors
 class JS_PUBLIC_API(CompartmentOptions)
 {
   public:
     explicit CompartmentOptions()
       : creationOptions_(),
         behaviors_()
     {}
 
-    CompartmentOptions(CompartmentCreationOptions  compartmentCreation,
-                       CompartmentBehaviors  compartmentBehaviors)
-      : creationOptions_(std::move(compartmentCreation)),
-        behaviors_(std::move(compartmentBehaviors))
+    CompartmentOptions(const CompartmentCreationOptions& compartmentCreation,
+                       const CompartmentBehaviors& compartmentBehaviors)
+      : creationOptions_(compartmentCreation),
+        behaviors_(compartmentBehaviors)
     {}
 
     // CompartmentCreationOptions specify fundamental compartment
     // characteristics that must be specified when the compartment is created,
     // that can't be changed after the compartment is created.
     CompartmentCreationOptions& creationOptions() {
         return creationOptions_;
     }