Bug 1103859 - Fix some -Wunused-variable warnings in jsapi-tests by replacing MOZ_ASSERTs with MOZ_RELEASE_ASSERTs; mark jsapi-tests as FAIL_ON_WARNINGS (for clang). r=jorendorff
authorChris Peterson <cpeterson@mozilla.com>
Sun, 23 Nov 2014 23:16:16 -0800
changeset 219643 f6beecf60b094020b517f9eb07fc2fdd2d8b1d50
parent 219642 7d0b5801159a89338ec078ed88a68e31f86fedf7
child 219644 adb8e0572744dbc1197c33964087405d80d31c66
push id10400
push userryanvm@gmail.com
push dateMon, 15 Dec 2014 18:54:54 +0000
treeherderfx-team@5d6e0d038f95 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1103859
milestone37.0a1
Bug 1103859 - Fix some -Wunused-variable warnings in jsapi-tests by replacing MOZ_ASSERTs with MOZ_RELEASE_ASSERTs; mark jsapi-tests as FAIL_ON_WARNINGS (for clang). r=jorendorff
js/src/jsapi-tests/moz.build
js/src/jsapi-tests/testCallNonGenericMethodOnProxy.cpp
js/src/jsapi-tests/testGCAllocator.cpp
js/src/jsapi-tests/testJitGVN.cpp
js/src/jsapi-tests/testLooselyEqual.cpp
js/src/jsapi-tests/testOOM.cpp
js/src/jsapi-tests/testParseJSON.cpp
js/src/jsapi-tests/testSetProperty.cpp
js/src/jsapi-tests/testWeakMap.cpp
js/src/jsapi-tests/tests.h
--- a/js/src/jsapi-tests/moz.build
+++ b/js/src/jsapi-tests/moz.build
@@ -104,8 +104,11 @@ DEFINES['IMPL_MFBT'] = True
 LOCAL_INCLUDES += ['..']
 GENERATED_INCLUDES += ['..']
 
 USE_LIBS += [
     'static:js',
 ]
 
 OS_LIBS += CONFIG['MOZ_ZLIB_LIBS']
