Bug 1115477 - Fix -Wunused and -Wtype-limits warnings in js/src. r=jandem
authorChris Peterson <cpeterson@mozilla.com>
Wed, 24 Dec 2014 21:06:21 -0800
changeset 247733 2fbdaa8a5ea77c689fe7003217866f1674a0292d
parent 247732 9096b9b4aa73d58742e88ced38f1d2018464f295
child 247734 9689b122bc76c62b769bd8a30bf989eb669e4bd0
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1115477
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1115477 - Fix -Wunused and -Wtype-limits warnings in js/src. r=jandem
js/ipc/JavaScriptLogging.h
js/src/asmjs/AsmJSFrameIterator.cpp
js/src/jsinfer.cpp
js/src/jsscript.h
js/src/vm/String.cpp
--- a/js/ipc/JavaScriptLogging.h
+++ b/js/ipc/JavaScriptLogging.h
@@ -114,20 +114,19 @@ class Logging
             side = shared->isParent() ? "parent" : "child";
             ptr = js::UncheckedUnwrap(obj, true);
         } else {
             objDesc = "<cpow>";
             side = shared->isParent() ? "child" : "parent";
             ptr = nullptr;
         }
 
-        out = nsPrintfCString("<%s %s:%d:%p>", side, objDesc, id, ptr);
+        out = nsPrintfCString("<%s %s:%d:%p>", side, objDesc, id.serialNumber(), ptr);
     }
 
