From 5c6bd8bcfd12eb14647d12792f10c95cf1c27d13 Mon Sep 17 00:00:00 2001 From: Razvan Maries Date: Wed, 27 May 2020 23:20:51 +0300 Subject: [PATCH] Backed out changeset 2a44daf61d7f (bug 1640479) for build bustages on bug1640479.js. CLOSED TREE --- js/src/jit-test/tests/regexp/bug1640479.js | 13 ------------- js/src/new-regexp/RegExpAPI.cpp | 8 ++++---- js/src/vm/RegExpObject.cpp | 1 + 3 files changed, 5 insertions(+), 17 deletions(-) delete mode 100644 js/src/jit-test/tests/regexp/bug1640479.js diff --git a/js/src/jit-test/tests/regexp/bug1640479.js b/js/src/jit-test/tests/regexp/bug1640479.js deleted file mode 100644 index a04b44a2a343..000000000000 --- a/js/src/jit-test/tests/regexp/bug1640479.js +++ /dev/null @@ -1,13 +0,0 @@ -var failures = 0; -var i = 0; - -function foo() { - var e; - var r = RegExp("(?<_" + (i++) + "a>)"); - try { e = r.exec("a"); } catch {} - e = r.exec("a"); - if (e.groups === undefined) failures++; -} - -oomTest(foo); -assertEq(failures, 0); diff --git a/js/src/new-regexp/RegExpAPI.cpp b/js/src/new-regexp/RegExpAPI.cpp index a759f7fe4d11..79fc33357447 100644 --- a/js/src/new-regexp/RegExpAPI.cpp +++ b/js/src/new-regexp/RegExpAPI.cpp @@ -480,16 +480,16 @@ bool CompilePattern(JSContext* cx, MutableHandleRegExpShared re, return true; } } + // Add one to account for the whole-match capture + uint32_t pairCount = data.capture_count + 1; + re->useRegExpMatch(pairCount); + if (!data.capture_name_map.is_null()) { RootedNativeObject namedCaptures(cx, data.capture_name_map->inner()); if (!RegExpShared::initializeNamedCaptures(cx, re, namedCaptures)) { return false; } } - // All fallible initialization has succeeded, so we can change state. - // Add one to capture_count to account for the whole-match capture. - uint32_t pairCount = data.capture_count + 1; - re->useRegExpMatch(pairCount); } MOZ_ASSERT(re->kind() == RegExpShared::Kind::RegExp); diff --git a/js/src/vm/RegExpObject.cpp b/js/src/vm/RegExpObject.cpp index c3ddaa716cf9..a7e6b08eb34b 100644 --- a/js/src/vm/RegExpObject.cpp +++ b/js/src/vm/RegExpObject.cpp @@ -1137,6 +1137,7 @@ void RegExpShared::useRegExpMatch(size_t pairCount) { /* static */ bool RegExpShared::initializeNamedCaptures(JSContext* cx, HandleRegExpShared re, HandleNativeObject namedCaptures) { + MOZ_ASSERT(re->kind() == RegExpShared::Kind::RegExp); MOZ_ASSERT(!re->groupsTemplate_); MOZ_ASSERT(!re->namedCaptureIndices_);