Bug 1362154: Part 2: Avoid rooting hazard in CheckPatternSyntax r=mgaudet
authorIain Ireland <iireland@mozilla.com>
Wed, 20 May 2020 21:09:36 +0000
changeset 531647 e7d2300295143bf951d8bdecd7619ea78722bb80
parent 531646 7f7a204fa0246f1aa85bc58137bfc023ee2b8d43
child 531648 7c315167d74aa8afe314d5491a3cdfc105229686
push id37441
push userapavel@mozilla.com
push dateFri, 22 May 2020 21:38:53 +0000
treeherdermozilla-central@d6abd35b54ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmgaudet
bugs1362154
milestone78.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 1362154: Part 2: Avoid rooting hazard in CheckPatternSyntax r=mgaudet In debug, CheckPatternSyntax holds an unrooted RegExpShared across a call to the regexp parser. This is the only remaining obstacle to allocating GC things while parsing regexps. Differential Revision: https://phabricator.services.mozilla.com/D76034
js/src/builtin/RegExp.cpp
--- a/js/src/builtin/RegExp.cpp
+++ b/js/src/builtin/RegExp.cpp
@@ -204,17 +204,18 @@ static bool CheckPatternSyntaxSlow(JSCon
 #endif
 }
 
 static RegExpShared* CheckPatternSyntax(JSContext* cx, HandleAtom pattern,
                                         RegExpFlags flags) {
   // If we already have a RegExpShared for this pattern/flags, we can
   // avoid the much slower CheckPatternSyntaxSlow call.
 
-  if (RegExpShared* shared = cx->zone()->regExps().maybeGet(pattern, flags)) {
+  RootedRegExpShared shared(cx, cx->zone()->regExps().maybeGet(pattern, flags));
+  if (shared) {
 #ifdef DEBUG
     // Assert the pattern is valid.
     if (!CheckPatternSyntaxSlow(cx, pattern, flags)) {
       MOZ_ASSERT(cx->isThrowingOutOfMemory() || cx->isThrowingOverRecursed());
       return nullptr;
     }
 #endif
     return shared;