Bug 1125371 - Silence some GCC-only warnings about uninitialized varaibles when building with --enable-optimize. r=jandem.
authorJason Orendorff <jorendorff@mozilla.com>
Fri, 23 Jan 2015 16:05:38 -0600
changeset 225914 ead7aa880dbe3c021242b5cd1333945e5937c501
parent 225913 780d7bb5eb822d16e34233005dd71fce07a0586c
child 225915 a2f4d6a4a23b594b3be9f88bf0a56cb25e71e220
push id28179
push usercbook@mozilla.com
push dateTue, 27 Jan 2015 14:24:11 +0000
treeherdermozilla-central@232401a6d1cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1125371
milestone38.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 1125371 - Silence some GCC-only warnings about uninitialized varaibles when building with --enable-optimize. r=jandem.
js/src/asmjs/AsmJSModule.cpp
js/src/asmjs/AsmJSValidate.cpp
js/src/frontend/BytecodeEmitter.cpp
js/src/jit/BaselineIC.cpp
js/src/jit/IonBuilder.cpp
js/src/jit/LiveRangeAllocator.cpp
js/src/jit/MCallOptimize.cpp
js/src/jit/x64/Lowering-x64.cpp
js/src/jsstr.cpp
js/src/vm/String.cpp
--- a/js/src/asmjs/AsmJSModule.cpp
+++ b/js/src/asmjs/AsmJSModule.cpp
@@ -1914,23 +1914,23 @@ struct PropertyNameWrapper
 class ModuleChars
 {
   protected:
     uint32_t isFunCtor_;
     Vector<PropertyNameWrapper, 0, SystemAllocPolicy> funCtorArgs_;
 
   public:
     static uint32_t beginOffset(AsmJSParser &parser) {
-      return parser.pc->maybeFunction->pn_pos.begin;
+        return parser.pc->maybeFunction->pn_pos.begin;
     }
 
     static uint32_t endOffset(AsmJSParser &parser) {
-      TokenPos pos;
-      MOZ_ALWAYS_TRUE(parser.tokenStream.peekTokenPos(&pos));
-      return pos.end;
+        TokenPos pos(0, 0);  // initialize to silence GCC warning
+        MOZ_ALWAYS_TRUE(parser.tokenStream.peekTokenPos(&pos));
+        return pos.end;
     }
 };
 
 class ModuleCharsForStore : ModuleChars
 {
     uint32_t uncompressedSize_;
     uint32_t compressedSize_;
     Vector<char, 0, SystemAllocPolicy> compressedBuffer_;
--- a/js/src/asmjs/AsmJSValidate.cpp
+++ b/js/src/asmjs/AsmJSValidate.cpp
@@ -630,16 +630,17 @@ class RetType
 
   private:
     Which which_;
 
   public:
     RetType() : which_(Which(-1)) {}
     MOZ_IMPLICIT RetType(Which w) : which_(w) {}
     MOZ_IMPLICIT RetType(AsmJSCoercion coercion) {
+        which_ = Which(-1);  // initialize to silence GCC warning
         switch (coercion) {
           case AsmJS_ToInt32: which_ = Signed; break;
           case AsmJS_ToNumber: which_ = Double; break;
           case AsmJS_FRound: which_ = Float; break;
           case AsmJS_ToInt32x4: which_ = Int32x4; break;
           case AsmJS_ToFloat32x4: which_ = Float32x4; break;
         }
     }
@@ -3026,17 +3027,17 @@ class FunctionCompiler
         if (inDeadCode()) {
             *def = nullptr;
             return true;
         }
 
         uint32_t line, column;
         m_.tokenStream().srcCoords.lineNumAndColumnIndex(call.node_->pn_pos.begin, &line, &column);
 
-        CallSiteDesc::Kind kind;
+        CallSiteDesc::Kind kind = CallSiteDesc::Kind(-1);  // initialize to silence GCC warning
         switch (callee.which()) {
           case MAsmJSCall::Callee::Internal: kind = CallSiteDesc::Relative; break;
           case MAsmJSCall::Callee::Dynamic:  kind = CallSiteDesc::Register; break;
           case MAsmJSCall::Callee::Builtin:  kind = CallSiteDesc::Register; break;
         }
 
         MAsmJSCall *ins = MAsmJSCall::New(alloc(), CallSiteDesc(line, column, kind), callee,
                                           call.regArgs_, returnType, call.spIncrement_);
@@ -7287,17 +7288,17 @@ CheckChangeHeap(ModuleCompiler &m, Parse
     if (!bufferName)
         return m.fail(fn, "to change heaps, the module must have a buffer argument");
 
     ParseNode *cond = TernaryKid1(stmtIter);
     ParseNode *thenStmt = TernaryKid2(stmtIter);
     if (ParseNode *elseStmt = TernaryKid3(stmtIter))
         return m.fail(elseStmt, "unexpected else statement");
 
-    uint32_t mask, min, max;
+    uint32_t mask, min = 0, max;  // initialize min to silence GCC warning
     if (!CheckHeapLengthCondition(m, cond, newBufferName, &mask, &min, &max))
         return false;
 
     if (!CheckReturnBoolLiteral(m, thenStmt, false))
         return false;
 
     stmtIter = NextNonEmptyStatement(stmtIter);
 
@@ -7411,17 +7412,17 @@ static bool
 CheckFunction(ModuleCompiler &m, LifoAlloc &lifo, MIRGenerator **mir, ModuleCompiler::Func **funcOut)
 {
     int64_t before = PRMJ_Now();
 
     // asm.js modules can be quite large when represented as parse trees so pop
     // the backing LifoAlloc after parsing/compiling each function.
     AsmJSParser::Mark mark = m.parser().mark();
 
-    ParseNode *fn;
+    ParseNode *fn = nullptr;  // initialize to silence GCC warning
     if (!ParseFunction(m, &fn))
         return false;
 
     if (!CheckFunctionHead(m, fn))
         return false;
 
     if (m.tryOnceToValidateChangeHeap()) {
         bool validated;
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -3096,16 +3096,17 @@ frontend::EmitFunctionScript(ExclusiveCo
         bce->switchToProlog();
         if (Emit1(cx, bce, JSOP_ARGUMENTS) < 0)
             return false;
         InternalBindingsHandle bindings(bce->script, &bce->script->bindings);
         BindingIter bi = Bindings::argumentsBinding(cx, bindings);
         if (bce->script->bindingIsAliased(bi)) {
             ScopeCoordinate sc;
             sc.setHops(0);
+            sc.setSlot(0);  // initialize to silence GCC warning
             JS_ALWAYS_TRUE(LookupAliasedNameSlot(bce, bce->script, cx->names().arguments, &sc));
             if (!EmitAliasedVarOp(cx, JSOP_SETALIASEDVAR, sc, DontCheckLexical, bce))
                 return false;
         } else {
             if (!EmitUnaliasedVarOp(cx, JSOP_SETLOCAL, bi.localIndex(), DontCheckLexical, bce))
                 return false;
         }
         if (Emit1(cx, bce, JSOP_POP) < 0)
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -7528,16 +7528,18 @@ ICGetPropCallDOMProxyNativeCompiler::get
 
     Value expandoSlot = GetProxyExtra(proxy_, GetDOMProxyExpandoSlot());
     RootedShape expandoShape(cx, nullptr);
     ExpandoAndGeneration *expandoAndGeneration;
     int32_t generation;
     Value expandoVal;
     if (kind == ICStub::GetProp_CallDOMProxyNative) {
         expandoVal = expandoSlot;
+        expandoAndGeneration = nullptr;  // initialize to silence GCC warning
+        generation = 0;  // initialize to silence GCC warning
     } else {
         MOZ_ASSERT(kind == ICStub::GetProp_CallDOMProxyWithGenerationNative);
         MOZ_ASSERT(!expandoSlot.isObject() && !expandoSlot.isUndefined());
         expandoAndGeneration = (ExpandoAndGeneration*)expandoSlot.toPrivate();
         expandoVal = expandoAndGeneration->expando;
         generation = expandoAndGeneration->generation;
     }
 
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -7547,17 +7547,17 @@ IonBuilder::pushReferenceLoadFromTypedOb
     // Find location within the owner object.
     MDefinition *elements, *scaledOffset;
     int32_t adjustment;
     size_t alignment = ReferenceTypeDescr::alignment(type);
     loadTypedObjectElements(typedObj, byteOffset, alignment, &elements, &scaledOffset, &adjustment);
 
     types::TemporaryTypeSet *observedTypes = bytecodeTypes(pc);
 
-    MInstruction *load;
+    MInstruction *load = nullptr;  // initialize to silence GCC warning
     BarrierKind barrier = PropertyReadNeedsTypeBarrier(analysisContext, constraints(),
                                                        typedObj, name, observedTypes);
 
     switch (type) {
       case ReferenceTypeDescr::TYPE_ANY: {
         // Make sure the barrier reflects the possibility of reading undefined.
         bool bailOnUndefined = barrier == BarrierKind::NoBarrier &&
                                !observedTypes->hasType(types::Type::UndefinedType());
@@ -11629,17 +11629,17 @@ IonBuilder::storeReferenceTypedObjectVal
     }
 
     // Find location within the owner object.
     MDefinition *elements, *scaledOffset;
     int32_t adjustment;
     size_t alignment = ReferenceTypeDescr::alignment(type);
     loadTypedObjectElements(typedObj, byteOffset, alignment, &elements, &scaledOffset, &adjustment);
 
-    MInstruction *store;
+    MInstruction *store = nullptr;  // initialize to silence GCC warning
     switch (type) {
       case ReferenceTypeDescr::TYPE_ANY:
         if (NeedsPostBarrier(info(), value))
             current->add(MPostWriteBarrier::New(alloc(), typedObj, value));
         store = MStoreElement::New(alloc(), elements, scaledOffset, value, false, adjustment);
         store->toStoreElement()->setNeedsBarrier();
         break;
       case ReferenceTypeDescr::TYPE_OBJECT:
--- a/js/src/jit/LiveRangeAllocator.cpp
+++ b/js/src/jit/LiveRangeAllocator.cpp
@@ -42,17 +42,17 @@ Requirement::toString() const
 {
 #ifdef DEBUG
     // Not reentrant!
     static char buf[1000];
 
     char *cursor = buf;
     char *end = cursor + sizeof(buf);
 
-    int n;
+    int n = -1;  // initialize to silence GCC warning
     switch (kind()) {
       case NONE:
         return "none";
       case REGISTER:
         n = JS_snprintf(cursor, end - cursor, "r");
         break;
       case FIXED:
         n = JS_snprintf(cursor, end - cursor, "%s", allocation().toString());
--- a/js/src/jit/MCallOptimize.cpp
+++ b/js/src/jit/MCallOptimize.cpp
@@ -2569,17 +2569,17 @@ IonBuilder::inlineConstructTypedObject(C
 
 IonBuilder::InliningStatus
 IonBuilder::inlineConstructSimdObject(CallInfo &callInfo, SimdTypeDescr *descr)
 {
     if (callInfo.argc() == 1)
         return InliningStatus_NotInlined;
 
     // Generic constructor of SIMD valuesX4.
-    MIRType simdType;
+    MIRType simdType = MIRType(-1);  // initialize to silence GCC warning
     switch (descr->type()) {
       case SimdTypeDescr::TYPE_INT32:
         simdType = MIRType_Int32x4;
         break;
       case SimdTypeDescr::TYPE_FLOAT32:
         simdType = MIRType_Float32x4;
         break;
       case SimdTypeDescr::TYPE_FLOAT64:
--- a/js/src/jit/x64/Lowering-x64.cpp
+++ b/js/src/jit/x64/Lowering-x64.cpp
@@ -166,17 +166,17 @@ LIRGeneratorX64::visitAsmJSStoreHeap(MAs
     // offset in the addressing mode would not wrap back into the protected area
     // reserved for the heap. For simplicity (and since we don't care about
     // getting maximum performance in these cases) only allow constant
     // opererands when skipping bounds checks.
     LAllocation ptrAlloc = ins->needsBoundsCheck()
                            ? useRegisterAtStart(ptr)
                            : useRegisterOrNonNegativeConstantAtStart(ptr);
 
-    LAsmJSStoreHeap *lir;
+    LAsmJSStoreHeap *lir = nullptr;  // initialize to silence GCC warning
     switch (ins->viewType()) {
       case Scalar::Int8:
       case Scalar::Uint8:
       case Scalar::Int16:
       case Scalar::Uint16:
       case Scalar::Int32:
       case Scalar::Uint32:
         lir = new(alloc()) LAsmJSStoreHeap(ptrAlloc, useRegisterOrConstantAtStart(ins->value()));
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -177,17 +177,17 @@ str_escape(JSContext *cx, unsigned argc,
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     JSLinearString *str = ArgToRootedString(cx, args, 0);
     if (!str)
         return false;
 
     ScopedJSFreePtr<Latin1Char> newChars;
-    uint32_t newLength;
+    uint32_t newLength = 0;  // initialize to silence GCC warning
     if (str->hasLatin1Chars()) {
         AutoCheckCannotGC nogc;
         newChars = Escape(cx, str->latin1Chars(nogc), str->length(), &newLength);
     } else {
         AutoCheckCannotGC nogc;
         newChars = Escape(cx, str->twoByteChars(nogc), str->length(), &newLength);
     }
 
--- a/js/src/vm/String.cpp
+++ b/js/src/vm/String.cpp
@@ -480,18 +480,18 @@ js::ConcatStrings(ExclusiveContext *cx,
     if (!JSString::validateLength(cx, wholeLength))
         return nullptr;
 
     bool isLatin1 = left->hasLatin1Chars() && right->hasLatin1Chars();
     bool canUseInline = isLatin1
                         ? JSInlineString::lengthFits<Latin1Char>(wholeLength)
                         : JSInlineString::lengthFits<char16_t>(wholeLength);
     if (canUseInline && cx->isJSContext()) {
-        Latin1Char *latin1Buf;
-        char16_t *twoByteBuf;
+        Latin1Char *latin1Buf = nullptr;  // initialize to silence GCC warning
+        char16_t *twoByteBuf = nullptr;  // initialize to silence GCC warning
         JSInlineString *str = isLatin1
             ? AllocateInlineString<allowGC>(cx, wholeLength, &latin1Buf)
             : AllocateInlineString<allowGC>(cx, wholeLength, &twoByteBuf);
         if (!str)
             return nullptr;
 
         AutoCheckCannotGC nogc;
         JSLinearString *leftLinear = left->ensureLinear(cx);