Skip to content

Commit

Permalink
[code-serializer] Handlify in CodeSerializer::Deserialize
Browse files Browse the repository at this point in the history
This section potentially contains allocations and thus gc, all object
references should be handlified.

Bug: v8:9333
Change-Id: I5814e66e8b9b75a8bd952afecae7a3a27b42a642
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1647695
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62012}
  • Loading branch information
schuay authored and Commit Bot committed Jun 6, 2019
1 parent ea04708 commit b107214
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/snapshot/code-serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
PrintF("[Deserializing from %d bytes took %0.3f ms]\n", length, ms);
}

bool log_code_creation =
const bool log_code_creation =
isolate->logger()->is_listening_to_code_events() ||
isolate->is_profiling() ||
isolate->code_event_dispatcher()->IsListeningToCodeEvents();
Expand All @@ -313,29 +313,31 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
#endif // V8_TARGET_ARCH_ARM

if (log_code_creation || FLAG_log_function_events) {
String name = ReadOnlyRoots(isolate).empty_string();
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);
Handle<Script> script(Script::cast(result->script()), isolate);
Handle<String> name(script->name().IsString()
? String::cast(script->name())
: ReadOnlyRoots(isolate).empty_string(),
isolate);

if (FLAG_log_function_events) {
LOG(isolate, FunctionEvent("deserialize", script.id(),
timer.Elapsed().InMillisecondsF(),
result->StartPosition(), result->EndPosition(),
*name_handle));
LOG(isolate,
FunctionEvent("deserialize", script->id(),
timer.Elapsed().InMillisecondsF(),
result->StartPosition(), result->EndPosition(), *name));
}
if (log_code_creation) {
Script::InitLineEnds(Handle<Script>(script, isolate));
Script::InitLineEnds(script);

DisallowHeapAllocation no_gc;
SharedFunctionInfo::ScriptIterator iter(isolate, script);
SharedFunctionInfo::ScriptIterator iter(isolate, *script);
for (i::SharedFunctionInfo info = iter.Next(); !info.is_null();
info = iter.Next()) {
if (info.is_compiled()) {
int line_num = script.GetLineNumber(info.StartPosition()) + 1;
int column_num = script.GetColumnNumber(info.StartPosition()) + 1;
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_handle, line_num, column_num));
info.abstract_code(), info, *name,
line_num, column_num));
}
}
}
Expand Down

0 comments on commit b107214

Please sign in to comment.