[regexp] Refactor eager tier-up for global replaces
This CL changes the eager tier-up for global replaces slightly to include a previously unaccounted for path by moving the logic into the caller so that it includes this path as well. Change-Id: Ifc265ddb1183b8bb3ea75ca5d6c83d66e55e2837 Bug: v8:9566 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1829276 Commit-Queue: Ana Pesko <anapesko@google.com> Reviewed-by: Peter Marshall <petermarshall@chromium.org> Cr-Commit-Position: refs/heads/master@{#64042}
This commit is contained in:
parent
8de672cbe8
commit
95ec4803fd
@ -613,20 +613,6 @@ V8_WARN_UNUSED_RESULT static Object StringReplaceGlobalRegExpWithString(
|
||||
|
||||
JSRegExp::Type typeTag = regexp->TypeTag();
|
||||
if (typeTag == JSRegExp::IRREGEXP) {
|
||||
// Force tier up to native code for global replaces. The global replace is
|
||||
// implemented differently for native code and bytecode execution, where the
|
||||
// native code expects an array to store all the matches, and the bytecode
|
||||
// matches one at a time, so it's easier to tier-up to native code from the
|
||||
// start.
|
||||
if (FLAG_regexp_tier_up) {
|
||||
regexp->MarkTierUpForNextExec();
|
||||
if (FLAG_trace_regexp_tier_up) {
|
||||
PrintF(
|
||||
"Forcing tier-up of JSRegExp object %p in "
|
||||
"StringReplaceGlobalRegExpWithString\n",
|
||||
reinterpret_cast<void*>(regexp->ptr()));
|
||||
}
|
||||
}
|
||||
// Ensure the RegExp is compiled so we can access the capture-name map.
|
||||
if (RegExp::IrregexpPrepare(isolate, regexp, subject) == -1) {
|
||||
DCHECK(isolate->has_pending_exception());
|
||||
@ -1349,6 +1335,19 @@ V8_WARN_UNUSED_RESULT MaybeHandle<String> RegExpReplace(
|
||||
RETURN_ON_EXCEPTION(isolate, RegExpUtils::SetLastIndex(isolate, regexp, 0),
|
||||
String);
|
||||
|
||||
// Force tier up to native code for global replaces. The global replace is
|
||||
// implemented differently for native code and bytecode execution, where the
|
||||
// native code expects an array to store all the matches, and the bytecode
|
||||
// matches one at a time, so it's easier to tier-up to native code from the
|
||||
// start.
|
||||
if (FLAG_regexp_tier_up && regexp->TypeTag() == JSRegExp::IRREGEXP) {
|
||||
regexp->MarkTierUpForNextExec();
|
||||
if (FLAG_trace_regexp_tier_up) {
|
||||
PrintF("Forcing tier-up of JSRegExp object %p in RegExpReplace\n",
|
||||
reinterpret_cast<void*>(regexp->ptr()));
|
||||
}
|
||||
}
|
||||
|
||||
if (replace->length() == 0) {
|
||||
if (string->IsOneByteRepresentation()) {
|
||||
Object result =
|
||||
|
Loading…
Reference in New Issue
Block a user