Bug 886128 - Fix various clang warnings and some potential bugs in nonstandard configurations. r=nnethercote,terrence.
authorEmanuel Hoogeveen <emanuel.hoogeveen@gmail.com>
Mon, 24 Jun 2013 21:32:05 -0700
changeset 136389 b3f8eee3c38943a29cca0d1c97049c352324332c
parent 136388 df3ad1eb9ebbd79b0a5658fa1d3cae6cd01997aa
child 136390 fc4ef42eb153c33c9b9fc2c292d30183f745ed28
push id24882
push userryanvm@gmail.com
push dateTue, 25 Jun 2013 21:02:44 +0000
treeherdermozilla-central@cc80aa0c7c13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnnethercote, terrence
bugs886128
milestone25.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 886128 - Fix various clang warnings and some potential bugs in nonstandard configurations. r=nnethercote,terrence.
js/src/builtin/Profilers.cpp
js/src/frontend/NameFunctions.h
js/src/frontend/ParseNode.h
js/src/frontend/Parser.h
js/src/gc/Nursery-inl.h
js/src/gc/Nursery.cpp
js/src/gc/StoreBuffer.cpp
js/src/gc/StoreBuffer.h
js/src/ion/AsmJS.h
js/src/ion/BaselineJIT.h
js/src/ion/IonCompartment.h
js/src/jsapi-tests/testVersion.cpp
js/src/jsatom.cpp
js/src/jsgc.h
js/src/jsprvtd.h
js/src/jsscript.h
js/src/vm/ForkJoin.h
js/src/vm/String.cpp
mfbt/CheckedInt.h
--- a/js/src/builtin/Profilers.cpp
+++ b/js/src/builtin/Profilers.cpp
@@ -16,16 +16,20 @@
 
 #ifdef __APPLE__
 #include "devtools/sharkctl.h"
 #include "devtools/Instruments.h"
 #endif
 
 #include "jscntxtinlines.h"
 
+#ifdef JSGC_GENERATIONAL
+#include "vm/Shape-inl.h"
+#endif
+
 using namespace js;
 
 using mozilla::ArrayLength;
 
 /* Thread-unsafe error management */
 
 static char gLastError[2000];
 
--- a/js/src/frontend/NameFunctions.h
+++ b/js/src/frontend/NameFunctions.h
@@ -7,17 +7,17 @@
 #ifndef frontend_NameFunctions_h
 #define frontend_NameFunctions_h
 
 struct JSContext;
 
 namespace js {
 namespace frontend {
 
-struct ParseNode;
+class ParseNode;
 
 bool
 NameFunctions(JSContext *cx, ParseNode *pn);
 
 } /* namespace frontend */
 } /* namespace js */
 
 #endif /* frontend_NameFunctions_h */
--- a/js/src/frontend/ParseNode.h
+++ b/js/src/frontend/ParseNode.h
@@ -411,19 +411,18 @@ struct Definition;
 class LabeledStatement;
 class LoopControlStatement;
 class BreakStatement;
 class ContinueStatement;
 class ConditionalExpression;
 class PropertyAccess;
 class ModuleBox;
 
