Bug 553032 - use MOZ_FORMAT_PRINTF in js; r?evilpie draft
authorTom Tromey <tom@tromey.com>
Tue, 11 Oct 2016 12:44:40 -0600
changeset 427637 e5db2b19e3f3eb35aeea9716283a05ddfd85ade2
parent 427636 1e000e4846678714cba4cc3f25239993bc97f24a
child 427638 50fb2a9233c6f3e7886b88383873b0b3494df7e4
push id33071
push userbmo:ttromey@mozilla.com
push dateThu, 20 Oct 2016 17:13:29 +0000
reviewersevilpie
bugs553032
milestone52.0a1
Bug 553032 - use MOZ_FORMAT_PRINTF in js; r?evilpie MozReview-Commit-ID: DD3DJRkOxmC
caps/nsScriptSecurityManager.cpp
dom/plugins/base/nsJSNPRuntime.cpp
js/src/asmjs/AsmJS.cpp
js/src/asmjs/WasmBinary.cpp
js/src/asmjs/WasmBinary.h
js/src/asmjs/WasmBinaryIterator.h
js/src/asmjs/WasmCode.cpp
js/src/asmjs/WasmTextToBinary.cpp
js/src/devtools/gctrace/gcstats.cpp
js/src/irregexp/RegExpEngine.cpp
js/src/jit/BacktrackingAllocator.cpp
js/src/jit/BaselineBailouts.cpp
js/src/jit/BaselineCompiler.cpp
js/src/jit/BaselineDebugModeOSR.cpp
js/src/jit/BaselineIC.cpp
js/src/jit/CodeGenerator.cpp
js/src/jit/FlowAliasAnalysis.cpp
js/src/jit/Ion.cpp
js/src/jit/IonAnalysis.cpp
js/src/jit/IonBuilder.h
js/src/jit/JSONSpewer.cpp
js/src/jit/JSONSpewer.h
js/src/jit/JitSpewer.h
js/src/jit/MIRGenerator.h
js/src/jit/OptimizationTracking.cpp
js/src/jit/Recover.cpp
js/src/jit/Safepoints.cpp
js/src/jit/SharedIC.cpp
js/src/jit/SharedIC.h
js/src/jit/ValueNumbering.cpp
js/src/jit/arm/Assembler-arm.h
js/src/jit/arm/disasm/Disasm-arm.cpp
js/src/jit/shared/CodeGenerator-shared.cpp
js/src/jit/shared/IonAssemblerBufferWithConstantPools.h
js/src/jsapi.h
js/src/jsobj.cpp
js/src/jsopcode.cpp
js/src/jsprf.cpp
js/src/jsprf.h
js/src/moz.build
js/src/shell/js.cpp
js/src/shell/jsoptparse.cpp
js/src/shell/jsoptparse.h
js/src/shell/moz.build
js/src/vm/CodeCoverage.cpp
js/src/vm/Printer.h
js/src/vm/TraceLoggingGraph.cpp
js/src/vm/TypeInference.cpp
js/src/vm/TypeInference.h
js/xpconnect/loader/mozJSComponentLoader.cpp
js/xpconnect/src/XPCThrower.cpp
js/xpconnect/src/XPCWrappedJSClass.cpp
js/xpconnect/src/moz.build
js/xpconnect/wrappers/AccessCheck.cpp
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -149,18 +149,18 @@ GetPrincipalDomainOrigin(nsIPrincipal* a
 
 inline void SetPendingExceptionASCII(JSContext *cx, const char *aMsg)
 {
     JS_ReportErrorASCII(cx, "%s", aMsg);
 }
 
 inline void SetPendingException(JSContext *cx, const char16_t *aMsg)
 {
-    // FIXME: Need to convert to UTF-8 (bug XXX).
-    JS_ReportErrorLatin1(cx, "%hs", aMsg);
+    NS_ConvertUTF16toUTF8 msg(aMsg);
+    JS_ReportErrorUTF8(cx, "%s", msg.get());
 }
 
 // Helper class to get stuff from the ClassInfo and not waste extra time with
 // virtual method calls for things it has already gotten
 class ClassInfoData
 {
 public:
     ClassInfoData(nsIClassInfo *aClassInfo, const char *aName)
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -633,17 +633,17 @@ ThrowJSExceptionASCII(JSContext *cx, con
 
     if (str) {
       JS::Rooted<JS::Value> exn(cx, JS::StringValue(str));
       ::JS_SetPendingException(cx, exn);
     }
 
     PopException();
   } else {
-    ::JS_ReportErrorASCII(cx, message);
+    ::JS_ReportErrorASCII(cx, "%s", message);
   }
 }
 
 static bool
 ReportExceptionIfPending(JSContext *cx)
 {
   const char *ex = PeekException();
 
--- a/js/src/asmjs/AsmJS.cpp
+++ b/js/src/asmjs/AsmJS.cpp
@@ -2245,25 +2245,25 @@ class MOZ_STACK_CLASS ModuleValidator
         MOZ_ASSERT(!hasAlreadyFailed());
         MOZ_ASSERT(errorOffset_ == UINT32_MAX);
         MOZ_ASSERT(fmt);
         errorOffset_ = offset;
         errorString_.reset(JS_vsmprintf(fmt, ap));
         return false;
     }
 
-    bool failfOffset(uint32_t offset, const char* fmt, ...) {
+    bool failfOffset(uint32_t offset, const char* fmt, ...) MOZ_FORMAT_PRINTF(3, 4) {
         va_list ap;
         va_start(ap, fmt);
         failfVAOffset(offset, fmt, ap);
         va_end(ap);
         return false;
     }
 
-    bool failf(ParseNode* pn, const char* fmt, ...) {
+    bool failf(ParseNode* pn, const char* fmt, ...) MOZ_FORMAT_PRINTF(3, 4) {
         va_list ap;
         va_start(ap, fmt);
         failfVAOffset(pn->pn_pos.begin, fmt, ap);
         va_end(ap);
         return false;
     }
 
     bool failNameOffset(uint32_t offset, const char* fmt, PropertyName* name) {
@@ -2939,17 +2939,17 @@ class MOZ_STACK_CLASS FunctionValidator
 
         return m_.mg().finishFuncDef(funcIndex, &fg_);
     }
 
     bool fail(ParseNode* pn, const char* str) {
         return m_.fail(pn, str);
     }
 
-    bool failf(ParseNode* pn, const char* fmt, ...) {
+    bool failf(ParseNode* pn, const char* fmt, ...) MOZ_FORMAT_PRINTF(3, 4) {
         va_list ap;
         va_start(ap, fmt);
         m_.failfVAOffset(pn->pn_pos.begin, fmt, ap);
         va_end(ap);
         return false;
     }
 
     bool failName(ParseNode* pn, const char* fmt, PropertyName* name) {
@@ -4715,17 +4715,18 @@ CheckCallArgs(FunctionValidator& f, Pars
     }
     return true;
 }
 
 static bool
 CheckSignatureAgainstExisting(ModuleValidator& m, ParseNode* usepn, const Sig& sig, const Sig& existing)
 {
     if (sig.args().length() != existing.args().length()) {
-        return m.failf(usepn, "incompatible number of arguments (%u here vs. %u before)",
+        return m.failf(usepn, "incompatible number of arguments (%" PRIuSIZE
+                       " here vs. %" PRIuSIZE " before)",
                        sig.args().length(), existing.args().length());
     }
 
     for (unsigned i = 0; i < sig.args().length(); i++) {
         if (sig.arg(i) != existing.arg(i)) {
             return m.failf(usepn, "incompatible type for argument %u: (%s here vs. %s before)", i,
                            ToCString(sig.arg(i)), ToCString(existing.arg(i)));
         }
--- a/js/src/asmjs/WasmBinary.cpp
+++ b/js/src/asmjs/WasmBinary.cpp
@@ -52,17 +52,17 @@ Decoder::fail(UniqueChars msg) {
 bool
 wasm::DecodePreamble(Decoder& d)
 {
     uint32_t u32;
     if (!d.readFixedU32(&u32) || u32 != MagicNumber)
         return d.fail("failed to match magic number");
 
     if (!d.readFixedU32(&u32) || u32 != EncodingVersion)
-        return d.fail("binary version 0x%lx does not match expected version 0x%lx",
+        return d.fail("binary version 0x%" PRIx32 " does not match expected version 0x%" PRIx32,
                       u32, EncodingVersion);
 
     return true;
 }
 
 bool
 wasm::EncodeLocalEntries(Encoder& e, const ValTypeVector& locals)
 {
@@ -146,29 +146,29 @@ wasm::DecodeLimits(Decoder& d, Limits* l
 {
     uint32_t flags;
     if (!d.readVarU32(&flags))
         return d.fail("expected flags");
 
     // TODO (bug 1310149): tighten this check (s/3/1) when the AngryBots demo
     // gets updated.
     if (flags & ~uint32_t(0x3))
-        return d.fail("unexpected bits set in flags: %lu", (flags & ~uint32_t(0x3)));
+        return d.fail("unexpected bits set in flags: %" PRIu32, (flags & ~uint32_t(0x3)));
 
     if (!d.readVarU32(&limits->initial))
         return d.fail("expected initial length");
 
     if (flags & 0x1) {
         uint32_t maximum;
         if (!d.readVarU32(&maximum))
             return d.fail("expected maximum length");
 
         if (limits->initial > maximum) {
             return d.fail("memory size minimum must not be greater than maximum; "
-                          "maximum length %lu is less than initial length %lu",
+                          "maximum length %" PRIu32 " is less than initial length %" PRIu32 ,
                           maximum, limits->initial);
         }
 
         limits->maximum.emplace(maximum);
     }
 
     return true;
 }
--- a/js/src/asmjs/WasmBinary.h
+++ b/js/src/asmjs/WasmBinary.h
@@ -773,17 +773,17 @@ class Decoder
     }
     explicit Decoder(const Bytes& bytes, UniqueChars* error = nullptr)
       : beg_(bytes.begin()),
         end_(bytes.end()),
         cur_(bytes.begin()),
         error_(error)
     {}
 
-    bool fail(const char* msg, ...);
+    bool fail(const char* msg, ...) MOZ_FORMAT_PRINTF(2, 3);
     bool fail(UniqueChars msg);
     void clearError() {
         if (error_)
             error_->reset();
     }
 
     bool done() const {
         MOZ_ASSERT(cur_ <= end_);
--- a/js/src/asmjs/WasmBinaryIterator.h
+++ b/js/src/asmjs/WasmBinaryIterator.h
@@ -720,17 +720,17 @@ ExprIter<Policy>::unrecognizedOpcode(Exp
 
     return fail(error.get());
 }
 
 template <typename Policy>
 bool
 ExprIter<Policy>::fail(const char* msg)
 {
-    return d_.fail(msg);
+    return d_.fail("%s", msg);
 }
 
 template <typename Policy>
 inline bool
 ExprIter<Policy>::pushControl(LabelKind kind, ExprType type, bool reachable)
 {
     return controlStack_.emplaceBack(kind, type, reachable, valueStack_.length());
 }
--- a/js/src/asmjs/WasmCode.cpp
+++ b/js/src/asmjs/WasmCode.cpp
@@ -791,18 +791,20 @@ Code::ensureProfilingState(JSContext* cx
                 continue;
 
             TwoByteName name(cx);
             if (!getFuncDefName(cx, codeRange.funcDefIndex(), &name))
                 return false;
             if (!name.append('\0'))
                 return false;
 
-            UniqueChars label(JS_smprintf("%hs (%s:%u)",
-                                          name.begin(),
+            TwoByteChars chars(name.begin(), name.length());
+            UniqueChars utf8Name(JS::CharsToNewUTF8CharsZ(nullptr, chars).c_str());
+            UniqueChars label(JS_smprintf("%s (%s:%u)",
+                                          utf8Name.get(),
                                           metadata_->filename.get(),
                                           codeRange.funcLineOrBytecode()));
             if (!label) {
                 ReportOutOfMemory(cx);
                 return false;
             }
 
             if (codeRange.funcDefIndex() >= funcLabels_.length()) {
--- a/js/src/asmjs/WasmTextToBinary.cpp
+++ b/js/src/asmjs/WasmTextToBinary.cpp
@@ -1483,17 +1483,17 @@ struct WasmParseContext
     WasmParseContext(const char16_t* text, LifoAlloc& lifo, UniqueChars* error)
       : ts(text, error),
         lifo(lifo),
         error(error),
         dtoaState(NewDtoaState())
     {}
 
     bool fail(const char* message) {
-        error->reset(JS_smprintf(message));
+        error->reset(js_strdup(message));
         return false;
     }
     ~WasmParseContext() {
         DestroyDtoaState(dtoaState);
     }
 };
 
 } // end anonymous namespace
@@ -3331,22 +3331,19 @@ class Resolver
         AstNameMap::Ptr p = map.lookup(ref.name());
         if (p) {
             ref.setIndex(p->value());
             return true;
         }
         return false;
     }
     bool failResolveLabel(const char* kind, AstName name) {
-        Vector<char16_t, 0, SystemAllocPolicy> nameWithNull;
-        if (!nameWithNull.append(name.begin(), name.length()))
-            return false;
-        if (!nameWithNull.append(0))
-            return false;
-        error_->reset(JS_smprintf("%s label '%hs' not found", kind, nameWithNull.begin()));
+        TwoByteChars chars(name.begin(), name.length());
+        UniqueChars utf8Chars(CharsToNewUTF8CharsZ(nullptr, chars).c_str());
+        error_->reset(JS_smprintf("%s label '%s' not found", kind, utf8Chars.get()));
         return false;
     }
 
   public:
     explicit Resolver(LifoAlloc& lifo, UniqueChars* error)
       : error_(error),
         varMap_(lifo),
         globalMap_(lifo),
--- a/js/src/devtools/gctrace/gcstats.cpp
+++ b/js/src/devtools/gctrace/gcstats.cpp
@@ -160,16 +160,17 @@ Array<uint64_t, MaxClasses> objectCountB
 std::vector<uint64_t> objectCountByType;
 Array<Array<uint64_t, MaxClasses>, HeapKinds> objectCountByHeapAndClass;
 Array<Array<Array<uint64_t, MaxLifetimeBins>, MaxClasses>, HeapKinds> objectCountByHeapClassAndLifetime;
 Array<Array<uint64_t, MaxLifetimeBins>, FinalizerKinds> heapObjectCountByFinalizerAndLifetime;
 Array<Array<uint64_t, MaxLifetimeBins>, MaxClasses> finalizedHeapObjectCountByClassAndLifetime;
 std::vector<Array<Array<uint64_t, MaxLifetimeBins>, HeapKinds> > objectCountByTypeHeapAndLifetime;
 
 static void
+MOZ_FORMAT_PRINTF(1, 2)
 die(const char* format, ...)
 {
     va_list va;
     va_start(va, format);
     vfprintf(stderr, format, va);
     fprintf(stderr, "\n");
     va_end(va);
     exit(1);
--- a/js/src/irregexp/RegExpEngine.cpp
+++ b/js/src/irregexp/RegExpEngine.cpp
@@ -1867,17 +1867,17 @@ irregexp::CompilePattern(JSContext* cx, 
     }
 
     if (node == nullptr)
         node = alloc.newInfallible<EndNode>(&alloc, EndNode::BACKTRACK);
 
     Analysis analysis(cx, ignore_case, is_ascii, unicode);
     analysis.EnsureAnalyzed(node);
     if (analysis.has_failed()) {
-        JS_ReportErrorASCII(cx, analysis.errorMessage());
+        JS_ReportErrorASCII(cx, "%s", analysis.errorMessage());
         return RegExpCode();
     }
 
     Maybe<jit::JitContext> ctx;
     Maybe<NativeRegExpMacroAssembler> native_assembler;
     Maybe<InterpretedRegExpMacroAssembler> interpreted_assembler;
 
     RegExpMacroAssembler* assembler;
--- a/js/src/jit/BacktrackingAllocator.cpp
+++ b/js/src/jit/BacktrackingAllocator.cpp
@@ -1240,17 +1240,17 @@ BacktrackingAllocator::tryAllocateNonFix
     MOZ_ASSERT(!*success);
     return true;
 }
 
 bool
 BacktrackingAllocator::processBundle(MIRGenerator* mir, LiveBundle* bundle)
 {
     if (JitSpewEnabled(JitSpew_RegAlloc)) {
-        JitSpew(JitSpew_RegAlloc, "Allocating %s [priority %lu] [weight %lu]",
+        JitSpew(JitSpew_RegAlloc, "Allocating %s [priority %" PRIuSIZE "] [weight %" PRIuSIZE "]",
                 bundle->toString().get(), computePriority(bundle), computeSpillWeight(bundle));
     }
 
     // A bundle can be processed by doing any of the following:
     //
     // - Assigning the bundle a register. The bundle cannot overlap any other
     //   bundle allocated for that physical register.
     //
@@ -1432,23 +1432,23 @@ BacktrackingAllocator::tryAllocateRegist
         // case of multiple conflicting sets keep track of the set with the
         // lowest maximum spill weight.
 
         // The #ifdef guards against "unused variable 'existing'" bustage.
 #ifdef JS_JITSPEW
         if (JitSpewEnabled(JitSpew_RegAlloc)) {
             if (aliasedConflicting.length() == 1) {
                 LiveBundle* existing = aliasedConflicting[0];
-                JitSpew(JitSpew_RegAlloc, "  %s collides with %s [weight %lu]",
+                JitSpew(JitSpew_RegAlloc, "  %s collides with %s [weight %" PRIuSIZE "]",
                         r.reg.name(), existing->toString().get(), computeSpillWeight(existing));
             } else {
                 JitSpew(JitSpew_RegAlloc, "  %s collides with the following", r.reg.name());
                 for (size_t i = 0; i < aliasedConflicting.length(); i++) {
                     LiveBundle* existing = aliasedConflicting[i];
-                    JitSpew(JitSpew_RegAlloc, "      %s [weight %lu]",
+                    JitSpew(JitSpew_RegAlloc, "      %s [weight %" PRIuSIZE "]",
                             existing->toString().get(), computeSpillWeight(existing));
                 }
             }
         }
 #endif
 
         if (conflicting.empty()) {
             if (!conflicting.appendAll(aliasedConflicting))
@@ -1477,17 +1477,17 @@ BacktrackingAllocator::tryAllocateRegist
     *success = true;
     return true;
 }
 
 bool
 BacktrackingAllocator::evictBundle(LiveBundle* bundle)
 {
     if (JitSpewEnabled(JitSpew_RegAlloc)) {
-        JitSpew(JitSpew_RegAlloc, "  Evicting %s [priority %lu] [weight %lu]",
+        JitSpew(JitSpew_RegAlloc, "  Evicting %s [priority %" PRIuSIZE "] [weight %" PRIuSIZE "]",
                 bundle->toString().get(), computePriority(bundle), computeSpillWeight(bundle));
     }
 
     AnyRegister reg(bundle->allocation().toRegister());
     PhysicalRegister& physical = registers[reg.code()];
     MOZ_ASSERT(physical.reg == reg && physical.allocatable);
 
     for (LiveRange::BundleLinkIterator iter = bundle->rangesBegin(); iter; iter++) {
@@ -2291,17 +2291,18 @@ LiveRange::toString() const
     return UniqueChars(buf);
 }
 
 UniqueChars
 LiveBundle::toString() const
 {
     AutoEnterOOMUnsafeRegion oomUnsafe;
 
-    char *buf = JS_smprintf("");
+    // Suppress -Wformat warning.
+    char *buf = JS_smprintf("%s", "");
 
     for (LiveRange::BundleLinkIterator iter = rangesBegin(); buf && iter; iter++) {
         buf = JS_sprintf_append(buf, "%s %s",
                                 (iter == rangesBegin()) ? "" : " ##",
                                 LiveRange::get(*iter)->toString().get());
     }
 
     if (!buf)
--- a/js/src/jit/BaselineBailouts.cpp
+++ b/js/src/jit/BaselineBailouts.cpp
@@ -225,33 +225,33 @@ struct BaselineStackBuilder
     }
 
     MOZ_MUST_USE bool writeWord(size_t w, const char* info) {
         if (!write<size_t>(w))
             return false;
         if (info) {
             if (sizeof(size_t) == 4) {
                 JitSpew(JitSpew_BaselineBailouts,
-                        "      WRITE_WRD %p/%p %-15s %08x",
+                        "      WRITE_WRD %p/%p %-15s %08" PRIxSIZE,
                         header_->copyStackBottom, virtualPointerAtStackOffset(0), info, w);
             } else {
                 JitSpew(JitSpew_BaselineBailouts,
-                        "      WRITE_WRD %p/%p %-15s %016llx",
+                        "      WRITE_WRD %p/%p %-15s %016" PRIxSIZE,
                         header_->copyStackBottom, virtualPointerAtStackOffset(0), info, w);
             }
         }
         return true;
     }
 
     MOZ_MUST_USE bool writeValue(const Value& val, const char* info) {
         if (!write<Value>(val))
             return false;
         if (info) {
             JitSpew(JitSpew_BaselineBailouts,
-                    "      WRITE_VAL %p/%p %-15s %016llx",
+                    "      WRITE_VAL %p/%p %-15s %016" PRIx64,
                     header_->copyStackBottom, virtualPointerAtStackOffset(0), info,
                     *((uint64_t*) &val));
         }
         return true;
     }
 
     MOZ_MUST_USE bool maybeWritePadding(size_t alignment, size_t after, const char* info) {
         MOZ_ASSERT(framePushed_ % sizeof(Value) == 0);
@@ -632,17 +632,17 @@ InitFromBailout(JSContext* cx, HandleScr
     // +---------------+
     // |    StackS     |
     // +---------------+  --- IF NOT LAST INLINE FRAME,
     // |  Descr(BLJS)  |  --- CALLING INFO STARTS HERE
     // +---------------+
     // |  ReturnAddr   | <-- return into main jitcode after IC
     // +===============+
 
-    JitSpew(JitSpew_BaselineBailouts, "      Unpacking %s:%d", script->filename(), script->lineno());
+    JitSpew(JitSpew_BaselineBailouts, "      Unpacking %s:%" PRIuSIZE, script->filename(), script->lineno());
     JitSpew(JitSpew_BaselineBailouts, "      [BASELINE-JS FRAME]");
 
     // Calculate and write the previous frame pointer value.
     // Record the virtual stack offset at this location.  Later on, if we end up
     // writing out a BaselineStub frame for the next callee, we'll need to save the
     // address.
     void* prevFramePtr = builder.calculatePrevFramePtr();
     if (!builder.writePtr(prevFramePtr, "PrevFramePtr"))
@@ -744,54 +744,54 @@ InitFromBailout(JSContext* cx, HandleScr
             v = iter.read();
             MOZ_ASSERT(v.isObject() || v.isUndefined() || v.isMagic(JS_OPTIMIZED_OUT));
             if (v.isObject())
                 argsObj = &v.toObject().as<ArgumentsObject>();
         }
     }
     JitSpew(JitSpew_BaselineBailouts, "      EnvChain=%p", envChain);
     blFrame->setEnvironmentChain(envChain);
-    JitSpew(JitSpew_BaselineBailouts, "      ReturnValue=%016llx", *((uint64_t*) &returnValue));
+    JitSpew(JitSpew_BaselineBailouts, "      ReturnValue=%016" PRIx64, *((uint64_t*) &returnValue));
     blFrame->setReturnValue(returnValue);
 
     // Do not need to initialize scratchValue field in BaselineFrame.
     blFrame->setFlags(flags);
 
     // initArgsObjUnchecked modifies the frame's flags, so call it after setFlags.
     if (argsObj)
         blFrame->initArgsObjUnchecked(*argsObj);
 
     if (fun) {
         // The unpacked thisv and arguments should overwrite the pushed args present
         // in the calling frame.
         Value thisv = iter.read();
         JitSpew(JitSpew_BaselineBailouts, "      Is function!");
-        JitSpew(JitSpew_BaselineBailouts, "      thisv=%016llx", *((uint64_t*) &thisv));
+        JitSpew(JitSpew_BaselineBailouts, "      thisv=%016" PRIx64, *((uint64_t*) &thisv));
 
         size_t thisvOffset = builder.framePushed() + JitFrameLayout::offsetOfThis();
         builder.valuePointerAtStackOffset(thisvOffset).set(thisv);
 
         MOZ_ASSERT(iter.numAllocations() >= CountArgSlots(script, fun));
-        JitSpew(JitSpew_BaselineBailouts, "      frame slots %u, nargs %u, nfixed %u",
+        JitSpew(JitSpew_BaselineBailouts, "      frame slots %u, nargs %" PRIuSIZE ", nfixed %" PRIuSIZE,
                 iter.numAllocations(), fun->nargs(), script->nfixed());
 
         if (!callerPC) {
             // This is the first frame. Store the formals in a Vector until we
             // are done. Due to UCE and phi elimination, we could store an
             // UndefinedValue() here for formals we think are unused, but
             // locals may still reference the original argument slot
             // (MParameter/LArgument) and expect the original Value.
             MOZ_ASSERT(startFrameFormals.empty());
             if (!startFrameFormals.resize(fun->nargs()))
                 return false;
         }
 
         for (uint32_t i = 0; i < fun->nargs(); i++) {
             Value arg = iter.read();
-            JitSpew(JitSpew_BaselineBailouts, "      arg %d = %016llx",
+            JitSpew(JitSpew_BaselineBailouts, "      arg %d = %016" PRIx64,
                         (int) i, *((uint64_t*) &arg));
             if (callerPC) {
                 size_t argOffset = builder.framePushed() + JitFrameLayout::offsetOfActualArg(i);
                 builder.valuePointerAtStackOffset(argOffset).set(arg);
             } else {
                 startFrameFormals[i].set(arg);
             }
         }
@@ -1309,17 +1309,17 @@ InitFromBailout(JSContext* cx, HandleScr
                                                         JitFrame_BaselineStub,
                                                         JitFrameLayout::Size());
 
     // Push actual argc
     if (!builder.writeWord(actualArgc, "ActualArgc"))
         return false;
 
     // Push callee token (must be a JS Function)
-    JitSpew(JitSpew_BaselineBailouts, "      Callee = %016llx", callee.asRawBits());
+    JitSpew(JitSpew_BaselineBailouts, "      Callee = %016" PRIx64, callee.asRawBits());
 
     JSFunction* calleeFun = &callee.toObject().as<JSFunction>();
     if (!builder.writePtr(CalleeToToken(calleeFun, JSOp(*pc) == JSOP_NEW), "CalleeToken"))
         return false;
     nextCallee.set(calleeFun);
 
     // Push BaselineStub frame descriptor
     if (!builder.writeWord(baselineStubFrameDescr, "Descriptor"))
@@ -1489,17 +1489,17 @@ jit::BailoutIonToBaseline(JSContext* cx,
     //      +---------------+
     //      |  ReturnAddr   |
     //      +---------------+
     //      |    |||||      | <---- Overwrite starting here.
     //      |    |||||      |
     //      |    |||||      |
     //      +---------------+
 
-    JitSpew(JitSpew_BaselineBailouts, "Bailing to baseline %s:%u (IonScript=%p) (FrameType=%d)",
+    JitSpew(JitSpew_BaselineBailouts, "Bailing to baseline %s:%" PRIuSIZE " (IonScript=%p) (FrameType=%d)",
             iter.script()->filename(), iter.script()->lineno(), (void*) iter.ionScript(),
             (int) prevFrameType);
 
     bool catchingException;
     bool propagatingExceptionForDebugMode;
     if (excInfo) {
         catchingException = excInfo->catchingException();
         propagatingExceptionForDebugMode = excInfo->propagatingIonExceptionForDebugMode();
@@ -1509,17 +1509,17 @@ jit::BailoutIonToBaseline(JSContext* cx,
 
         if (propagatingExceptionForDebugMode)
             JitSpew(JitSpew_BaselineBailouts, "Resuming in-place for debug mode");
     } else {
         catchingException = false;
         propagatingExceptionForDebugMode = false;
     }
 
-    JitSpew(JitSpew_BaselineBailouts, "  Reading from snapshot offset %u size %u",
+    JitSpew(JitSpew_BaselineBailouts, "  Reading from snapshot offset %u size %" PRIuSIZE,
             iter.snapshotOffset(), iter.ionScript()->snapshotsListSize());
 
     if (!excInfo)
         iter.ionScript()->incNumBailouts();
     iter.script()->updateBaselineOrIonRaw(cx->runtime());
 
     // Allocate buffer to hold stack replacement data.
     BaselineStackBuilder builder(iter, 1024);
@@ -1535,17 +1535,17 @@ jit::BailoutIonToBaseline(JSContext* cx,
 
 #ifdef TRACK_SNAPSHOTS
     snapIter.spewBailingFrom();
 #endif
 
     RootedFunction callee(cx, iter.maybeCallee());
     RootedScript scr(cx, iter.script());
     if (callee) {
-        JitSpew(JitSpew_BaselineBailouts, "  Callee function (%s:%u)",
+        JitSpew(JitSpew_BaselineBailouts, "  Callee function (%s:%" PRIuSIZE ")",
                 scr->filename(), scr->lineno());
     } else {
         JitSpew(JitSpew_BaselineBailouts, "  No callee!");
     }
 
     if (iter.isConstructing())
         JitSpew(JitSpew_BaselineBailouts, "  Constructing!");
     else
@@ -1570,17 +1570,17 @@ jit::BailoutIonToBaseline(JSContext* cx,
             // TraceLogger doesn't create entries for inlined frames. But we
             // see them in Baseline. Here we create the start events of those
             // entries. So they correspond to what we will see in Baseline.
             TraceLoggerEvent scriptEvent(logger, TraceLogger_Scripts, scr);
             TraceLogStartEvent(logger, scriptEvent);
             TraceLogStartEvent(logger, TraceLogger_Baseline);
         }
 
-        JitSpew(JitSpew_BaselineBailouts, "    FrameNo %d", frameNo);
+        JitSpew(JitSpew_BaselineBailouts, "    FrameNo %" PRIuSIZE, frameNo);
 
         // If we are bailing out to a catch or finally block in this frame,
         // pass excInfo to InitFromBailout and don't unpack any other frames.
         bool handleException = (catchingException && excInfo->frameNo() == frameNo);
 
         // We also need to pass excInfo if we're bailing out in place for
         // debug mode.
         bool passExcInfo = handleException || propagatingExceptionForDebugMode;
@@ -1666,57 +1666,57 @@ InvalidateAfterBailout(JSContext* cx, Ha
 
     JitSpew(JitSpew_BaselineBailouts, "Invalidating due to %s", reason);
     Invalidate(cx, outerScript);
 }
 
 static void
 HandleBoundsCheckFailure(JSContext* cx, HandleScript outerScript, HandleScript innerScript)
 {
-    JitSpew(JitSpew_IonBailouts, "Bounds check failure %s:%d, inlined into %s:%d",
+    JitSpew(JitSpew_IonBailouts, "Bounds check failure %s:%" PRIuSIZE ", inlined into %s:%" PRIuSIZE,
             innerScript->filename(), innerScript->lineno(),
             outerScript->filename(), outerScript->lineno());
 
     if (!innerScript->failedBoundsCheck())
         innerScript->setFailedBoundsCheck();
 
     InvalidateAfterBailout(cx, outerScript, "bounds check failure");
     if (innerScript->hasIonScript())
         Invalidate(cx, innerScript);
 }
 
 static void
 HandleShapeGuardFailure(JSContext* cx, HandleScript outerScript, HandleScript innerScript)
 {
-    JitSpew(JitSpew_IonBailouts, "Shape guard failure %s:%d, inlined into %s:%d",
+    JitSpew(JitSpew_IonBailouts, "Shape guard failure %s:%" PRIuSIZE ", inlined into %s:%" PRIuSIZE,
             innerScript->filename(), innerScript->lineno(),
             outerScript->filename(), outerScript->lineno());
 
     // TODO: Currently this mimic's Ion's handling of this case.  Investigate setting
     // the flag on innerScript as opposed to outerScript, and maybe invalidating both
     // inner and outer scripts, instead of just the outer one.
     outerScript->setFailedShapeGuard();
 
     InvalidateAfterBailout(cx, outerScript, "shape guard failure");
 }
 
 static void
 HandleBaselineInfoBailout(JSContext* cx, HandleScript outerScript, HandleScript innerScript)
 {
-    JitSpew(JitSpew_IonBailouts, "Baseline info failure %s:%d, inlined into %s:%d",
+    JitSpew(JitSpew_IonBailouts, "Baseline info failure %s:%" PRIuSIZE ", inlined into %s:%" PRIuSIZE,
             innerScript->filename(), innerScript->lineno(),
             outerScript->filename(), outerScript->lineno());
 
     InvalidateAfterBailout(cx, outerScript, "invalid baseline info");
 }
 
 static void
 HandleLexicalCheckFailure(JSContext* cx, HandleScript outerScript, HandleScript innerScript)
 {
-    JitSpew(JitSpew_IonBailouts, "Lexical check failure %s:%d, inlined into %s:%d",
+    JitSpew(JitSpew_IonBailouts, "Lexical check failure %s:%" PRIuSIZE ", inlined into %s:%" PRIuSIZE,
             innerScript->filename(), innerScript->lineno(),
             outerScript->filename(), outerScript->lineno());
 
     if (!innerScript->failedLexicalCheck())
         innerScript->setFailedLexicalCheck();
 
     InvalidateAfterBailout(cx, outerScript, "lexical check failure");
     if (innerScript->hasIonScript())
@@ -1749,17 +1749,17 @@ CopyFromRematerializedFrame(JSContext* c
         *frame->valueSlot(i) = rematFrame->locals()[i];
 
     frame->setReturnValue(rematFrame->returnValue());
 
     if (rematFrame->hasCachedSavedFrame())
         frame->setHasCachedSavedFrame();
 
     JitSpew(JitSpew_BaselineBailouts,
-            "  Copied from rematerialized frame at (%p,%u)",
+            "  Copied from rematerialized frame at (%p,%" PRIuSIZE ")",
             fp, inlineDepth);
 
     // Propagate the debuggee frame flag. For the case where the Debugger did
     // not rematerialize an Ion frame, the baseline frame has its debuggee
     // flag set iff its script is considered a debuggee. See the debuggee case
     // in InitFromBailout.
     if (rematFrame->isDebuggee()) {
         frame->setIsDebuggee();
@@ -1886,17 +1886,17 @@ jit::FinishBailoutToBaseline(BaselineBai
         // the table to keep the table up to date.
         act->removeRematerializedFrame(outerFp);
 
         if (!ok)
             return false;
     }
 
     JitSpew(JitSpew_BaselineBailouts,
-            "  Restored outerScript=(%s:%u,%u) innerScript=(%s:%u,%u) (bailoutKind=%u)",
+            "  Restored outerScript=(%s:%" PRIuSIZE ",%u) innerScript=(%s:%" PRIuSIZE ",%u) (bailoutKind=%u)",
             outerScript->filename(), outerScript->lineno(), outerScript->getWarmUpCount(),
             innerScript->filename(), innerScript->lineno(), innerScript->getWarmUpCount(),
             (unsigned) bailoutKind);
 
     switch (bailoutKind) {
       // Normal bailouts.
       case Bailout_Inevitable:
       case Bailout_DuringVMCall:
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -2,16 +2,17 @@
  * 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 "jit/BaselineCompiler.h"
 
 #include "mozilla/Casting.h"
+#include "mozilla/SizePrintfMacros.h"
 
 #include "jit/BaselineIC.h"
 #include "jit/BaselineJIT.h"
 #include "jit/FixedList.h"
 #include "jit/IonAnalysis.h"
 #include "jit/JitcodeMap.h"
 #include "jit/JitSpewer.h"
 #include "jit/Linker.h"
@@ -77,20 +78,20 @@ BaselineCompiler::addPCMappingEntry(bool
     entry.addIndexEntry = addIndexEntry;
 
     return pcMappingEntries_.append(entry);
 }
 
 MethodStatus
 BaselineCompiler::compile()
 {
-    JitSpew(JitSpew_BaselineScripts, "Baseline compiling script %s:%d (%p)",
+    JitSpew(JitSpew_BaselineScripts, "Baseline compiling script %s:%" PRIuSIZE " (%p)",
             script->filename(), script->lineno(), script);
 
-    JitSpew(JitSpew_Codegen, "# Emitting baseline code for script %s:%d",
+    JitSpew(JitSpew_Codegen, "# Emitting baseline code for script %s:%" PRIuSIZE,
             script->filename(), script->lineno());
 
     TraceLoggerThread* logger = TraceLoggerForMainThread(cx->runtime());
     TraceLoggerEvent scriptEvent(logger, TraceLogger_AnnotateScripts, script);
     AutoTraceLog logScript(logger, scriptEvent);
     AutoTraceLog logCompile(logger, TraceLogger_BaselineCompilation);
 
     if (!script->ensureHasTypes(cx) || !script->ensureHasAnalyzedArgsUsage(cx))
@@ -212,17 +213,17 @@ BaselineCompiler::compile()
     if (!baselineScript) {
         ReportOutOfMemory(cx);
         return Method_Error;
     }
 
     baselineScript->setMethod(code);
     baselineScript->setTemplateEnvironment(templateEnv);
 
-    JitSpew(JitSpew_BaselineScripts, "Created BaselineScript %p (raw %p) for %s:%d",
+    JitSpew(JitSpew_BaselineScripts, "Created BaselineScript %p (raw %p) for %s:%" PRIuSIZE,
             (void*) baselineScript.get(), (void*) code->raw(),
             script->filename(), script->lineno());
 
 #ifdef JS_ION_PERF
     writePerfSpewerBaselineProfile(script, code);
 #endif
 
     MOZ_ASSERT(pcMappingIndexEntries.length() > 0);
@@ -274,17 +275,17 @@ BaselineCompiler::compile()
     baselineScript->copyYieldEntries(script, yieldOffsets_);
 
     if (compileDebugInstrumentation_)
         baselineScript->setHasDebugInstrumentation();
 
     // Always register a native => bytecode mapping entry, since profiler can be
     // turned on with baseline jitcode on stack, and baseline jitcode cannot be invalidated.
     {
-        JitSpew(JitSpew_Profiling, "Added JitcodeGlobalEntry for baseline script %s:%d (%p)",
+        JitSpew(JitSpew_Profiling, "Added JitcodeGlobalEntry for baseline script %s:%" PRIuSIZE " (%p)",
                     script->filename(), script->lineno(), baselineScript.get());
 
         // Generate profiling string.
         char* str = JitcodeGlobalEntry::createScriptString(cx, script);
         if (!str)
             return Method_Error;
 
         JitcodeGlobalEntry::BaselineEntry entry;
--- a/js/src/jit/BaselineDebugModeOSR.cpp
+++ b/js/src/jit/BaselineDebugModeOSR.cpp
@@ -2,16 +2,17 @@
  * 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 "jit/BaselineDebugModeOSR.h"
 
 #include "mozilla/DebugOnly.h"
+#include "mozilla/SizePrintfMacros.h"
 
 #include "jit/BaselineIC.h"
 #include "jit/JitcodeMap.h"
 #include "jit/Linker.h"
 #include "jit/PerfSpewer.h"
 
 #include "jit/JitFrames-inl.h"
 #include "jit/MacroAssembler-inl.h"
@@ -317,27 +318,27 @@ ICEntryKindToString(ICEntry::Kind kind)
 }
 #endif // JS_JITSPEW
 
 static void
 SpewPatchBaselineFrame(uint8_t* oldReturnAddress, uint8_t* newReturnAddress,
                        JSScript* script, ICEntry::Kind frameKind, jsbytecode* pc)
 {
     JitSpew(JitSpew_BaselineDebugModeOSR,
-            "Patch return %p -> %p on BaselineJS frame (%s:%d) from %s at %s",
+            "Patch return %p -> %p on BaselineJS frame (%s:%" PRIuSIZE ") from %s at %s",
             oldReturnAddress, newReturnAddress, script->filename(), script->lineno(),
             ICEntryKindToString(frameKind), CodeName[(JSOp)*pc]);
 }
 
 static void
 SpewPatchBaselineFrameFromExceptionHandler(uint8_t* oldReturnAddress, uint8_t* newReturnAddress,
                                            JSScript* script, jsbytecode* pc)
 {
     JitSpew(JitSpew_BaselineDebugModeOSR,
-            "Patch return %p -> %p on BaselineJS frame (%s:%d) from exception handler at %s",
+            "Patch return %p -> %p on BaselineJS frame (%s:%" PRIuSIZE ") from exception handler at %s",
             oldReturnAddress, newReturnAddress, script->filename(), script->lineno(),
             CodeName[(JSOp)*pc]);
 }
 
 static void
 SpewPatchStubFrame(ICStub* oldStub, ICStub* newStub)
 {
     JitSpew(JitSpew_BaselineDebugModeOSR,
@@ -662,17 +663,17 @@ RecompileBaselineScriptForDebugMode(JSCo
 {
     BaselineScript* oldBaselineScript = script->baselineScript();
 
     // If a script is on the stack multiple times, it may have already
     // been recompiled.
     if (oldBaselineScript->hasDebugInstrumentation() == observing)
         return true;
 
-    JitSpew(JitSpew_BaselineDebugModeOSR, "Recompiling (%s:%d) for %s",
+    JitSpew(JitSpew_BaselineDebugModeOSR, "Recompiling (%s:%" PRIuSIZE ") for %s",
             script->filename(), script->lineno(), observing ? "DEBUGGING" : "NORMAL EXECUTION");
 
     script->setBaselineScript(cx->runtime(), nullptr);
 
     MethodStatus status = BaselineCompile(cx, script, /* forceDebugMode = */ observing);
     if (status != Method_Compiled) {
         // We will only fail to recompile for debug mode due to OOM. Restore
         // the old baseline script in case something doesn't properly
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -2581,17 +2581,17 @@ DoSetElemFallback(JSContext* cx, Baselin
                 return false;
 
             if (addingCase &&
                 !DenseOrUnboxedArraySetElemStubExists(cx, ICStub::SetElem_DenseOrUnboxedArrayAdd,
                                                       stub, obj))
             {
                 JitSpew(JitSpew_BaselineIC,
                         "  Generating SetElem_DenseOrUnboxedArrayAdd stub "
-                        "(shape=%p, group=%p, protoDepth=%u)",
+                        "(shape=%p, group=%p, protoDepth=%" PRIuSIZE ")",
                         shape.get(), group.get(), protoDepth);
                 ICSetElemDenseOrUnboxedArrayAddCompiler compiler(cx, obj, protoDepth);
                 ICUpdatedStub* newStub = compiler.getStub(compiler.getStubSpace(outerScript));
                 if (!newStub)
                     return false;
                 if (compiler.needsUpdateStubs() &&
                     !newStub->addUpdateStubForValue(cx, outerScript, obj, JSID_VOIDHANDLE, rhs))
                 {
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -9239,17 +9239,17 @@ CodeGenerator::generateWasm(wasm::SigIdD
     MOZ_ASSERT(safepoints_.size() == 0);
     MOZ_ASSERT(!scriptCounts_);
     return true;
 }
 
 bool
 CodeGenerator::generate()
 {
-    JitSpew(JitSpew_Codegen, "# Emitting code for script %s:%d",
+    JitSpew(JitSpew_Codegen, "# Emitting code for script %s:%" PRIuSIZE,
             gen->info().script()->filename(),
             gen->info().script()->lineno());
 
     // Initialize native code table with an entry to the start of
     // top-level script.
     InlineScriptTree* tree = gen->info().inlineScriptTree();
     jsbytecode* startPC = tree->script()->code();
     BytecodeSite* startSite = new(gen->alloc()) BytecodeSite(tree, startPC);
--- a/js/src/jit/FlowAliasAnalysis.cpp
+++ b/js/src/jit/FlowAliasAnalysis.cpp
@@ -397,17 +397,17 @@ DumpLoopInvariant(MDefinition* load, MBa
 
 static void
 DumpImprovement(MDefinition *load, MDefinitionVector& input, MDefinitionVector& output)
 {
 #ifdef JS_JITSPEW
     if (JitSpewEnabled(JitSpew_Alias)) {
         Fprinter &print = JitSpewPrinter();
         JitSpewHeader(JitSpew_Alias);
-        print.printf("   Improve dependency from ", load->id());
+        print.printf("   Improve dependency from %d", load->id());
         DumpStoreList(input);
         print.printf(" to ");
         DumpStoreList(output);
         print.printf("\n");
     }
 #endif
 }
 
--- a/js/src/jit/Ion.cpp
+++ b/js/src/jit/Ion.cpp
@@ -1,16 +1,17 @@
 /* -*- 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 "jit/Ion.h"
 
+#include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/SizePrintfMacros.h"
 #include "mozilla/ThreadLocal.h"
 
 #include "jscompartment.h"
 #include "jsgc.h"
 #include "jsprf.h"
 
@@ -2131,17 +2132,17 @@ TrackIonAbort(JSContext* cx, JSScript* s
     void* ptr = script->baselineScript()->method()->raw();
     JitcodeGlobalEntry& entry = table->lookupInfallible(ptr);
     entry.baselineEntry().trackIonAbort(pc, message);
 }
 
 static void
 TrackAndSpewIonAbort(JSContext* cx, JSScript* script, const char* message)
 {
-    JitSpew(JitSpew_IonAbort, message);
+    JitSpew(JitSpew_IonAbort, "%s", message);
     TrackIonAbort(cx, script, script->code(), message);
 }
 
 static AbortReason
 IonCompile(JSContext* cx, JSScript* script,
            BaselineFrame* baselineFrame, jsbytecode* osrPc, bool constructing,
            bool recompile, OptimizationLevel optimizationLevel)
 {
@@ -2390,17 +2391,17 @@ CheckScriptSize(JSContext* cx, JSScript*
         return Method_Compiled;
 
     uint32_t numLocalsAndArgs = NumLocalsAndArgs(script);
 
     if (script->length() > MAX_MAIN_THREAD_SCRIPT_SIZE ||
         numLocalsAndArgs > MAX_MAIN_THREAD_LOCALS_AND_ARGS)
     {
         if (!OffThreadCompilationAvailable(cx)) {
-            JitSpew(JitSpew_IonAbort, "Script too large (%u bytes) (%u locals/args)",
+            JitSpew(JitSpew_IonAbort, "Script too large (%" PRIuSIZE " bytes) (%u locals/args)",
                     script->length(), numLocalsAndArgs);
             TrackIonAbort(cx, script, script->code(), "too large");
             return Method_CantCompile;
         }
     }
 
     return Method_Compiled;
 }
@@ -3009,51 +3010,51 @@ InvalidateActivation(FreeOp* fop, const 
     size_t frameno = 1;
 
     for (JitFrameIterator it(activations); !it.done(); ++it, ++frameno) {
         MOZ_ASSERT_IF(frameno == 1, it.isExitFrame() || it.type() == JitFrame_Bailout);
 
 #ifdef JS_JITSPEW
         switch (it.type()) {
           case JitFrame_Exit:
-            JitSpew(JitSpew_IonInvalidate, "#%d exit frame @ %p", frameno, it.fp());
+            JitSpew(JitSpew_IonInvalidate, "#%" PRIuSIZE " exit frame @ %p", frameno, it.fp());
             break;
           case JitFrame_BaselineJS:
           case JitFrame_IonJS:
           case JitFrame_Bailout:
           {
             MOZ_ASSERT(it.isScripted());
             const char* type = "Unknown";
             if (it.isIonJS())
                 type = "Optimized";
             else if (it.isBaselineJS())
                 type = "Baseline";
             else if (it.isBailoutJS())
                 type = "Bailing";
             JitSpew(JitSpew_IonInvalidate,
-                    "#%d %s JS frame @ %p, %s:%" PRIuSIZE " (fun: %p, script: %p, pc %p)",
+                    "#%" PRIuSIZE " %s JS frame @ %p, %s:%" PRIuSIZE " (fun: %p, script: %p, pc %p)",
                     frameno, type, it.fp(), it.script()->maybeForwardedFilename(),
                     it.script()->lineno(), it.maybeCallee(), (JSScript*)it.script(),
                     it.returnAddressToFp());
             break;
           }
           case JitFrame_IonStub:
-            JitSpew(JitSpew_IonInvalidate, "#%d ion stub frame @ %p", frameno, it.fp());
+            JitSpew(JitSpew_IonInvalidate, "#%" PRIuSIZE " ion stub frame @ %p", frameno, it.fp());
             break;
           case JitFrame_BaselineStub:
-            JitSpew(JitSpew_IonInvalidate, "#%d baseline stub frame @ %p", frameno, it.fp());
+            JitSpew(JitSpew_IonInvalidate, "#%" PRIuSIZE " baseline stub frame @ %p", frameno, it.fp());
             break;
           case JitFrame_Rectifier:
-            JitSpew(JitSpew_IonInvalidate, "#%d rectifier frame @ %p", frameno, it.fp());
+            JitSpew(JitSpew_IonInvalidate, "#%" PRIuSIZE " rectifier frame @ %p", frameno, it.fp());
             break;
           case JitFrame_IonAccessorIC:
-            JitSpew(JitSpew_IonInvalidate, "#%d ion IC getter/setter frame @ %p", frameno, it.fp());
+            JitSpew(JitSpew_IonInvalidate, "#%" PRIuSIZE " ion IC getter/setter frame @ %p", frameno, it.fp());
             break;
           case JitFrame_Entry:
-            JitSpew(JitSpew_IonInvalidate, "#%d entry frame @ %p", frameno, it.fp());
+            JitSpew(JitSpew_IonInvalidate, "#%" PRIuSIZE " entry frame @ %p", frameno, it.fp());
             break;
         }
 #endif // JS_JITSPEW
 
         if (!it.isIonScripted())
             continue;
 
         bool calledFromLinkStub = false;
@@ -3138,17 +3139,17 @@ InvalidateActivation(FreeOp* fop, const 
         CodeLocationLabel dataLabelToMunge(it.returnAddressToFp());
         ptrdiff_t delta = ionScript->invalidateEpilogueDataOffset() -
                           (it.returnAddressToFp() - ionCode->raw());
         Assembler::PatchWrite_Imm32(dataLabelToMunge, Imm32(delta));
 
         CodeLocationLabel osiPatchPoint = SafepointReader::InvalidationPatchPoint(ionScript, si);
         CodeLocationLabel invalidateEpilogue(ionCode, CodeOffset(ionScript->invalidateEpilogueOffset()));
 
-        JitSpew(JitSpew_IonInvalidate, "   ! Invalidate ionScript %p (inv count %u) -> patching osipoint %p",
+        JitSpew(JitSpew_IonInvalidate, "   ! Invalidate ionScript %p (inv count %" PRIuSIZE ") -> patching osipoint %p",
                 ionScript, ionScript->invalidationCount(), (void*) osiPatchPoint.raw());
         Assembler::PatchWrite_NearCall(osiPatchPoint, invalidateEpilogue);
     }
 
     JitSpew(JitSpew_IonInvalidate, "END invalidating activation");
 }
 
 void
@@ -3355,17 +3356,17 @@ PerThreadData::setAutoFlushICache(AutoFl
 // AutoFlushICache context.
 void
 AutoFlushICache::setRange(uintptr_t start, size_t len)
 {
 #if defined(JS_CODEGEN_ARM) || defined(JS_CODEGEN_ARM64) || defined(JS_CODEGEN_MIPS32) || defined(JS_CODEGEN_MIPS64)
     AutoFlushICache* afc = TlsPerThreadData.get()->PerThreadData::autoFlushICache();
     MOZ_ASSERT(afc);
     MOZ_ASSERT(!afc->start_);
-    JitSpewCont(JitSpew_CacheFlush, "(%x %x):", start, len);
+    JitSpewCont(JitSpew_CacheFlush, "(%" PRIxPTR " %" PRIxSIZE "):", start, len);
 
     uintptr_t stop = start + len;
     afc->start_ = start;
     afc->stop_ = stop;
 #endif
 }
 
 // Flush the instruction cache.
--- a/js/src/jit/IonAnalysis.cpp
+++ b/js/src/jit/IonAnalysis.cpp
@@ -1,16 +1,18 @@
 /* -*- 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 "jit/IonAnalysis.h"
 
+#include "mozilla/SizePrintfMacros.h"
+
 #include "jit/AliasAnalysis.h"
 #include "jit/BaselineInspector.h"
 #include "jit/BaselineJIT.h"
 #include "jit/FlowAliasAnalysis.h"
 #include "jit/Ion.h"
 #include "jit/IonBuilder.h"
 #include "jit/IonOptimizationLevels.h"
 #include "jit/LIR.h"
@@ -440,19 +442,20 @@ jit::PruneUnusedBranches(MIRGenerator* m
             // Interpreters are often implemented as a table switch within a for
             // loop. What might happen is that the interpreter heats up in a
             // subset of instructions, but might need other instructions for the
             // rest of the evaluation.
             if (numSuccessorsOfPreds > 8)
                 shouldBailout = false;
 
             JitSpew(JitSpew_Prune, "info: block %d,"
-                    " predCount: %lu, domInst: %lu, span: %lu, effectful: %lu, "
-                    " isLoopExit: %s, numSuccessorsOfPred: %lu."
-                    " (score: %lu, shouldBailout: %s)",
+                    " predCount: %" PRIuSIZE ", domInst: %" PRIuSIZE
+                    ", span: %" PRIuSIZE ", effectful: %" PRIuSIZE ", "
+                    " isLoopExit: %s, numSuccessorsOfPred: %" PRIuSIZE "."
+                    " (score: %" PRIuSIZE ", shouldBailout: %s)",
                     block->id(), predCount, numDominatedInst, branchSpan, numEffectfulInst,
                     isLoopExit ? "true" : "false", numSuccessorsOfPreds,
                     score, shouldBailout ? "true" : "false");
         }
 
         // Continue to the next basic block if the current basic block can
         // remain unchanged.
         if (!isUnreachable && !shouldBailout)
--- a/js/src/jit/IonBuilder.h
+++ b/js/src/jit/IonBuilder.h
@@ -224,17 +224,17 @@ class IonBuilder
 
   private:
     MOZ_MUST_USE bool traverseBytecode();
     ControlStatus snoopControlFlow(JSOp op);
     MOZ_MUST_USE bool processIterators();
     MOZ_MUST_USE bool inspectOpcode(JSOp op);
     uint32_t readIndex(jsbytecode* pc);
     JSAtom* readAtom(jsbytecode* pc);
-    bool abort(const char* message, ...);
+    bool abort(const char* message, ...) MOZ_FORMAT_PRINTF(2, 3);
     void trackActionableAbort(const char* message);
     void spew(const char* message);
 
     JSFunction* getSingleCallTarget(TemporaryTypeSet* calleeTypes);
     MOZ_MUST_USE bool getPolyCallTargets(TemporaryTypeSet* calleeTypes, bool constructing,
                                          ObjectVector& targets, uint32_t maxTargets);
 
     void popCfgStack();
--- a/js/src/jit/JSONSpewer.cpp
+++ b/js/src/jit/JSONSpewer.cpp
@@ -3,16 +3,18 @@
  * 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 JS_JITSPEW
 
 #include "jit/JSONSpewer.h"
 
+#include "mozilla/SizePrintfMacros.h"
+
 #include <stdarg.h>
 
 #include "jit/BacktrackingAllocator.h"
 #include "jit/LIR.h"
 #include "jit/MIR.h"
 #include "jit/MIRGraph.h"
 #include "jit/RangeAnalysis.h"
 
@@ -141,27 +143,27 @@ JSONSpewer::endList()
     first_ = false;
 }
 
 void
 JSONSpewer::beginFunction(JSScript* script)
 {
     beginObject();
     if (script)
-        stringProperty("name", "%s:%d", script->filename(), script->lineno());
+        stringProperty("name", "%s:%" PRIuSIZE, script->filename(), script->lineno());
     else
         stringProperty("name", "asm.js compilation");
     beginListProperty("passes");
 }
 
 void
 JSONSpewer::beginPass(const char* pass)
 {
     beginObject();
-    stringProperty("name", pass);
+    stringProperty("name", "%s", pass);
 }
 
 void
 JSONSpewer::spewMResumePoint(MResumePoint* rp)
 {
     if (!rp)
         return;
 
--- a/js/src/jit/JSONSpewer.h
+++ b/js/src/jit/JSONSpewer.h
@@ -31,18 +31,18 @@ class JSONSpewer
     GenericPrinter& out_;
 
     void indent();
 
     void property(const char* name);
     void beginObject();
     void beginObjectProperty(const char* name);
     void beginListProperty(const char* name);
-    void stringValue(const char* format, ...);
-    void stringProperty(const char* name, const char* format, ...);
+    void stringValue(const char* format, ...) MOZ_FORMAT_PRINTF(2, 3);
+    void stringProperty(const char* name, const char* format, ...) MOZ_FORMAT_PRINTF(3, 4);
     void beginStringProperty(const char* name);
     void endStringProperty();
     void integerValue(int value);
     void integerProperty(const char* name, int value);
     void endObject();
     void endList();
 
   public:
--- a/js/src/jit/JitSpewer.h
+++ b/js/src/jit/JitSpewer.h
@@ -167,19 +167,19 @@ class JitSpewIndent
 {
     JitSpewChannel channel_;
 
   public:
     explicit JitSpewIndent(JitSpewChannel channel);
     ~JitSpewIndent();
 };
 
-void JitSpew(JitSpewChannel channel, const char* fmt, ...);
-void JitSpewStart(JitSpewChannel channel, const char* fmt, ...);
-void JitSpewCont(JitSpewChannel channel, const char* fmt, ...);
+void JitSpew(JitSpewChannel channel, const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3);
+void JitSpewStart(JitSpewChannel channel, const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3);
+void JitSpewCont(JitSpewChannel channel, const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3);
 void JitSpewFin(JitSpewChannel channel);
 void JitSpewHeader(JitSpewChannel channel);
 bool JitSpewEnabled(JitSpewChannel channel);
 void JitSpewVA(JitSpewChannel channel, const char* fmt, va_list ap);
 void JitSpewStartVA(JitSpewChannel channel, const char* fmt, va_list ap);
 void JitSpewContVA(JitSpewChannel channel, const char* fmt, va_list ap);
 void JitSpewDef(JitSpewChannel channel, const char* str, MDefinition* def);
 
--- a/js/src/jit/MIRGenerator.h
+++ b/js/src/jit/MIRGenerator.h
@@ -67,17 +67,17 @@ class MIRGenerator
         size_t bytes;
         if (MOZ_UNLIKELY(!CalculateAllocSize<T>(count, &bytes)))
             return nullptr;
         return static_cast<T*>(alloc().allocate(bytes));
     }
 
     // Set an error state and prints a message. Returns false so errors can be
     // propagated up.
-    bool abort(const char* message, ...);           // always returns false
+    bool abort(const char* message, ...) MOZ_FORMAT_PRINTF(2, 3); // always returns false
     bool abortFmt(const char* message, va_list ap); // always returns false
 
     bool errored() const {
         return error_;
     }
 
     MOZ_MUST_USE bool instrumentedProfiling() {
         if (!instrumentedProfilingIsCached_) {
--- a/js/src/jit/OptimizationTracking.cpp
+++ b/js/src/jit/OptimizationTracking.cpp
@@ -321,17 +321,17 @@ UniqueTrackedOptimizations::sortByFreque
     for (size_t i = 0; i < entries.length(); i++) {
         Key key;
         key.types = entries[i].types;
         key.attempts = entries[i].attempts;
         AttemptsMap::Ptr p = map_.lookup(key);
         MOZ_ASSERT(p);
         p->value().index = sorted_.length();
 
-        JitSpew(JitSpew_OptimizationTracking, "   Entry %u has frequency %u",
+        JitSpew(JitSpew_OptimizationTracking, "   Entry %" PRIuSIZE " has frequency %" PRIu32,
                 sorted_.length(), p->value().frequency);
 
         if (!sorted_.append(entries[i]))
             return false;
     }
 
     return true;
 }
@@ -760,41 +760,41 @@ IonTrackedOptimizationsRegion::WriteDelt
 
 /* static */ bool
 IonTrackedOptimizationsRegion::WriteRun(CompactBufferWriter& writer,
                                         const NativeToTrackedOptimizations* start,
                                         const NativeToTrackedOptimizations* end,
                                         const UniqueTrackedOptimizations& unique)
 {
     // Write the header, which is the range that this whole run encompasses.
-    JitSpew(JitSpew_OptimizationTracking, "     Header: [%u, %u]",
+    JitSpew(JitSpew_OptimizationTracking, "     Header: [%" PRIuSIZE ", %" PRIuSIZE "]",
             start->startOffset.offset(), (end - 1)->endOffset.offset());
     writer.writeUnsigned(start->startOffset.offset());
     writer.writeUnsigned((end - 1)->endOffset.offset());
 
     // Write the first entry of the run, which is not delta-encoded.
     JitSpew(JitSpew_OptimizationTracking,
-            "     [%6u, %6u]                        vector %3u, offset %4u",
+            "     [%6" PRIuSIZE ", %6" PRIuSIZE "]                        vector %3u, offset %4" PRIuSIZE,
             start->startOffset.offset(), start->endOffset.offset(),
             unique.indexOf(start->optimizations), writer.length());
     uint32_t prevEndOffset = start->endOffset.offset();
     writer.writeUnsigned(prevEndOffset);
     writer.writeByte(unique.indexOf(start->optimizations));
 
     // Delta encode the run.
     for (const NativeToTrackedOptimizations* entry = start + 1; entry != end; entry++) {
         uint32_t startOffset = entry->startOffset.offset();
         uint32_t endOffset = entry->endOffset.offset();
 
         uint32_t startDelta = startOffset - prevEndOffset;
         uint32_t length = endOffset - startOffset;
         uint8_t index = unique.indexOf(entry->optimizations);
 
         JitSpew(JitSpew_OptimizationTracking,
-                "     [%6u, %6u] delta [+%5u, +%5u] vector %3u, offset %4u",
+                "     [%6u, %6u] delta [+%5u, +%5u] vector %3u, offset %4" PRIuSIZE,
                 startOffset, endOffset, startDelta, length, index, writer.length());
 
         WriteDelta(writer, startDelta, length, index);
 
         prevEndOffset = endOffset;
     }
 
     if (writer.oom())
@@ -820,17 +820,17 @@ WriteOffsetsTable(CompactBufferWriter& w
     uint32_t tableOffset = writer.length();
 
     // Write how many bytes were padded and numEntries.
     writer.writeNativeEndianUint32_t(padding);
     writer.writeNativeEndianUint32_t(offsets.length());
 
     // Write entry offset table.
     for (size_t i = 0; i < offsets.length(); i++) {
-        JitSpew(JitSpew_OptimizationTracking, "   Entry %u reverse offset %u",
+        JitSpew(JitSpew_OptimizationTracking, "   Entry %" PRIuSIZE " reverse offset %u",
                 i, tableOffset - padding - offsets[i]);
         writer.writeNativeEndianUint32_t(tableOffset - padding - offsets[i]);
     }
 
     if (writer.oom())
         return false;
 
     *tableOffsetp = tableOffset;
@@ -880,17 +880,17 @@ SpewConstructor(TypeSet::Type ty, JSFunc
         PutEscapedString(buf, 512, constructor->displayAtom(), 0);
     else
         snprintf(buf, mozilla::ArrayLength(buf), "??");
 
     const char* filename;
     Maybe<unsigned> lineno;
     InterpretedFunctionFilenameAndLineNumber(constructor, &filename, &lineno);
 
-    JitSpew(JitSpew_OptimizationTracking, "   Unique type %s has constructor %s (%s:%" PRIuSIZE ")",
+    JitSpew(JitSpew_OptimizationTracking, "   Unique type %s has constructor %s (%s:%u)",
             TypeSet::TypeString(ty), buf, filename, lineno.isSome() ? *lineno : 0);
 #endif
 }
 
 static void
 SpewAllocationSite(TypeSet::Type ty, JSScript* script, uint32_t offset)
 {
 #ifdef JS_JITSPEW
@@ -914,32 +914,33 @@ jit::WriteIonTrackedOptimizationsTable(J
     MOZ_ASSERT(unique.sorted());
 
 #ifdef JS_JITSPEW
     // Spew training data, which may be fed into a script to determine a good
     // encoding strategy.
     if (JitSpewEnabled(JitSpew_OptimizationTracking)) {
         JitSpewStart(JitSpew_OptimizationTracking, "=> Training data: ");
         for (const NativeToTrackedOptimizations* entry = start; entry != end; entry++) {
-            JitSpewCont(JitSpew_OptimizationTracking, "%u,%u,%u ",
+            JitSpewCont(JitSpew_OptimizationTracking, "%" PRIuSIZE ",%" PRIuSIZE ",%u ",
                         entry->startOffset.offset(), entry->endOffset.offset(),
                         unique.indexOf(entry->optimizations));
         }
         JitSpewFin(JitSpew_OptimizationTracking);
     }
 #endif
 
     Vector<uint32_t, 16> offsets(cx);
     const NativeToTrackedOptimizations* entry = start;
 
     // Write out region offloads, partitioned into runs.
     JitSpew(JitSpew_Profiling, "=> Writing regions");
     while (entry != end) {
         uint32_t runLength = IonTrackedOptimizationsRegion::ExpectedRunLength(entry, end);
-        JitSpew(JitSpew_OptimizationTracking, "   Run at entry %u, length %u, offset %u",
+        JitSpew(JitSpew_OptimizationTracking,
+                "   Run at entry %" PRIuSIZE ", length %" PRIu32 ", offset %" PRIuSIZE,
                 entry - start, runLength, writer.length());
 
         if (!offsets.append(writer.length()))
             return false;
 
         if (!IonTrackedOptimizationsRegion::WriteRun(writer, entry, entry + runLength, unique))
             return false;
 
@@ -952,27 +953,28 @@ jit::WriteIonTrackedOptimizationsTable(J
 
     *numRegions = offsets.length();
 
     // Clear offsets so that it may be reused below for the unique
     // optimizations table.
     offsets.clear();
 
     const UniqueTrackedOptimizations::SortedVector& vec = unique.sortedVector();
-    JitSpew(JitSpew_OptimizationTracking, "=> Writing unique optimizations table with %u entr%s",
+    JitSpew(JitSpew_OptimizationTracking, "=> Writing unique optimizations table with %" PRIuSIZE " entr%s",
             vec.length(), vec.length() == 1 ? "y" : "ies");
 
     // Write out type info payloads.
     UniqueTrackedTypes uniqueTypes(cx);
     if (!uniqueTypes.init())
         return false;
 
     for (const UniqueTrackedOptimizations::SortEntry* p = vec.begin(); p != vec.end(); p++) {
         const TempOptimizationTypeInfoVector* v = p->types;
-        JitSpew(JitSpew_OptimizationTracking, "   Type info entry %u of length %u, offset %u",
+        JitSpew(JitSpew_OptimizationTracking,
+                "   Type info entry %" PRIuSIZE " of length %" PRIuSIZE ", offset %" PRIuSIZE,
                 p - vec.begin(), v->length(), writer.length());
         SpewTempOptimizationTypeInfoVector(v, "  ");
 
         if (!offsets.append(writer.length()))
             return false;
 
         for (const OptimizationTypeInfo* t = v->begin(); t != v->end(); t++) {
             if (!t->writeCompact(cx, writer, uniqueTypes))
@@ -1012,17 +1014,18 @@ jit::WriteIonTrackedOptimizationsTable(J
 
     if (!WriteOffsetsTable(writer, offsets, typesTableOffsetp))
         return false;
     offsets.clear();
 
     // Write out attempts payloads.
     for (const UniqueTrackedOptimizations::SortEntry* p = vec.begin(); p != vec.end(); p++) {
         const TempOptimizationAttemptsVector* v = p->attempts;
-        JitSpew(JitSpew_OptimizationTracking, "   Attempts entry %u of length %u, offset %u",
+        JitSpew(JitSpew_OptimizationTracking,
+                "   Attempts entry %" PRIuSIZE " of length %" PRIuSIZE ", offset %" PRIuSIZE,
                 p - vec.begin(), v->length(), writer.length());
         SpewTempOptimizationAttemptsVector(v, "  ");
 
         if (!offsets.append(writer.length()))
             return false;
 
         for (const OptimizationAttempt* a = v->begin(); a != v->end(); a++)
             a->writeCompact(writer);
--- a/js/src/jit/Recover.cpp
+++ b/js/src/jit/Recover.cpp
@@ -1,16 +1,18 @@
 /* -*- 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 "jit/Recover.h"
 
+#include "mozilla/SizePrintfMacros.h"
+
 #include "jsapi.h"
 #include "jscntxt.h"
 #include "jsmath.h"
 #include "jsobj.h"
 #include "jsstr.h"
 
 #include "builtin/RegExp.h"
 #include "builtin/SIMD.h"
@@ -118,17 +120,17 @@ MResumePoint::writeRecoverData(CompactBu
     MOZ_ASSERT(CountArgSlots(script, fun) < SNAPSHOT_MAX_NARGS + 4);
 
 #ifdef JS_JITSPEW
     uint32_t implicit = StartArgSlot(script);
 #endif
     uint32_t formalArgs = CountArgSlots(script, fun);
     uint32_t nallocs = formalArgs + script->nfixed() + exprStack;
 
-    JitSpew(JitSpew_IonSnapshots, "Starting frame; implicit %u, formals %u, fixed %u, exprs %u",
+    JitSpew(JitSpew_IonSnapshots, "Starting frame; implicit %u, formals %u, fixed %" PRIuSIZE ", exprs %u",
             implicit, formalArgs - implicit, script->nfixed(), exprStack);
 
     uint32_t pcoff = script->pcToOffset(pc());
     JitSpew(JitSpew_IonSnapshots, "Writing pc offset %u, nslots %u", pcoff, nallocs);
     writer.writeUnsigned(pcoff);
     writer.writeUnsigned(nallocs);
     return true;
 }
--- a/js/src/jit/Safepoints.cpp
+++ b/js/src/jit/Safepoints.cpp
@@ -2,16 +2,17 @@
  * 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 "jit/Safepoints.h"
 
 #include "mozilla/MathAlgorithms.h"
+#include "mozilla/SizePrintfMacros.h"
 
 #include "jit/BitSet.h"
 #include "jit/JitSpewer.h"
 #include "jit/LIR.h"
 
 using namespace js;
 using namespace jit;
 
@@ -26,17 +27,17 @@ bool
 SafepointWriter::init(TempAllocator& alloc)
 {
     return frameSlots_.init(alloc) && argumentSlots_.init(alloc);
 }
 
 uint32_t
 SafepointWriter::startEntry()
 {
-    JitSpew(JitSpew_Safepoints, "Encoding safepoint (position %d):", stream_.length());
+    JitSpew(JitSpew_Safepoints, "Encoding safepoint (position %" PRIuSIZE "):", stream_.length());
     return uint32_t(stream_.length());
 }
 
 void
 SafepointWriter::writeOsiCallPointOffset(uint32_t osiCallPointOffset)
 {
     stream_.writeUnsigned(osiCallPointOffset);
 }
--- a/js/src/jit/SharedIC.cpp
+++ b/js/src/jit/SharedIC.cpp
@@ -2127,17 +2127,17 @@ UpdateExistingGenerationalDOMProxyStub(I
     for (ICStubConstIterator iter = stub->beginChainConst(); !iter.atEnd(); iter++) {
         if (iter->isGetProp_CallDOMProxyWithGenerationNative()) {
             ICGetProp_CallDOMProxyWithGenerationNative* updateStub =
                 iter->toGetProp_CallDOMProxyWithGenerationNative();
             if (updateStub->expandoAndGeneration() == expandoAndGeneration) {
                 // Update generation
                 uint64_t generation = expandoAndGeneration->generation;
                 JitSpew(JitSpew_BaselineIC,
-                        "  Updating existing stub with generation, old value: %i, "
+                        "  Updating existing stub with generation, old value: %" PRIu64 ", "
                         "new value: %" PRIu64 "", updateStub->generation(),
                         generation);
                 updateStub->setGeneration(generation);
                 return true;
             }
         }
     }
     return false;
--- a/js/src/jit/SharedIC.h
+++ b/js/src/jit/SharedIC.h
@@ -197,18 +197,20 @@ class ICStub;
 class ICFallbackStub;
 
 #define FORWARD_DECLARE_STUBS(kindName) class IC##kindName;
     IC_BASELINE_STUB_KIND_LIST(FORWARD_DECLARE_STUBS)
     IC_SHARED_STUB_KIND_LIST(FORWARD_DECLARE_STUBS)
 #undef FORWARD_DECLARE_STUBS
 
 #ifdef JS_JITSPEW
-void FallbackICSpew(JSContext* cx, ICFallbackStub* stub, const char* fmt, ...);
-void TypeFallbackICSpew(JSContext* cx, ICTypeMonitor_Fallback* stub, const char* fmt, ...);
+void FallbackICSpew(JSContext* cx, ICFallbackStub* stub, const char* fmt, ...)
+    MOZ_FORMAT_PRINTF(3, 4);
+void TypeFallbackICSpew(JSContext* cx, ICTypeMonitor_Fallback* stub, const char* fmt, ...)
+    MOZ_FORMAT_PRINTF(3, 4);
 #else
 #define FallbackICSpew(...)
 #define TypeFallbackICSpew(...)
 #endif
 
 //
 // An entry in the JIT IC descriptor table.
 //
--- a/js/src/jit/ValueNumbering.cpp
+++ b/js/src/jit/ValueNumbering.cpp
@@ -991,17 +991,17 @@ ValueNumberer::visitBlock(MBasicBlock* b
 
     return visitControlInstruction(block, dominatorRoot);
 }
 
 // Visit all the blocks dominated by dominatorRoot.
 bool
 ValueNumberer::visitDominatorTree(MBasicBlock* dominatorRoot)
 {
-    JitSpew(JitSpew_GVN, "  Visiting dominator tree (with %llu blocks) rooted at block%u%s",
+    JitSpew(JitSpew_GVN, "  Visiting dominator tree (with %" PRIu64 " blocks) rooted at block%u%s",
             uint64_t(dominatorRoot->numDominated()), dominatorRoot->id(),
             dominatorRoot == graph_.entryBlock() ? " (normal entry block)" :
             dominatorRoot == graph_.osrBlock() ? " (OSR entry block)" :
             dominatorRoot->numPredecessors() == 0 ? " (odd unreachable block)" :
             " (merge point from normal entry and OSR entry)");
     MOZ_ASSERT(dominatorRoot->immediateDominator() == dominatorRoot,
             "root is not a dominator tree root");
 
@@ -1217,17 +1217,17 @@ ValueNumberer::init()
     return values_.init();
 }
 
 bool
 ValueNumberer::run(UpdateAliasAnalysisFlag updateAliasAnalysis)
 {
     updateAliasAnalysis_ = updateAliasAnalysis == UpdateAliasAnalysis;
 
-    JitSpew(JitSpew_GVN, "Running GVN on graph (with %llu blocks)",
+    JitSpew(JitSpew_GVN, "Running GVN on graph (with %" PRIu64 " blocks)",
             uint64_t(graph_.numBlocks()));
 
     // Adding fixup blocks only make sense iff we have a second entry point into
     // the graph which cannot be reached any more from the entry point.
     if (graph_.osrBlock()) {
         if (!insertOSRFixups())
             return false;
     }
@@ -1277,17 +1277,17 @@ ValueNumberer::run(UpdateAliasAnalysisFl
         // re-run we discard the construct which triggered the re-run), but it
         // does help avoid slow compile times on pathological code.
         ++runs;
         if (runs == 6) {
             JitSpew(JitSpew_GVN, "Re-run cutoff of %d reached. Terminating GVN!", runs);
             break;
         }
 
-        JitSpew(JitSpew_GVN, "Re-running GVN on graph (run %d, now with %llu blocks)",
+        JitSpew(JitSpew_GVN, "Re-running GVN on graph (run %d, now with %" PRIu64 " blocks)",
                 runs, uint64_t(graph_.numBlocks()));
     }
 
     if (MOZ_UNLIKELY(hasOSRFixups_)) {
         if (!cleanupOSRFixups())
             return false;
         hasOSRFixups_ = false;
     }
--- a/js/src/jit/arm/Assembler-arm.h
+++ b/js/src/jit/arm/Assembler-arm.h
@@ -1358,17 +1358,17 @@ class Assembler : public AssemblerShared
     SpewNodes spewNodes_;
     uint32_t spewNext_;
     Sprinter* printer_;
 
     bool spewDisabled();
     uint32_t spewResolve(Label* l);
     uint32_t spewProbe(Label* l);
     uint32_t spewDefine(Label* l);
-    void spew(const char* fmt, ...);
+    void spew(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3);
     void spew(const char* fmt, va_list args);
 #endif
 
   public:
     // For the alignment fill use NOP: 0x0320f000 or (Always | InstNOP::NopInst).
     // For the nopFill use a branch to the next instruction: 0xeaffffff.
     Assembler()
       : m_buffer(1, 1, 8, GetPoolMaxOffset(), 8, 0xe320f000, 0xeaffffff, GetNopFill()),
--- a/js/src/jit/arm/disasm/Disasm-arm.cpp
+++ b/js/src/jit/arm/disasm/Disasm-arm.cpp
@@ -38,16 +38,17 @@
 
 namespace js {
 namespace jit {
 namespace disasm {
 
 
 // Helper function for printing to a Vector.
 static int
+MOZ_FORMAT_PRINTF(2, 3)
 SNPrintF(V8Vector<char> str, const char* format, ...)
 {
     va_list args;
     va_start(args, format);
     int result = vsnprintf(str.start(), str.length(), format, args);
     va_end(args);
     return result;
 }
--- a/js/src/jit/shared/CodeGenerator-shared.cpp
+++ b/js/src/jit/shared/CodeGenerator-shared.cpp
@@ -2,16 +2,17 @@
  * 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 "jit/shared/CodeGenerator-shared-inl.h"
 
 #include "mozilla/DebugOnly.h"
+#include "mozilla/SizePrintfMacros.h"
 
 #include "jit/CompactBuffer.h"
 #include "jit/IonCaches.h"
 #include "jit/JitcodeMap.h"
 #include "jit/JitSpewer.h"
 #include "jit/MacroAssembler.h"
 #include "jit/MIR.h"
 #include "jit/MIRGenerator.h"
@@ -228,17 +229,17 @@ CodeGeneratorShared::addNativeToBytecode
         NativeToBytecode& lastEntry = nativeToBytecodeList_[lastIdx];
 
         MOZ_ASSERT(nativeOffset >= lastEntry.nativeOffset.offset());
 
         // If the new entry is for the same inlineScriptTree and same
         // bytecodeOffset, but the nativeOffset has changed, do nothing.
         // The same site just generated some more code.
         if (lastEntry.tree == tree && lastEntry.pc == pc) {
-            JitSpew(JitSpew_Profiling, " => In-place update [%u-%u]",
+            JitSpew(JitSpew_Profiling, " => In-place update [%" PRIuSIZE "-%" PRIu32 "]",
                     lastEntry.nativeOffset.offset(), nativeOffset);
             return true;
         }
 
         // If the new entry is for the same native offset, then update the
         // previous entry with the new bytecode site, since the previous
         // bytecode site did not generate any native code.
         if (lastEntry.nativeOffset.offset() == nativeOffset) {
@@ -275,17 +276,17 @@ CodeGeneratorShared::addNativeToBytecode
     return true;
 }
 
 void
 CodeGeneratorShared::dumpNativeToBytecodeEntries()
 {
 #ifdef JS_JITSPEW
     InlineScriptTree* topTree = gen->info().inlineScriptTree();
-    JitSpewStart(JitSpew_Profiling, "Native To Bytecode Entries for %s:%d\n",
+    JitSpewStart(JitSpew_Profiling, "Native To Bytecode Entries for %s:%" PRIuSIZE "\n",
                  topTree->script()->filename(), topTree->script()->lineno());
     for (unsigned i = 0; i < nativeToBytecodeList_.length(); i++)
         dumpNativeToBytecodeEntry(i);
 #endif
 }
 
 void
 CodeGeneratorShared::dumpNativeToBytecodeEntry(uint32_t idx)
@@ -298,26 +299,26 @@ CodeGeneratorShared::dumpNativeToBytecod
     unsigned nativeDelta = 0;
     unsigned pcDelta = 0;
     if (idx + 1 < nativeToBytecodeList_.length()) {
         NativeToBytecode* nextRef = &ref + 1;
         nativeDelta = nextRef->nativeOffset.offset() - nativeOffset;
         if (nextRef->tree == ref.tree)
             pcDelta = nextRef->pc - ref.pc;
     }
-    JitSpewStart(JitSpew_Profiling, "    %08x [+%-6d] => %-6d [%-4d] {%-10s} (%s:%d",
+    JitSpewStart(JitSpew_Profiling, "    %08" PRIxSIZE " [+%-6d] => %-6ld [%-4d] {%-10s} (%s:%" PRIuSIZE,
                  ref.nativeOffset.offset(),
                  nativeDelta,
-                 ref.pc - script->code(),
+                 (long) (ref.pc - script->code()),
                  pcDelta,
                  CodeName[JSOp(*ref.pc)],
                  script->filename(), script->lineno());
 
     for (tree = tree->caller(); tree; tree = tree->caller()) {
-        JitSpewCont(JitSpew_Profiling, " <= %s:%d", tree->script()->filename(),
+        JitSpewCont(JitSpew_Profiling, " <= %s:%" PRIuSIZE, tree->script()->filename(),
                                                     tree->script()->lineno());
     }
     JitSpewCont(JitSpew_Profiling, ")");
     JitSpewFin(JitSpew_Profiling);
 #endif
 }
 
 bool
@@ -922,17 +923,17 @@ CodeGeneratorShared::generateCompactTrac
     trackedOptimizationsAttemptsTableOffset_ = attemptsTableOffset;
 
     verifyCompactTrackedOptimizationsMap(code, numRegions, unique, allTypes);
 
     JitSpew(JitSpew_OptimizationTracking,
             "== Compact Native To Optimizations Map [%p-%p] size %u",
             data, data + trackedOptimizationsMapSize_, trackedOptimizationsMapSize_);
     JitSpew(JitSpew_OptimizationTracking,
-            "     with type list of length %u, size %u",
+            "     with type list of length %" PRIuSIZE ", size %" PRIuSIZE,
             allTypes->length(), allTypes->length() * sizeof(IonTrackedTypeWithAddendum));
 
     return true;
 }
 
 #ifdef DEBUG
 class ReadTempAttemptsVectorOp : public JS::ForEachTrackedOptimizationAttemptOp
 {
--- a/js/src/jit/shared/IonAssemblerBufferWithConstantPools.h
+++ b/js/src/jit/shared/IonAssemblerBufferWithConstantPools.h
@@ -3,16 +3,17 @@
  * 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/. */
 
 #ifndef jit_shared_IonAssemblerBufferWithConstantPools_h
 #define jit_shared_IonAssemblerBufferWithConstantPools_h
 
 #include "mozilla/MathAlgorithms.h"
+#include "mozilla/SizePrintfMacros.h"
 
 #include <algorithm>
 
 #include "jit/JitSpewer.h"
 #include "jit/shared/IonAssemblerBuffer.h"
 
 // This code extends the AssemblerBuffer to support the pooling of values loaded
 // using program-counter relative addressing modes. This is necessary with the
@@ -787,17 +788,17 @@ struct AssemblerBufferWithConstantPools 
         // range check.
         if (numPoolEntries)
             pool_.updateLimiter(BufferOffset(sizeExcludingCurrentPool()));
 
         if (!hasSpaceForInsts(numInst, numPoolEntries)) {
             if (numPoolEntries)
                 JitSpew(JitSpew_Pools, "[%d] Inserting pool entry caused a spill", id);
             else
-                JitSpew(JitSpew_Pools, "[%d] Inserting instruction(%d) caused a spill", id,
+                JitSpew(JitSpew_Pools, "[%d] Inserting instruction(%" PRIuSIZE ") caused a spill", id,
                         sizeExcludingCurrentPool());
 
             finishPool();
             if (this->oom())
                 return OOM_FAIL;
             return insertEntryForwards(numInst, numPoolEntries, inst, data);
         }
         if (numPoolEntries) {
@@ -858,17 +859,17 @@ struct AssemblerBufferWithConstantPools 
         // Insert the pool value.
         unsigned index = insertEntryForwards(numInst, numPoolEntries, inst, data);
         if (this->oom())
             return BufferOffset();
 
         // Now to get an instruction to write.
         PoolEntry retPE;
         if (numPoolEntries) {
-            JitSpew(JitSpew_Pools, "[%d] Entry has index %u, offset %u", id, index,
+            JitSpew(JitSpew_Pools, "[%d] Entry has index %u, offset %" PRIuSIZE, id, index,
                     sizeExcludingCurrentPool());
             Asm::InsertIndexIntoTag(inst, index);
             // Figure out the offset within the pool entries.
             retPE = PoolEntry(poolEntryCount);
             poolEntryCount += numPoolEntries;
         }
         // Now inst is a valid thing to insert into the instruction stream.
         if (pe != nullptr)
@@ -930,18 +931,18 @@ struct AssemblerBufferWithConstantPools 
         // Include branches that would expire in the next N bytes.
         // The hysteresis avoids the needless creation of many tiny constant
         // pools.
         return this->nextOffset().getOffset() + ShortRangeBranchHysteresis >
                size_t(branchDeadlines_.earliestDeadline().getOffset());
     }
 
     void finishPool() {
-        JitSpew(JitSpew_Pools, "[%d] Attempting to finish pool %d with %d entries.", id,
-                poolInfo_.length(), pool_.numEntries());
+        JitSpew(JitSpew_Pools, "[%d] Attempting to finish pool %" PRIuSIZE " with %u entries.",
+                id, poolInfo_.length(), pool_.numEntries());
 
         if (pool_.numEntries() == 0 && !hasExpirableShortRangeBranches()) {
             // If there is no data in the pool being dumped, don't dump anything.
             JitSpew(JitSpew_Pools, "[%d] Aborting because the pool is empty", id);
             return;
         }
 
         // Should not be placing a pool in a no-pool region, check.
@@ -999,17 +1000,17 @@ struct AssemblerBufferWithConstantPools 
             // substitutions.
             Inst* inst = this->getInst(*iter);
             size_t codeOffset = poolOffset - iter->getOffset();
 
             // That is, PatchConstantPoolLoad wants to be handed the address of
             // the pool entry that is being loaded.  We need to do a non-trivial
             // amount of math here, since the pool that we've made does not
             // actually reside there in memory.
-            JitSpew(JitSpew_Pools, "[%d] Fixing entry %d offset to %u", id, idx, codeOffset);
+            JitSpew(JitSpew_Pools, "[%d] Fixing entry %d offset to %" PRIuSIZE, id, idx, codeOffset);
             Asm::PatchConstantPoolLoad(inst, (uint8_t*)inst + codeOffset);
         }
 
         // Record the pool info.
         unsigned firstEntry = poolEntryCount - pool_.numEntries();
         if (!poolInfo_.append(PoolInfo(firstEntry, data))) {
             this->fail_oom();
             return;
@@ -1032,17 +1033,17 @@ struct AssemblerBufferWithConstantPools 
         MOZ_ASSERT(!canNotPlacePool_);
         insertNopFill();
 
         // Check if the pool will spill by adding maxInst instructions, and if
         // so then finish the pool before entering the no-pool region. It is
         // assumed that no pool entries are allocated in a no-pool region and
         // this is asserted when allocating entries.
         if (!hasSpaceForInsts(maxInst, 0)) {
-            JitSpew(JitSpew_Pools, "[%d] No-Pool instruction(%d) caused a spill.", id,
+            JitSpew(JitSpew_Pools, "[%d] No-Pool instruction(%" PRIuSIZE ") caused a spill.", id,
                     sizeExcludingCurrentPool());
             finishPool();
         }
 
 #ifdef DEBUG
         // Record the buffer position to allow validating maxInst when leaving
         // the region.
         canNotPlacePoolStartOffset_ = this->nextOffset().getOffset();
@@ -1072,18 +1073,18 @@ struct AssemblerBufferWithConstantPools 
         if (requiredFill == 0)
             return;
         requiredFill = alignment - requiredFill;
 
         // Add an InstSize because it is probably not useful for a pool to be
         // dumped at the aligned code position.
         if (!hasSpaceForInsts(requiredFill / InstSize + 1, 0)) {
             // Alignment would cause a pool dump, so dump the pool now.
-            JitSpew(JitSpew_Pools, "[%d] Alignment of %d at %d caused a spill.", id, alignment,
-                    sizeExcludingCurrentPool());
+            JitSpew(JitSpew_Pools, "[%d] Alignment of %d at %" PRIuSIZE " caused a spill.",
+                    id, alignment, sizeExcludingCurrentPool());
             finishPool();
         }
 
         inhibitNops_ = true;
         while ((sizeExcludingCurrentPool() & (alignment - 1)) && !this->oom())
             putInt(alignFillInst_);
         inhibitNops_ = false;
     }
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -5194,23 +5194,26 @@ namespace JS {
 const uint16_t MaxNumErrorArguments = 10;
 };
 
 /**
  * Report an exception represented by the sprintf-like conversion of format
  * and its arguments.
  */
 extern JS_PUBLIC_API(void)
-JS_ReportErrorASCII(JSContext* cx, const char* format, ...);
+JS_ReportErrorASCII(JSContext* cx, const char* format, ...)
+    MOZ_FORMAT_PRINTF(2, 3);
 
 extern JS_PUBLIC_API(void)
-JS_ReportErrorLatin1(JSContext* cx, const char* format, ...);
+JS_ReportErrorLatin1(JSContext* cx, const char* format, ...)
+    MOZ_FORMAT_PRINTF(2, 3);
 
 extern JS_PUBLIC_API(void)
-JS_ReportErrorUTF8(JSContext* cx, const char* format, ...);
+JS_ReportErrorUTF8(JSContext* cx, const char* format, ...)
+    MOZ_FORMAT_PRINTF(2, 3);
 
 /*
  * Use an errorNumber to retrieve the format string, args are char*
  */
 extern JS_PUBLIC_API(void)
 JS_ReportErrorNumberASCII(JSContext* cx, JSErrorCallback errorCallback,
                           void* userRef, const unsigned errorNumber, ...);
 
@@ -5252,23 +5255,26 @@ JS_ReportErrorNumberUCArray(JSContext* c
 
 /**
  * As above, but report a warning instead (JSREPORT_IS_WARNING(report.flags)).
  * Return true if there was no error trying to issue the warning, and if the
  * warning was not converted into an error due to the JSOPTION_WERROR option
  * being set, false otherwise.
  */
 extern JS_PUBLIC_API(bool)
-JS_ReportWarningASCII(JSContext* cx, const char* format, ...);
-
-extern JS_PUBLIC_API(bool)
-JS_ReportWarningLatin1(JSContext* cx, const char* format, ...);
-
-extern JS_PUBLIC_API(bool)
-JS_ReportWarningUTF8(JSContext* cx, const char* format, ...);
+JS_ReportWarningASCII(JSContext* cx, const char* format, ...)
+    MOZ_FORMAT_PRINTF(2, 3);
+
+extern JS_PUBLIC_API(bool)
+JS_ReportWarningLatin1(JSContext* cx, const char* format, ...)
+    MOZ_FORMAT_PRINTF(2, 3);
+
+extern JS_PUBLIC_API(bool)
+JS_ReportWarningUTF8(JSContext* cx, const char* format, ...)
+    MOZ_FORMAT_PRINTF(2, 3);
 
 extern JS_PUBLIC_API(bool)
 JS_ReportErrorFlagsAndNumberASCII(JSContext* cx, unsigned flags,
                                   JSErrorCallback errorCallback, void* userRef,
                                   const unsigned errorNumber, ...);
 
 extern JS_PUBLIC_API(bool)
 JS_ReportErrorFlagsAndNumberLatin1(JSContext* cx, unsigned flags,
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -3625,21 +3625,21 @@ js::DumpBacktrace(JSContext* cx, FILE* f
         }
         char frameType =
             i.isInterp() ? 'i' :
             i.isBaseline() ? 'b' :
             i.isIon() ? 'I' :
             i.isWasm() ? 'W' :
             '?';
 
-        sprinter.printf("#%d %14p %c   %s:%d",
+        sprinter.printf("#%" PRIuSIZE " %14p %c   %s:%d",
                         depth, i.rawFramePtr(), frameType, filename, line);
 
         if (i.hasScript()) {
-            sprinter.printf(" (%p @ %d)\n",
+            sprinter.printf(" (%p @ %" PRIuSIZE ")\n",
                             i.script(), i.script()->pcToOffset(i.pc()));
         } else {
             sprinter.printf(" (%p)\n", i.pc());
         }
     }
     fprintf(fp, "%s", sprinter.string());
 #ifdef XP_WIN32
     if (IsDebuggerPresent())
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -146,37 +146,37 @@ js::StackDefs(JSScript* script, jsbyteco
     return cs.ndefs;
 }
 
 const char * PCCounts::numExecName = "interp";
 
 static MOZ_MUST_USE bool
 DumpIonScriptCounts(Sprinter* sp, HandleScript script, jit::IonScriptCounts* ionCounts)
 {
-    if (!sp->jsprintf("IonScript [%lu blocks]:\n", ionCounts->numBlocks()))
+    if (!sp->jsprintf("IonScript [%" PRIuSIZE " blocks]:\n", ionCounts->numBlocks()))
         return false;
 
     for (size_t i = 0; i < ionCounts->numBlocks(); i++) {
         const jit::IonBlockCounts& block = ionCounts->block(i);
         unsigned lineNumber = 0, columnNumber = 0;
         lineNumber = PCToLineNumber(script, script->offsetToPC(block.offset()), &columnNumber);
-        if (!sp->jsprintf("BB #%lu [%05u,%u,%u]",
+        if (!sp->jsprintf("BB #%" PRIu32 " [%05u,%u,%u]",
                           block.id(), block.offset(), lineNumber, columnNumber))
         {
             return false;
         }
         if (block.description()) {
             if (!sp->jsprintf(" [inlined %s]", block.description()))
                 return false;
         }
         for (size_t j = 0; j < block.numSuccessors(); j++) {
-            if (!sp->jsprintf(" -> #%lu", block.successor(j)))
+            if (!sp->jsprintf(" -> #%" PRIu32, block.successor(j)))
                 return false;
         }
-        if (!sp->jsprintf(" :: %llu hits\n", block.hitCount()))
+        if (!sp->jsprintf(" :: %" PRIu64 " hits\n", block.hitCount()))
             return false;
         if (!sp->jsprintf("%s\n", block.code()))
             return false;
     }
 
     return true;
 }
 
--- a/js/src/jsprf.cpp
+++ b/js/src/jsprf.cpp
@@ -58,67 +58,45 @@ struct NumArgState
 {
     int type;       // type of the current ap
     va_list ap;     // point to the corresponding position on ap
 };
 
 typedef mozilla::Vector<NumArgState, 20, js::SystemAllocPolicy> NumArgStateVector;
 
 
-#define TYPE_INT16      0
-#define TYPE_UINT16     1
+#define TYPE_SHORT      0
+#define TYPE_USHORT     1
 #define TYPE_INTN       2
 #define TYPE_UINTN      3
-#define TYPE_INT32      4
-#define TYPE_UINT32     5
-#define TYPE_INT64      6
-#define TYPE_UINT64     7
+#define TYPE_LONG       4
+#define TYPE_ULONG      5
+#define TYPE_LONGLONG   6
+#define TYPE_ULONGLONG  7
 #define TYPE_STRING     8
 #define TYPE_DOUBLE     9
 #define TYPE_INTSTR     10
-#define TYPE_WSTRING    11
+#define TYPE_POINTER    11
 #define TYPE_UNKNOWN    20
 
 #define FLAG_LEFT       0x1
 #define FLAG_SIGNED     0x2
 #define FLAG_SPACED     0x4
 #define FLAG_ZEROS      0x8
 #define FLAG_NEG        0x10
 
 inline bool
 generic_write(SprintfState* ss, const char* src, size_t srclen)
 {
     return (*ss->stuff)(ss, src, srclen);
 }
 
-inline bool
-generic_write(SprintfState* ss, const char16_t* src, size_t srclen)
-{
-    const size_t CHUNK_SIZE = 64;
-    char chunk[CHUNK_SIZE];
-
-    size_t j = 0;
-    size_t i = 0;
-    while (i < srclen) {
-        // FIXME: truncates characters to 8 bits
-        chunk[j++] = char(src[i++]);
-
-        if (j == CHUNK_SIZE || i == srclen) {
-            if (!(*ss->stuff)(ss, chunk, j))
-                return false;
-            j = 0;
-        }
-    }
-    return true;
-}
-
 // Fill into the buffer using the data in src
-template <typename Char>
 static bool
-fill2(SprintfState* ss, const Char* src, int srclen, int width, int flags)
+fill2(SprintfState* ss, const char* src, int srclen, int width, int flags)
 {
     char space = ' ';
 
     width -= srclen;
     if (width > 0 && (flags & FLAG_LEFT) == 0) {    // Right adjusting
         if (flags & FLAG_ZEROS)
             space = '0';
         while (--width >= 0) {
@@ -313,29 +291,26 @@ static bool cvt_f(SprintfState* ss, doub
     }
 #endif
     SprintfLiteral(fout, fin, d);
 
     return (*ss->stuff)(ss, fout, strlen(fout));
 }
 
 static inline const char* generic_null_str(const char*) { return "(null)"; }
-static inline const char16_t* generic_null_str(const char16_t*) { return u"(null)"; }
 
 static inline size_t generic_strlen(const char* s) { return strlen(s); }
-static inline size_t generic_strlen(const char16_t* s) { return js_strlen(s); }
 
 /*
  * Convert a string into its printable form.  "width" is the output
  * width. "prec" is the maximum number of characters of "s" to output,
  * where -1 means until NUL.
  */
-template <typename Char>
 static bool
-cvt_s(SprintfState* ss, const Char* s, int width, int prec, int flags)
+cvt_s(SprintfState* ss, const char* s, int width, int prec, int flags)
 {
     if (prec == 0)
         return true;
     if (!s)
         s = generic_null_str(s);
 
     // Limit string length by precision value
     int slen = int(generic_strlen(s));
@@ -447,33 +422,34 @@ BuildArgArray(const char* fmt, va_list a
             while ((c >= '0') && (c <= '9')) {
                 c = *p++;
             }
         }
 
         // size
         nas[cn].type = TYPE_INTN;
         if (c == 'h') {
-            nas[cn].type = TYPE_INT16;
+            nas[cn].type = TYPE_SHORT;
             c = *p++;
         } else if (c == 'L') {
-            // XXX not quite sure here
-            nas[cn].type = TYPE_INT64;
+            nas[cn].type = TYPE_LONGLONG;
             c = *p++;
         } else if (c == 'l') {
-            nas[cn].type = TYPE_INT32;
+            nas[cn].type = TYPE_LONG;
             c = *p++;
             if (c == 'l') {
-                nas[cn].type = TYPE_INT64;
+                nas[cn].type = TYPE_LONGLONG;
                 c = *p++;
             }
         } else if (c == 'z' || c == 'I') {
-            static_assert(sizeof(size_t) == sizeof(int32_t) || sizeof(size_t) == sizeof(int64_t),
+            static_assert(sizeof(size_t) == sizeof(int) || sizeof(size_t) == sizeof(long) ||
+                          sizeof(size_t) == sizeof(long long),
                           "size_t is not one of the expected sizes");
-            nas[cn].type = sizeof(size_t) == sizeof(int64_t) ? TYPE_INT64 : TYPE_INT32;
+            nas[cn].type = sizeof(size_t) == sizeof(int) ? TYPE_INTN :
+                sizeof(size_t) == sizeof(long) ? TYPE_LONG : TYPE_LONGLONG;
             c = *p++;
         }
 
         // format
         switch (c) {
         case 'd':
         case 'c':
         case 'i':
@@ -485,39 +461,30 @@ BuildArgArray(const char* fmt, va_list a
 
         case 'e':
         case 'f':
         case 'g':
             nas[cn].type = TYPE_DOUBLE;
             break;
 
         case 'p':
-            // XXX should use cpp
-            if (sizeof(void*) == sizeof(int32_t)) {
-                nas[cn].type = TYPE_UINT32;
-            } else if (sizeof(void*) == sizeof(int64_t)) {
-                nas[cn].type = TYPE_UINT64;
-            } else if (sizeof(void*) == sizeof(int)) {
-                nas[cn].type = TYPE_UINTN;
-            } else {
-                nas[cn].type = TYPE_UNKNOWN;
-            }
+            nas[cn].type = TYPE_POINTER;
             break;
 
         case 'C':
         case 'S':
         case 'E':
         case 'G':
             // XXX not supported I suppose
             MOZ_ASSERT(0);
             nas[cn].type = TYPE_UNKNOWN;
             break;
 
         case 's':
-            nas[cn].type = (nas[cn].type == TYPE_UINT16) ? TYPE_WSTRING : TYPE_STRING;
+            nas[cn].type = TYPE_STRING;
             break;
 
         case 'n':
             nas[cn].type = TYPE_INTSTR;
             break;
 
         default:
             MOZ_ASSERT(0);
@@ -539,28 +506,28 @@ BuildArgArray(const char* fmt, va_list a
         if (nas[cn].type == TYPE_UNKNOWN) {
             cn++;
             continue;
         }
 
         VARARGS_ASSIGN(nas[cn].ap, ap);
 
         switch (nas[cn].type) {
-        case TYPE_INT16:
-        case TYPE_UINT16:
+        case TYPE_SHORT:
+        case TYPE_USHORT:
         case TYPE_INTN:
         case TYPE_UINTN:        (void) va_arg(ap, int);         break;
-        case TYPE_INT32:        (void) va_arg(ap, int32_t);     break;
-        case TYPE_UINT32:       (void) va_arg(ap, uint32_t);    break;
-        case TYPE_INT64:        (void) va_arg(ap, int64_t);     break;
-        case TYPE_UINT64:       (void) va_arg(ap, uint64_t);    break;
+        case TYPE_LONG:         (void) va_arg(ap, long);        break;
+        case TYPE_ULONG:        (void) va_arg(ap, unsigned long); break;
+        case TYPE_LONGLONG:     (void) va_arg(ap, long long);   break;
+        case TYPE_ULONGLONG:    (void) va_arg(ap, unsigned long long); break;
         case TYPE_STRING:       (void) va_arg(ap, char*);       break;
-        case TYPE_WSTRING:      (void) va_arg(ap, char16_t*);   break;
         case TYPE_INTSTR:       (void) va_arg(ap, int*);        break;
         case TYPE_DOUBLE:       (void) va_arg(ap, double);      break;
+        case TYPE_POINTER:      (void) va_arg(ap, void*);       break;
 
         default: MOZ_CRASH();
         }
 
         cn++;
     }
 
     return true;
@@ -571,24 +538,23 @@ BuildArgArray(const char* fmt, va_list a
  */
 static bool
 dosprintf(SprintfState* ss, const char* fmt, va_list ap)
 {
     char c;
     int flags, width, prec, radix, type;
     union {
         char ch;
-        char16_t wch;
         int i;
         long l;
-        int64_t ll;
+        long long ll;
         double d;
         const char* s;
-        const char16_t* ws;
         int* ip;
+        void* p;
     } u;
     const char* fmt0;
     static const char hex[] = "0123456789abcdef";
     static const char HEX[] = "0123456789ABCDEF";
     const char* hexp;
     int i;
     char pattern[20];
     const char* dolPt = nullptr;  // in "%4$.2f", dolPt will point to '.'
@@ -680,33 +646,34 @@ dosprintf(SprintfState* ss, const char* 
                     c = *fmt++;
                 }
             }
         }
 
         // size
         type = TYPE_INTN;
         if (c == 'h') {
-            type = TYPE_INT16;
+            type = TYPE_SHORT;
             c = *fmt++;
         } else if (c == 'L') {
-            // XXX not quite sure here
-            type = TYPE_INT64;
+            type = TYPE_LONGLONG;
             c = *fmt++;
         } else if (c == 'l') {
-            type = TYPE_INT32;
+            type = TYPE_LONG;
             c = *fmt++;
             if (c == 'l') {
-                type = TYPE_INT64;
+                type = TYPE_LONGLONG;
                 c = *fmt++;
             }
         } else if (c == 'z' || c == 'I') {
-            static_assert(sizeof(size_t) == sizeof(int32_t) || sizeof(size_t) == sizeof(int64_t),
+            static_assert(sizeof(size_t) == sizeof(int) || sizeof(size_t) == sizeof(long) ||
+                          sizeof(size_t) == sizeof(long long),
                           "size_t is not one of the expected sizes");
-            type = sizeof(size_t) == sizeof(int64_t) ? TYPE_INT64 : TYPE_INT32;
+            type = sizeof(size_t) == sizeof(int) ? TYPE_INTN :
+                sizeof(size_t) == sizeof(long) ? TYPE_LONG : TYPE_LONGLONG;
             c = *fmt++;
         }
 
         // format
         hexp = hex;
         switch (c) {
           case 'd': case 'i':                   // decimal/integer
             radix = 10;
@@ -730,61 +697,64 @@ dosprintf(SprintfState* ss, const char* 
           case 'X':                             // unsigned HEX
             radix = 16;
             hexp = HEX;
             type |= 1;
             goto fetch_and_convert;
 
           fetch_and_convert:
             switch (type) {
-              case TYPE_INT16:
+              case TYPE_SHORT:
                 u.l = va_arg(ap, int);
                 if (u.l < 0) {
                     u.l = -u.l;
                     flags |= FLAG_NEG;
                 }
                 goto do_long;
-              case TYPE_UINT16:
-                u.l = va_arg(ap, int) & 0xffff;
+              case TYPE_USHORT:
+                u.l = (unsigned short) va_arg(ap, unsigned int);
                 goto do_long;
               case TYPE_INTN:
                 u.l = va_arg(ap, int);
                 if (u.l < 0) {
                     u.l = -u.l;
                     flags |= FLAG_NEG;
                 }
                 goto do_long;
               case TYPE_UINTN:
                 u.l = (long)va_arg(ap, unsigned int);
                 goto do_long;
 
-              case TYPE_INT32:
-                u.l = va_arg(ap, int32_t);
+              case TYPE_LONG:
+                u.l = va_arg(ap, long);
                 if (u.l < 0) {
                     u.l = -u.l;
                     flags |= FLAG_NEG;
                 }
                 goto do_long;
-              case TYPE_UINT32:
-                u.l = (long)va_arg(ap, uint32_t);
+              case TYPE_ULONG:
+                u.l = (long)va_arg(ap, unsigned long);
               do_long:
                 if (!cvt_l(ss, u.l, width, prec, radix, type, flags, hexp))
                     return false;
 
                 break;
 
-              case TYPE_INT64:
-                u.ll = va_arg(ap, int64_t);
+              case TYPE_LONGLONG:
+                u.ll = va_arg(ap, long long);
                 if (u.ll < 0) {
                     u.ll = -u.ll;
                     flags |= FLAG_NEG;
                 }
                 goto do_longlong;
-              case TYPE_UINT64:
-                u.ll = va_arg(ap, uint64_t);
+              case TYPE_POINTER:
+                u.ll = (uintptr_t)va_arg(ap, void*);
+                goto do_longlong;
+              case TYPE_ULONGLONG:
+                u.ll = va_arg(ap, unsigned long long);
               do_longlong:
                 if (!cvt_ll(ss, u.ll, width, prec, radix, type, flags, hexp))
                     return false;
 
                 break;
             }
             break;
 
@@ -811,65 +781,50 @@ dosprintf(SprintfState* ss, const char* 
           case 'c':
             if ((flags & FLAG_LEFT) == 0) {
                 while (width-- > 1) {
                     if (!(*ss->stuff)(ss, " ", 1))
                         return false;
                 }
             }
             switch (type) {
-              case TYPE_INT16:
+              case TYPE_SHORT:
               case TYPE_INTN:
                 u.ch = va_arg(ap, int);
                 if (!(*ss->stuff)(ss, &u.ch, 1))
                     return false;
                 break;
             }
             if (flags & FLAG_LEFT) {
                 while (width-- > 1) {
                     if (!(*ss->stuff)(ss, " ", 1))
                         return false;
                 }
             }
             break;
 
           case 'p':
-            if (sizeof(void*) == sizeof(int32_t)) {
-                type = TYPE_UINT32;
-            } else if (sizeof(void*) == sizeof(int64_t)) {
-                type = TYPE_UINT64;
-            } else if (sizeof(void*) == sizeof(int)) {
-                type = TYPE_UINTN;
-            } else {
-                MOZ_ASSERT(0);
-                break;
-            }
+            type = TYPE_POINTER;
             radix = 16;
             goto fetch_and_convert;
 
 #if 0
           case 'C':
           case 'S':
           case 'E':
           case 'G':
             // XXX not supported I suppose
             MOZ_ASSERT(0);
             break;
 #endif
 
           case 's':
-            if(type == TYPE_INT16) {
-                u.ws = va_arg(ap, const char16_t*);
-                if (!cvt_s(ss, u.ws, width, prec, flags))
-                    return false;
-            } else {
-                u.s = va_arg(ap, const char*);
-                if (!cvt_s(ss, u.s, width, prec, flags))
-                    return false;
-            }
+            u.s = va_arg(ap, const char*);
+            if (!cvt_s(ss, u.s, width, prec, flags))
+                return false;
             break;
 
           case 'n':
             u.ip = va_arg(ap, int*);
             if (u.ip) {
                 *u.ip = ss->cur - ss->base;
             }
             break;
@@ -999,27 +954,27 @@ JS_vsprintf_append(char* last, const cha
     }
     if (!dosprintf(&ss, fmt, ap)) {
         js_free(ss.base);
         return 0;
     }
     return ss.base;
 }
 
-#undef TYPE_INT16
-#undef TYPE_UINT16
+#undef TYPE_SHORT
+#undef TYPE_USHORT
 #undef TYPE_INTN
 #undef TYPE_UINTN
-#undef TYPE_INT32
-#undef TYPE_UINT32
-#undef TYPE_INT64
-#undef TYPE_UINT64
+#undef TYPE_LONG
+#undef TYPE_ULONG
+#undef TYPE_LONGLONG
+#undef TYPE_ULONGLONG
 #undef TYPE_STRING
 #undef TYPE_DOUBLE
 #undef TYPE_INTSTR
-#undef TYPE_WSTRING
+#undef TYPE_POINTER
 #undef TYPE_UNKNOWN
 
 #undef FLAG_LEFT
 #undef FLAG_SIGNED
 #undef FLAG_SPACED
 #undef FLAG_ZEROS
 #undef FLAG_NEG
--- a/js/src/jsprf.h
+++ b/js/src/jsprf.h
@@ -9,21 +9,23 @@
 
 /*
 ** API for PR printf like routines. Supports the following formats
 **      %d - decimal
 **      %u - unsigned decimal
 **      %x - unsigned hex
 **      %X - unsigned uppercase hex
 **      %o - unsigned octal
-**      %hd, %hu, %hx, %hX, %ho - 16-bit versions of above
-**      %ld, %lu, %lx, %lX, %lo - 32-bit versions of above
-**      %lld, %llu, %llx, %llX, %llo - 64 bit versions of above
-**      %s - ascii string
-**      %hs - ucs2 string
+**      %hd, %hu, %hx, %hX, %ho - "short" versions of above
+**      %ld, %lu, %lx, %lX, %lo - "long" versions of above
+**      %lld, %llu, %llx, %llX, %llo - "long long" versions of above
+**      %zd, %zo, %zu, %zx, %zX - size_t versions of above
+**      %Id, %Io, %Iu, %Ix, %IX - size_t versions of above (for Windows compat)
+**           You should use PRI*SIZE macros instead
+**      %s - string
 **      %c - character
 **      %p - pointer (deals with machine dependent pointer size)
 **      %f - float
 **      %g - float
 */
 
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/SizePrintfMacros.h"
@@ -32,31 +34,33 @@
 
 #include "jstypes.h"
 
 /*
 ** sprintf into a malloc'd buffer. Return a pointer to the malloc'd
 ** buffer on success, nullptr on failure. Call "JS_smprintf_free" to release
 ** the memory returned.
 */
-extern JS_PUBLIC_API(char*) JS_smprintf(const char* fmt, ...);
+extern JS_PUBLIC_API(char*) JS_smprintf(const char* fmt, ...)
+    MOZ_FORMAT_PRINTF(1, 2);
 
 /*
 ** Free the memory allocated, for the caller, by JS_smprintf
 */
 extern JS_PUBLIC_API(void) JS_smprintf_free(char* mem);
 
 /*
 ** "append" sprintf into a malloc'd buffer. "last" is the last value of
 ** the malloc'd buffer. sprintf will append data to the end of last,
 ** growing it as necessary using realloc. If last is nullptr, JS_sprintf_append
 ** will allocate the initial string. The return value is the new value of
 ** last for subsequent calls, or nullptr if there is a malloc failure.
 */
-extern JS_PUBLIC_API(char*) JS_sprintf_append(char* last, const char* fmt, ...);
+extern JS_PUBLIC_API(char*) JS_sprintf_append(char* last, const char* fmt, ...)
+    MOZ_FORMAT_PRINTF(2, 3);
 
 /*
 ** va_list forms of the above.
 */
 extern JS_PUBLIC_API(char*) JS_vsmprintf(const char* fmt, va_list ap);
 extern JS_PUBLIC_API(char*) JS_vsprintf_append(char* last, const char* fmt, va_list ap);
 
 #endif /* jsprf_h */
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -778,13 +778,13 @@ if CONFIG['SPIDERMONKEY_PROMISE']:
 if CONFIG['JS_HAS_CTYPES']:
     if CONFIG['MOZ_SYSTEM_FFI']:
         CXXFLAGS += CONFIG['MOZ_FFI_CFLAGS']
     else:
         # Windows needs this to be linked with a static library.
         DEFINES['FFI_BUILDING'] = True
 
 if CONFIG['GNU_CXX']:
-    CXXFLAGS += ['-Wno-shadow']
+    CXXFLAGS += ['-Wno-shadow', '-Werror=format']
 
 # Suppress warnings in third-party code.
 if CONFIG['CLANG_CXX']:
     SOURCES['jsdtoa.cpp'].flags += ['-Wno-implicit-fallthrough']
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -5227,17 +5227,17 @@ ReflectTrackedOptimizations(JSContext* c
             // Use endOffset, as startOffset may be associated with a
             // previous, adjacent region ending exactly at startOffset. That
             // is, suppose we have two regions [0, startOffset], [startOffset,
             // endOffset]. Since we are not querying a return address, we want
             // the second region and not the first.
             uint8_t* addr = ion->method()->raw() + endOffset;
             entry.youngestFrameLocationAtAddr(rt, addr, &script, &pc);
 
-            if (!sp.jsprintf("{\"location\":\"%s:%u\",\"offset\":%u,\"index\":%u}%s",
+            if (!sp.jsprintf("{\"location\":\"%s:%" PRIuSIZE "\",\"offset\":%" PRIuSIZE ",\"index\":%u}%s",
                              script->filename(), script->lineno(), script->pcToOffset(pc), index,
                              iter.more() ? "," : ""))
             {
                 return false;
             }
         }
     }
 
--- a/js/src/shell/jsoptparse.cpp
+++ b/js/src/shell/jsoptparse.cpp
@@ -259,17 +259,17 @@ OptionParser::printVersion()
 OptionParser::Result
 OptionParser::extractValue(size_t argc, char** argv, size_t* i, char** value)
 {
     MOZ_ASSERT(*i < argc);
     char* eq = strchr(argv[*i], '=');
     if (eq) {
         *value = eq + 1;
         if (*value[0] == '\0')
-            return error("A value is required for option %.*s", eq - argv[*i], argv[*i]);
+            return error("A value is required for option %.*s", (int) (eq - argv[*i]), argv[*i]);
         return Okay;
     }
 
     if (argc == *i + 1)
         return error("Expected a value for option %s", argv[*i]);
 
     *i += 1;
     *value = argv[*i];
--- a/js/src/shell/jsoptparse.h
+++ b/js/src/shell/jsoptparse.h
@@ -223,17 +223,17 @@ class OptionParser
     Option* findOption(char shortflag);
     const Option* findOption(char shortflag) const;
     Option* findOption(const char* longflag);
     const Option* findOption(const char* longflag) const;
     int findArgumentIndex(const char* name) const;
     Option* findArgument(const char* name);
     const Option* findArgument(const char* name) const;
 
-    Result error(const char* fmt, ...);
+    Result error(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3);
     Result extractValue(size_t argc, char** argv, size_t* i, char** value);
     Result handleArg(size_t argc, char** argv, size_t* i, bool* optsAllowed);
     Result handleOption(Option* opt, size_t argc, char** argv, size_t* i, bool* optsAllowed);
 
   public:
     explicit OptionParser(const char* usage)
       : helpOption('h', "help", "Display help information"),
         versionOption('v', "version", "Display version information and exit"),
--- a/js/src/shell/moz.build
+++ b/js/src/shell/moz.build
@@ -46,17 +46,17 @@ GENERATED_FILES += ['shellmoduleloader.o
 shellmoduleloader = GENERATED_FILES['shellmoduleloader.out.h']
 shellmoduleloader.script = '../builtin/embedjs.py:generate_shellmoduleloader'
 shellmoduleloader.inputs = [
     '../js.msg',
     'ModuleLoader.js',
 ]
 
 if CONFIG['GNU_CXX']:
-    CXXFLAGS += ['-Wno-shadow']
+    CXXFLAGS += ['-Wno-shadow', '-Werror=format']
 
 # This is intended as a temporary workaround to enable VS2015.
 if CONFIG['_MSC_VER']:
     CXXFLAGS += ['-wd4312']
 
 # Place a GDB Python auto-load file next to the shell executable, both in
 # the build directory and in the dist/bin directory.
 DEFINES['topsrcdir'] = '%s/js/src' % TOPSRCDIR
--- a/js/src/vm/CodeCoverage.cpp
+++ b/js/src/vm/CodeCoverage.cpp
@@ -86,26 +86,26 @@ LCovSource::exportInto(GenericPrinter& o
     // Only write if everything got recorded.
     if (!hasFilename_ || !hasTopLevelScript_)
         return;
 
     outSF_.exportInto(out);
 
     outFN_.exportInto(out);
     outFNDA_.exportInto(out);
-    out.printf("FNF:%d\n", numFunctionsFound_);
-    out.printf("FNH:%d\n", numFunctionsHit_);
+    out.printf("FNF:%" PRIuSIZE "\n", numFunctionsFound_);
+    out.printf("FNH:%" PRIuSIZE "\n", numFunctionsHit_);
 
     outBRDA_.exportInto(out);
-    out.printf("BRF:%d\n", numBranchesFound_);
-    out.printf("BRH:%d\n", numBranchesHit_);
+    out.printf("BRF:%" PRIuSIZE "\n", numBranchesFound_);
+    out.printf("BRH:%" PRIuSIZE "\n", numBranchesHit_);
 
     outDA_.exportInto(out);
-    out.printf("LF:%d\n", numLinesInstrumented_);
-    out.printf("LH:%d\n", numLinesHit_);
+    out.printf("LF:%" PRIuSIZE "\n", numLinesInstrumented_);
+    out.printf("LH:%" PRIuSIZE "\n", numLinesHit_);
 
     out.put("end_of_record\n");
 }
 
 bool
 LCovSource::writeSourceFilename(ScriptSourceObject* sso)
 {
     outSF_.printf("SF:%s\n", sso->source()->filename());
@@ -125,17 +125,17 @@ LCovSource::writeScriptName(LSprinter& o
     out.printf("top-level");
     return true;
 }
 
 bool
 LCovSource::writeScript(JSScript* script)
 {
     numFunctionsFound_++;
-    outFN_.printf("FN:%d,", script->lineno());
+    outFN_.printf("FN:%" PRIuSIZE ",", script->lineno());
     if (!writeScriptName(outFN_, script))
         return false;
     outFN_.put("\n", 1);
 
     uint64_t hits = 0;
     ScriptCounts* sc = nullptr;
     if (script->hasScriptCounts()) {
         sc = &script->getScriptCounts();
@@ -186,17 +186,17 @@ LCovSource::writeScript(JSScript* script
                 else if (type == SRC_TABLESWITCH)
                     tableswitchExitOffset = GetSrcNoteOffset(sn, 0);
 
                 sn = SN_NEXT(sn);
                 snpc += SN_DELTA(sn);
             }
 
             if (oldLine != lineno && fallsthrough) {
-                outDA_.printf("DA:%d,%" PRIu64 "\n", lineno, hits);
+                outDA_.printf("DA:%" PRIuSIZE ",%" PRIu64 "\n", lineno, hits);
 
                 // Count the number of lines instrumented & hit.
                 numLinesInstrumented_++;
                 if (hits)
                     numLinesHit_++;
             }
         }
 
@@ -215,23 +215,23 @@ LCovSource::writeScript(JSScript* script
             uint64_t fallthroughHits = 0;
             if (sc) {
                 const PCCounts* counts = sc->maybeGetPCCounts(script->pcToOffset(fallthroughTarget));
                 if (counts)
                     fallthroughHits = counts->numExec();
             }
 
             uint64_t taken = hits - fallthroughHits;
-            outBRDA_.printf("BRDA:%d,%d,0,", lineno, branchId);
+            outBRDA_.printf("BRDA:%" PRIuSIZE ",%" PRIuSIZE ",0,", lineno, branchId);
             if (taken)
                 outBRDA_.printf("%" PRIu64 "\n", taken);
             else
                 outBRDA_.put("-\n", 2);
 
-            outBRDA_.printf("BRDA:%d,%d,1,", lineno, branchId);
+            outBRDA_.printf("BRDA:%" PRIuSIZE ",%" PRIuSIZE ",1,", lineno, branchId);
             if (fallthroughHits)
                 outBRDA_.printf("%" PRIu64 "\n", fallthroughHits);
             else
                 outBRDA_.put("-\n", 2);
 
             // Count the number of branches, and the number of branches hit.
             numBranchesFound_ += 2;
             if (hits)
@@ -303,17 +303,18 @@ LCovSource::writeScript(JSScript* script
 
                             if (BytecodeFallsThrough(JSOp(*endpc)))
                                 fallsThroughHits = script->getHitCount(endpc);
                         }
 
                         caseHits -= fallsThroughHits;
                     }
 
-                    outBRDA_.printf("BRDA:%d,%d,%d,", lineno, branchId, caseId);
+                    outBRDA_.printf("BRDA:%" PRIuSIZE ",%" PRIuSIZE ",%" PRIuSIZE ",",
+                                    lineno, branchId, caseId);
                     if (caseHits)
                         outBRDA_.printf("%" PRIu64 "\n", caseHits);
                     else
                         outBRDA_.put("-\n", 2);
 
                     numBranchesFound_++;
                     numBranchesHit_ += !!caseHits;
                     defaultHits -= caseHits;
@@ -354,17 +355,18 @@ LCovSource::writeScript(JSScript* script
                     const PCCounts* counts = sc->maybeGetPCCounts(script->pcToOffset(defaultpc));
                     if (counts)
                         defaultHits = counts->numExec();
                 }
                 defaultHits -= fallsThroughHits;
             }
 
             if (defaultHasOwnClause) {
-                outBRDA_.printf("BRDA:%d,%d,%d,", lineno, branchId, caseId);
+                outBRDA_.printf("BRDA:%" PRIuSIZE ",%" PRIuSIZE ",%" PRIuSIZE ",",
+                                lineno, branchId, caseId);
                 if (defaultHits)
                     outBRDA_.printf("%" PRIu64 "\n", defaultHits);
                 else
                     outBRDA_.put("-\n", 2);
                 numBranchesFound_++;
                 numBranchesHit_ += !!defaultHits;
             }
 
--- a/js/src/vm/Printer.h
+++ b/js/src/vm/Printer.h
@@ -38,17 +38,17 @@ class GenericPrinter
     // the beginning of this new data.
     virtual int put(const char* s, size_t len) = 0;
 
     inline int put(const char* s) {
         return put(s, strlen(s));
     }
 
     // Prints a formatted string into the buffer.
-    virtual int printf(const char* fmt, ...);
+    virtual int printf(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3);
     virtual int vprintf(const char* fmt, va_list ap);
 
     // Report that a string operation failed to get the memory it requested. The
     // first call to this function calls JS_ReportOutOfMemory, and sets this
     // Sprinter's outOfMemory flag; subsequent calls do nothing.
     virtual void reportOutOfMemory();
 
     // Return true if this Sprinter ran out of memory.
@@ -110,17 +110,17 @@ class Sprinter final : public GenericPri
     // Puts |len| characters from |s| at the current position and return an offset to
     // the beginning of this new data.
     virtual int put(const char* s, size_t len) override;
     using GenericPrinter::put; // pick up |inline int put(const char* s);|
 
     // Format the given format/arguments as if by JS_vsmprintf, then put it.
     // Return true on success, else return false and report an error (typically
     // OOM).
-    MOZ_MUST_USE bool jsprintf(const char* fmt, ...);
+    MOZ_MUST_USE bool jsprintf(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3);
 
     // Prints a formatted string into the buffer.
     virtual int vprintf(const char* fmt, va_list ap) override;
 
     int putString(JSString* str);
 
     ptrdiff_t getOffset() const;
 
@@ -152,17 +152,17 @@ class Fprinter final : public GenericPri
     void finish();
 
     // Puts |len| characters from |s| at the current position and return an
     // offset to the beginning of this new data.
     virtual int put(const char* s, size_t len) override;
     using GenericPrinter::put; // pick up |inline int put(const char* s);|
 
     // Prints a formatted string into the buffer.
-    virtual int printf(const char* fmt, ...) override;
+    virtual int printf(const char* fmt, ...) override MOZ_FORMAT_PRINTF(2, 3);
     virtual int vprintf(const char* fmt, va_list ap) override;
 };
 
 // LSprinter, is similar to Sprinter except that instead of using an
 // ExclusiveContext to allocate strings, it use a LifoAlloc as a backend for the
 // allocation of the chunk of the string.
 class LSprinter final : public GenericPrinter
 {
@@ -198,17 +198,17 @@ class LSprinter final : public GenericPr
     void clear();
 
     // Puts |len| characters from |s| at the current position and return an
     // offset to the beginning of this new data.
     virtual int put(const char* s, size_t len) override;
     using GenericPrinter::put; // pick up |inline int put(const char* s);|
 
     // Prints a formatted string into the buffer.
-    virtual int printf(const char* fmt, ...) override;
+    virtual int printf(const char* fmt, ...) override MOZ_FORMAT_PRINTF(2, 3);
     virtual int vprintf(const char* fmt, va_list ap) override;
 
     // Report that a string operation failed to get the memory it requested. The
     // first call to this function calls JS_ReportOutOfMemory, and sets this
     // Sprinter's outOfMemory flag; subsequent calls do nothing.
     virtual void reportOutOfMemory() override;
 
     // Return true if this Sprinter ran out of memory.
--- a/js/src/vm/TraceLoggingGraph.cpp
+++ b/js/src/vm/TraceLoggingGraph.cpp
@@ -45,16 +45,17 @@ TraceLoggerGraphState* traceLoggerGraphS
 #endif
 
 #define MAX_LOGGERS 999
 
 // Return a filename relative to the output directory. %u and %d substitutions
 // are allowed, with %u standing for a full 32-bit number and %d standing for
 // an up to 3-digit number.
 static js::UniqueChars
+MOZ_FORMAT_PRINTF(1, 2)
 AllocTraceLogFilename(const char* pattern, ...) {
     js::UniqueChars filename;
 
     va_list ap;
 
     static const char* outdir = getenv("TLDIR") ? getenv("TLDIR") : DEFAULT_TRACE_LOG_DIR;
     size_t len = strlen(outdir) + 1; // "+ 1" is for the '/'
 
--- a/js/src/vm/TypeInference.cpp
+++ b/js/src/vm/TypeInference.cpp
@@ -232,16 +232,17 @@ js::InferSpewImpl(const char* fmt, ...)
     fprintf(stderr, "[infer] ");
     vfprintf(stderr, fmt, ap);
     fprintf(stderr, "\n");
     va_end(ap);
 }
 #endif
 
 MOZ_NORETURN MOZ_COLD static void
+MOZ_FORMAT_PRINTF(2, 3)
 TypeFailure(JSContext* cx, const char* fmt, ...)
 {
     char msgbuf[1024]; /* Larger error messages will be truncated */
     char errbuf[1024];
 
     va_list ap;
     va_start(ap, fmt);
     VsprintfLiteral(errbuf, fmt, ap);
@@ -3283,17 +3284,17 @@ js::TypeMonitorResult(JSContext* cx, JSS
     assertSameCompartment(cx, script, type);
 
     AutoEnterAnalysis enter(cx);
 
     StackTypeSet* types = TypeScript::BytecodeTypes(script, pc);
     if (types->hasType(type))
         return;
 
-    InferSpew(ISpewOps, "bytecodeType: %p %05u: %s",
+    InferSpew(ISpewOps, "bytecodeType: %p %05" PRIuSIZE ": %s",
               script, script->pcToOffset(pc), TypeSet::TypeString(type));
     types->addType(cx, type);
 }
 
 void
 js::TypeMonitorResult(JSContext* cx, JSScript* script, jsbytecode* pc, const js::Value& rval)
 {
     /* Allow the non-TYPESET scenario to simplify stubs used in compound opcodes. */
--- a/js/src/vm/TypeInference.h
+++ b/js/src/vm/TypeInference.h
@@ -1291,17 +1291,17 @@ enum SpewChannel {
 #ifdef DEBUG
 
 bool InferSpewActive(SpewChannel channel);
 const char * InferSpewColorReset();
 const char * InferSpewColor(TypeConstraint* constraint);
 const char * InferSpewColor(TypeSet* types);
 
 #define InferSpew(channel, ...) if (InferSpewActive(channel)) { InferSpewImpl(__VA_ARGS__); } else {}
-void InferSpewImpl(const char* fmt, ...);
+void InferSpewImpl(const char* fmt, ...) MOZ_FORMAT_PRINTF(1, 2);
 
 /* Check that the type property for id in group contains value. */
 bool ObjectGroupHasProperty(JSContext* cx, ObjectGroup* group, jsid id, const Value& value);
 
 #else
 
 inline const char * InferSpewColorReset() { return nullptr; }
 inline const char * InferSpewColor(TypeConstraint* constraint) { return nullptr; }
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -149,16 +149,17 @@ private:
     char*      mBuf;
 
     // prevent copying and assignment
     JSCLContextHelper(const JSCLContextHelper&) = delete;
     const JSCLContextHelper& operator=(const JSCLContextHelper&) = delete;
 };
 
 static nsresult
+MOZ_FORMAT_PRINTF(2, 3)
 ReportOnCallerUTF8(JSContext* callerContext,
                    const char* format, ...) {
     if (!callerContext) {
         return NS_ERROR_FAILURE;
     }
 
     va_list ap;
     va_start(ap, format);
@@ -172,16 +173,17 @@ ReportOnCallerUTF8(JSContext* callerCont
     JS_ReportErrorUTF8(callerContext, "%s", buf);
     JS_smprintf_free(buf);
 
     va_end(ap);
     return NS_OK;
 }
 
 static nsresult
+MOZ_FORMAT_PRINTF(2, 3)
 ReportOnCallerUTF8(JSCLContextHelper& helper,
                    const char* format, ...)
 {
     va_list ap;
     va_start(ap, format);
 
     char* buf = JS_vsmprintf(format, ap);
     if (!buf) {
--- a/js/xpconnect/src/XPCThrower.cpp
+++ b/js/xpconnect/src/XPCThrower.cpp
@@ -111,19 +111,19 @@ XPCThrower::ThrowBadResult(nsresult rv, 
         return;
 
     // else...
 
     if (!nsXPCException::NameAndFormatForNSResult(rv, nullptr, &format) || !format)
         format = "";
 
     if (nsXPCException::NameAndFormatForNSResult(result, &name, nullptr) && name)
-        sz = JS_smprintf("%s 0x%x (%s)", format, result, name);
+        sz = JS_smprintf("%s 0x%x (%s)", format, (unsigned) result, name);
     else
-        sz = JS_smprintf("%s 0x%x", format, result);
+        sz = JS_smprintf("%s 0x%x", format, (unsigned) result);
     NS_ENSURE_TRUE_VOID(sz);
 
     if (sz && sVerbose)
         Verbosify(ccx, &sz, true);
 
     dom::Throw(ccx, result, nsDependentCString(sz));
 
     if (sz)
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -966,17 +966,17 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
         return NS_ERROR_FAILURE;
 
     // [implicit_jscontext] and [optional_argc] have a different calling
     // convention, which we don't support for JS-implemented components.
     if (info->WantsOptArgc() || info->WantsContext()) {
         const char* str = "IDL methods marked with [implicit_jscontext] "
                           "or [optional_argc] may not be implemented in JS";
         // Throw and warn for good measure.
-        JS_ReportErrorASCII(cx, str);
+        JS_ReportErrorASCII(cx, "%s", str);
         NS_WARNING(str);
         return CheckForException(ccx, aes, name, GetInterfaceName());
     }
 
     RootedValue fval(cx);
     RootedObject obj(cx, wrapper->GetJSObject());
     RootedObject thisObj(cx, obj);
 
--- a/js/xpconnect/src/moz.build
+++ b/js/xpconnect/src/moz.build
@@ -67,9 +67,9 @@ LOCAL_INCLUDES += [
 ]
 
 if CONFIG['MOZ_B2G_BT']:
     LOCAL_INCLUDES += [
         '/dom/bluetooth/common',
     ]
 
 if CONFIG['GNU_CXX']:
-    CXXFLAGS += ['-Wno-shadow']
+    CXXFLAGS += ['-Wno-shadow', '-Werror=format']
--- a/js/xpconnect/wrappers/AccessCheck.cpp
+++ b/js/xpconnect/wrappers/AccessCheck.cpp
@@ -269,17 +269,17 @@ AccessCheck::checkPassToPrivilegedCode(J
 }
 
 enum Access { READ = (1<<0), WRITE = (1<<1), NO_ACCESS = 0 };
 
 static void
 EnterAndThrowASCII(JSContext* cx, JSObject* wrapper, const char* msg)
 {
     JSAutoCompartment ac(cx, wrapper);
-    JS_ReportErrorASCII(cx, msg);
+    JS_ReportErrorASCII(cx, "%s", msg);
 }
 
 bool
 ExposedPropertiesOnly::check(JSContext* cx, HandleObject wrapper, HandleId id, Wrapper::Action act)
 {
     RootedObject wrappedObject(cx, Wrapper::wrappedObject(wrapper));
 
     if (act == Wrapper::CALL)