Bug 1105974 - Fix more clang/gcc and MSVC warnings in js/src/asmjs and js/src/jit. r=jandem
authorChris Peterson <cpeterson@mozilla.com>
Thu, 27 Nov 2014 11:29:32 -0800
changeset 244114 99a49bcc523dd4dfa89114732d35bae34475e3d5
parent 244099 b68cac7a8a91f2de14db9617ad7e8c9cfacb39ef
child 244115 9107df18cdd9de3c58bf5a3f9266bdc1c029fc6c
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
bugs1105974
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 1105974 - Fix more clang/gcc and MSVC warnings in js/src/asmjs and js/src/jit. r=jandem
js/src/asmjs/AsmJSFrameIterator.cpp
js/src/jit/BaselineBailouts.cpp
js/src/jit/JitcodeMap.cpp
js/src/jit/ParallelFunctions.cpp
js/src/jit/arm/Assembler-arm.cpp
js/src/jit/arm/Lowering-arm.cpp
js/src/jit/x86/Lowering-x86.cpp
--- a/js/src/asmjs/AsmJSFrameIterator.cpp
+++ b/js/src/asmjs/AsmJSFrameIterator.cpp
@@ -106,33 +106,39 @@ AsmJSFrameIterator::computeLine(uint32_t
 
 /*****************************************************************************/
 // Prologue/epilogue code generation
 
 // These constants reflect statically-determined offsets in the profiling
 // prologue/epilogue. The offsets are dynamically asserted during code
 // generation.
 #if defined(JS_CODEGEN_X64)
+# if defined(DEBUG)
 static const unsigned PushedRetAddr = 0;
+# endif
 static const unsigned PushedFP = 10;
 static const unsigned StoredFP = 14;
 #elif defined(JS_CODEGEN_X86)
+# if defined(DEBUG)
 static const unsigned PushedRetAddr = 0;
+# endif
 static const unsigned PushedFP = 8;
 static const unsigned StoredFP = 11;
 #elif defined(JS_CODEGEN_ARM)
 static const unsigned PushedRetAddr = 4;
 static const unsigned PushedFP = 16;
 static const unsigned StoredFP = 20;
 #elif defined(JS_CODEGEN_MIPS)
 static const unsigned PushedRetAddr = 8;
 static const unsigned PushedFP = 24;
 static const unsigned StoredFP = 28;
 #elif defined(JS_CODEGEN_NONE)
+# if defined(DEBUG)
 static const unsigned PushedRetAddr = 0;
+# endif
 static const unsigned PushedFP = 1;
 static const unsigned StoredFP = 1;
 #else
 # error "Unknown architecture!"
 #endif
 
 static void
 PushRetAddr(MacroAssembler &masm)
@@ -697,9 +703,8 @@ AsmJSProfilingFrameIterator::label() con
       case AsmJSModule::CodeRange::SlowFFI:   return slowFFIDescription;
       case AsmJSModule::CodeRange::Interrupt: return interruptDescription;
       case AsmJSModule::CodeRange::Inline:    return "inline stub (in asm.js)";
       case AsmJSModule::CodeRange::Thunk:     return BuiltinToName(codeRange->thunkTarget());
     }
 
     MOZ_CRASH("Bad exit kind");
 }
-
--- a/js/src/jit/BaselineBailouts.cpp
+++ b/js/src/jit/BaselineBailouts.cpp
@@ -410,22 +410,24 @@ class SnapshotIteratorForBailout : publi
         // Under a bailout, there is no need to invalidate the frame after
         // evaluating the recover instruction, as the invalidation is only
         // needed to cause of the frame which has been introspected.
         MaybeReadFallback recoverBailout(cx, activation_, &iter_, MaybeReadFallback::Fallback_DoNothing);
         return initInstructionResults(recoverBailout);
     }
 };
 
+#ifdef DEBUG
 static inline bool
 IsInlinableFallback(ICFallbackStub *icEntry)
 {
     return icEntry->isCall_Fallback() || icEntry->isGetProp_Fallback() ||
            icEntry->isSetProp_Fallback();
 }