-struct ParseNode
+class ParseNode
 {
-  private:
     uint32_t            pn_type   : 16, /* PNK_* type */
                         pn_op     : 8,  /* see JSOp enum and jsopcode.tbl */
                         pn_arity  : 5,  /* see ParseNodeArity enum */
                         pn_parens : 1,  /* this expr was enclosed in parens */
                         pn_used   : 1,  /* name node is on a use-chain */
                         pn_defn   : 1;  /* this node is a Definition */
 
     ParseNode(const ParseNode &other) MOZ_DELETE;
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -253,18 +253,19 @@ class CompExprTransplanter;
 template <typename ParseHandler>
 class GenexpGuard;
 
 enum LetContext { LetExpresion, LetStatement };
 enum VarContext { HoistVars, DontHoistVars };
 enum FunctionType { Getter, Setter, Normal };
 
 template <typename ParseHandler>
-struct Parser : private AutoGCRooter, public StrictModeGetter
+class Parser : private AutoGCRooter, public StrictModeGetter
 {
+  public:
     JSContext           *const context; /* FIXME Bug 551291: use AutoGCRooter::context? */
     TokenStream         tokenStream;
     LifoAlloc::Mark     tempPoolMark;
 
     /* list of parsed objects for GC tracing */
     ObjectBox *traceListHead;
 
     /* innermost parse context (stack-allocated) */
--- a/js/src/gc/Nursery-inl.h
+++ b/js/src/gc/Nursery-inl.h
@@ -17,17 +17,17 @@ namespace js {
 namespace gc {
 
 /*
  * This structure overlays a Cell in the Nursery and re-purposes its memory
  * for managing the Nursery collection process.
  */
 class RelocationOverlay
 {
-    friend struct MinorCollectionTracer;
+    friend class MinorCollectionTracer;
 
     /* The low bit is set so this should never equal a normal pointer. */
     const static uintptr_t Relocated = uintptr_t(0xbad0bad1);
 
     /* Set to Relocated when moved. */
     uintptr_t magic_;
 
     /* The location |this| was moved to. */
--- a/js/src/gc/Nursery.cpp
+++ b/js/src/gc/Nursery.cpp
@@ -43,27 +43,29 @@ js::Nursery::init()
     // poison range, because it might already have been taken up by something
     // else (shared library, previous allocation). So we'll just loop and
     // discard poison pointers until we get something valid.
     //
     // This leaks all of these poisoned pointers. It would be better if they
     // were marked as uncommitted, but it's a little complicated to avoid
     // clobbering pre-existing unrelated mappings.
     while (IsPoisonedPtr(heap) || IsPoisonedPtr((void*)(uintptr_t(heap) + NurserySize)))
-        heap = MapAlignedPages(NurserySize, Alignment);
+        heap = MapAlignedPages(runtime(), NurserySize, Alignment);
 #endif
     if (!heap)
         return false;
 
     JSRuntime *rt = runtime();
     rt->gcNurseryStart_ = uintptr_t(heap);
     rt->gcNurseryEnd_ = chunk(LastNurseryChunk).end();
     numActiveChunks_ = 1;
     setCurrentChunk(0);
+#ifdef DEBUG
     JS_POISON(heap, FreshNursery, NurserySize);
+#endif
     for (int i = 0; i < NumNurseryChunks; ++i)
         chunk(i).runtime = rt;
 
     JS_ASSERT(isEnabled());
     return true;
 }
 
 js::Nursery::~Nursery()
@@ -103,17 +105,19 @@ js::Nursery::allocate(size_t size)
         if (currentChunk_ + 1 == numActiveChunks_)
             return NULL;
         setCurrentChunk(currentChunk_ + 1);
     }
 
     void *thing = (void *)position();
     position_ = position() + size;
 
+#ifdef DEBUG
     JS_POISON(thing, AllocatedThing, size);
+#endif
     return thing;
 }
 
 /* Internally, this function is used to allocate elements as well as slots. */
 HeapSlot *
 js::Nursery::allocateSlots(JSContext *cx, JSObject *obj, uint32_t nslots)
 {
     JS_ASSERT(obj);
--- a/js/src/gc/StoreBuffer.cpp
+++ b/js/src/gc/StoreBuffer.cpp
@@ -1,21 +1,23 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * 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/. */
 
 #ifdef JSGC_GENERATIONAL
 
-#include "jsgc.h"
+#include "gc/StoreBuffer.h"
+
+#include "mozilla/Assertions.h"
+
+#include "vm/ForkJoin.h"
 
 #include "gc/Barrier-inl.h"
-#include "gc/StoreBuffer.h"
-#include "vm/ForkJoin.h"
 #include "vm/ObjectImpl-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
 /*** SlotEdge ***/
 
 JS_ALWAYS_INLINE HeapSlot *
@@ -59,18 +61,22 @@ StoreBuffer::SlotEdge::isNullEdge() cons
 void
 StoreBuffer::WholeCellEdges::mark(JSTracer *trc)
 {
     JSGCTraceKind kind = GetGCThingTraceKind(tenured);
     if (kind <= JSTRACE_OBJECT) {
         MarkChildren(trc, static_cast<JSObject *>(tenured));
         return;
     }
+#ifdef JS_ION
     JS_ASSERT(kind == JSTRACE_IONCODE);
     static_cast<ion::IonCode *>(tenured)->trace(trc);
+#else
+    MOZ_NOT_REACHED("Only objects can be in the wholeCellBuffer if IonMonkey is disabled.");
+#endif
 }
 
 /*** MonoTypeBuffer ***/
 
 /* How full we allow a store buffer to become before we request a MinorGC. */
 const static double HighwaterRatio = 7.0 / 8.0;
 
 template <typename T>
--- a/js/src/gc/StoreBuffer.h
+++ b/js/src/gc/StoreBuffer.h
@@ -8,20 +8,22 @@
 #define gc_StoreBuffer_h
 
 #ifdef JSGC_GENERATIONAL
 
 #ifndef JSGC_USE_EXACT_ROOTING
 # error "Generational GC requires exact rooting."
 #endif
 
+#include "jsalloc.h"
 #include "jsgc.h"
-#include "jsalloc.h"
 #include "jsobj.h"
 
+#include "gc/Nursery.h"
+
 namespace js {
 namespace gc {
 
 class AccumulateEdgesTracer;
 
 /*
  * BufferableRef represents an abstract reference for use in the generational
  * GC's remembered set. Entries in the store buffer that cannot be represented
--- a/js/src/ion/AsmJS.h
+++ b/js/src/ion/AsmJS.h
@@ -12,17 +12,17 @@
 # include <mach/mach.h>
 #endif
 
 namespace js {
 
 class ScriptSource;
 class SPSProfiler;
 class AsmJSModule;
-namespace frontend { struct TokenStream; struct ParseNode; }
+namespace frontend { class TokenStream; class ParseNode; }
 namespace ion { class MIRGenerator; class LIRGraph; }
 
 // Called after parsing a function 'fn' which contains the "use asm" directive.
 // This function performs type-checking and code-generation. If type-checking
 // succeeds, the generated native function is assigned to |moduleFun|.
 // Otherwise, a warning will be emitted and |moduleFun| is left unchanged. The
 // function returns 'false' only if a real JS semantic error (probably OOM) is
 // pending.
--- a/js/src/ion/BaselineJIT.h
+++ b/js/src/ion/BaselineJIT.h
@@ -19,17 +19,17 @@
 #include "Bailouts.h"
 
 #include "ds/LifoAlloc.h"
 
 namespace js {
 namespace ion {
 
 class StackValue;
-struct ICEntry;
+class ICEntry;
 class ICStub;
 
 class PCMappingSlotInfo
 {
     uint8_t slotInfo_;
 
   public:
     // SlotInfo encoding:
--- a/js/src/ion/IonCompartment.h
+++ b/js/src/ion/IonCompartment.h
@@ -61,17 +61,17 @@ typedef Vector<IonBuilder*, 0, SystemAll
 
 // ICStubSpace is an abstraction for allocation policy and storage for stub data.
 // There are two kinds of stubs: optimized stubs and fallback stubs (the latter
 // also includes stubs that can make non-tail calls that can GC).
 //
 // Optimized stubs are allocated per-compartment and are always purged when
 // JIT-code is discarded. Fallback stubs are allocated per BaselineScript and
 // are only destroyed when the BaselineScript is destroyed.
-struct ICStubSpace
+class ICStubSpace
 {
   protected:
     LifoAlloc allocator_;
 
     explicit ICStubSpace(size_t chunkSize)
       : allocator_(chunkSize)
     {}
 
--- a/js/src/jsapi-tests/testVersion.cpp
+++ b/js/src/jsapi-tests/testVersion.cpp
@@ -3,16 +3,20 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "tests.h"
 #include "jsscript.h"
 #include "jscntxt.h"
 
 #include "jscntxtinlines.h"
 
+#ifdef JSGC_GENERATIONAL
+#include "vm/Shape-inl.h"
+#endif
+
 using namespace js;
 
 struct VersionFixture;
 
 /*
  * Fast-native callbacks for use from JS.
  * They set their results on the current fixture instance.
  */
--- a/js/src/jsatom.cpp
+++ b/js/src/jsatom.cpp
@@ -2,34 +2,36 @@
  * 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/. */
 
 /*
  * JS atom table.
  */
-#include "jsatom.h"
+#include "jsatominlines.h"
 
 #include "mozilla/RangedPtr.h"
 #include "mozilla/Util.h"
 
 #include <string.h>
 
 #include "jsapi.h"
 #include "jscntxt.h"
 #include "jsstr.h"
 #include "jstypes.h"
 
 #include "gc/Marking.h"
 #include "vm/Xdr.h"
 
-#include "jsatominlines.h"
 #include "jscompartmentinlines.h"
 
+#ifdef JSGC_GENERATIONAL
+#include "vm/Shape-inl.h"
+#endif
 #include "vm/String-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
 using mozilla::ArrayEnd;
 using mozilla::ArrayLength;
 using mozilla::RangedPtr;
--- a/js/src/jsgc.h
+++ b/js/src/jsgc.h
@@ -20,21 +20,21 @@
 #include "jsscript.h"
 #include "jstypes.h"
 
 #include "gc/Heap.h"
 #include "js/GCAPI.h"
 #include "js/HashTable.h"
 #include "js/Vector.h"
 
-struct JSAtom;
+class JSAtom;
 struct JSCompartment;
-struct JSFunction;
-struct JSFlatString;
-struct JSLinearString;
+class JSFunction;
+class JSFlatString;
+class JSLinearString;
 
 namespace js {
 
 class ArgumentsObject;
 class ArrayBufferObject;
 class BaseShape;
 class DebugScopeObject;
 class GCHelperThread;
@@ -253,19 +253,18 @@ struct ArenaList {
     void clear() {
         head = NULL;
         cursor = &head;
     }
 
     void insert(ArenaHeader *arena);
 };
 
-struct ArenaLists
+class ArenaLists
 {
-  private:
     /*
      * For each arena kind its free list is represented as the first span with
      * free things. Initially all the spans are initialized as empty. After we
      * find a new arena with available things we move its first free span into
      * the list and set the arena as fully allocated. way we do not need to
      * update the arena header after the initial allocation. When starting the
      * GC we only move the head of the of the list of spans back to the arena
      * only for the arena that was not fully allocated.
@@ -679,17 +678,17 @@ class GCHelperThread {
     bool              shrinkFlag;
 
     Vector<void **, 16, js::SystemAllocPolicy> freeVector;
     void            **freeCursor;
     void            **freeCursorEnd;
 
     bool              backgroundAllocation;
 
-    friend struct js::gc::ArenaLists;
+    friend class js::gc::ArenaLists;
 
     void
     replenishAndFreeLater(void *ptr);
 
     static void freeElementsAndArray(void **array, void **end) {
         JS_ASSERT(array <= end);
         for (void **p = array; p != end; ++p)
             js_free(*p);
--- a/js/src/jsprvtd.h
+++ b/js/src/jsprvtd.h
@@ -143,20 +143,20 @@ struct BytecodeEmitter;
 struct Definition;
 class FullParseHandler;
 class FunctionBox;
 class ObjectBox;
 struct Token;
 struct TokenPos;
 class TokenStream;
 class ParseMapPool;
-struct ParseNode;
+class ParseNode;
 
 template <typename ParseHandler>
-struct Parser;
+class Parser;
 
 } /* namespace frontend */
 
 namespace analyze {
 
 struct LifetimeVariable;
 class LoopAnalysis;
 class ScriptAnalysis;
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -274,20 +274,19 @@ class DebugScript
     BreakpointSite  *breakpoints[1];
 };
 
 typedef HashMap<JSScript *,
                 DebugScript *,
                 DefaultHasher<JSScript *>,
                 SystemAllocPolicy> DebugScriptMap;
 
-struct ScriptSource
+class ScriptSource
 {
     friend class SourceCompressorThread;
-  private:
     union {
         // Before setSourceCopy or setSource are successfully called, this union
         // has a NULL pointer. When the script source is ready,
         // compressedLength_ != 0 implies compressed holds the compressed data;
         // otherwise, source holds the uncompressed source. There is a special
         // pointer |emptySource| for source code for length 0.
         //
         // The only function allowed to malloc, realloc, or free the pointers in
@@ -1323,17 +1322,17 @@ class SourceCompressorThread
     void waitOnCompression(SourceCompressionToken *userTok);
     void abort(SourceCompressionToken *userTok);
     const jschar *currentChars() const;
 };
 #endif
 
 struct SourceCompressionToken
 {
-    friend struct ScriptSource;
+    friend class ScriptSource;
     friend class SourceCompressorThread;
   private:
     JSContext *cx;
     ScriptSource *ss;
     const jschar *chars;
     bool oom;
   public:
     explicit SourceCompressionToken(JSContext *cx)
--- a/js/src/vm/ForkJoin.h
+++ b/js/src/vm/ForkJoin.h
@@ -195,17 +195,17 @@
 // - No load balancing is performed between worker threads.  That means that
 //   the fork-join system is best suited for problems that can be slice into
 //   uniform bits.
 //
 ///////////////////////////////////////////////////////////////////////////
 
 namespace js {
 
-struct ForkJoinSlice;
+class ForkJoinSlice;
 
 bool ForkJoin(JSContext *cx, CallArgs &args);
 
 // Returns the number of slices that a fork-join op will have when
 // executed.
 uint32_t ForkJoinSlices(JSContext *cx);
 
 #ifdef DEBUG
@@ -285,17 +285,17 @@ struct ParallelBailoutRecord {
                   JSScript *currentScript,     // inlinee (if applicable)
                   jsbytecode *currentPc);
     void addTrace(JSScript *script,
                   jsbytecode *pc);
 };
 
 struct ForkJoinShared;
 
-struct ForkJoinSlice : ThreadSafeContext
+class ForkJoinSlice : public ThreadSafeContext
 {
   public:
     // Which slice should you process? Ranges from 0 to |numSlices|.
     const uint32_t sliceId;
 
     // How many slices are there in total?
     const uint32_t numSlices;
 
--- a/js/src/vm/String.cpp
+++ b/js/src/vm/String.cpp
@@ -1,25 +1,27 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * 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/. */
 
-#include "vm/String.h"
+#include "vm/String-inl.h"
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/RangedPtr.h"
 
 #include "gc/Marking.h"
 
 #include "jscompartmentinlines.h"
 
-#include "String-inl.h"
+#ifdef JSGC_GENERATIONAL
+#include "vm/Shape-inl.h"
+#endif
 
 using namespace js;
 
 using mozilla::PodCopy;
 using mozilla::RangedPtr;
 
 bool
 JSString::isShort() const
--- a/mfbt/CheckedInt.h
+++ b/mfbt/CheckedInt.h
@@ -599,17 +599,17 @@ class CheckedInt
     template<typename U>
     CheckedInt(U value, bool isValid) : mValue(value), mIsValid(isValid)
     {
       MOZ_STATIC_ASSERT(detail::IsSupported<T>::value &&
                         detail::IsSupported<U>::value,
                         "This type is not supported by CheckedInt");
     }
 
-    friend class detail::NegateImpl<T>;
+    friend struct detail::NegateImpl<T>;
 
   public:
     /**
      * Constructs a checked integer with given @a value. The checked integer is
      * initialized as valid or invalid depending on whether the @a value
      * is in range.
      *
      * This constructor is not explicit. Instead, the type of its argument is a