diff --git a/js/public/RootingAPI.h b/js/public/RootingAPI.h index f6796e7460ce..ada108c9c628 100644 --- a/js/public/RootingAPI.h +++ b/js/public/RootingAPI.h @@ -1165,7 +1165,9 @@ class PersistentRooted : private mozilla::LinkedListElement registerWithRuntime(rt); } - PersistentRooted(PersistentRooted &rhs) : ptr(rhs.ptr) + PersistentRooted(PersistentRooted &rhs) + : mozilla::LinkedListElement >(), + ptr(rhs.ptr) { /* * Copy construction takes advantage of the fact that the original diff --git a/js/src/configure.in b/js/src/configure.in index a3a18f1cbda9..f4ccbd551cd3 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -1162,6 +1162,7 @@ if test "$GNU_CC"; then _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement" MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type) MOZ_C_SUPPORTS_WARNING(-W, error=int-to-pointer-cast, ac_c_has_werror_int_to_pointer_cast) + MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits) MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body) MOZ_C_SUPPORTS_WARNING(-W, sign-compare, ac_c_has_sign_compare) diff --git a/js/src/jit/IonFrames.h b/js/src/jit/IonFrames.h index 085b15e0de7b..c760fda4a293 100644 --- a/js/src/jit/IonFrames.h +++ b/js/src/jit/IonFrames.h @@ -177,7 +177,6 @@ class OsiIndex // < highest - - - - - - - - - - - - - - lowest > static const uintptr_t FRAMESIZE_SHIFT = 4; static const uintptr_t FRAMETYPE_BITS = 4; -static const uintptr_t FRAMETYPE_MASK = (1 << FRAMETYPE_BITS) - 1; // Ion frames have a few important numbers associated with them: // Local depth: The number of bytes required to spill local variables. @@ -464,7 +463,7 @@ class IonExitFrameLayout : public IonCommonFrameLayout public: // Pushed for "bare" fake exit frames that have no GC things on stack to be // marked. - static JitCode *const BareToken() { return (JitCode *)0xFF; } + static JitCode *BareToken() { return (JitCode *)0xFF; } static inline size_t Size() { return sizeof(IonExitFrameLayout); @@ -518,7 +517,7 @@ class IonNativeExitFrameLayout uint32_t hiCalleeResult_; public: - static JitCode *const Token() { return (JitCode *)0x0; } + static JitCode *Token() { return (JitCode *)0x0; } static inline size_t Size() { return sizeof(IonNativeExitFrameLayout); @@ -556,7 +555,7 @@ class IonOOLNativeExitFrameLayout uint32_t hiThis_; public: - static JitCode *const Token() { return (JitCode *)0x4; } + static JitCode *Token() { return (JitCode *)0x4; } static inline size_t Size(size_t argc) { // The frame accounts for the callee/result and |this|, so we only need args. @@ -602,7 +601,7 @@ class IonOOLPropertyOpExitFrameLayout JitCode *stubCode_; public: - static JitCode *const Token() { return (JitCode *)0x5; } + static JitCode *Token() { return (JitCode *)0x5; } static inline size_t Size() { return sizeof(IonOOLPropertyOpExitFrameLayout); @@ -654,7 +653,7 @@ class IonOOLProxyExitFrameLayout JitCode *stubCode_; public: - static JitCode *const Token() { return (JitCode *)0x6; } + static JitCode *Token() { return (JitCode *)0x6; } static inline size_t Size() { return sizeof(IonOOLProxyExitFrameLayout); @@ -694,8 +693,8 @@ class IonDOMExitFrameLayout uint32_t hiCalleeResult_; public: - static JitCode *const GetterToken() { return (JitCode *)0x1; } - static JitCode *const SetterToken() { return (JitCode *)0x2; } + static JitCode *GetterToken() { return (JitCode *)0x1; } + static JitCode *SetterToken() { return (JitCode *)0x2; } static inline size_t Size() { return sizeof(IonDOMExitFrameLayout); @@ -734,7 +733,7 @@ class IonDOMMethodExitFrameLayout friend struct IonDOMMethodExitFrameLayoutTraits; public: - static JitCode *const Token() { return (JitCode *)0x3; } + static JitCode *Token() { return (JitCode *)0x3; } static inline size_t Size() { return sizeof(IonDOMMethodExitFrameLayout); diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index 9faa3d03e997..f1e0d42c0cab 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -14,8 +14,6 @@ #include "mozilla/Array.h" -#include "jsinfer.h" - #include "jit/CompilerRoot.h" #include "jit/FixedList.h" #include "jit/InlineList.h" @@ -37,7 +35,7 @@ class BaselineInspector; class ValueNumberData; class Range; -static const inline +static inline MIRType MIRTypeFromValue(const js::Value &vp) { if (vp.isDouble()) @@ -1074,7 +1072,7 @@ class MConstant : public MNullaryInstruction const js::Value *vp() const { return &value_; } - const bool valueToBoolean() const { + bool valueToBoolean() const { // A hack to avoid this wordy pattern everywhere in the JIT. return ToBoolean(HandleValue::fromMarkedLocation(&value_)); } @@ -8579,13 +8577,13 @@ class MSetDOMProperty public: INSTRUCTION_HEADER(SetDOMProperty) - static MSetDOMProperty *New(TempAllocator &alloc, const JSJitSetterOp func, MDefinition *obj, + static MSetDOMProperty *New(TempAllocator &alloc, JSJitSetterOp func, MDefinition *obj, MDefinition *val) { return new(alloc) MSetDOMProperty(func, obj, val); } - const JSJitSetterOp fun() { + JSJitSetterOp fun() const { return func_; } @@ -8652,7 +8650,7 @@ class MGetDOMProperty return new(alloc) MGetDOMProperty(info, obj, guard); } - const JSJitGetterOp fun() { + JSJitGetterOp fun() const { return info_->getter; } bool isInfallible() const { diff --git a/js/src/jit/PerfSpewer.cpp b/js/src/jit/PerfSpewer.cpp index 35d993251d28..b5cfce7db7e0 100644 --- a/js/src/jit/PerfSpewer.cpp +++ b/js/src/jit/PerfSpewer.cpp @@ -212,7 +212,7 @@ PerfSpewer::writeProfile(JSScript *script, size_t size = code->instructionsSize(); if (size > 0) { - fprintf(PerfFilePtr, "%zx %zx %s:%d: Func%02d\n", + fprintf(PerfFilePtr, "%zx %zx %s:%zu: Func%02d\n", reinterpret_cast(code->raw()), size, script->filename(), @@ -236,7 +236,7 @@ PerfSpewer::writeProfile(JSScript *script, size_t prologueSize = masm.actualOffset(basicBlocks_[0].start.offset()); if (prologueSize > 0) { - fprintf(PerfFilePtr, "%zx %zx %s:%d: Func%02d-Prologue\n", + fprintf(PerfFilePtr, "%zx %zx %s:%zu: Func%02d-Prologue\n", funcStart, prologueSize, script->filename(), script->lineno(), thisFunctionIndex); } @@ -249,7 +249,7 @@ PerfSpewer::writeProfile(JSScript *script, JS_ASSERT(cur <= blockStart); if (cur < blockStart) { - fprintf(PerfFilePtr, "%zx %zx %s:%d: Func%02d-Block?\n", + fprintf(PerfFilePtr, "%zx %zx %s:%zu: Func%02d-Block?\n", static_cast(cur), static_cast(blockStart - cur), script->filename(), script->lineno(), @@ -269,7 +269,7 @@ PerfSpewer::writeProfile(JSScript *script, JS_ASSERT(cur <= funcEndInlineCode); if (cur < funcEndInlineCode) { - fprintf(PerfFilePtr, "%zx %zx %s:%d: Func%02d-Epilogue\n", + fprintf(PerfFilePtr, "%zx %zx %s:%zu: Func%02d-Epilogue\n", cur, funcEndInlineCode - cur, script->filename(), script->lineno(), thisFunctionIndex); @@ -277,7 +277,7 @@ PerfSpewer::writeProfile(JSScript *script, JS_ASSERT(funcEndInlineCode <= funcEnd); if (funcEndInlineCode < funcEnd) { - fprintf(PerfFilePtr, "%zx %zx %s:%d: Func%02d-OOL\n", + fprintf(PerfFilePtr, "%zx %zx %s:%zu: Func%02d-OOL\n", funcEndInlineCode, funcEnd - funcEndInlineCode, script->filename(), script->lineno(), thisFunctionIndex); @@ -299,7 +299,7 @@ js::jit::writePerfSpewerBaselineProfile(JSScript *script, JitCode *code) size_t size = code->instructionsSize(); if (size > 0) { - fprintf(PerfFilePtr, "%zx %zx %s:%d: Baseline\n", + fprintf(PerfFilePtr, "%zx %zx %s:%zu: Baseline\n", reinterpret_cast(code->raw()), size, script->filename(), script->lineno()); } diff --git a/js/src/jit/RegisterSets.h b/js/src/jit/RegisterSets.h index 5070b2131f7a..fdb085b5e1a0 100644 --- a/js/src/jit/RegisterSets.h +++ b/js/src/jit/RegisterSets.h @@ -60,7 +60,7 @@ struct AnyRegister { const char *name() const { return isFloat() ? fpu().name() : gpr().name(); } - const Code code() const { + Code code() const { return code_; } bool volatile_() const { diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index b86ad22cb392..8c21024405f5 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -244,7 +244,7 @@ struct ThreadSafeContext : ContextFriendFields, public: static size_t offsetOfAllocator() { return offsetof(ThreadSafeContext, allocator_); } - inline Allocator *const allocator(); + inline Allocator *allocator() const; // Allocations can only trigger GC when running on the main thread. inline AllowGC allowGC() const { return isJSContext() ? CanGC : NoGC; } diff --git a/js/src/jsgcinlines.h b/js/src/jsgcinlines.h index 10021ac9546b..ac4da3a99f27 100644 --- a/js/src/jsgcinlines.h +++ b/js/src/jsgcinlines.h @@ -42,8 +42,8 @@ struct AutoMarkInDeadZone bool scheduled; }; -inline Allocator *const -ThreadSafeContext::allocator() +inline Allocator * +ThreadSafeContext::allocator() const { JS_ASSERT_IF(isJSContext(), &asJSContext()->zone()->allocator == allocator_); return allocator_; diff --git a/js/src/jsopcode.cpp b/js/src/jsopcode.cpp index 15aaf7be57dd..33ced5fe96bb 100644 --- a/js/src/jsopcode.cpp +++ b/js/src/jsopcode.cpp @@ -1610,7 +1610,7 @@ ExpressionDecompiler::write(JSString *str) bool ExpressionDecompiler::quote(JSString *s, uint32_t quote) { - return QuoteString(&sprinter, s, quote) >= 0; + return QuoteString(&sprinter, s, quote) != nullptr; } JSAtom * diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 514b8629928e..9ce1dbbe0484 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -3422,11 +3422,11 @@ JSScript::getStaticScope(jsbytecode *pc) if (!hasBlockScopes()) return nullptr; - ptrdiff_t offset = pc - main(); - - if (offset < 0) + if (pc < main()) return nullptr; + size_t offset = pc - main(); + BlockScopeArray *scopes = blockScopes(); NestedScopeObject *blockChain = nullptr; diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 73cb9f1338ea..1c9e46216f9a 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -755,7 +755,7 @@ CreateMappedArrayBuffer(JSContext *cx, unsigned argc, Value *vp) JS_ReportError(cx, "Unable to stat file"); return false; } - if (st.st_size < offset) { + if (st.st_size < off_t(offset)) { JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "2"); return false; diff --git a/js/src/vm/ArrayBufferObject.h b/js/src/vm/ArrayBufferObject.h index 6f2a2b34631a..51824cc52524 100644 --- a/js/src/vm/ArrayBufferObject.h +++ b/js/src/vm/ArrayBufferObject.h @@ -388,14 +388,14 @@ struct uint8_clamped { }; /* Note that we can't use std::numeric_limits here due to uint8_clamped. */ -template inline const bool TypeIsFloatingPoint() { return false; } -template<> inline const bool TypeIsFloatingPoint() { return true; } -template<> inline const bool TypeIsFloatingPoint() { return true; } +template inline bool TypeIsFloatingPoint() { return false; } +template<> inline bool TypeIsFloatingPoint() { return true; } +template<> inline bool TypeIsFloatingPoint() { return true; } -template inline const bool TypeIsUnsigned() { return false; } -template<> inline const bool TypeIsUnsigned() { return true; } -template<> inline const bool TypeIsUnsigned() { return true; } -template<> inline const bool TypeIsUnsigned() { return true; } +template inline bool TypeIsUnsigned() { return false; } +template<> inline bool TypeIsUnsigned() { return true; } +template<> inline bool TypeIsUnsigned() { return true; } +template<> inline bool TypeIsUnsigned() { return true; } } // namespace js diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index e82f3457dbe6..12f3b6c7fc59 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -172,16 +172,16 @@ js::ClampDoubleToUint8(const double x) return y; } -template static inline const int TypeIDOfType(); -template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_INT8; } -template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_UINT8; } -template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_INT16; } -template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_UINT16; } -template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_INT32; } -template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_UINT32; } -template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_FLOAT32; } -template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_FLOAT64; } -template<> inline const int TypeIDOfType() { return ScalarTypeDescr::TYPE_UINT8_CLAMPED; } +template static inline int TypeIDOfType(); +template<> inline int TypeIDOfType() { return ScalarTypeDescr::TYPE_INT8; } +template<> inline int TypeIDOfType() { return ScalarTypeDescr::TYPE_UINT8; } +template<> inline int TypeIDOfType() { return ScalarTypeDescr::TYPE_INT16; } +template<> inline int TypeIDOfType() { return ScalarTypeDescr::TYPE_UINT16; } +template<> inline int TypeIDOfType() { return ScalarTypeDescr::TYPE_INT32; } +template<> inline int TypeIDOfType() { return ScalarTypeDescr::TYPE_UINT32; } +template<> inline int TypeIDOfType() { return ScalarTypeDescr::TYPE_FLOAT32; } +template<> inline int TypeIDOfType() { return ScalarTypeDescr::TYPE_FLOAT64; } +template<> inline int TypeIDOfType() { return ScalarTypeDescr::TYPE_UINT8_CLAMPED; } template static inline JSObject * @@ -195,9 +195,9 @@ class TypedArrayObjectTemplate : public TypedArrayObject public: typedef NativeType ThisType; typedef TypedArrayObjectTemplate ThisTypedArrayObject; - static const int ArrayTypeID() { return TypeIDOfType(); } - static const bool ArrayTypeIsUnsigned() { return TypeIsUnsigned(); } - static const bool ArrayTypeIsFloatingPoint() { return TypeIsFloatingPoint(); } + static int ArrayTypeID() { return TypeIDOfType(); } + static bool ArrayTypeIsUnsigned() { return TypeIsUnsigned(); } + static bool ArrayTypeIsFloatingPoint() { return TypeIsFloatingPoint(); } static const size_t BYTES_PER_ELEMENT = sizeof(ThisType);