Commit 26de9a25 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Compile] Reattach PreParseData for inner functions when recompiling flushed function.

If the function has been uncompiled (bytecode flushed) it will have lost any preparsed data.
When we recompile the outer function we will regenerate this PreParseData but it wasn't
being reattached to the inner function. This CL fixes this by checking for this case in
Compiler::GetSharedFunctionInfo and creating a new NewUncompiledDataWithPreparseData to
attach to the inner function.

BUG=v8:9479

Change-Id: I5c0fc8251006f8f5c7c7f5f9dd17b2ecc671b672
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1741655
Auto-Submit: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63128}
parent 5577c69d
......@@ -2221,7 +2221,28 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
// If we found an existing shared function info, return it.
Handle<SharedFunctionInfo> existing;
if (maybe_existing.ToHandle(&existing)) return existing;
if (maybe_existing.ToHandle(&existing)) {
// If the function has been uncompiled (bytecode flushed) it will have lost
// any preparsed data. If we produced preparsed data during this compile for
// 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()));
DCHECK_EQ(literal->start_position(),
existing->uncompiled_data().start_position());
DCHECK_EQ(literal->end_position(),
existing->uncompiled_data().end_position());
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);
existing->set_uncompiled_data(*new_uncompiled_data);
}
return existing;
}
// Allocate a shared function info object which will be compiled lazily.
Handle<SharedFunctionInfo> result =
......
......@@ -572,7 +572,8 @@ UncompiledData SharedFunctionInfo::uncompiled_data() const {
}
void SharedFunctionInfo::set_uncompiled_data(UncompiledData uncompiled_data) {
DCHECK(function_data() == Smi::FromEnum(Builtins::kCompileLazy));
DCHECK(function_data() == Smi::FromEnum(Builtins::kCompileLazy) ||
HasUncompiledData());
DCHECK(uncompiled_data.IsUncompiledData());
set_function_data(uncompiled_data);
}
......
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