Commit 5d0cf6bc authored by Anna Henningsen's avatar Anna Henningsen Committed by Commit Bot

[snapshot] Use Handle to track name in `CodeSerializer::Deserialize`

The `Script::InitLineEnds(Handle<Script>(script, isolate));` line
may lead to objects being moved around on the heap, so it’s necessary
to use a `Handle` to track that.

This was causing crashes in Node.js in Debug mode when using the
code cache in combination with the CPU profiler.

Refs: https://github.com/nodejs/node/issues/27307
Change-Id: I392b4c00c6ebad44753f87fcbf2e3278ea7799a6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1575698Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61036}
parent b422b173
......@@ -319,11 +319,12 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
Script script = Script::cast(result->script());
Handle<Script> script_handle(script, isolate);
if (script->name()->IsString()) name = String::cast(script->name());
Handle<String> name_handle(name, isolate);
if (FLAG_log_function_events) {
LOG(isolate,
FunctionEvent("deserialize", script->id(),
timer.Elapsed().InMillisecondsF(),
result->StartPosition(), result->EndPosition(), name));
LOG(isolate, FunctionEvent("deserialize", script->id(),
timer.Elapsed().InMillisecondsF(),
result->StartPosition(), result->EndPosition(),
*name_handle));
}
if (log_code_creation) {
Script::InitLineEnds(Handle<Script>(script, isolate));
......@@ -335,8 +336,8 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
int line_num = script->GetLineNumber(info->StartPosition()) + 1;
int column_num = script->GetColumnNumber(info->StartPosition()) + 1;
PROFILE(isolate, CodeCreateEvent(CodeEventListener::SCRIPT_TAG,
info->abstract_code(), info, name,
line_num, column_num));
info->abstract_code(), info,
*name_handle, line_num, column_num));
}
}
}
......
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