Bug 1387400 - Part 2: Pass the original regexp flags to the specializer replacer functions. r=till

This commit is contained in:
André Bargull 2017-08-09 11:36:34 +02:00
Родитель e80a99ac14
Коммит a1ebd80a83
3 изменённых файлов: 18 добавлений и 19 удалений

Просмотреть файл

@ -281,32 +281,25 @@ function RegExpReplace(string, replaceValue) {
// Steps 8-16.
if (global) {
// Step 8.a.
var fullUnicode = !!(flags & REGEXP_UNICODE_FLAG);
if (functionalReplace) {
// For large strings check if the replacer function is
// applicable for the elem-base optimization.
if (lengthS > 5000) {
var elemBase = GetElemBaseForLambda(replaceValue);
if (IsObject(elemBase)) {
return RegExpGlobalReplaceOptElemBase(rx, S, lengthS, replaceValue,
fullUnicode, elemBase);
return RegExpGlobalReplaceOptElemBase(rx, S, lengthS, replaceValue, flags,
elemBase);
}
}
return RegExpGlobalReplaceOptFunc(rx, S, lengthS, replaceValue,
fullUnicode);
return RegExpGlobalReplaceOptFunc(rx, S, lengthS, replaceValue, flags);
}
if (firstDollarIndex !== -1) {
return RegExpGlobalReplaceOptSubst(rx, S, lengthS, replaceValue,
fullUnicode, firstDollarIndex);
return RegExpGlobalReplaceOptSubst(rx, S, lengthS, replaceValue, flags,
firstDollarIndex);
}
if (lengthS < 0x7fff) {
return RegExpGlobalReplaceShortOpt(rx, S, lengthS, replaceValue,
fullUnicode);
}
return RegExpGlobalReplaceOpt(rx, S, lengthS, replaceValue,
fullUnicode);
if (lengthS < 0x7fff)
return RegExpGlobalReplaceShortOpt(rx, S, lengthS, replaceValue, flags);
return RegExpGlobalReplaceOpt(rx, S, lengthS, replaceValue, flags);
}
if (functionalReplace)
@ -537,8 +530,11 @@ function RegExpGetFunctionalReplacement(result, S, position, replaceValue) {
// * global flag is true
// * S is a short string (lengthS < 0x7fff)
// * replaceValue is a string without "$"
function RegExpGlobalReplaceShortOpt(rx, S, lengthS, replaceValue, fullUnicode)
function RegExpGlobalReplaceShortOpt(rx, S, lengthS, replaceValue, flags)
{
// Step 8.a.
var fullUnicode = !!(flags & REGEXP_UNICODE_FLAG);
// Step 8.b.
var lastIndex = 0;
rx.lastIndex = 0;

Просмотреть файл

@ -18,7 +18,7 @@
// steps 8.b-16.
// Optimized path for @@replace with the following conditions:
// * global flag is true
function FUNC_NAME(rx, S, lengthS, replaceValue, fullUnicode
function FUNC_NAME(rx, S, lengthS, replaceValue, flags
#ifdef SUBSTITUTION
, firstDollarIndex
#endif
@ -27,6 +27,9 @@ function FUNC_NAME(rx, S, lengthS, replaceValue, fullUnicode
#endif
)
{
// Step 8.a.
var fullUnicode = !!(flags & REGEXP_UNICODE_FLAG);
// Step 8.b.
var lastIndex = 0;
rx.lastIndex = 0;
@ -35,7 +38,7 @@ function FUNC_NAME(rx, S, lengthS, replaceValue, fullUnicode
// Save the original source and flags, so we can check if the replacer
// function recompiled the regexp.
var originalSource = UnsafeGetStringFromReservedSlot(rx, REGEXP_SOURCE_SLOT);
var originalFlags = UnsafeGetInt32FromReservedSlot(rx, REGEXP_FLAGS_SLOT);
var originalFlags = flags;
#endif
// Step 12 (reordered).

Просмотреть файл

@ -92,7 +92,7 @@ function FUNC_NAME(rx, S, lengthS, replaceValue
var position = result.index;
// Step 14.l.iii (reordered)
// To set rx.lastIndex before RegExpGetComplexReplacement.
// To set rx.lastIndex before RegExpGetFunctionalReplacement.
var nextSourcePosition = position + matchLength;
#else
// Steps 14.a-d (skipped).