Bug 780051 - Remove JS_MAX and JS_MIN. r=luke
authorBenjamin Peterson <benjamin@python.org>
Thu, 02 Aug 2012 20:50:51 -0700
changeset 106748 20c3e03a259abf4fb9f6fbd0617bfc838f45bd41
parent 106747 e3c588f74c89894fbf856f73f7714d91d9022155
child 106749 46653198caac5e4273f27e2fe2f188ef1e9ff4cf
push id1490
push userakeybl@mozilla.com
push dateMon, 08 Oct 2012 18:29:50 +0000
treeherdermozilla-beta@f335e7dacdc1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs780051
milestone17.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 780051 - Remove JS_MAX and JS_MIN. r=luke
js/jsd/jsd_text.c
js/src/frontend/BytecodeEmitter.cpp
js/src/gc/Memory.cpp
js/src/jsapi.cpp
js/src/jsarray.cpp
js/src/jsclone.cpp
js/src/jsdate.cpp
js/src/jsdhash.cpp
js/src/jsinterp.cpp
js/src/jsobj.cpp
js/src/json.cpp
js/src/jsstrinlines.h
js/src/jstypes.h
js/src/jsutil.cpp
js/src/methodjit/BaseCompiler.h
js/src/prmjtime.cpp
js/src/shell/jsoptparse.cpp
js/src/vm/Debugger.cpp
js/src/yarr/wtfbridge.h
js/xpconnect/src/XPCInlines.h
--- a/js/jsd/jsd_text.c
+++ b/js/jsd/jsd_text.c
@@ -439,17 +439,17 @@ jsd_AppendUCSourceText(JSDContext* jsdc,
         buf = malloc(UNICODE_TRUNCATE_BUF_SIZE);
         if(!buf)
         {
             JSD_UNLOCK_SOURCE_TEXT(jsdc);
             return NULL;
         }
     }
     while(remaining && jsdsrc) {
-        int bytes = JS_MIN(remaining, UNICODE_TRUNCATE_BUF_SIZE);
+        int bytes = (remaining < UNICODE_TRUNCATE_BUF_SIZE) ? remaining : UNICODE_TRUNCATE_BUF_SIZE;
         int i;
         for(i = 0; i < bytes; i++)
             buf[i] = (const char) *(text++);
         jsdsrc = jsd_AppendSourceText(jsdc,jsdsrc,
                                       buf, bytes,
                                       JSD_SOURCE_PARTIAL);
         remaining -= bytes;
     }
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -6710,17 +6710,17 @@ frontend::NewSrcNote(JSContext *cx, Byte
      * Compute delta from the last annotated bytecode's offset.  If it's too
      * big to fit in sn, allocate one or more xdelta notes and reset sn.
      */
     offset = bce->offset();
     delta = offset - bce->lastNoteOffset();
     bce->current->lastNoteOffset = offset;
     if (delta >= SN_DELTA_LIMIT) {
         do {
-            xdelta = JS_MIN(delta, SN_XDELTA_MASK);
+            xdelta = Min(delta, SN_XDELTA_MASK);
             SN_MAKE_XDELTA(sn, xdelta);
             delta -= xdelta;
             index = AllocSrcNote(cx, bce);
             if (index < 0)
                 return -1;
             sn = &bce->notes()[index];
         } while (delta >= SN_DELTA_LIMIT);
     }
@@ -6943,17 +6943,17 @@ frontend::FinishTakingSrcNotes(JSContext
             if (offset < delta)
                 delta = offset;
             for (;;) {
                 if (!AddToSrcNoteDelta(cx, bce, sn, delta))
                     return false;
                 offset -= delta;
                 if (offset == 0)
                     break;
-                delta = JS_MIN(offset, SN_XDELTA_MASK);
+                delta = Min(offset, SN_XDELTA_MASK);
                 sn = bce->main.notes;
             }
         }
     }
 
     mainCount = bce->main.noteCount;
     totalCount = prologCount + mainCount;
     if (prologCount)
