Bug 1366263 - Part 2: Force Int32 type to lastIndex in RegExpGlobalReplaceOpt. r=anba
authorTooru Fujisawa <arai_a@mac.com>
Mon, 31 Jul 2017 21:16:22 +0900
changeset 372070 b790837d862c
parent 372069 fca89bbfc897
child 372071 bf3ae82e04e6
push id32264
push userkwierso@gmail.com
push dateTue, 01 Aug 2017 00:43:47 +0000
treeherdermozilla-central@44121dbcac6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersanba
bugs1366263
milestone56.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 1366263 - Part 2: Force Int32 type to lastIndex in RegExpGlobalReplaceOpt. r=anba
js/src/builtin/RegExpGlobalReplaceOpt.h.js
--- a/js/src/builtin/RegExpGlobalReplaceOpt.h.js
+++ b/js/src/builtin/RegExpGlobalReplaceOpt.h.js
@@ -58,20 +58,20 @@ function FUNC_NAME(rx, S, lengthS, repla
         assert(result.length >= 1, "RegExpMatcher doesn't return an empty array");
         var nCaptures = result.length - 1;
 #endif
 
         // Step 14.c.
         var matched = result[0];
 
         // Step 14.d.
-        var matchLength = matched.length;
+        var matchLength = matched.length | 0;
 
         // Steps 14.e-f.
-        var position = result.index;
+        var position = result.index | 0;
         lastIndex = position + matchLength;
 
         // Steps g-k.
         var replacement;
 #if defined(FUNCTIONAL)
         replacement = RegExpGetFunctionalReplacement(result, S, position, replaceValue);
 #elif defined(SUBSTITUTION)
         replacement = RegExpGetComplexReplacement(result, matched, S, position,
@@ -102,16 +102,17 @@ function FUNC_NAME(rx, S, lengthS, repla
         // Step 14.l.iii.
         nextSourcePosition = lastIndex;
 
         // Step 11.c.iii.2.
         if (matchLength === 0) {
             lastIndex = fullUnicode ? AdvanceStringIndex(S, lastIndex) : lastIndex + 1;
             if (lastIndex > lengthS)
                 break;
+            lastIndex |= 0;
         }
 
 #if defined(FUNCTIONAL) || defined(ELEMBASE)
         // Ensure the current source and flags match the original regexp, the
         // replaceValue function may have called RegExp#compile.
         if (UnsafeGetStringFromReservedSlot(rx, REGEXP_SOURCE_SLOT) !== originalSource ||
             UnsafeGetInt32FromReservedSlot(rx, REGEXP_FLAGS_SLOT) !== originalFlags)
         {