Bug 1060976 - Fix more bad implicit constructors in the JS engine; r=jorendorff
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 05 Sep 2014 15:11:39 -0400
changeset 227184 1b69fdc32b25bf2e2d772ea7594d545bf3b5cac1
parent 227183 54d37aeae2ce55a240c02d19096f9b3f575b1e81
child 227185 e3ccede35d02f082b5e4a03a803b0eed32ef1be8
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1060976
milestone35.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 1060976 - Fix more bad implicit constructors in the JS engine; r=jorendorff
js/public/UbiNode.h
js/src/jit/IonBuilder.cpp
js/src/jit/JitcodeMap.cpp
js/src/jit/JitcodeMap.h
js/src/jit/LIR-Common.h
js/src/jit/MIR.h
js/src/jit/x64/MacroAssembler-x64.h
js/src/vm/Debugger.h
js/src/vm/DebuggerMemory.cpp
js/src/vm/Runtime.h
js/src/vm/SavedStacks.cpp
--- a/js/public/UbiNode.h
+++ b/js/public/UbiNode.h
@@ -445,17 +445,17 @@ class TracerConcrete : public Base {
 // For JS_TraceChildren-based types that have a 'compartment' method.
 template<typename Referent>
 class TracerConcreteWithCompartment : public TracerConcrete<Referent> {
     typedef TracerConcrete<Referent> TracerBase;
     JSCompartment *compartment() const MOZ_OVERRIDE {
         return TracerBase::get().compartment();
     }
 
-    TracerConcreteWithCompartment(Referent *ptr) : TracerBase(ptr) { }
+    explicit TracerConcreteWithCompartment(Referent *ptr) : TracerBase(ptr) { }
 
   public:
     static void construct(void *storage, Referent *ptr) {
         new (storage) TracerConcreteWithCompartment(ptr);
     }
 };
 
 template<> struct Concrete<JSObject> : TracerConcreteWithCompartment<JSObject> { };
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -4297,17 +4297,17 @@ class WrapMGetPropertyCache
             return;
         MResumePoint *rp = propTable->takePriorResumePoint();
         if (!rp)
             return;
         cache_->block()->discardPreAllocatedResumePoint(rp);
     }
 
   public:
