c51e4f3c66
RegExp assertions (e.g.: '^', '$', '\b', ...) sequences have certain properties that this rewriter exploits: 1. They are zero-width and order-independent, thus one can remove all duplicate assertions. 2. If a subsequence is guaranteed to fail, the entire sequence fails. Any sequence always known to fail (e.g. containing both '\b' and '\B') can be rewritten to a single node that triggers failure. This CL generalizes the previous optimization for repeated assertions to be order-independent, i.e. assertions only have to be in the same sequence but not next to each other. Bug: v8:6515, v8:6126 Change-Id: I3f92f081ce8a55ad8c34c269a09a6686e3b008f3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1657925 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Peter Marshall <petermarshall@chromium.org> Cr-Commit-Position: refs/heads/master@{#62201}
9 lines
423 B
JavaScript
9 lines
423 B
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.
|
|
|
|
// These patterns shouldn't generate code of excessive size.
|
|
assertNull(/\b\B\b\B\b\B\b\B\b\B\b\B\b\B\b\B\b\B/.exec(" aa "));
|
|
assertNull(/\b\b\b\b\b\b\b\b\b\B\B\B\B\B\B\B\B\B/.exec(" aa "));
|
|
assertNull(/\b\B$\b\B$\b\B$\b\B$\b\B$\b\B$\b\B$/.exec(" aa "));
|