5720d2056c
This commit adds the 'l' (linear) RegExp flag (as in e.g. /asdf|123/l) that forces execution in linear time. These regexps are handled by the experimental engine. If the experimental engine cannot handle the pattern, an exception is thrown on creation of the regexp. The commit also adds a new global V8 flag and changes an existing one: * --enable-experimental-engine, which turns on recognition of the RegExp 'l' flag. Previously this flag also caused all supported regexps to be executed by the experimental engine; this is not the case anymore. * --default-to-experimental-regexp-engine takes over the previous semantics of --enable-experimental-regexp-engine: We execute all supported regexps with the experimental engine. Cq-Include-Trybots: luci.v8.try:v8_linux64_fyi_rel_ng Bug: v8:10765 Change-Id: I5622a89b19404105e8be280d454e9fdd63c003b3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2461244 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Martin Bidlingmaier <mbid@google.com> Cr-Commit-Position: refs/heads/master@{#70892}
36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
// Copyright 2020 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: --allow-natives-syntax
|
|
// Flags: --enable-experimental-regexp-engine
|
|
// Flags: --no-default-to-experimental-regexp-engine
|
|
// Flags: --no-force-slow-path
|
|
|
|
// We shouldn't assign the experimental engine to regexps without 'l' flag.
|
|
assertNotEquals("EXPERIMENTAL", %RegexpTypeTag(/asdf/));
|
|
assertNotEquals("EXPERIMENTAL", %RegexpTypeTag(/123|asdf/));
|
|
assertNotEquals("EXPERIMENTAL", %RegexpTypeTag(/(a*)*x/));
|
|
assertNotEquals("EXPERIMENTAL", %RegexpTypeTag(/(a*)\1/));
|
|
|
|
// We should assign the experimental engine to regexps with 'l' flag.
|
|
assertEquals("EXPERIMENTAL", %RegexpTypeTag(/asdf/l));
|
|
assertEquals("EXPERIMENTAL", %RegexpTypeTag(/123|asdf/l));
|
|
assertEquals("EXPERIMENTAL", %RegexpTypeTag(/(a*)*x/l));
|
|
|
|
// We should throw if a regexp with 'l' flag can't be handled by the
|
|
// experimental engine.
|
|
assertThrows(() => /(a*)\1/l, SyntaxError);
|
|
|
|
// The flags field of a regexp should be sorted.
|
|
assertEquals("glmsy", (/asdf/lymsg).flags);
|
|
|
|
// The 'linear' member should be set according to the linear flag.
|
|
assertTrue((/asdf/lymsg).linear);
|
|
assertFalse((/asdf/ymsg).linear);
|
|
|
|
// The new fields installed on the regexp prototype map shouldn't make
|
|
// unmodified regexps slow.
|
|
assertTrue(%RegexpIsUnmodified(/asdf/));
|
|
assertTrue(%RegexpIsUnmodified(/asdf/l));
|