-    WrapMGetPropertyCache(MGetPropertyCache *cache)
+    explicit WrapMGetPropertyCache(MGetPropertyCache *cache)
       : cache_(cache)
     { }
 
     ~WrapMGetPropertyCache() {
         discardPriorResumePoint();
     }
 
     MGetPropertyCache *get() {
--- a/js/src/jit/JitcodeMap.cpp
+++ b/js/src/jit/JitcodeMap.cpp
@@ -358,17 +358,17 @@ JitcodeRegionEntry::ExpectedRunLength(co
 struct JitcodeMapBufferWriteSpewer
 {
 #ifdef DEBUG
     CompactBufferWriter *writer;
     uint32_t startPos;
 
     static const uint32_t DumpMaxBytes = 50;
 
-    JitcodeMapBufferWriteSpewer(CompactBufferWriter &w)
+    explicit JitcodeMapBufferWriteSpewer(CompactBufferWriter &w)
       : writer(&w), startPos(writer->length())
     {}
 
     void spewAndAdvance(const char *name) {
         uint32_t curPos = writer->length();
         const uint8_t *start = writer->buffer() + startPos;
         const uint8_t *end = writer->buffer() + curPos;
         const char *MAP = "0123456789ABCDEF";
--- a/js/src/jit/JitcodeMap.h
+++ b/js/src/jit/JitcodeMap.h
@@ -309,29 +309,29 @@ class JitcodeGlobalEntry
         QueryEntry query_;
     };
 
   public:
     JitcodeGlobalEntry() {
         base_.init();
     }
 
-    JitcodeGlobalEntry(const IonEntry &ion) {
+    explicit JitcodeGlobalEntry(const IonEntry &ion) {
         ion_ = ion;
     }
 
-    JitcodeGlobalEntry(const BaselineEntry &baseline) {
+    explicit JitcodeGlobalEntry(const BaselineEntry &baseline) {
         baseline_ = baseline;
     }
 
-    JitcodeGlobalEntry(const IonCacheEntry &ionCache) {
+    explicit JitcodeGlobalEntry(const IonCacheEntry &ionCache) {
         ionCache_ = ionCache;
     }
 
-    JitcodeGlobalEntry(const QueryEntry &query) {
+    explicit JitcodeGlobalEntry(const QueryEntry &query) {
         query_ = query;
     }
 
     static JitcodeGlobalEntry MakeQuery(void *ptr) {
         QueryEntry query;
         query.init(ptr);
         return JitcodeGlobalEntry(query);
     }
@@ -799,17 +799,17 @@ class JitcodeIonTable
     uint32_t numRegions_;
     uint32_t regionOffsets_[0];
 
     const uint8_t *payloadEnd() const {
         return reinterpret_cast<const uint8_t *>(this);
     }
 
   public:
-    JitcodeIonTable(uint32_t numRegions)
+    explicit JitcodeIonTable(uint32_t numRegions)
       : numRegions_(numRegions)
     {
         for (uint32_t i = 0; i < numRegions; i++)
             regionOffsets_[i] = 0;
     }
 
     bool makeIonEntry(JSContext *cx, JitCode *code, uint32_t numScripts, JSScript **scripts,
                       JitcodeGlobalEntry::IonEntry &out);
--- a/js/src/jit/LIR-Common.h
+++ b/js/src/jit/LIR-Common.h
@@ -200,17 +200,17 @@ class LSimdExtractElementF : public LIns
     }
 };
 
 class LSimdSignMaskX4 : public LInstructionHelper<1, 1, 0>
 {
   public:
     LIR_HEADER(SimdSignMaskX4);
 
-    LSimdSignMaskX4(const LAllocation &input) {
+    explicit LSimdSignMaskX4(const LAllocation &input) {
         setOperand(0, input);
     }
 };
 
 // Binary SIMD comparison operation between two SIMD operands
 class LSimdBinaryComp: public LInstructionHelper<1, 2, 0>
 {
   protected:
@@ -2789,17 +2789,17 @@ class LAbsF : public LInstructionHelper<
     }
 };
 
 // Count leading zeroes
 class LClzI : public LInstructionHelper<1, 1, 0>
 {
   public:
     LIR_HEADER(ClzI)
-    LClzI(const LAllocation &num) {
+    explicit LClzI(const LAllocation &num) {
         setOperand(0, num);
     }
 
     MClz *mir() const {
         return mir_->toClz();
     }
 };
 
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -2484,17 +2484,17 @@ class MObjectState : public MVariadicIns
 
 // Represent the contents of all elements of an array.  This instruction is not
 // lowered and is not used to generate code.
 class MArrayState : public MVariadicInstruction
 {
   private:
     uint32_t numElements_;
 
-    MArrayState(MDefinition *arr)
+    explicit MArrayState(MDefinition *arr)
     {
         // This instruction is only used as a summary for bailout paths.
         setRecoveredOnBailout();
         numElements_ = arr->toNewArray()->count();
     }
 
     bool init(TempAllocator &alloc, MDefinition *obj, MDefinition *len) {
         if (!MVariadicInstruction::init(alloc, numElements() + 2))
@@ -4750,17 +4750,17 @@ class MAbs
 };
 
 class MClz
     : public MUnaryInstruction
     , public BitwisePolicy
 {
     bool operandIsNeverZero_;
 
-    MClz(MDefinition *num)
+    explicit MClz(MDefinition *num)
       : MUnaryInstruction(num),
         operandIsNeverZero_(false)
     {
         JS_ASSERT(IsNumberType(num->type()));
         specialization_ = MIRType_Int32;
         setResultType(MIRType_Int32);
         setMovable();
     }
--- a/js/src/jit/x64/MacroAssembler-x64.h
+++ b/js/src/jit/x64/MacroAssembler-x64.h
@@ -65,17 +65,17 @@ class MacroAssemblerX64 : public MacroAs
 
     typedef HashMap<float, size_t, DefaultHasher<float>, SystemAllocPolicy> FloatMap;
     FloatMap floatMap_;
 
     struct SimdData {
         SimdConstant value;
         NonAssertingLabel uses;
 
-        SimdData(const SimdConstant &v) : value(v) {}
+        explicit SimdData(const SimdConstant &v) : value(v) {}
         SimdConstant::Type type() { return value.type(); }
     };
     Vector<SimdData, 0, SystemAllocPolicy> simds_;
     typedef HashMap<SimdConstant, size_t, SimdConstant, SystemAllocPolicy> SimdMap;
     SimdMap simdMap_;
 
     void setupABICall(uint32_t arg);
 
--- a/js/src/vm/Debugger.h
+++ b/js/src/vm/Debugger.h
@@ -196,17 +196,17 @@ class Debugger : private mozilla::Linked
     HeapPtrObject object;               /* The Debugger object. Strong reference. */
     GlobalObjectSet debuggees;          /* Debuggee globals. Cross-compartment weak references. */
     js::HeapPtrObject uncaughtExceptionHook; /* Strong reference. */
     bool enabled;
     JSCList breakpoints;                /* Circular list of all js::Breakpoints in this debugger */
 
     struct AllocationSite : public mozilla::LinkedListElement<AllocationSite>
     {
-        AllocationSite(HandleObject frame) : frame(frame) {
+        explicit AllocationSite(HandleObject frame) : frame(frame) {
             JS_ASSERT_IF(frame, UncheckedUnwrap(frame)->is<SavedFrame>());
         };
         RelocatablePtrObject frame;
     };
     typedef mozilla::LinkedList<AllocationSite> AllocationSiteList;
 
     bool trackingAllocationSites;
     AllocationSiteList allocationsLog;
--- a/js/src/vm/DebuggerMemory.cpp
+++ b/js/src/vm/DebuggerMemory.cpp
@@ -259,17 +259,17 @@ namespace js {
 namespace dbg {
 
 // Common data for census traversals.
 struct Census {
     JSContext * const cx;
     Zone::ZoneSet debuggeeZones;
     Zone *atomsZone;
 
-    Census(JSContext *cx) : cx(cx), atomsZone(nullptr) { }
+    explicit Census(JSContext *cx) : cx(cx), atomsZone(nullptr) { }
 
     bool init() {
         AutoLockForExclusiveAccess lock(cx);
         atomsZone = cx->runtime()->atomsCompartment()->zone();
         return debuggeeZones.init();
     }
 };
 
@@ -299,17 +299,17 @@ struct Census {
 // In each of these, |census| provides ambient information needed for assorting,
 // like a JSContext for reporting errors.
 
 // The simplest assorter: count everything, and return a tally form.
 class Tally {
     size_t total_;
 
   public:
-    Tally(Census &census) : total_(0) { }
+    explicit Tally(Census &census) : total_(0) { }
     Tally(Tally &&rhs) : total_(rhs.total_) { }
     Tally &operator=(Tally &&rhs) { total_ = rhs.total_; return *this; }
 
     bool init(Census &census) { return true; }
 
     bool count(Census &census, const Node &node) {
         total_++;
         return true;
@@ -343,17 +343,17 @@ template<typename EachObject = Tally,
 class ByJSType {
     size_t total_;
     EachObject objects;
     EachScript scripts;
     EachString strings;
     EachOther other;
 
   public:
-    ByJSType(Census &census)
+    explicit ByJSType(Census &census)
       : total_(0),
         objects(census),
         scripts(census),
         strings(census),
         other(census)
     { }
     ByJSType(ByJSType &&rhs)
       : total_(rhs.total_),
@@ -457,17 +457,17 @@ class ByObjectClass {
         if (lhs < rhs)
             return 1;
         if (lhs > rhs)
             return -1;
         return 0;
     }
 
   public:
-    ByObjectClass(Census &census) : total_(0), other(census) { }
+    explicit ByObjectClass(Census &census) : total_(0), other(census) { }
     ByObjectClass(ByObjectClass &&rhs)
       : total_(rhs.total_), table(Move(rhs.table)), other(Move(rhs.other))
     { }
     ByObjectClass &operator=(ByObjectClass &&rhs) {
         MOZ_ASSERT(&rhs != this);
         this->~ByObjectClass();
         new (this) ByObjectClass(Move(rhs));
         return *this;
@@ -556,17 +556,17 @@ class ByUbinodeType {
     // Note that, because ubi::Node::typeName promises to return a specific
     // pointer, not just any string whose contents are correct, we can use their
     // addresses as hash table keys.
     typedef HashMap<const jschar *, EachType, DefaultHasher<const jschar *>, SystemAllocPolicy> Table;
     typedef typename Table::Entry Entry;
     Table table;
 
   public:
-    ByUbinodeType(Census &census) : total_(0) { }
+    explicit ByUbinodeType(Census &census) : total_(0) { }
     ByUbinodeType(ByUbinodeType &&rhs) : total_(rhs.total_), table(Move(rhs.table)) { }
     ByUbinodeType &operator=(ByUbinodeType &&rhs) {
         MOZ_ASSERT(&rhs != this);
         this->~ByUbinodeType();
         new (this) ByUbinodeType(Move(rhs));
         return *this;
     }
 
@@ -645,17 +645,17 @@ class ByUbinodeType {
 // A BreadthFirst handler type that conducts a census, using Assorter
 // to categorize and count each node.
 template<typename Assorter>
 class CensusHandler {
     Census &census;
     Assorter assorter;
 
   public:
-    CensusHandler(Census &census) : census(census), assorter(census) { }
+    explicit CensusHandler(Census &census) : census(census), assorter(census) { }
 
     bool init(Census &census) { return assorter.init(census); }
     bool report(Census &census, MutableHandleValue report) {
         return assorter.report(census, report);
     }
 
     // This class needs to retain no per-node data.
     class NodeData { };
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -383,17 +383,17 @@ class FreeOp : public JSFreeOp
 {
     Vector<void *, 0, SystemAllocPolicy> freeLaterList;
 
   public:
     static FreeOp *get(JSFreeOp *fop) {
         return static_cast<FreeOp *>(fop);
     }
 
-    FreeOp(JSRuntime *rt)
+    explicit FreeOp(JSRuntime *rt)
       : JSFreeOp(rt)
     {}
 
     ~FreeOp() {
         for (size_t i = 0; i < freeLaterList.length(); i++)
             free_(freeLaterList[i]);
     }
 
--- a/js/src/vm/SavedStacks.cpp
+++ b/js/src/vm/SavedStacks.cpp
@@ -10,16 +10,17 @@
 #include "jsapi.h"
 #include "jscompartment.h"
 #include "jsfriendapi.h"
 #include "jshashutil.h"
 #include "jsnum.h"
 
 #include "gc/Marking.h"
 #include "js/Vector.h"
+#include "mozilla/Attributes.h"
 #include "vm/Debugger.h"
 #include "vm/GlobalObject.h"
 #include "vm/StringBuffer.h"
 
 #include "jscntxtinlines.h"
 #include "jsobjinlines.h"
 
 using mozilla::AddToHash;
@@ -71,17 +72,17 @@ class SavedFrame::AutoLookupRooter : pub
     }
 
     SavedFrame::Lookup value;
 };
 
 class SavedFrame::HandleLookup
 {
   public:
-    HandleLookup(SavedFrame::AutoLookupRooter &lookup) : ref(lookup) { }
+    MOZ_IMPLICIT HandleLookup(SavedFrame::AutoLookupRooter &lookup) : ref(lookup) { }
     SavedFrame::Lookup *operator->() { return &ref.get(); }
     operator const SavedFrame::Lookup&() const { return ref; }
   private:
     SavedFrame::AutoLookupRooter &ref;
 };
 
 /* static */ HashNumber
 SavedFrame::HashPolicy::hash(const Lookup &lookup)