[regexp] Allow empty ranges in GetQuickCheckDetails

A follow-up to crrev.com/c/3240782.

Drive-by: extend JSRegExp printing.

Fixed: chromium:1263327
Bug: v8:11069
Change-Id: Iff64ded27ca93641f0f572df2ce0a9f846948f7f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3245110
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Mathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77536}
This commit is contained in:
Jakob Gruber 2021-10-26 07:52:08 +02:00 committed by V8 LUCI CQ
parent e53e9c108f
commit c1e32791a3
3 changed files with 11 additions and 2 deletions

View File

@ -688,9 +688,11 @@ void JSPromise::JSPromisePrint(std::ostream& os) {
}
void JSRegExp::JSRegExpPrint(std::ostream& os) {
Isolate* isolate = GetIsolate();
JSObjectPrintHeader(os, *this, "JSRegExp");
os << "\n - data: " << Brief(data());
os << "\n - source: " << Brief(source());
os << "\n - flags: " << Brief(*JSRegExp::StringFromFlags(isolate, flags()));
JSObjectPrintBody(os, *this);
}

View File

@ -1669,12 +1669,14 @@ void TextNode::GetQuickCheckDetails(QuickCheckDetails* details,
details->positions(characters_filled_in);
RegExpCharacterClass* tree = elm.char_class();
ZoneList<CharacterRange>* ranges = tree->ranges(zone());
DCHECK(!ranges->is_empty());
if (tree->is_negated()) {
if (tree->is_negated() || ranges->is_empty()) {
// A quick check uses multi-character mask and compare. There is no
// useful way to incorporate a negative char class into this scheme
// so we just conservatively create a mask and value that will always
// succeed.
// Likewise for empty ranges (empty ranges can occur e.g. when
// compiling for one-byte subjects and impossible (non-one-byte) ranges
// have been removed).
pos->mask = 0;
pos->value = 0;
} else {

View File

@ -0,0 +1,5 @@
// Copyright 2021 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.
assertNull(/.?\ud833{6,}/gsu.exec());