Bug 1119232 - Fix a warning for the usage of the uninitialized gc member in JSRuntime's constructor; r=jandem
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 08 Jan 2015 09:36:31 -0500
changeset 248613 b2cf412dad7a0c7f9d1df7b612a5c10b3529e3d9
parent 248612 bcacb5692ad902fc0ec6ebea2ad382a8a3fd5183
child 248614 1ce77cbf99f31888dafcd61c0499b1019e0e859c
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1119232
milestone37.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 1119232 - Fix a warning for the usage of the uninitialized gc member in JSRuntime's constructor; r=jandem clang emits the following warning on this code: warning: field 'gc' is uninitialized when used here [-Wuninitialized] The warning is not an indication of a real bug since we're just taking the store buffer's address, but we may as well silence it.
js/src/jspubtd.h
js/src/vm/Runtime.cpp
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -141,31 +141,36 @@ struct Runtime
 {
     /* Restrict zone access during Minor GC. */
     bool needsIncrementalBarrier_;
 
   private:
     js::gc::StoreBuffer *gcStoreBufferPtr_;
 
   public:
-    explicit Runtime(js::gc::StoreBuffer *storeBuffer)
+    Runtime()
       : needsIncrementalBarrier_(false)
-      , gcStoreBufferPtr_(storeBuffer)
+      , gcStoreBufferPtr_(nullptr)
     {}
 
     bool needsIncrementalBarrier() const {
         return needsIncrementalBarrier_;
     }
 
     js::gc::StoreBuffer *gcStoreBufferPtr() { return gcStoreBufferPtr_; }
 
     static JS::shadow::Runtime *asShadowRuntime(JSRuntime *rt) {
         return reinterpret_cast<JS::shadow::Runtime*>(rt);
     }
 
+  protected:
+    void setGCStoreBufferPtr(js::gc::StoreBuffer *storeBuffer) {
+        gcStoreBufferPtr_ = storeBuffer;
+    }
+
     /* Allow inlining of PersistentRooted constructors and destructors. */
   private:
     template <typename Referent> friend class JS::PersistentRooted;
     friend void js::gc::MarkPersistentRootedChains(JSTracer *);
     friend void js::gc::FinishPersistentRootedChains(JSRuntime *rt);
 
     mozilla::LinkedList<PersistentRootedFunction> functionPersistentRooteds;
     mozilla::LinkedList<PersistentRootedId>       idPersistentRooteds;
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -125,18 +125,17 @@ static const JSWrapObjectCallbacks Defau
 
 static size_t
 ReturnZeroSize(const void *p)
 {
     return 0;
 }
 
 JSRuntime::JSRuntime(JSRuntime *parentRuntime)
-  : JS::shadow::Runtime(&gc.storeBuffer),
-    mainThread(this),
+  : mainThread(this),
     parentRuntime(parentRuntime),
     interrupt_(false),
     interruptPar_(false),
     telemetryCallback(nullptr),
     handlingSignal(false),
     interruptCallback(nullptr),
     exclusiveAccessLock(nullptr),
     exclusiveAccessOwner(nullptr),
@@ -225,16 +224,18 @@ JSRuntime::JSRuntime(JSRuntime *parentRu
     parallelParsingEnabled_(true),
 #ifdef DEBUG
     enteredPolicy(nullptr),
 #endif
     largeAllocationFailureCallback(nullptr),
     oomCallback(nullptr),
     debuggerMallocSizeOf(ReturnZeroSize)
 {
+    setGCStoreBufferPtr(&gc.storeBuffer);
+
     liveRuntimesCount++;
 
     /* Initialize infallibly first, so we can goto bad and JS_DestroyRuntime. */
     JS_INIT_CLIST(&onNewGlobalObjectWatchers);
 
     PodArrayZero(nativeStackQuota);
     PodZero(&asmJSCacheOps);
 }