Reland "[regexp] Eagerly tier-up for very long strings"
This is a reland of cfb60d430b
Original change's description:
> [regexp] Eagerly tier-up for very long strings
>
> For very long subject strings, the regexp interpreter is currently much slower
> than the native machine code execution. This CL implements eager tier-up to the
> compiler to avoid the performance penalty for subject strings of length greater
> than 1000.
>
> Change-Id: I244ccbd60255e0f3bedc493b1cc3d25cdd42133e
> Bug: v8:9566
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1829273
> Reviewed-by: Peter Marshall <petermarshall@chromium.org>
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Ana Pesko <anapesko@google.com>
> Cr-Commit-Position: refs/heads/master@{#64046}
Bug: v8:9566
Change-Id: I81a10728c64ce3b35258c31eb8178e458d3de205
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1832167
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Ana Pesko <anapesko@google.com>
Cr-Commit-Position: refs/heads/master@{#64063}
This commit is contained in:
parent
12b22b5198
commit
14ffd21dd9
@ -200,6 +200,10 @@ class JSRegExp : public TorqueGeneratedJSRegExp<JSRegExp, JSObject> {
|
|||||||
// The uninitialized value for a regexp code object.
|
// The uninitialized value for a regexp code object.
|
||||||
static const int kUninitializedValue = -1;
|
static const int kUninitializedValue = -1;
|
||||||
|
|
||||||
|
// The heuristic value for the length of the subject string for which we
|
||||||
|
// tier-up to the compiler immediately, instead of using the interpreter.
|
||||||
|
static constexpr int kTierUpForSubjectLengthValue = 1000;
|
||||||
|
|
||||||
TQ_OBJECT_CONSTRUCTORS(JSRegExp)
|
TQ_OBJECT_CONSTRUCTORS(JSRegExp)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -600,6 +600,20 @@ MaybeHandle<Object> RegExpImpl::IrregexpExec(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// For very long subject strings, the regexp interpreter is currently much
|
||||||
|
// slower than the jitted code execution. If the tier-up strategy is turned
|
||||||
|
// on, we want to avoid this performance penalty so we eagerly tier-up if the
|
||||||
|
// subject string length is equal or greater than the given heuristic value.
|
||||||
|
if (FLAG_regexp_tier_up &&
|
||||||
|
subject->length() >= JSRegExp::kTierUpForSubjectLengthValue) {
|
||||||
|
regexp->MarkTierUpForNextExec();
|
||||||
|
if (FLAG_trace_regexp_tier_up) {
|
||||||
|
PrintF(
|
||||||
|
"Forcing tier-up for very long strings in "
|
||||||
|
"RegExpImpl::IrregexpExec\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare space for the return values.
|
// Prepare space for the return values.
|
||||||
int required_registers = RegExp::IrregexpPrepare(isolate, regexp, subject);
|
int required_registers = RegExp::IrregexpPrepare(isolate, regexp, subject);
|
||||||
if (required_registers < 0) {
|
if (required_registers < 0) {
|
||||||
|
@ -91,3 +91,15 @@ assertTrue(!%RegexpHasBytecode(re_g, kLatin1) &&
|
|||||||
%RegexpHasNativeCode(re_g, kLatin1));
|
%RegexpHasNativeCode(re_g, kLatin1));
|
||||||
assertTrue(!%RegexpHasBytecode(re_g, kUnicode) &&
|
assertTrue(!%RegexpHasBytecode(re_g, kUnicode) &&
|
||||||
!%RegexpHasNativeCode(re_g, kUnicode));
|
!%RegexpHasNativeCode(re_g, kUnicode));
|
||||||
|
|
||||||
|
// Testing eager tier-up for very long strings.
|
||||||
|
let dna = "ATCG".repeat(251);
|
||||||
|
|
||||||
|
re_g = />.*\n|\n/;
|
||||||
|
CheckRegexpNotYetCompiled(re_g);
|
||||||
|
|
||||||
|
dna = dna.replace(re_g,"");
|
||||||
|
assertTrue(!%RegexpHasBytecode(re_g, kLatin1) &&
|
||||||
|
%RegexpHasNativeCode(re_g, kLatin1));
|
||||||
|
assertTrue(!%RegexpHasBytecode(re_g, kUnicode) &&
|
||||||
|
!%RegexpHasNativeCode(re_g, kUnicode));
|
||||||
|
Loading…
Reference in New Issue
Block a user