Commit 719bc030 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Compiler] Use existing inferred name when adding preparse data to SFI.

The inferred name in the function literal might not be as accurate as the one
already on the shared function info, so use the existing one instead.

BUG=chromium:995813

Change-Id: Ie06eb964934fc039e56ebf9452f706e1192b7ab0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1782169
Auto-Submit: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63566}
parent 610faced
......@@ -2234,18 +2234,22 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
// this function, replace the uncompiled data with one that includes it.
if (literal->produced_preparse_data() != nullptr &&
existing->HasUncompiledDataWithoutPreparseData()) {
DCHECK(literal->inferred_name()->Equals(
existing->uncompiled_data().inferred_name()));
Handle<UncompiledData> existing_uncompiled_data =
handle(existing->uncompiled_data(), isolate);
DCHECK_EQ(literal->start_position(),
existing->uncompiled_data().start_position());
existing_uncompiled_data->start_position());
DCHECK_EQ(literal->end_position(),
existing->uncompiled_data().end_position());
existing_uncompiled_data->end_position());
// Use existing uncompiled data's inferred name as it may be more
// accurate than the literal we preparsed.
Handle<String> inferred_name =
handle(existing_uncompiled_data->inferred_name(), isolate);
Handle<PreparseData> preparse_data =
literal->produced_preparse_data()->Serialize(isolate);
Handle<UncompiledData> new_uncompiled_data =
isolate->factory()->NewUncompiledDataWithPreparseData(
literal->inferred_name(), literal->start_position(),
literal->end_position(), preparse_data);
inferred_name, existing_uncompiled_data->start_position(),
existing_uncompiled_data->end_position(), preparse_data);
existing->set_uncompiled_data(*new_uncompiled_data);
}
return existing;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment