diff options
author | Moonchild <moonchild@palemoon.org> | 2023-07-07 19:41:06 +0200 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2023-07-07 19:41:06 +0200 |
commit | ea9077a8a5fd8b9f7d5397d18e84aa20fb87f406 (patch) | |
tree | 64c21104a540df2812482dcc520952869db04ebf /js/src/builtin/RegExp.cpp | |
parent | b4af6b6265ed489acbc3dc5a2fd9d4ed7f783b13 (diff) | |
parent | af5dbfc12003e61f21d2a7c71f239d18ae3945cf (diff) | |
download | uxp-RC_20230707.tar.gz |
Merge branch 'master' into releaseRC_20230707RB_20230711
Diffstat (limited to 'js/src/builtin/RegExp.cpp')
-rw-r--r-- | js/src/builtin/RegExp.cpp | 76 |
1 files changed, 15 insertions, 61 deletions
diff --git a/js/src/builtin/RegExp.cpp b/js/src/builtin/RegExp.cpp index 46a2862909..f3d34762f6 100644 --- a/js/src/builtin/RegExp.cpp +++ b/js/src/builtin/RegExp.cpp @@ -974,8 +974,7 @@ IsTrailSurrogateWithLeadSurrogate(JSContext* cx, HandleLinearString input, int32 */ static RegExpRunStatus ExecuteRegExp(JSContext* cx, HandleObject regexp, HandleString string, - int32_t lastIndex, - MatchPairs* matches, size_t* endIndex, RegExpStaticsUpdate staticsUpdate) + int32_t lastIndex, MatchPairs* matches, size_t* endIndex) { /* * WARNING: Despite the presence of spec step comment numbers, this @@ -990,14 +989,9 @@ ExecuteRegExp(JSContext* cx, HandleObject regexp, HandleString string, if (!RegExpObject::getShared(cx, reobj, &re)) return RegExpRunStatus_Error; - RegExpStatics* res; - if (staticsUpdate == UpdateRegExpStatics) { - res = GlobalObject::getRegExpStatics(cx, cx->global()); - if (!res) - return RegExpRunStatus_Error; - } else { - res = nullptr; - } + RegExpStatics* res = GlobalObject::getRegExpStatics(cx, cx->global()); + if (!res) + return RegExpRunStatus_Error; RootedLinearString input(cx, string->ensureLinear(cx)); if (!input) @@ -1051,15 +1045,14 @@ ExecuteRegExp(JSContext* cx, HandleObject regexp, HandleString string, * steps 3, 9-25, except 12.a.i, 12.c.i.1, 15. */ static bool -RegExpMatcherImpl(JSContext* cx, HandleObject regexp, HandleString string, - int32_t lastIndex, RegExpStaticsUpdate staticsUpdate, MutableHandleValue rval) +RegExpMatcherImpl(JSContext* cx, HandleObject regexp, HandleString string, int32_t lastIndex, + MutableHandleValue rval) { /* Execute regular expression and gather matches. */ ScopedMatchPairs matches(&cx->tempLifoAlloc()); /* Steps 3, 9-14, except 12.a.i, 12.c.i.1. */ - RegExpRunStatus status = ExecuteRegExp(cx, regexp, string, lastIndex, - &matches, nullptr, staticsUpdate); + RegExpRunStatus status = ExecuteRegExp(cx, regexp, string, lastIndex, &matches, nullptr); if (status == RegExpRunStatus_Error) return false; @@ -1099,8 +1092,7 @@ js::RegExpMatcher(JSContext* cx, unsigned argc, Value* vp) return false; /* Steps 3, 9-25, except 12.a.i, 12.c.i.1, 15. */ - return RegExpMatcherImpl(cx, regexp, string, lastIndex, - UpdateRegExpStatics, args.rval()); + return RegExpMatcherImpl(cx, regexp, string, lastIndex, args.rval()); } /* @@ -1123,8 +1115,7 @@ js::RegExpMatcherRaw(JSContext* cx, HandleObject regexp, HandleString input, return false; return CreateRegExpMatchResult(cx, *shared, input, *maybeMatches, output); } - return RegExpMatcherImpl(cx, regexp, input, lastIndex, - UpdateRegExpStatics, output); + return RegExpMatcherImpl(cx, regexp, input, lastIndex, output); } /* @@ -1135,14 +1126,13 @@ js::RegExpMatcherRaw(JSContext* cx, HandleObject regexp, HandleString input, */ static bool RegExpSearcherImpl(JSContext* cx, HandleObject regexp, HandleString string, - int32_t lastIndex, RegExpStaticsUpdate staticsUpdate, int32_t* result) + int32_t lastIndex, int32_t* result) { /* Execute regular expression and gather matches. */ ScopedMatchPairs matches(&cx->tempLifoAlloc()); /* Steps 3, 9-14, except 12.a.i, 12.c.i.1. */ - RegExpRunStatus status = ExecuteRegExp(cx, regexp, string, lastIndex, - &matches, nullptr, staticsUpdate); + RegExpRunStatus status = ExecuteRegExp(cx, regexp, string, lastIndex, &matches, nullptr); if (status == RegExpRunStatus_Error) return false; @@ -1180,7 +1170,7 @@ js::RegExpSearcher(JSContext* cx, unsigned argc, Value* vp) /* Steps 3, 9-25, except 12.a.i, 12.c.i.1, 15. */ int32_t result = 0; - if (!RegExpSearcherImpl(cx, regexp, string, lastIndex, UpdateRegExpStatics, &result)) + if (!RegExpSearcherImpl(cx, regexp, string, lastIndex, &result)) return false; args.rval().setInt32(result); @@ -1203,23 +1193,7 @@ js::RegExpSearcherRaw(JSContext* cx, HandleObject regexp, HandleString input, *result = CreateRegExpSearchResult(cx, *maybeMatches); return true; } - return RegExpSearcherImpl(cx, regexp, input, lastIndex, - UpdateRegExpStatics, result); -} - -bool -js::regexp_exec_no_statics(JSContext* cx, unsigned argc, Value* vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - MOZ_ASSERT(args.length() == 2); - MOZ_ASSERT(IsRegExpObject(args[0])); - MOZ_ASSERT(args[1].isString()); - - RootedObject regexp(cx, &args[0].toObject()); - RootedString string(cx, args[1].toString()); - - return RegExpMatcherImpl(cx, regexp, string, 0, - DontUpdateRegExpStatics, args.rval()); + return RegExpSearcherImpl(cx, regexp, input, lastIndex, result); } /* @@ -1245,8 +1219,7 @@ js::RegExpTester(JSContext* cx, unsigned argc, Value* vp) /* Steps 3, 9-14, except 12.a.i, 12.c.i.1. */ size_t endIndex = 0; - RegExpRunStatus status = ExecuteRegExp(cx, regexp, string, lastIndex, - nullptr, &endIndex, UpdateRegExpStatics); + RegExpRunStatus status = ExecuteRegExp(cx, regexp, string, lastIndex, nullptr, &endIndex); if (status == RegExpRunStatus_Error) return false; @@ -1271,8 +1244,7 @@ js::RegExpTesterRaw(JSContext* cx, HandleObject regexp, HandleString input, MOZ_ASSERT(lastIndex >= 0); size_t endIndexTmp = 0; - RegExpRunStatus status = ExecuteRegExp(cx, regexp, input, lastIndex, - nullptr, &endIndexTmp, UpdateRegExpStatics); + RegExpRunStatus status = ExecuteRegExp(cx, regexp, input, lastIndex, nullptr, &endIndexTmp); if (status == RegExpRunStatus_Success) { MOZ_ASSERT(endIndexTmp <= INT32_MAX); @@ -1287,24 +1259,6 @@ js::RegExpTesterRaw(JSContext* cx, HandleObject regexp, HandleString input, return false; } -bool -js::regexp_test_no_statics(JSContext* cx, unsigned argc, Value* vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - MOZ_ASSERT(args.length() == 2); - MOZ_ASSERT(IsRegExpObject(args[0])); - MOZ_ASSERT(args[1].isString()); - - RootedObject regexp(cx, &args[0].toObject()); - RootedString string(cx, args[1].toString()); - - size_t ignored = 0; - RegExpRunStatus status = ExecuteRegExp(cx, regexp, string, 0, - nullptr, &ignored, DontUpdateRegExpStatics); - args.rval().setBoolean(status == RegExpRunStatus_Success); - return status != RegExpRunStatus_Error; -} - static void GetParen(JSLinearString* matched, const JS::Value& capture, JSSubString* out) { |