Commit d9f35f05 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[tracing] Fix SharedFunctionInfo::ToTracedValue().

Pass the FunctionLiteral to `SharedFunctionInfo::ToTracedValue()` and
take the source position from that for logging, as the SFI itself might
not have a way to get to the source position in the beginning (currently
that's the case for functions that are marked for eager compilation).

Tbr: ulan@chromium.org
Bug: chromium:956848, v8:8598, v8:9039
Change-Id: I05c31c7d48734f1f301930ba455d3d5a77b9df13
Doc: bit.ly/v8-tracing-signals
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1601146
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61329}
parent bf47bfd1
......@@ -3462,7 +3462,7 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForLiteral(
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "SharedFunctionInfo",
TRACE_ID_WITH_SCOPE(SharedFunctionInfo::kTraceScope, shared->TraceID()),
shared->ToTracedValue());
shared->ToTracedValue(literal));
return shared;
}
......
......@@ -4905,7 +4905,8 @@ uint32_t SharedFunctionInfo::Hash() {
return static_cast<uint32_t>(base::hash_combine(start_pos, script_id));
}
std::unique_ptr<v8::tracing::TracedValue> SharedFunctionInfo::ToTracedValue() {
std::unique_ptr<v8::tracing::TracedValue> SharedFunctionInfo::ToTracedValue(
FunctionLiteral* literal) {
auto value = v8::tracing::TracedValue::Create();
if (HasSharedName()) {
value->SetString("name", Name()->ToCString());
......@@ -4923,8 +4924,12 @@ std::unique_ptr<v8::tracing::TracedValue> SharedFunctionInfo::ToTracedValue() {
value->SetValue("script", Script::cast(script())->TraceIDRef());
value->BeginDictionary("sourcePosition");
Script::PositionInfo info;
if (Script::cast(script())->GetPositionInfo(StartPosition(), &info,
Script::WITH_OFFSET)) {
// We get the start position from the {literal} here, because the
// SharedFunctionInfo itself might not have a way to get to the
// start position early on (currently that's the case when it's
// marked for eager compilation).
if (Script::cast(script())->GetPositionInfo(literal->start_position(),
&info, Script::WITH_OFFSET)) {
value->SetInteger("line", info.line + 1);
value->SetInteger("column", info.column + 1);
}
......
......@@ -601,7 +601,8 @@ class SharedFunctionInfo : public HeapObject {
#endif
// Returns the SharedFunctionInfo in a format tracing can support.
std::unique_ptr<v8::tracing::TracedValue> ToTracedValue();
std::unique_ptr<v8::tracing::TracedValue> ToTracedValue(
FunctionLiteral* literal);
// The tracing scope for SharedFunctionInfo objects.
static const char* kTraceScope;
......
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