+
+if CONFIG['CLANG_CXX']:
+    FAIL_ON_WARNINGS = True
--- a/js/src/jsapi-tests/testCallNonGenericMethodOnProxy.cpp
+++ b/js/src/jsapi-tests/testCallNonGenericMethodOnProxy.cpp
@@ -17,17 +17,17 @@ static bool
 IsCustomClass(JS::Handle<JS::Value> v)
 {
   return v.isObject() && JS_GetClass(&v.toObject()) == &CustomClass;
 }
 
 static bool
 CustomMethodImpl(JSContext *cx, CallArgs args)
 {
-  MOZ_ASSERT(IsCustomClass(args.thisv()));
+  MOZ_RELEASE_ASSERT(IsCustomClass(args.thisv()));
   args.rval().set(JS_GetReservedSlot(&args.thisv().toObject(), CUSTOM_SLOT));
   return true;
 }
 
 static bool
 CustomMethod(JSContext *cx, unsigned argc, Value *vp)
 {
   CallArgs args = CallArgsFromVp(argc, vp);
--- a/js/src/jsapi-tests/testGCAllocator.cpp
+++ b/js/src/jsapi-tests/testGCAllocator.cpp
@@ -253,24 +253,24 @@ unmapPages(void *p, size_t size)
 #elif defined(SOLARIS)
 // This test doesn't apply to Solaris.
 #elif defined(XP_UNIX)
 
 void *
 mapMemoryAt(void *desired, size_t length)
 {
 #if defined(__ia64__)
-    MOZ_ASSERT(0xffff800000000000ULL & (uintptr_t(desired) + length - 1) == 0);
+    MOZ_RELEASE_ASSERT(0xffff800000000000ULL & (uintptr_t(desired) + length - 1) == 0);
 #endif
     void *region = mmap(desired, length, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
     if (region == MAP_FAILED)
         return nullptr;
     if (region != desired) {
         if (munmap(region, length))
-            MOZ_ASSERT(errno == ENOMEM);
+            MOZ_RELEASE_ASSERT(errno == ENOMEM);
         return nullptr;
     }
     return region;
 }
 
 void *
 mapMemory(size_t length)
 {
@@ -279,26 +279,26 @@ mapMemory(size_t length)
     hint = (void*)0x0000070000000000ULL;
 #endif
     void *region = mmap(hint, length, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
     if (region == MAP_FAILED)
         return nullptr;
 #if defined(__ia64__)
     if ((uintptr_t(region) + (length - 1)) & 0xffff800000000000ULL) {
         if (munmap(region, length))
-            MOZ_ASSERT(errno == ENOMEM);
+            MOZ_RELEASE_ASSERT(errno == ENOMEM);
         return nullptr;
     }
 #endif
     return region;
 }
 
 void
 unmapPages(void *p, size_t size)
 {
     if (munmap(p, size))
-        MOZ_ASSERT(errno == ENOMEM);
+        MOZ_RELEASE_ASSERT(errno == ENOMEM);
 }
 
 #else // !defined(XP_WIN) && !defined(SOLARIS) && !defined(XP_UNIX)
 #error "Memory mapping functions are not defined for your OS."
 #endif
 END_TEST(testGCAllocator)
--- a/js/src/jsapi-tests/testJitGVN.cpp
+++ b/js/src/jsapi-tests/testJitGVN.cpp
@@ -76,38 +76,38 @@ BEGIN_TEST(testJitGVN_FixupOSROnlyLoop)
     outerHeader->setLoopHeader(outerBackedge);
     innerHeader->setLoopHeader(innerBackedge);
 
     if (!func.runGVN())
         return false;
 
     // The loops are no longer reachable from the normal entry. They are
     // doinated by the osrEntry.
-    MOZ_ASSERT(func.graph.osrBlock() == osrEntry);
+    MOZ_RELEASE_ASSERT(func.graph.osrBlock() == osrEntry);
     MBasicBlock *newInner = FollowTrivialGotos(osrEntry->lastIns()->toGoto()->target());
     MBasicBlock *newOuter = FollowTrivialGotos(newInner->lastIns()->toTest()->ifFalse());
     MBasicBlock *newExit = FollowTrivialGotos(entry);
-    MOZ_ASSERT(newInner->isLoopHeader());
-    MOZ_ASSERT(newOuter->isLoopHeader());
-    MOZ_ASSERT(newExit->lastIns()->isReturn());
+    MOZ_RELEASE_ASSERT(newInner->isLoopHeader());
+    MOZ_RELEASE_ASSERT(newOuter->isLoopHeader());
+    MOZ_RELEASE_ASSERT(newExit->lastIns()->isReturn());
 
     // One more time.
     ClearDominatorTree(func.graph);
     if (!func.runGVN())
         return false;
 
     // The loops are no longer reachable from the normal entry. They are
     // doinated by the osrEntry.
-    MOZ_ASSERT(func.graph.osrBlock() == osrEntry);
+    MOZ_RELEASE_ASSERT(func.graph.osrBlock() == osrEntry);
     newInner = FollowTrivialGotos(osrEntry->lastIns()->toGoto()->target());
     newOuter = FollowTrivialGotos(newInner->lastIns()->toTest()->ifFalse());
     newExit = FollowTrivialGotos(entry);
-    MOZ_ASSERT(newInner->isLoopHeader());
-    MOZ_ASSERT(newOuter->isLoopHeader());
-    MOZ_ASSERT(newExit->lastIns()->isReturn());
+    MOZ_RELEASE_ASSERT(newInner->isLoopHeader());
+    MOZ_RELEASE_ASSERT(newOuter->isLoopHeader());
+    MOZ_RELEASE_ASSERT(newExit->lastIns()->isReturn());
 
     return true;
 }
 END_TEST(testJitGVN_FixupOSROnlyLoop)
 
 BEGIN_TEST(testJitGVN_FixupOSROnlyLoopNested)
 {
     // Same as testJitGVN_FixupOSROnlyLoop but adds another level of loop
@@ -170,38 +170,38 @@ BEGIN_TEST(testJitGVN_FixupOSROnlyLoopNe
     middleHeader->setLoopHeader(middleBackedge);
     innerHeader->setLoopHeader(innerBackedge);
 
     if (!func.runGVN())
         return false;
 
     // The loops are no longer reachable from the normal entry. They are
     // doinated by the osrEntry.
-    MOZ_ASSERT(func.graph.osrBlock() == osrEntry);
+    MOZ_RELEASE_ASSERT(func.graph.osrBlock() == osrEntry);
     MBasicBlock *newInner = FollowTrivialGotos(osrEntry->lastIns()->toGoto()->target());
     MBasicBlock *newMiddle = FollowTrivialGotos(newInner->lastIns()->toTest()->ifFalse());
     MBasicBlock *newOuter = FollowTrivialGotos(newMiddle->lastIns()->toTest()->ifFalse());
     MBasicBlock *newExit = FollowTrivialGotos(entry);
-    MOZ_ASSERT(newInner->isLoopHeader());
-    MOZ_ASSERT(newMiddle->isLoopHeader());
-    MOZ_ASSERT(newOuter->isLoopHeader());
-    MOZ_ASSERT(newExit->lastIns()->isReturn());
+    MOZ_RELEASE_ASSERT(newInner->isLoopHeader());
+    MOZ_RELEASE_ASSERT(newMiddle->isLoopHeader());
+    MOZ_RELEASE_ASSERT(newOuter->isLoopHeader());
+    MOZ_RELEASE_ASSERT(newExit->lastIns()->isReturn());
 
     // One more time.
     ClearDominatorTree(func.graph);
     if (!func.runGVN())
         return false;
 
     // The loops are no longer reachable from the normal entry. They are
     // doinated by the osrEntry.
-    MOZ_ASSERT(func.graph.osrBlock() == osrEntry);
+    MOZ_RELEASE_ASSERT(func.graph.osrBlock() == osrEntry);
     newInner = FollowTrivialGotos(osrEntry->lastIns()->toGoto()->target());
     newMiddle = FollowTrivialGotos(newInner->lastIns()->toTest()->ifFalse());
     newOuter = FollowTrivialGotos(newMiddle->lastIns()->toTest()->ifFalse());
     newExit = FollowTrivialGotos(entry);
-    MOZ_ASSERT(newInner->isLoopHeader());
-    MOZ_ASSERT(newMiddle->isLoopHeader());
-    MOZ_ASSERT(newOuter->isLoopHeader());
-    MOZ_ASSERT(newExit->lastIns()->isReturn());
+    MOZ_RELEASE_ASSERT(newInner->isLoopHeader());
+    MOZ_RELEASE_ASSERT(newMiddle->isLoopHeader());
+    MOZ_RELEASE_ASSERT(newOuter->isLoopHeader());
+    MOZ_RELEASE_ASSERT(newExit->lastIns()->isReturn());
 
     return true;
 }
 END_TEST(testJitGVN_FixupOSROnlyLoopNested)
--- a/js/src/jsapi-tests/testLooselyEqual.cpp
+++ b/js/src/jsapi-tests/testLooselyEqual.cpp
@@ -58,18 +58,18 @@ struct LooseEqualityData
         undef = JSVAL_VOID;
         null = JSVAL_NULL;
         obj = OBJECT_TO_JSVAL(JS::CurrentGlobalOrNull(cx));
         poszero = DOUBLE_TO_JSVAL(0.0);
         negzero = DOUBLE_TO_JSVAL(-0.0);
 #ifdef XP_WIN
 # define copysign _copysign
 #endif
-        MOZ_ASSERT(copysign(1.0, poszero.toDouble()) == 1.0);
-        MOZ_ASSERT(copysign(1.0, negzero.toDouble()) == -1.0);
+        MOZ_RELEASE_ASSERT(copysign(1.0, poszero.toDouble()) == 1.0);
+        MOZ_RELEASE_ASSERT(copysign(1.0, negzero.toDouble()) == -1.0);
 #ifdef XP_WIN
 # undef copysign
 #endif
     }
 };
 
 // 11.9.3 1a
 BEGIN_FIXTURE_TEST(LooseEqualityFixture, test_undef_leq_undef)
--- a/js/src/jsapi-tests/testOOM.cpp
+++ b/js/src/jsapi-tests/testOOM.cpp
@@ -8,17 +8,17 @@
 
 BEGIN_TEST(testOOM)
 {
     JS::RootedValue v(cx, JS::Int32Value(9));
     JS::RootedString jsstr(cx, JS::ToString(cx, v));
     char16_t ch;
     if (!JS_GetStringCharAt(cx, jsstr, 0, &ch))
         return false;
-    MOZ_ASSERT(ch == '9');
+    MOZ_RELEASE_ASSERT(ch == '9');
     return true;
 }
 
 virtual JSRuntime * createRuntime()
 {
     JSRuntime *rt = JS_NewRuntime(0);
     if (!rt)
         return nullptr;
--- a/js/src/jsapi-tests/testParseJSON.cpp
+++ b/js/src/jsapi-tests/testParseJSON.cpp
@@ -325,20 +325,18 @@ ReportJSONError(JSContext *cx, const cha
 }
 
 END_TEST(testParseJSON_error)
 
 static bool
 Censor(JSContext *cx, unsigned argc, jsval *vp)
 {
     JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
-    MOZ_ASSERT(args.length() == 2);
-#ifdef DEBUG
-    MOZ_ASSERT(args[0].isString());
-#endif
+    MOZ_RELEASE_ASSERT(args.length() == 2);
+    MOZ_RELEASE_ASSERT(args[0].isString());
     args.rval().setNull();
     return true;
 }
 
 BEGIN_TEST(testParseJSON_reviver)
 {
     JSFunction *fun = JS_NewFunction(cx, Censor, 0, 0, global, "censor");
     CHECK(fun);
--- a/js/src/jsapi-tests/testSetProperty.cpp
+++ b/js/src/jsapi-tests/testSetProperty.cpp
@@ -63,23 +63,22 @@ NativeGet(JSContext *cx, JS::HandleObjec
 }
 END_TEST(testSetProperty_NativeGetterStubSetter)
 
 BEGIN_TEST(testSetProperty_InheritedGlobalSetter)
 {
     // This is a JSAPI test because jsapi-test globals do not have a resolve
     // hook and therefore can use the property cache in some cases where the
     // shell can't.
-    MOZ_ASSERT(!JS_GetClass(global)->resolve);
+    MOZ_RELEASE_ASSERT(!JS_GetClass(global)->resolve);
 
     CHECK(JS_DefineProperty(cx, global, "HOTLOOP", 8, 0));
     EXEC("var n = 0;\n"
          "var global = this;\n"
          "function f() { n++; }\n"
          "Object.defineProperty(Object.prototype, 'x', {set: f});\n"
          "for (var i = 0; i < HOTLOOP; i++)\n"
          "    global.x = i;\n");
     EXEC("if (n != HOTLOOP)\n"
          "    throw 'FAIL';\n");
     return true;
 }
 END_TEST(testSetProperty_InheritedGlobalSetter)
-
--- a/js/src/jsapi-tests/testWeakMap.cpp
+++ b/js/src/jsapi-tests/testWeakMap.cpp
@@ -122,26 +122,25 @@ BEGIN_TEST(testWeakMap_keyDelegates)
     JS_GC(rt);
     CHECK(checkSize(map, 0));
 
     return true;
 }
 
 static void DelegateObjectMoved(JSObject *obj, const JSObject *old)
 {
-    MOZ_ASSERT(keyDelegate == old);
+    MOZ_RELEASE_ASSERT(keyDelegate == old);
     keyDelegate = obj;
 }
 
 static JSObject *GetKeyDelegate(JSObject *obj)
 {
     return keyDelegate;
 }
 
-
 JSObject *newKey()
 {
     static const js::Class keyClass = {
         "keyWithDelgate",
         JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(1),
         nullptr, /* addProperty */
         nullptr, /* delProperty */
         nullptr, /* getProperty */
--- a/js/src/jsapi-tests/tests.h
+++ b/js/src/jsapi-tests/tests.h
@@ -63,19 +63,19 @@ class JSAPITest
 
     JSAPITest() : rt(nullptr), cx(nullptr), global(nullptr),
                   knownFail(false), oldCompartment(nullptr) {
         next = list;
         list = this;
     }
 
     virtual ~JSAPITest() {
-        MOZ_ASSERT(!rt);
-        MOZ_ASSERT(!cx);
-        MOZ_ASSERT(!global);
+        MOZ_RELEASE_ASSERT(!rt);
+        MOZ_RELEASE_ASSERT(!cx);
+        MOZ_RELEASE_ASSERT(!global);
     }
 
     virtual bool init();
     virtual void uninit();
 
     virtual const char * name() = 0;
     virtual bool run(JS::HandleObject global) = 0;
 
@@ -285,19 +285,20 @@ class JSAPITest
             return nullptr;
         JS_SetErrorReporter(rt, &reportError);
         setNativeStackQuota(rt);
         JS::RuntimeOptionsRef(rt).setVarObjFix(true);
         return rt;
     }
 
     virtual void destroyRuntime() {
-        MOZ_ASSERT(!cx);
-        MOZ_ASSERT(rt);
+        MOZ_RELEASE_ASSERT(!cx);
+        MOZ_RELEASE_ASSERT(rt);
         JS_DestroyRuntime(rt);
+        rt = nullptr;
     }
 
     static void reportError(JSContext *cx, const char *message, JSErrorReport *report) {
         fprintf(stderr, "%s:%u:%s\n",
                 report->filename ? report->filename : "<no filename>",
                 (unsigned int) report->lineno,
                 message);
     }