1a6ffffb30
This reverts commitd4574d186f
. Reason for revert: In addition to the earlier octane regression, this cl also created a regression in desktop browsing Bug: chromium:1019601 Original change's description: > Reland "[regexp] Clone match info for match indices." > > This reverts commitd7793c0684
. > > Reason for revert: This cl *will* cause regexp regressions. We are trying to gauge the real world impact. > > Original change's description: > > Revert "[regexp] Clone match info for match indices." > > > > This reverts commitdfd9ceb984
. > > > > Reason for revert: Regressions https://chromeperf.appspot.com/group_report?rev=64356 https://crbug.com/1015749 > > > > Original change's description: > > > [regexp] Clone match info for match indices. > > > > > > The current behavior for generating match indices simply stashes a > > > pointer to the match info and then constructs the indices lazily. > > > However, it turns out the match info object used to create the result > > > object is the regexp_last_match_info living on native context, and thus > > > it can change between the creation of the result object and the generation > > > of indices. This cl clones the match info which will be safer. > > > > > > Bug: v8:9548 > > > Change-Id: Ia6f26f88fbc22fd09671bf4c579d39a1510b552d > > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1864585 > > > Commit-Queue: Joshua Litt <joshualitt@chromium.org> > > > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > > > Cr-Commit-Position: refs/heads/master@{#64356} > > > > TBR=jgruber@chromium.org,joshualitt@chromium.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: v8:9548, chromium:1015749 > > Change-Id: I9c30b8fb459cf2aa89d920bf061614441250844d > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1870236 > > Commit-Queue: Jakob Gruber <jgruber@chromium.org> > > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#64407} > > TBR=jgruber@chromium.org,joshualitt@chromium.org > > > Bug: v8:9548, chromium:1015749 > Change-Id: I151511307e3d8752fdbde4b8247514031b141b08 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1879587 > Reviewed-by: Joshua Litt <joshualitt@chromium.org> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Commit-Queue: Joshua Litt <joshualitt@chromium.org> > Cr-Commit-Position: refs/heads/master@{#64587} TBR=jgruber@chromium.org,joshualitt@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: v8:9548, chromium:1015749 Change-Id: Ie5a8e55338728aae33102d82e60a188f6440e8f5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1898030 Reviewed-by: Joshua Litt <joshualitt@chromium.org> Commit-Queue: Joshua Litt <joshualitt@chromium.org> Cr-Commit-Position: refs/heads/master@{#64749}
114 lines
2.2 KiB
JavaScript
114 lines
2.2 KiB
JavaScript
// Copyright 2019 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
//
|
|
// Flags: --harmony-regexp-match-indices --expose-gc
|
|
|
|
// Sanity test.
|
|
{
|
|
const re = /a+(?<Z>z)?/;
|
|
const m = re.exec("xaaaz");
|
|
|
|
assertEquals(m.indices, [[1, 5], [4, 5]]);
|
|
assertEquals(m.indices.groups, {'Z': [4, 5]})
|
|
}
|
|
|
|
// Capture groups that are not matched return `undefined`.
|
|
{
|
|
const re = /a+(?<Z>z)?/;
|
|
const m = re.exec("xaaay");
|
|
|
|
assertEquals(m.indices, [[1, 4], undefined]);
|
|
assertEquals(m.indices.groups, {'Z': undefined});
|
|
}
|
|
|
|
// Two capture groups.
|
|
{
|
|
const re = /a+(?<A>zz)?(?<B>ii)?/;
|
|
const m = re.exec("xaaazzii");
|
|
|
|
assertEquals(m.indices, [[1, 8], [4, 6], [6, 8]]);
|
|
assertEquals(m.indices.groups, {'A': [4, 6], 'B': [6, 8]});
|
|
}
|
|
|
|
// No capture groups.
|
|
{
|
|
const re = /a+/;
|
|
const m = re.exec("xaaazzii");
|
|
|
|
assertEquals(m.indices [[1, 4]]);
|
|
assertEquals(m.indices.groups, undefined);
|
|
}
|
|
|
|
// No match.
|
|
{
|
|
const re = /a+/;
|
|
const m = re.exec("xzzii");
|
|
|
|
assertEquals(null, m);
|
|
}
|
|
|
|
// Unnamed capture groups.
|
|
{
|
|
const re = /a+(z)?/;
|
|
const m = re.exec("xaaaz")
|
|
|
|
assertEquals(m.indices, [[1, 5], [4, 5]]);
|
|
assertEquals(m.indices.groups, undefined)
|
|
}
|
|
|
|
// Named and unnamed capture groups.
|
|
{
|
|
const re = /a+(z)?(?<Y>y)?/;
|
|
const m = re.exec("xaaazyy")
|
|
|
|
assertEquals(m.indices, [[1, 6], [4, 5], [5, 6]]);
|
|
assertEquals(m.indices.groups, {'Y': [5, 6]})
|
|
}
|
|
|
|
|
|
// Verify property overwrite.
|
|
{
|
|
const re = /a+(?<Z>z)?/;
|
|
const m = re.exec("xaaaz");
|
|
|
|
m.indices = null;
|
|
assertEquals(null, m.indices);
|
|
}
|
|
|
|
// Mess with array prototype, we should still do the right thing.
|
|
{
|
|
Object.defineProperty(Array.prototype, "groups", {
|
|
get: () => {
|
|
assertUnreachable();
|
|
return null;
|
|
},
|
|
set: (x) => {
|
|
assertUnreachable();
|
|
}
|
|
});
|
|
|
|
Object.defineProperty(Array.prototype, "0", {
|
|
get: () => {
|
|
assertUnreachable();
|
|
return null;
|
|
},
|
|
set: (x) => {
|
|
assertUnreachable();
|
|
}
|
|
});
|
|
|
|
const re = /a+(?<Z>z)?/;
|
|
const m = re.exec("xaaaz");
|
|
|
|
assertEquals(m.indices.groups, {'Z': [4, 5]})
|
|
}
|
|
|
|
// Test deleting unrelated fields does not break.
|
|
{
|
|
const m = /undefined/.exec();
|
|
delete m['index'];
|
|
gc();
|
|
assertEquals(m.indices, [[0, 9]]);
|
|
}
|