[runtime] Remove buggy dead code path from Runtime_CreateRegExpLiteral

Runtime_CreateRegExpLiteral pretends to handle the case where we
already have a boilerplate but the code just passes an empty handle
to JSRegExp::Copy. This CL replaces the code with a CHECK that the
boilerplate doesn't exist.

A few mostly cosmetic changes along the way.

Change-Id: I856c77c1cdf58f09e920b773b66b037c5178edc7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1809357
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63852}
This commit is contained in:
Georg Neis 2019-09-17 15:59:12 +02:00 committed by Commit Bot
parent 84d724deda
commit f1fb43a0ab

View File

@ -595,10 +595,11 @@ RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) {
CONVERT_SMI_ARG_CHECKED(literals_index, 1);
CONVERT_ARG_HANDLE_CHECKED(ObjectBoilerplateDescription, description, 2);
CONVERT_SMI_ARG_CHECKED(flags, 3);
Handle<FeedbackVector> vector = Handle<FeedbackVector>();
if (!maybe_vector->IsUndefined()) {
DCHECK(maybe_vector->IsFeedbackVector());
Handle<FeedbackVector> vector;
if (maybe_vector->IsFeedbackVector()) {
vector = Handle<FeedbackVector>::cast(maybe_vector);
} else {
DCHECK(maybe_vector->IsUndefined());
}
RETURN_RESULT_OR_FAILURE(
isolate, CreateLiteral<ObjectLiteralHelper>(
@ -632,10 +633,11 @@ RUNTIME_FUNCTION(Runtime_CreateArrayLiteral) {
CONVERT_SMI_ARG_CHECKED(literals_index, 1);
CONVERT_ARG_HANDLE_CHECKED(ArrayBoilerplateDescription, elements, 2);
CONVERT_SMI_ARG_CHECKED(flags, 3);
Handle<FeedbackVector> vector = Handle<FeedbackVector>();
if (!maybe_vector->IsUndefined()) {
DCHECK(maybe_vector->IsFeedbackVector());
Handle<FeedbackVector> vector;
if (maybe_vector->IsFeedbackVector()) {
vector = Handle<FeedbackVector>::cast(maybe_vector);
} else {
DCHECK(maybe_vector->IsUndefined());
}
RETURN_RESULT_OR_FAILURE(
isolate, CreateLiteral<ArrayLiteralHelper>(
@ -649,11 +651,12 @@ RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) {
CONVERT_SMI_ARG_CHECKED(index, 1);
CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2);
CONVERT_SMI_ARG_CHECKED(flags, 3);
FeedbackSlot literal_slot(FeedbackVector::ToSlot(index));
Handle<FeedbackVector> vector = Handle<FeedbackVector>();
if (!maybe_vector->IsUndefined()) {
DCHECK(maybe_vector->IsFeedbackVector());
Handle<FeedbackVector> vector;
if (maybe_vector->IsFeedbackVector()) {
vector = Handle<FeedbackVector>::cast(maybe_vector);
} else {
DCHECK(maybe_vector->IsUndefined());
}
if (vector.is_null()) {
Handle<JSRegExp> new_regexp;
@ -663,11 +666,13 @@ RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) {
return *new_regexp;
}
// Check if boilerplate exists. If not, create it first.
Handle<JSRegExp> boilerplate;
// This function assumes that the boilerplate does not yet exist.
FeedbackSlot literal_slot(FeedbackVector::ToSlot(index));
Handle<Object> literal_site(vector->Get(literal_slot)->cast<Object>(),
isolate);
if (!HasBoilerplate(literal_site)) {
CHECK(!HasBoilerplate(literal_site));
Handle<JSRegExp> boilerplate;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, boilerplate,
JSRegExp::New(isolate, pattern, JSRegExp::Flags(flags)));
@ -676,7 +681,6 @@ RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) {
return *boilerplate;
}
vector->Set(literal_slot, *boilerplate);
}
return *JSRegExp::Copy(boilerplate);
}