-
     void format(const ReceiverObj &obj, nsCString &out) {
         formatObject(true, true, obj.id, out);
     }
 
     void format(const nsTArray<JSParam> &values, nsCString &out) {
         nsAutoCString tmp;
         out.Truncate();
         for (size_t i = 0; i < values.Length(); i++) {
--- a/js/src/asmjs/AsmJSFrameIterator.cpp
+++ b/js/src/asmjs/AsmJSFrameIterator.cpp
@@ -108,44 +108,44 @@ AsmJSFrameIterator::computeLine(uint32_t
 // Prologue/epilogue code generation
 
 // These constants reflect statically-determined offsets in the profiling
 // prologue/epilogue. The offsets are dynamically asserted during code
 // generation.
 #if defined(JS_CODEGEN_X64)
 # if defined(DEBUG)
 static const unsigned PushedRetAddr = 0;
+static const unsigned PostStorePrePopFP = 0;
 # endif
 static const unsigned PushedFP = 10;
 static const unsigned StoredFP = 14;
-static const unsigned PostStorePrePopFP = 0;
 #elif defined(JS_CODEGEN_X86)
 # if defined(DEBUG)
 static const unsigned PushedRetAddr = 0;
+static const unsigned PostStorePrePopFP = 0;
 # endif
 static const unsigned PushedFP = 8;
 static const unsigned StoredFP = 11;
-static const unsigned PostStorePrePopFP = 0;
 #elif defined(JS_CODEGEN_ARM)
 static const unsigned PushedRetAddr = 4;
 static const unsigned PushedFP = 16;
 static const unsigned StoredFP = 20;
 static const unsigned PostStorePrePopFP = 4;
 #elif defined(JS_CODEGEN_MIPS)
 static const unsigned PushedRetAddr = 8;
 static const unsigned PushedFP = 24;
 static const unsigned StoredFP = 28;
 static const unsigned PostStorePrePopFP = 4;
 #elif defined(JS_CODEGEN_NONE)
 # if defined(DEBUG)
 static const unsigned PushedRetAddr = 0;
+static const unsigned PostStorePrePopFP = 0;
 # endif
 static const unsigned PushedFP = 1;
 static const unsigned StoredFP = 1;
-static const unsigned PostStorePrePopFP = 0;
 #else
 # error "Unknown architecture!"
 #endif
 
 static void
 PushRetAddr(MacroAssembler &masm)
 {
 #if defined(JS_CODEGEN_ARM)
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -44,51 +44,57 @@ using namespace js::types;
 
 using mozilla::DebugOnly;
 using mozilla::Maybe;
 using mozilla::PodArrayZero;
 using mozilla::PodCopy;
 using mozilla::PodZero;
 
 static inline jsid
-id_prototype(JSContext *cx) {
+id_prototype(JSContext *cx)
+{
     return NameToId(cx->names().prototype);
 }
 
+#ifdef DEBUG
+
 static inline jsid
-id___proto__(JSContext *cx) {
+id___proto__(JSContext *cx)
+{
     return NameToId(cx->names().proto);
 }
 
 static inline jsid
-id_constructor(JSContext *cx) {
+id_constructor(JSContext *cx)
+{
     return NameToId(cx->names().constructor);
 }
 
 static inline jsid
-id_caller(JSContext *cx) {
+id_caller(JSContext *cx)
+{
     return NameToId(cx->names().caller);
 }
 
-#ifdef DEBUG
 const char *
 types::TypeIdStringImpl(jsid id)
 {
     if (JSID_IS_VOID(id))
         return "(index)";
     if (JSID_IS_EMPTY(id))
         return "(new)";
     if (JSID_IS_SYMBOL(id))
         return "(symbol)";
     static char bufs[4][100];
     static unsigned which = 0;
     which = (which + 1) & 3;
     PutEscapedString(bufs[which], 100, JSID_TO_FLAT_STRING(id), 0);
     return bufs[which];
 }
+
 #endif
 
 /////////////////////////////////////////////////////////////////////
 // Logging
 /////////////////////////////////////////////////////////////////////
 
 #ifdef DEBUG
 
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -57,22 +57,22 @@ namespace frontend {
 }
 
 /*
  * Type of try note associated with each catch or finally block, and also with
  * for-in and other kinds of loops. Non-for-in loops do not need these notes
  * for exception unwinding, but storing their boundaries here is helpful for
  * heuristics that need to know whether a given op is inside a loop.
  */
-typedef enum JSTryNoteKind {
+enum JSTryNoteKind {
     JSTRY_CATCH,
     JSTRY_FINALLY,
     JSTRY_ITER,
     JSTRY_LOOP
-} JSTryNoteKind;
+};
 
 /*
  * Exception handling record.
  */
 struct JSTryNote {
     uint8_t         kind;       /* one of JSTryNoteKind */
     uint32_t        stackDepth; /* stack depth upon exception handler entry */
     uint32_t        start;      /* start of the try statement or loop
@@ -1867,19 +1867,23 @@ class LazyScript : public gc::TenuredCel
     // ScriptSourceObject, or nullptr if the script in which this is nested
     // has not been compiled yet. This is never a CCW; we don't clone
     // LazyScripts into other compartments.
     HeapPtrObject sourceObject_;
 
     // Heap allocated table with any free variables or inner functions.
     void *table_;
 
+    // Add padding so LazyScript is gc::Cell aligned. Make padding protected
+    // instead of private to suppress -Wunused-private-field compiler warnings.
+  protected:
 #if JS_BITS_PER_WORD == 32
     uint32_t padding;
 #endif
+  private:
 
     struct PackedView {
         // Assorted bits that should really be in ScriptSourceObject.
         uint32_t version : 8;
 
         uint32_t numFreeVariables : 24;
         uint32_t numInnerFunctions : 23;
 
--- a/js/src/vm/String.cpp
+++ b/js/src/vm/String.cpp
@@ -767,18 +767,20 @@ StaticStrings::trace(JSTracer *trc)
         MarkPermanentAtom(trc, intStaticTable[i], "int-static-string");
 }
 
 template <typename CharT>
 /* static */ bool
 StaticStrings::isStatic(const CharT *chars, size_t length)
 {
     switch (length) {
-      case 1:
-        return chars[0] < UNIT_STATIC_LIMIT;
+      case 1: {
+        char16_t c = chars[0];
+        return c < UNIT_STATIC_LIMIT;
+      }
       case 2:
         return fitsInSmallChar(chars[0]) && fitsInSmallChar(chars[1]);
       case 3:
         if ('1' <= chars[0] && chars[0] <= '9' &&
             '0' <= chars[1] && chars[1] <= '9' &&
             '0' <= chars[2] && chars[2] <= '9') {
             int i = (chars[0] - '0') * 100 +
                       (chars[1] - '0') * 10 +