+#endif
 
 static inline void*
 GetStubReturnAddress(JSContext *cx, jsbytecode *pc)
 {
     if (IsGetPropPC(pc))
         return cx->compartment()->jitCompartment()->baselineGetPropReturnAddr();
     if (IsSetPropPC(pc))
         return cx->compartment()->jitCompartment()->baselineSetPropReturnAddr();
--- a/js/src/jit/JitcodeMap.cpp
+++ b/js/src/jit/JitcodeMap.cpp
@@ -308,33 +308,33 @@ JitcodeRegionEntry::ReadDelta(CompactBuf
     //  NNNN-NNNN NNNB-BBBB BBBB-B011
     const uint32_t thirdByte = reader.readByte();
     if ((firstByte & ENC3_MASK) == ENC3_MASK_VAL) {
         uint32_t encVal = firstByte | secondByte << 8 | thirdByte << 16;
         *nativeDelta = encVal >> ENC3_NATIVE_DELTA_SHIFT;
 
         uint32_t pcDeltaU = (encVal & ENC3_PC_DELTA_MASK) >> ENC3_PC_DELTA_SHIFT;
         // Fix sign if necessary.
-        if (pcDeltaU > ENC3_PC_DELTA_MAX)
+        if (pcDeltaU > static_cast<uint32_t>(ENC3_PC_DELTA_MAX))
             pcDeltaU |= ~ENC3_PC_DELTA_MAX;
         *pcDelta = pcDeltaU;
         MOZ_ASSERT(*pcDelta != 0);
         MOZ_ASSERT_IF(*nativeDelta == 0, *pcDelta <= 0);
         return;
     }
 
     //  NNNN-NNNN NNNN-NNNN BBBB-BBBB BBBB-B111
     MOZ_ASSERT((firstByte & ENC4_MASK) == ENC4_MASK_VAL);
     const uint32_t fourthByte = reader.readByte();
     uint32_t encVal = firstByte | secondByte << 8 | thirdByte << 16 | fourthByte << 24;
     *nativeDelta = encVal >> ENC4_NATIVE_DELTA_SHIFT;
 
     uint32_t pcDeltaU = (encVal & ENC4_PC_DELTA_MASK) >> ENC4_PC_DELTA_SHIFT;
     // fix sign if necessary
-    if (pcDeltaU > ENC4_PC_DELTA_MAX)
+    if (pcDeltaU > static_cast<uint32_t>(ENC4_PC_DELTA_MAX))
         pcDeltaU |= ~ENC4_PC_DELTA_MAX;
     *pcDelta = pcDeltaU;
 
     MOZ_ASSERT(*pcDelta != 0);
     MOZ_ASSERT_IF(*nativeDelta == 0, *pcDelta <= 0);
 }
 
 /* static */ uint32_t
--- a/js/src/jit/ParallelFunctions.cpp
+++ b/js/src/jit/ParallelFunctions.cpp
@@ -275,30 +275,30 @@ jit::StringToNumberPar(ForkJoinContext *
 do {                                                                            \
     /* Optimize for two int-tagged operands (typical loop control). */          \
     if (lhs.isInt32() && rhs.isInt32()) {                                       \
         *res = (lhs.toInt32() OP rhs.toInt32()) == EXPECTED;                    \
     } else if (lhs.isNumber() && rhs.isNumber()) {                              \
         double l = lhs.toNumber(), r = rhs.toNumber();                          \
         *res = (l OP r) == EXPECTED;                                            \
     } else if (lhs.isBoolean() && rhs.isBoolean()) {                            \
-        bool l = lhs.toBoolean();                                               \
-        bool r = rhs.toBoolean();                                               \
+        int l = lhs.toBoolean() ? 1 : 0;                                        \
+        int r = rhs.toBoolean() ? 1 : 0;                                        \
         *res = (l OP r) == EXPECTED;                                            \
     } else if (lhs.isBoolean() && rhs.isNumber()) {                             \
-        bool l = lhs.toBoolean();                                               \
+        double l = lhs.toBoolean() ? 1.0 : 0.0;                                 \
         double r = rhs.toNumber();                                              \
         *res = (l OP r) == EXPECTED;                                            \
     } else if (lhs.isNumber() && rhs.isBoolean()) {                             \
         double l = lhs.toNumber();                                              \
-        bool r = rhs.toBoolean();                                               \
+        double r = lhs.toBoolean() ? 1.0 : 0.0;                                 \
         *res = (l OP r) == EXPECTED;                                            \
     } else {                                                                    \
         int32_t vsZero;                                                         \
-        if (!CompareMaybeStringsPar(cx, lhs, rhs, &vsZero))                  \
+        if (!CompareMaybeStringsPar(cx, lhs, rhs, &vsZero))                     \
             return false;                                                       \
         *res = (vsZero OP 0) == EXPECTED;                                       \
     }                                                                           \
     return true;                                                                \
 } while(0)
 
 static bool
 CompareStringsPar(ForkJoinContext *cx, JSString *left, JSString *right, int32_t *res)
--- a/js/src/jit/arm/Assembler-arm.cpp
+++ b/js/src/jit/arm/Assembler-arm.cpp
@@ -2879,35 +2879,37 @@ Assembler::BailoutTableStart(uint8_t *co
 void Assembler::UpdateBoundsCheck(uint32_t heapSize, Instruction *inst)
 {
     MOZ_ASSERT(inst->is<InstCMP>());
     InstCMP *cmp = inst->as<InstCMP>();
 
     Register index;
     cmp->extractOp1(&index);
 
+#ifdef DEBUG
     Operand2 op = cmp->extractOp2();
     MOZ_ASSERT(op.isImm8());
+#endif
 
     Imm8 imm8 = Imm8(heapSize);
     MOZ_ASSERT(!imm8.invalid);
 
     *inst = InstALU(InvalidReg, index, imm8, OpCmp, SetCond, Always);
     // NOTE: we don't update the Auto Flush Cache!  this function is currently
     // only called from within AsmJSModule::patchHeapAccesses, which does that
     // for us. Don't call this!
 }
 
 InstructionIterator::InstructionIterator(Instruction *i_) : i(i_)
 {
     // Work around pools with an artificial pool guard and around nop-fill.
     i = i->skipPool();
 }
+
 Assembler *Assembler::Dummy = nullptr;
-
 uint32_t Assembler::NopFill = 0;
 
 uint32_t
 Assembler::GetNopFill()
 {
     static bool isSet = false;
     if (!isSet) {
         char *fillStr = getenv("ARM_ASM_NOP_FILL");
--- a/js/src/jit/arm/Lowering-arm.cpp
+++ b/js/src/jit/arm/Lowering-arm.cpp
@@ -497,19 +497,18 @@ bool
 LIRGeneratorARM::visitAsmJSLoadHeap(MAsmJSLoadHeap *ins)
 {
     MDefinition *ptr = ins->ptr();
     MOZ_ASSERT(ptr->type() == MIRType_Int32);
     LAllocation ptrAlloc;
 
     // For the ARM it is best to keep the 'ptr' in a register if a bounds check is needed.
     if (ptr->isConstant() && !ins->needsBoundsCheck()) {
-        int32_t ptrValue = ptr->toConstant()->value().toInt32();
         // A bounds check is only skipped for a positive index.
-        MOZ_ASSERT(ptrValue >= 0);
+        MOZ_ASSERT(ptr->toConstant()->value().toInt32() >= 0);
         ptrAlloc = LAllocation(ptr->toConstant()->vp());
     } else
         ptrAlloc = useRegisterAtStart(ptr);
 
     return define(new(alloc()) LAsmJSLoadHeap(ptrAlloc), ins);
 }
 
 bool
--- a/js/src/jit/x86/Lowering-x86.cpp
+++ b/js/src/jit/x86/Lowering-x86.cpp
@@ -221,37 +221,35 @@ bool
 LIRGeneratorX86::visitAsmJSLoadHeap(MAsmJSLoadHeap *ins)
 {
     MDefinition *ptr = ins->ptr();
     LAllocation ptrAlloc;
     MOZ_ASSERT(ptr->type() == MIRType_Int32);
 
     // For the x86 it is best to keep the 'ptr' in a register if a bounds check is needed.
     if (ptr->isConstant() && !ins->needsBoundsCheck()) {
-        int32_t ptrValue = ptr->toConstant()->value().toInt32();
         // A bounds check is only skipped for a positive index.
-        MOZ_ASSERT(ptrValue >= 0);
+        MOZ_ASSERT(ptr->toConstant()->value().toInt32() >= 0);
         ptrAlloc = LAllocation(ptr->toConstant()->vp());
     } else {
         ptrAlloc = useRegisterAtStart(ptr);
     }
     LAsmJSLoadHeap *lir = new(alloc()) LAsmJSLoadHeap(ptrAlloc);
     return define(lir, ins);
 }
 
 bool
 LIRGeneratorX86::visitAsmJSStoreHeap(MAsmJSStoreHeap *ins)
 {
     MDefinition *ptr = ins->ptr();
     LAsmJSStoreHeap *lir;
     MOZ_ASSERT(ptr->type() == MIRType_Int32);
 
     if (ptr->isConstant() && !ins->needsBoundsCheck()) {
-        int32_t ptrValue = ptr->toConstant()->value().toInt32();
-        MOZ_ASSERT(ptrValue >= 0);
+        MOZ_ASSERT(ptr->toConstant()->value().toInt32() >= 0);
         LAllocation ptrAlloc = LAllocation(ptr->toConstant()->vp());
         switch (ins->viewType()) {
           case AsmJSHeapAccess::Int8: case AsmJSHeapAccess::Uint8:
             // See comment below.
             lir = new(alloc()) LAsmJSStoreHeap(ptrAlloc, useFixed(ins->value(), eax));
             break;
           case AsmJSHeapAccess::Int16: case AsmJSHeapAccess::Uint16:
           case AsmJSHeapAccess::Int32: case AsmJSHeapAccess::Uint32: