Bug 1453456 - Replace JS7_ISDEC with mozilla::IsAsciiDigit. r=froydnj
☠☠ backed out by f36928548891 ☠ ☠
authorJeff Walden <jwalden@mit.edu>
Fri, 13 Apr 2018 13:01:10 -0700
changeset 466856 e0f8f325c2ce3c0e39587f117d63d0872bb9826a
parent 466855 6a84718ddfe1282a2f3e2040eb44081afc5aea16
child 466857 e233cb06379dfefa544fe2dbd4c82945b627cc70
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1453456
milestone61.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 1453456 - Replace JS7_ISDEC with mozilla::IsAsciiDigit. r=froydnj
js/src/builtin/Array.cpp
js/src/builtin/Array.h
js/src/builtin/RegExp.cpp
js/src/frontend/TokenStream.cpp
js/src/util/Text.h
js/src/vm/JSONParser.cpp
js/src/vm/StringType.cpp
js/src/vm/StringType.h
js/src/vm/TypedArrayObject.cpp
js/src/vm/TypedArrayObject.h
--- a/js/src/builtin/Array.cpp
+++ b/js/src/builtin/Array.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "builtin/Array-inl.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/MathAlgorithms.h"
+#include "mozilla/TextUtils.h"
 
 #include <algorithm>
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "jsnum.h"
 #include "jstypes.h"
 #include "jsutil.h"
@@ -50,16 +51,17 @@
 using namespace js;
 using namespace js::gc;
 
 using mozilla::Abs;
 using mozilla::ArrayLength;
 using mozilla::CeilingLog2;
 using mozilla::CheckedInt;
 using mozilla::DebugOnly;
