[regexp] Don't clone new JSRegExps when there is no feedback vector
When creating a new JSRegExp for a literal, we sometimes create a boilerplate and store it in the feedback vector. Then for future creations, we can copy the boilerplate instead of re-creating the regexp from scratch. When we don't have a feedback vector, we currently create a boilerplate, copy it and return the copy, and then throw out the boilerplate, which is unnecessary. We can just return the first JSRegExp we create. Change-Id: I98b4e3a3082654ea989e0e6ba1524ce080b0125c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1776086 Reviewed-by: Sigurd Schneider <sigurds@chromium.org> Commit-Queue: Peter Marshall <petermarshall@chromium.org> Cr-Commit-Position: refs/heads/master@{#63496}
This commit is contained in:
parent
14243f1206
commit
6498f8bb33
@ -655,15 +655,16 @@ RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) {
|
||||
DCHECK(maybe_vector->IsFeedbackVector());
|
||||
vector = Handle<FeedbackVector>::cast(maybe_vector);
|
||||
}
|
||||
Handle<Object> boilerplate;
|
||||
if (vector.is_null()) {
|
||||
Handle<JSRegExp> new_regexp;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, boilerplate,
|
||||
isolate, new_regexp,
|
||||
JSRegExp::New(isolate, pattern, JSRegExp::Flags(flags)));
|
||||
return *JSRegExp::Copy(Handle<JSRegExp>::cast(boilerplate));
|
||||
return *new_regexp;
|
||||
}
|
||||
|
||||
// Check if boilerplate exists. If not, create it first.
|
||||
Handle<JSRegExp> boilerplate;
|
||||
Handle<Object> literal_site(vector->Get(literal_slot)->cast<Object>(),
|
||||
isolate);
|
||||
if (!HasBoilerplate(literal_site)) {
|
||||
@ -676,7 +677,7 @@ RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) {
|
||||
}
|
||||
vector->Set(literal_slot, *boilerplate);
|
||||
}
|
||||
return *JSRegExp::Copy(Handle<JSRegExp>::cast(boilerplate));
|
||||
return *JSRegExp::Copy(boilerplate);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
Loading…
Reference in New Issue
Block a user