--- a/js/src/gc/Memory.cpp
+++ b/js/src/gc/Memory.cpp
@@ -318,17 +318,17 @@ MapAlignedPages(size_t size, size_t alig
     int flags = MAP_PRIVATE | MAP_ANON;
 
     /* Special case: If we want page alignment, no further work is needed. */
     if (alignment == PageSize) {
         return mmap(NULL, size, prot, flags, -1, 0);
     }
 
     /* Overallocate and unmap the region's edges. */
-    size_t reqSize = JS_MIN(size + 2 * alignment, 2 * size);
+    size_t reqSize = Min(size + 2 * alignment, 2 * size);
     void *region = mmap(NULL, reqSize, prot, flags, -1, 0);
     if (region == MAP_FAILED)
         return NULL;
 
     uintptr_t regionEnd = uintptr_t(region) + reqSize;
     uintptr_t offset = uintptr_t(region) % alignment;
     JS_ASSERT(offset < reqSize - size);
 
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -2106,17 +2106,17 @@ SetIdArrayLength(JSContext *cx, JSIdArra
 }
 
 static JSIdArray *
 AddNameToArray(JSContext *cx, PropertyName *name, JSIdArray *ida, int *ip)
 {
     int i = *ip;
     int length = ida->length;
     if (i >= length) {
-        ida = SetIdArrayLength(cx, ida, JS_MAX(length * 2, 8));
+        ida = SetIdArrayLength(cx, ida, Max(length * 2, 8));
         if (!ida)
             return NULL;
         JS_ASSERT(i < ida->length);
     }
     ida->vector[i].init(NameToId(name));
     *ip = i + 1;
     return ida;
 }
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -2648,27 +2648,27 @@ array_splice(JSContext *cx, unsigned arg
     /* Step 5. */
     double relativeStart;
     if (!ToInteger(cx, argc >= 1 ? args[0] : UndefinedValue(), &relativeStart))
         return false;
 
     /* Step 6. */
     uint32_t actualStart;
     if (relativeStart < 0)
-        actualStart = JS_MAX(len + relativeStart, 0);
+        actualStart = Max(len + relativeStart, 0.0);
     else
-        actualStart = JS_MIN(relativeStart, len);
+        actualStart = Min(relativeStart, double(len));
 
     /* Step 7. */
     uint32_t actualDeleteCount;
     if (argc != 1) {
         double deleteCountDouble;
         if (!ToInteger(cx, argc >= 2 ? args[1] : Int32Value(0), &deleteCountDouble))
             return false;
-        actualDeleteCount = JS_MIN(JS_MAX(deleteCountDouble, 0), len - actualStart);
+        actualDeleteCount = Min(Max(deleteCountDouble, 0.0), double(len - actualStart));
     } else {
         /*
          * Non-standard: if start was specified but deleteCount was omitted,
          * delete to the end of the array.  See bug 668024 for discussion.
          */
         actualDeleteCount = len - actualStart;
     }
 
--- a/js/src/jsclone.cpp
+++ b/js/src/jsclone.cpp
@@ -374,17 +374,17 @@ JSStructuredCloneWriter::writeId(jsid id
 
 inline void
 JSStructuredCloneWriter::checkStack()
 {
 #ifdef DEBUG
     /* To avoid making serialization O(n^2), limit stack-checking at 10. */
     const size_t MAX = 10;
 
-    size_t limit = JS_MIN(counts.length(), MAX);
+    size_t limit = Min(counts.length(), MAX);
     JS_ASSERT(objs.length() == counts.length());
     size_t total = 0;
     for (size_t i = 0; i < limit; i++) {
         JS_ASSERT(total + counts[i] >= total);
         total += counts[i];
     }
     if (counts.length() <= MAX)
         JS_ASSERT(total == ids.length());
--- a/js/src/jsdate.cpp
+++ b/js/src/jsdate.cpp
@@ -733,17 +733,17 @@ fractional(double *result, const jschar 
  * Succeed if exactly n digits are converted. Advance *i only
  * on success.
  */
 static JSBool
 ndigits(size_t n, size_t *result, const jschar *s, size_t* i, size_t limit)
 {
     size_t init = *i;
 
-    if (digits(result, s, i, JS_MIN(limit, init+n)))
+    if (digits(result, s, i, Min(limit, init+n)))
         return ((*i - init) == n);
 
     *i = init;
     return JS_FALSE;
 }
 
 static int
 DaysInMonth(int year, int month)
--- a/js/src/jsdhash.cpp
+++ b/js/src/jsdhash.cpp
@@ -270,29 +270,29 @@ JS_DHashTableSetAlphaBounds(JSDHashTable
     /*
      * Ensure that at least one entry will always be free.  If maxAlpha at
      * minimum size leaves no entries free, reduce maxAlpha based on minimum
      * size and the precision limit of maxAlphaFrac's fixed point format.
      */
     JS_ASSERT(JS_DHASH_MIN_SIZE - (maxAlpha * JS_DHASH_MIN_SIZE) >= 1);
     if (JS_DHASH_MIN_SIZE - (maxAlpha * JS_DHASH_MIN_SIZE) < 1) {
         maxAlpha = (float)
-                   (JS_DHASH_MIN_SIZE - JS_MAX(JS_DHASH_MIN_SIZE / 256, 1))
+                   (JS_DHASH_MIN_SIZE - Max(JS_DHASH_MIN_SIZE / 256, 1))
                    / JS_DHASH_MIN_SIZE;
     }
 
     /*
      * Ensure that minAlpha is strictly less than half maxAlpha.  Take care
      * not to truncate an entry's worth of alpha when storing in minAlphaFrac
      * (8-bit fixed point format).
      */
     JS_ASSERT(minAlpha < maxAlpha / 2);
     if (minAlpha >= maxAlpha / 2) {
         size = JS_DHASH_TABLE_SIZE(table);
-        minAlpha = (size * maxAlpha - JS_MAX(size / 256, 1)) / (2 * size);
+        minAlpha = (size * maxAlpha - Max(size / 256, 1U)) / (2 * size);
     }
 
     table->maxAlphaFrac = (uint8_t)(maxAlpha * 256);
     table->minAlphaFrac = (uint8_t)(minAlpha * 256);
 }
 
 /*
  * Double hashing needs the second hash code to be relatively prime to table
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -2702,17 +2702,17 @@ BEGIN_CASE(JSOP_LOOKUPSWITCH)
   end_lookup_switch:
     len = GET_JUMP_OFFSET(pc2);
 }
 END_VARLEN_CASE
 }
 
 BEGIN_CASE(JSOP_ACTUALSFILLED)
 {
-    PUSH_INT32(JS_MAX(regs.fp()->numActualArgs(), GET_UINT16(regs.pc)));
+    PUSH_INT32(Max(regs.fp()->numActualArgs(), GET_UINT16(regs.pc)));
 }
 END_CASE(JSOP_ACTUALSFILLED)
 
 BEGIN_CASE(JSOP_ARGUMENTS)
     JS_ASSERT(!regs.fp()->fun()->hasRest());
     if (script->needsArgsObj()) {
         ArgumentsObject *obj = ArgumentsObject::createExpected(cx, regs.fp());
         if (!obj)
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -3612,17 +3612,17 @@ JSObject::growElements(JSContext *cx, un
     JS_ASSERT(oldcap <= newcap);
 
     size_t oldSize = Probes::objectResizeActive() ? computedSizeOfThisSlotsElements() : 0;
 
     uint32_t nextsize = (oldcap <= CAPACITY_DOUBLING_MAX)
                       ? oldcap * 2
                       : oldcap + (oldcap >> 3);
 
-    uint32_t actualCapacity = JS_MAX(newcap, nextsize);
+    uint32_t actualCapacity = Max(newcap, nextsize);
     if (actualCapacity >= CAPACITY_CHUNK)
         actualCapacity = JS_ROUNDUP(actualCapacity, CAPACITY_CHUNK);
     else if (actualCapacity < SLOT_CAPACITY_MIN)
         actualCapacity = SLOT_CAPACITY_MIN;
 
     /* Don't let nelements get close to wrapping around uint32_t. */
     if (actualCapacity >= NELEMENTS_LIMIT || actualCapacity < oldcap || actualCapacity < newcap) {
         JS_ReportOutOfMemory(cx);
--- a/js/src/json.cpp
+++ b/js/src/json.cpp
@@ -624,17 +624,17 @@ js_Stringify(JSContext *cx, MutableHandl
              *         a. Append item to the end of PropertyList.
              *      7. Let i be i + 1.
              */
 
             /* Step 4b(ii). */
             uint32_t len;
             JS_ALWAYS_TRUE(js_GetLengthProperty(cx, replacer, &len));
             if (replacer->isDenseArray())
-                len = JS_MIN(len, replacer->getDenseArrayCapacity());
+                len = Min(len, replacer->getDenseArrayCapacity());
 
             HashSet<jsid> idSet(cx);
             if (!idSet.init(len))
                 return false;
 
             /* Step 4b(iii). */
             uint32_t i = 0;
 
@@ -697,26 +697,26 @@ js_Stringify(JSContext *cx, MutableHandl
     }
 
     StringBuffer gap(cx);
 
     if (space.isNumber()) {
         /* Step 6. */
         double d;
         JS_ALWAYS_TRUE(ToInteger(cx, space, &d));
-        d = JS_MIN(10, d);
+        d = Min(10.0, d);
         if (d >= 1 && !gap.appendN(' ', uint32_t(d)))
             return false;
     } else if (space.isString()) {
         /* Step 7. */
         JSLinearString *str = space.toString()->ensureLinear(cx);
         if (!str)
             return false;
         JS::Anchor<JSString *> anchor(str);
-        size_t len = JS_MIN(10, space.toString()->length());
+        size_t len = Min(size_t(10), space.toString()->length());
         if (!gap.append(str->chars(), len))
             return false;
     } else {
         /* Step 8. */
         JS_ASSERT(gap.empty());
     }
 
     /* Step 9. */
--- a/js/src/jsstrinlines.h
+++ b/js/src/jsstrinlines.h
@@ -105,17 +105,17 @@ SkipSpace(const jschar *s, const jschar 
 
 /*
  * Return less than, equal to, or greater than zero depending on whether
  * s1 is less than, equal to, or greater than s2.
  */
 inline bool
 CompareChars(const jschar *s1, size_t l1, const jschar *s2, size_t l2, int32_t *result)
 {
-    size_t n = JS_MIN(l1, l2);
+    size_t n = Min(l1, l2);
     for (size_t i = 0; i < n; i++) {
         if (int32_t cmp = s1[i] - s2[i]) {
             *result = cmp;
             return true;
         }
     }
 
     *result = (int32_t)(l1 - l2);
--- a/js/src/jstypes.h
+++ b/js/src/jstypes.h
@@ -142,18 +142,16 @@
 **              JS_ROUNDUP
 **              JS_MIN
 **              JS_MAX
 ** DESCRIPTION:
 **      Commonly used macros for operations on compatible types.
 ***********************************************************************/
 #define JS_HOWMANY(x,y) (((x)+(y)-1)/(y))
 #define JS_ROUNDUP(x,y) (JS_HOWMANY(x,y)*(y))
-#define JS_MIN(x,y)     ((x)<(y)?(x):(y))
-#define JS_MAX(x,y)     ((x)>(y)?(x):(y))
 
 #include "jscpucfg.h"
 
 /*
  * Define JS_64BIT iff we are building in an environment with 64-bit
  * addresses.
  */
 #ifdef _MSC_VER
--- a/js/src/jsutil.cpp
+++ b/js/src/jsutil.cpp
@@ -172,17 +172,17 @@ ValToBin(unsigned logscale, uint32_t val
 
     if (val <= 1)
         return val;
     bin = (logscale == 10)
         ? (unsigned) ceil(log10((double) val))
         : (logscale == 2)
         ? (unsigned) JS_CEILING_LOG2W(val)
         : val;
-    return JS_MIN(bin, 10);
+    return Min(bin, 10U);
 }
 
 void
 JS_BasicStatsAccum(JSBasicStats *bs, uint32_t val)
 {
     unsigned oldscale, newscale, bin;
     double mean;
 
--- a/js/src/methodjit/BaseCompiler.h
+++ b/js/src/methodjit/BaseCompiler.h
@@ -69,18 +69,18 @@ class BaseCompiler : public MacroAssembl
 
 #ifdef JS_CPU_X64
 inline bool
 VerifyRange(void *start1, size_t size1, void *start2, size_t size2)
 {
     uintptr_t end1 = uintptr_t(start1) + size1;
     uintptr_t end2 = uintptr_t(start2) + size2;
 
-    uintptr_t lowest = JS_MIN(uintptr_t(start1), uintptr_t(start2));
-    uintptr_t highest = JS_MAX(end1, end2);
+    uintptr_t lowest = Min(uintptr_t(start1), uintptr_t(start2));
+    uintptr_t highest = Max(end1, end2);
 
     return (highest - lowest < INT_MAX);
 }
 #endif
 
 // This class wraps JSC::LinkBuffer for Mozilla-specific memory handling.
 // Every return |false| guarantees an OOM that has been correctly propagated,
 // and should continue to propagate.
--- a/js/src/prmjtime.cpp
+++ b/js/src/prmjtime.cpp
@@ -418,17 +418,17 @@ PRMJ_Now(void)
 
             MUTEX_LOCK(&calibration.data_lock);
             highresTime = calibration.offset + PRMJ_USEC_PER_SEC*
                  (highresTimerValue-calibration.timer_offset)/calibration.freq;
             cachedOffset = calibration.offset;
 
             /* On some dual processor/core systems, we might get an earlier time
                so we cache the last time that we returned */
-            calibration.last = JS_MAX(calibration.last, int64_t(highresTime));
+            calibration.last = js::Max(calibration.last, int64_t(highresTime));
             returnedTime = calibration.last;
             MUTEX_UNLOCK(&calibration.data_lock);
 
             /* Rather than assume the NT kernel ticks every 15.6ms, ask it */
             if (GetSystemTimeAdjustment(&timeAdjustment,
                                         &timeIncrement,
                                         &timeAdjustmentDisabled)) {
                 if (timeAdjustmentDisabled) {
@@ -687,17 +687,17 @@ DSTOffsetCache::getDSTOffsetMilliseconds
         return oldOffsetMilliseconds;
     }
 
     oldOffsetMilliseconds = offsetMilliseconds;
     oldRangeStartSeconds = rangeStartSeconds;
     oldRangeEndSeconds = rangeEndSeconds;
 
     if (rangeStartSeconds <= localTimeSeconds) {
-        int64_t newEndSeconds = JS_MIN(rangeEndSeconds + RANGE_EXPANSION_AMOUNT, MAX_UNIX_TIMET);
+        int64_t newEndSeconds = js::Min(rangeEndSeconds + RANGE_EXPANSION_AMOUNT, MAX_UNIX_TIMET);
         if (newEndSeconds >= localTimeSeconds) {
             int64_t endOffsetMilliseconds = computeDSTOffsetMilliseconds(newEndSeconds);
             if (endOffsetMilliseconds == offsetMilliseconds) {
                 rangeEndSeconds = newEndSeconds;
                 return offsetMilliseconds;
             }
 
             offsetMilliseconds = computeDSTOffsetMilliseconds(localTimeSeconds);
@@ -710,17 +710,17 @@ DSTOffsetCache::getDSTOffsetMilliseconds
             return offsetMilliseconds;
         }
 
         offsetMilliseconds = computeDSTOffsetMilliseconds(localTimeSeconds);
         rangeStartSeconds = rangeEndSeconds = localTimeSeconds;
         return offsetMilliseconds;
     }
 
-    int64_t newStartSeconds = JS_MAX(rangeStartSeconds - RANGE_EXPANSION_AMOUNT, 0);
+    int64_t newStartSeconds = js::Max(rangeStartSeconds - RANGE_EXPANSION_AMOUNT, int64_t(0));
     if (newStartSeconds <= localTimeSeconds) {
         int64_t startOffsetMilliseconds = computeDSTOffsetMilliseconds(newStartSeconds);
         if (startOffsetMilliseconds == offsetMilliseconds) {
             rangeStartSeconds = newStartSeconds;
             return offsetMilliseconds;
         }
 
         offsetMilliseconds = computeDSTOffsetMilliseconds(localTimeSeconds);
--- a/js/src/shell/jsoptparse.cpp
+++ b/js/src/shell/jsoptparse.cpp
@@ -173,17 +173,17 @@ OptionParser::printHelp(const char *prog
 
     if (!arguments.empty()) {
         printf("Arguments:\n");
 
         static const char fmt[] = "  %s ";
         size_t fmtChars = sizeof(fmt) - 2;
         size_t lhsLen = 0;
         for (Option **it = arguments.begin(), **end = arguments.end(); it != end; ++it)
-            lhsLen = JS_MAX(lhsLen, strlen((*it)->longflag) + fmtChars);
+            lhsLen = Max(lhsLen, strlen((*it)->longflag) + fmtChars);
 
         for (Option **it = arguments.begin(), **end = arguments.end(); it != end; ++it) {
             Option *arg = *it;
             size_t chars = printf(fmt, arg->longflag);
             for (; chars < lhsLen; ++chars)
                 putchar(' ');
             PrintParagraph(arg->help, lhsLen, helpWidth, false);
             putchar('\n');
@@ -201,17 +201,17 @@ OptionParser::printHelp(const char *prog
             size_t longflagLen = strlen(opt->longflag);
 
             size_t fmtLen;
             OptionFlagsToFormatInfo(opt->shortflag, opt->isValued(), &fmtLen);
 
             size_t len = fmtLen + longflagLen;
             if (opt->isValued())
                 len += strlen(opt->asValued()->metavar);
-            lhsLen = JS_MAX(lhsLen, len);
+            lhsLen = Max(lhsLen, len);
         }
 
         /* Print option help text. */
         for (Option **it = options.begin(), **end = options.end(); it != end; ++it) {
             Option *opt = *it;
             size_t fmtLen;
             const char *fmt = OptionFlagsToFormatInfo(opt->shortflag, opt->isValued(), &fmtLen);
             size_t chars;
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -4097,23 +4097,23 @@ ApplyOrCall(JSContext *cx, unsigned argc
             if (!args[1].isObject()) {
                 JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_APPLY_ARGS,
                                      js_apply_str);
                 return false;
             }
             RootedObject argsobj(cx, &args[1].toObject());
             if (!js_GetLengthProperty(cx, argsobj, &callArgc))
                 return false;
-            callArgc = unsigned(JS_MIN(callArgc, StackSpace::ARGS_LENGTH_MAX));
+            callArgc = unsigned(Min(callArgc, StackSpace::ARGS_LENGTH_MAX));
             if (!argv.growBy(callArgc) || !GetElements(cx, argsobj, callArgc, argv.begin()))
                 return false;
             callArgv = argv.begin();
         }
     } else {
-        callArgc = argc > 0 ? unsigned(JS_MIN(argc - 1, StackSpace::ARGS_LENGTH_MAX)) : 0;
+        callArgc = argc > 0 ? unsigned(Min(argc - 1, StackSpace::ARGS_LENGTH_MAX)) : 0;
         callArgv = args.array() + 1;
     }
     for (unsigned i = 0; i < callArgc; i++) {
         if (!dbg->unwrapDebuggeeValue(cx, &callArgv[i]))
             return false;
     }
 
     /*
--- a/js/src/yarr/wtfbridge.h
+++ b/js/src/yarr/wtfbridge.h
@@ -272,24 +272,24 @@ namespace std {
 # undef min
 # undef max
 #endif
 
 template<typename T>
 inline T
 min(T t1, T t2)
 {
-    return JS_MIN(t1, t2);
+    return js::Min(t1, t2);
 }
 
 template<typename T>
 inline T
 max(T t1, T t2)
 {
-    return JS_MAX(t1, t2);
+    return js::Max(t1, t2);
 }
 
 template<typename T>
 inline void
 swap(T &t1, T &t2)
 {
     T tmp = t1;
     t1 = t2;
--- a/js/xpconnect/src/XPCInlines.h
+++ b/js/xpconnect/src/XPCInlines.h
@@ -477,17 +477,17 @@ XPCNativeSet::HasInterfaceWithAncestor(c
 
     return false;
 }
 
 inline JSBool
 XPCNativeSet::MatchesSetUpToInterface(const XPCNativeSet* other,
                                       XPCNativeInterface* iface) const
 {
-    int count = JS_MIN((int)mInterfaceCount, (int)other->mInterfaceCount);
+    int count = js::Min(int(mInterfaceCount), int(other->mInterfaceCount));
 
     XPCNativeInterface* const * pp1 = mInterfaces;
     XPCNativeInterface* const * pp2 = other->mInterfaces;
 
     for (int i = (int) count; i > 0; i--, pp1++, pp2++) {
         XPCNativeInterface* cur = (*pp1);
         if (cur != (*pp2))
             return false;