+using mozilla::IsAsciiDigit;
 
 using JS::AutoCheckCannotGC;
 using JS::IsArrayAnswer;
 using JS::ToUint32;
 
 bool
 JS::IsArray(JSContext* cx, HandleObject obj, IsArrayAnswer* answer)
 {
@@ -212,28 +214,28 @@ GetLengthProperty(JSContext* cx, HandleO
  *
  */
 template <typename CharT>
 static bool
 StringIsArrayIndex(const CharT* s, uint32_t length, uint32_t* indexp)
 {
     const CharT* end = s + length;
 
-    if (length == 0 || length > (sizeof("4294967294") - 1) || !JS7_ISDEC(*s))
+    if (length == 0 || length > (sizeof("4294967294") - 1) || !IsAsciiDigit(*s))
         return false;
 
     uint32_t c = 0, previous = 0;
     uint32_t index = JS7_UNDEC(*s++);
 
     /* Don't allow leading zeros. */
     if (index == 0 && s != end)
         return false;
 
     for (; s < end; s++) {
-        if (!JS7_ISDEC(*s))
+        if (!IsAsciiDigit(*s))
             return false;
 
         previous = index;
         c = JS7_UNDEC(*s);
         index = 10 * index + c;
     }
 
     /* Make sure we didn't overflow. */
--- a/js/src/builtin/Array.h
+++ b/js/src/builtin/Array.h
@@ -4,16 +4,18 @@
  * 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/. */
 
 /* JS Array interface. */
 
 #ifndef builtin_Array_h
 #define builtin_Array_h
 
+#include "mozilla/TextUtils.h"
+
 #include "jspubtd.h"
 
 #include "vm/ArrayObject.h"
 #include "vm/JSObject.h"
 
 namespace js {
 /* 2^32-2, inclusive */
 const uint32_t MAX_ARRAY_INDEX = 4294967294u;
@@ -27,17 +29,17 @@ IdIsIndex(jsid id, uint32_t* indexp)
         *indexp = (uint32_t)i;
         return true;
     }
 
     if (MOZ_UNLIKELY(!JSID_IS_STRING(id)))
         return false;
 
     JSAtom* atom = JSID_TO_ATOM(id);
-    if (atom->length() == 0 || !JS7_ISDEC(atom->latin1OrTwoByteChar(0)))
+    if (atom->length() == 0 || !mozilla::IsAsciiDigit(atom->latin1OrTwoByteChar(0)))
         return false;
 
     return js::StringIsArrayIndex(atom, indexp);
 }
 
 // The methods below only create dense boxed arrays.
 
 /* Create a dense array with no capacity allocated, length set to 0. */
--- a/js/src/builtin/RegExp.cpp
+++ b/js/src/builtin/RegExp.cpp
@@ -20,16 +20,17 @@
 
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/UnboxedObject-inl.h"
 
 using namespace js;
 
 using mozilla::CheckedInt;
+using mozilla::IsAsciiDigit;
 
 /*
  * ES 2017 draft rev 6a13789aa9e7c6de4e96b7d3e24d9e6eba6584ad 21.2.5.2.2
  * steps 3, 16-25.
  */
 bool
 js::CreateRegExpMatchResult(JSContext* cx, HandleString input, const MatchPairs& matches,
                             MutableHandleValue rval)
@@ -1216,28 +1217,28 @@ InterpretDollar(JSLinearString* matched,
     MOZ_ASSERT(*currentDollar == '$');
 
     /* If there is only a dollar, bail now. */
     if (currentDollar + 1 >= replacementEnd)
         return false;
 
     /* ES 2016 draft Mar 25, 2016 Table 46. */
     char16_t c = currentDollar[1];
-    if (JS7_ISDEC(c)) {
+    if (IsAsciiDigit(c)) {
         /* $n, $nn */
         unsigned num = JS7_UNDEC(c);
         if (num > captures.length()) {
             // The result is implementation-defined, do not substitute.
             return false;
         }
 
         const CharT* currentChar = currentDollar + 2;
         if (currentChar < replacementEnd) {
             c = *currentChar;
-            if (JS7_ISDEC(c)) {
+            if (IsAsciiDigit(c)) {
                 unsigned tmpNum = 10 * num + JS7_UNDEC(c);
                 // If num > captures.length(), the result is implementation-defined.
                 // Consume next character only if num <= captures.length().
                 if (tmpNum <= captures.length()) {
                     currentChar++;
                     num = tmpNum;
                 }
             }
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -31,16 +31,17 @@
 #include "util/Unicode.h"
 #include "vm/HelperThreads.h"
 #include "vm/JSAtom.h"
 #include "vm/JSCompartment.h"
 #include "vm/JSContext.h"
 
 using mozilla::ArrayLength;
 using mozilla::IsAsciiAlpha;
+using mozilla::IsAsciiDigit;
 using mozilla::MakeScopeExit;
 using mozilla::PodArrayZero;
 using mozilla::PodCopy;
 
 struct ReservedWordInfo
 {
     const char* chars;         // C string with reserved word text
     js::frontend::TokenKind tokentype;
@@ -1594,39 +1595,39 @@ TokenStreamSpecific<CharT, AnyCharsAcces
     //
     if (c1kind == Dec) {
         tp = newToken(-1);
         numStart = userbuf.addressOfNextRawChar() - 1;
 
       decimal:
         decimalPoint = NoDecimal;
         hasExp = false;
-        while (JS7_ISDEC(c))
+        while (IsAsciiDigit(c))
             c = getCharIgnoreEOL();
 
         if (c == '.') {
             decimalPoint = HasDecimal;
           decimal_dot:
             do {
                 c = getCharIgnoreEOL();
-            } while (JS7_ISDEC(c));
+            } while (IsAsciiDigit(c));
         }
         if (c == 'e' || c == 'E') {
             hasExp = true;
             c = getCharIgnoreEOL();
             if (c == '+' || c == '-')
                 c = getCharIgnoreEOL();
-            if (!JS7_ISDEC(c)) {
+            if (!IsAsciiDigit(c)) {
                 ungetCharIgnoreEOL(c);
                 reportError(JSMSG_MISSING_EXPONENT);
                 goto error;
             }
             do {
                 c = getCharIgnoreEOL();
-            } while (JS7_ISDEC(c));
+            } while (IsAsciiDigit(c));
         }
         ungetCharIgnoreEOL(c);
 
         if (c != EOF) {
             if (unicode::IsIdentifierStart(char16_t(c))) {
                 reportError(JSMSG_IDSTART_AFTER_NUMBER);
                 goto error;
             }
@@ -1717,20 +1718,20 @@ TokenStreamSpecific<CharT, AnyCharsAcces
             if (c < '0' || c > '7') {
                 ungetCharIgnoreEOL(c);
                 reportError(JSMSG_MISSING_OCTAL_DIGITS);
                 goto error;
             }
             numStart = userbuf.addressOfNextRawChar() - 1;  // one past the '0o'
             while ('0' <= c && c <= '7')
                 c = getCharIgnoreEOL();
-        } else if (JS7_ISDEC(c)) {
+        } else if (IsAsciiDigit(c)) {
             radix = 8;
             numStart = userbuf.addressOfNextRawChar() - 1;  // one past the '0'
-            while (JS7_ISDEC(c)) {
+            while (IsAsciiDigit(c)) {
                 // Octal integer literals are not permitted in strict mode code.
                 if (!reportStrictModeError(JSMSG_DEPRECATED_OCTAL))
                     goto error;
 
                 // Outside strict mode, we permit 08 and 09 as decimal numbers,
                 // which makes our behaviour a superset of the ECMA numeric
                 // grammar. We might not always be so permissive, so we warn
                 // about it.
@@ -1780,17 +1781,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
 
     // This handles everything else.
     //
     MOZ_ASSERT(c1kind == Other);
     tp = newToken(-1);
     switch (c) {
       case '.':
         c = getCharIgnoreEOL();
-        if (JS7_ISDEC(c)) {
+        if (IsAsciiDigit(c)) {
             numStart = userbuf.addressOfNextRawChar() - 2;
             decimalPoint = HasDecimal;
             hasExp = false;
             goto decimal_dot;
         }
         if (c == '.') {
             if (matchChar('.')) {
                 tp->type = TokenKind::TripleDot;
@@ -2261,17 +2262,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
                 // Octal character specification.
                 if (JS7_ISOCT(c)) {
                     int32_t val = JS7_UNOCT(c);
 
                     if (!peekChar(&c))
                         return false;
 
                     // Strict mode code allows only \0, then a non-digit.
-                    if (val != 0 || JS7_ISDEC(c)) {
+                    if (val != 0 || IsAsciiDigit(c)) {
                         TokenStreamAnyChars& anyChars = anyCharsAccess();
                         if (parsingTemplate) {
                             anyChars.setInvalidTemplateEscape(userbuf.offset() - 2,
                                                               InvalidEscapeType::Octal);
                             continue;
                         }
                         if (!reportStrictModeError(JSMSG_DEPRECATED_OCTAL))
                             return false;
--- a/js/src/util/Text.h
+++ b/js/src/util/Text.h
@@ -4,16 +4,17 @@
  * 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 util_Text_h
 #define util_Text_h
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/TextUtils.h"
 
 #include <ctype.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <string>
 
 #include "jsutil.h"
@@ -24,23 +25,22 @@
 #include "vm/Printer.h"
 
 class JSLinearString;
 
 /*
  * Shorthands for ASCII (7-bit) decimal and hex conversion.
  * Manually inline isdigit and isxdigit for performance; MSVC doesn't do this for us.
  */
-#define JS7_ISDEC(c)    ((((unsigned)(c)) - '0') <= 9)
 #define JS7_ISA2F(c)    ((((((unsigned)(c)) - 'a') <= 5) || (((unsigned)(c)) - 'A') <= 5))
 #define JS7_UNDEC(c)    ((c) - '0')
 #define JS7_ISOCT(c)    ((((unsigned)(c)) - '0') <= 7)
 #define JS7_UNOCT(c)    (JS7_UNDEC(c))
-#define JS7_ISHEX(c)    ((c) < 128 && (JS7_ISDEC(c) || JS7_ISA2F(c)))
-#define JS7_UNHEX(c)    (unsigned)(JS7_ISDEC(c) ? (c) - '0' : 10 + tolower(c) - 'a')
+#define JS7_ISHEX(c)    ((c) < 128 && (mozilla::IsAsciiDigit(c) || JS7_ISA2F(c)))
+#define JS7_UNHEX(c)    (unsigned)(mozilla::IsAsciiDigit(c) ? (c) - '0' : 10 + tolower(c) - 'a')
 
 static MOZ_ALWAYS_INLINE size_t
 js_strlen(const char16_t* s)
 {
     return std::char_traits<char16_t>::length(s);
 }
 
 template <typename CharT>
--- a/js/src/vm/JSONParser.cpp
+++ b/js/src/vm/JSONParser.cpp
@@ -4,29 +4,31 @@
  * 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 "vm/JSONParser.h"
 
 #include "mozilla/Range.h"
 #include "mozilla/RangedPtr.h"
 #include "mozilla/Sprintf.h"
+#include "mozilla/TextUtils.h"
 
 #include <ctype.h>
 
 #include "jsnum.h"
 
 #include "builtin/Array.h"
 #include "util/StringBuffer.h"
 #include "vm/JSCompartment.h"
 
 #include "vm/NativeObject-inl.h"
 
 using namespace js;
 
+using mozilla::IsAsciiDigit;
 using mozilla::RangedPtr;
 
 JSONParserBase::~JSONParserBase()
 {
     for (size_t i = 0; i < stack.length(); i++) {
         if (stack[i].state == FinishArrayElement)
             js_delete(&stack[i].elements());
         else
@@ -240,17 +242,17 @@ JSONParser<CharT>::readString()
     return token(Error);
 }
 
 template <typename CharT>
 JSONParserBase::Token
 JSONParser<CharT>::readNumber()
 {
     MOZ_ASSERT(current < end);
-    MOZ_ASSERT(JS7_ISDEC(*current) || *current == '-');
+    MOZ_ASSERT(IsAsciiDigit(*current) || *current == '-');
 
     /*
      * JSONNumber:
      *   /^-?(0|[1-9][0-9]+)(\.[0-9]+)?([eE][\+\-]?[0-9]+)?$/
      */
 
     bool negative = *current == '-';
 
@@ -258,23 +260,23 @@ JSONParser<CharT>::readNumber()
     if (negative && ++current == end) {
         error("no number after minus sign");
         return token(Error);
     }
 
     const CharPtr digitStart = current;
 
     /* 0|[1-9][0-9]+ */
-    if (!JS7_ISDEC(*current)) {
+    if (!IsAsciiDigit(*current)) {
         error("unexpected non-digit");
         return token(Error);
     }
     if (*current++ != '0') {
         for (; current < end; current++) {
-            if (!JS7_ISDEC(*current))
+            if (!IsAsciiDigit(*current))
                 break;
         }
     }
 
     /* Fast path: no fractional or exponent part. */
     if (current == end || (*current != '.' && *current != 'e' && *current != 'E')) {
         mozilla::Range<const CharT> chars(digitStart.get(), current - digitStart);
         if (chars.length() < strlen("9007199254740992")) {
@@ -295,44 +297,44 @@ JSONParser<CharT>::readNumber()
     }
 
     /* (\.[0-9]+)? */
     if (current < end && *current == '.') {
         if (++current == end) {
             error("missing digits after decimal point");
             return token(Error);
         }
-        if (!JS7_ISDEC(*current)) {
+        if (!IsAsciiDigit(*current)) {
             error("unterminated fractional number");
             return token(Error);
         }
         while (++current < end) {
-            if (!JS7_ISDEC(*current))
+            if (!IsAsciiDigit(*current))
                 break;
         }
     }
 
     /* ([eE][\+\-]?[0-9]+)? */
     if (current < end && (*current == 'e' || *current == 'E')) {
         if (++current == end) {
             error("missing digits after exponent indicator");
             return token(Error);
         }
         if (*current == '+' || *current == '-') {
             if (++current == end) {
                 error("missing digits after exponent sign");
                 return token(Error);
             }
         }
-        if (!JS7_ISDEC(*current)) {
+        if (!IsAsciiDigit(*current)) {
             error("exponent part is missing a number");
             return token(Error);
         }
         while (++current < end) {
-            if (!JS7_ISDEC(*current))
+            if (!IsAsciiDigit(*current))
                 break;
         }
     }
 
     double d;
     const CharT* finish;
     if (!js_strtod(cx, digitStart.get(), current.get(), &finish, &d))
         return token(OOM);
@@ -473,17 +475,17 @@ AssertPastValue(const RangedPtr<const Ch
                (current[-1] == 'e' &&
                 current[-2] == 's' &&
                 current[-3] == 'l' &&
                 current[-4] == 'a' &&
                 current[-5] == 'f') ||
                current[-1] == '}' ||
                current[-1] == ']' ||
                current[-1] == '"' ||
-               JS7_ISDEC(current[-1]));
+               IsAsciiDigit(current[-1]));
 }
 
 template <typename CharT>
 JSONParserBase::Token
 JSONParser<CharT>::advanceAfterArrayElement()
 {
     AssertPastValue(current);
 
--- a/js/src/vm/StringType.cpp
+++ b/js/src/vm/StringType.cpp
@@ -6,32 +6,34 @@
 
 #include "vm/StringType-inl.h"
 
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/RangedPtr.h"
+#include "mozilla/TextUtils.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/Unused.h"
 
 #include "gc/Marking.h"
 #include "gc/Nursery.h"
 #include "js/UbiNode.h"
 #include "util/StringBuffer.h"
 #include "vm/GeckoProfiler.h"
 
 #include "vm/GeckoProfiler-inl.h"
 #include "vm/JSCompartment-inl.h"
 #include "vm/JSContext-inl.h"
 #include "vm/JSObject-inl.h"
 
 using namespace js;
 
+using mozilla::IsAsciiDigit;
 using mozilla::IsNegativeZero;
 using mozilla::IsSame;
 using mozilla::PodCopy;
 using mozilla::PodEqual;
 using mozilla::RangedPtr;
 using mozilla::RoundUpPow2;
 using mozilla::Unused;
 
@@ -920,17 +922,17 @@ js::StringEqualsAscii(JSLinearString* st
 }
 
 template <typename CharT>
 /* static */ bool
 JSFlatString::isIndexSlow(const CharT* s, size_t length, uint32_t* indexp)
 {
     CharT ch = *s;
 
-    if (!JS7_ISDEC(ch))
+    if (!IsAsciiDigit(ch))
         return false;
 
     if (length > UINT32_CHAR_BUFFER_LENGTH)
         return false;
 
     /*
      * Make sure to account for the '\0' at the end of characters, dereferenced
      * in the loop below.
@@ -938,17 +940,17 @@ JSFlatString::isIndexSlow(const CharT* s
     RangedPtr<const CharT> cp(s, length + 1);
     const RangedPtr<const CharT> end(s + length, s, length + 1);
 
     uint32_t index = JS7_UNDEC(*cp++);
     uint32_t oldIndex = 0;
     uint32_t c = 0;
 
     if (index != 0) {
-        while (JS7_ISDEC(*cp)) {
+        while (IsAsciiDigit(*cp)) {
             oldIndex = index;
             c = JS7_UNDEC(*cp);
             index = 10 * index + c;
             cp++;
         }
     }
 
     /* It's not an element if there are characters after the number. */
--- a/js/src/vm/StringType.h
+++ b/js/src/vm/StringType.h
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_StringType_h
 #define vm_StringType_h
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/Range.h"
+#include "mozilla/TextUtils.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 
 #include "builtin/String.h"
 #include "gc/Barrier.h"
 #include "gc/Cell.h"
 #include "gc/Heap.h"
@@ -885,20 +886,20 @@ class JSFlatString : public JSLinearStri
     static inline JSFlatString* new_(JSContext* cx,
                                      const CharT* chars, size_t length);
 
     inline bool isIndexSlow(uint32_t* indexp) const {
         MOZ_ASSERT(JSString::isFlat());
         JS::AutoCheckCannotGC nogc;
         if (hasLatin1Chars()) {
             const JS::Latin1Char* s = latin1Chars(nogc);
-            return JS7_ISDEC(*s) && isIndexSlow(s, length(), indexp);
+            return mozilla::IsAsciiDigit(*s) && isIndexSlow(s, length(), indexp);
         }
         const char16_t* s = twoByteChars(nogc);
-        return JS7_ISDEC(*s) && isIndexSlow(s, length(), indexp);
+        return mozilla::IsAsciiDigit(*s) && isIndexSlow(s, length(), indexp);
     }
 
     /*
      * Returns true if this string's characters store an unsigned 32-bit
      * integer value, initializing *indexp to that value if so.  (Thus if
      * calling isIndex returns true, js::IndexToString(cx, *indexp) will be a
      * string equal to this string.)
      */
--- a/js/src/vm/TypedArrayObject.cpp
+++ b/js/src/vm/TypedArrayObject.cpp
@@ -6,16 +6,17 @@
 
 #include "vm/TypedArrayObject-inl.h"
 #include "vm/TypedArrayObject.h"
 
 #include "mozilla/Alignment.h"
 #include "mozilla/Casting.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/PodOperations.h"
+#include "mozilla/TextUtils.h"
 
 #include <string.h>
 #ifndef XP_WIN
 # include <sys/mman.h>
 #endif
 
 #include "jsapi.h"
 #include "jsnum.h"
@@ -47,16 +48,17 @@
 #include "vm/JSAtom-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/Shape-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
 using mozilla::AssertedCast;
+using mozilla::IsAsciiDigit;
 using JS::CanonicalizeNaN;
 using JS::ToInt32;
 using JS::ToUint32;
 
 /*
  * TypedArrayObject
  *
  * The non-templated base class for the specific typed implementations.
@@ -2193,30 +2195,30 @@ js::StringIsTypedArrayIndex(const CharT*
 
     bool negative = false;
     if (*s == '-') {
         negative = true;
         if (++s == end)
             return false;
     }
 
-    if (!JS7_ISDEC(*s))
+    if (!IsAsciiDigit(*s))
         return false;
 
     uint64_t index = 0;
     uint32_t digit = JS7_UNDEC(*s++);
 
     /* Don't allow leading zeros. */
     if (digit == 0 && s != end)
         return false;
 
     index = digit;
 
     for (; s < end; s++) {
-        if (!JS7_ISDEC(*s))
+        if (!IsAsciiDigit(*s))
             return false;
 
         digit = JS7_UNDEC(*s);
 
         /* Watch for overflows. */
         if ((UINT64_MAX - digit) / 10 < index)
             index = UINT64_MAX;
         else
--- a/js/src/vm/TypedArrayObject.h
+++ b/js/src/vm/TypedArrayObject.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 vm_TypedArrayObject_h
 #define vm_TypedArrayObject_h
 
 #include "mozilla/Attributes.h"
+#include "mozilla/TextUtils.h"
 
 #include "gc/Barrier.h"
 #include "js/Class.h"
 #include "vm/ArrayBufferObject.h"
 #include "vm/JSObject.h"
 #include "vm/SharedArrayObject.h"
 
 #define JS_FOR_EACH_TYPED_ARRAY(macro) \
@@ -356,23 +357,23 @@ IsTypedArrayIndex(jsid id, uint64_t* ind
         return false;
 
     JS::AutoCheckCannotGC nogc;
     JSAtom* atom = JSID_TO_ATOM(id);
     size_t length = atom->length();
 
     if (atom->hasLatin1Chars()) {
         const Latin1Char* s = atom->latin1Chars(nogc);
-        if (!JS7_ISDEC(*s) && *s != '-')
+        if (!mozilla::IsAsciiDigit(*s) && *s != '-')
             return false;
         return StringIsTypedArrayIndex(s, length, indexp);
     }
 
     const char16_t* s = atom->twoByteChars(nogc);
-    if (!JS7_ISDEC(*s) && *s != '-')
+    if (!mozilla::IsAsciiDigit(*s) && *s != '-')
         return false;
     return StringIsTypedArrayIndex(s, length, indexp);
 }
 
 /*
  * Implements [[DefineOwnProperty]] for TypedArrays when the property
  * key is a TypedArray index.
  */