Skip to content

Commit

Permalink
[JSC] Include inliner information in SamplingProfiler JSON dump
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259995
rdar://113655463

Reviewed by Justin Michaud.

C++ SamplingProfiler::reportTopBytecodes has a feature showing inliner of the hot bytecodes.
This patch,

1. extends JSON dump with inliner information for each frame.
2. dumps inliner information as the same way to C++ SamplingProfiler::reportTopBytecodes from ruby script.

* Source/JavaScriptCore/runtime/SamplingProfiler.cpp:
(JSC::SamplingProfiler::stackTracesAsJSON):
* Tools/Scripts/display-sampling-profiler-output:

Canonical link: https://commits.webkit.org/266746@main
  • Loading branch information
Constellation committed Aug 9, 2023
1 parent b7bc61d commit 612cb56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Source/JavaScriptCore/runtime/SamplingProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,13 @@ Ref<JSON::Value> SamplingProfiler::stackTracesAsJSON()
result->setString("name"_s, stackFrame.displayName(m_vm));
result->setString("location"_s, descriptionForLocation(stackFrame.semanticLocation, stackFrame.wasmCompilationMode, stackFrame.wasmOffset));
result->setString("category"_s, tierName(stackFrame));
if (std::optional<std::pair<StackFrame::CodeLocation, CodeBlock*>> machineLocation = stackFrame.machineLocation) {
auto inliner = JSON::Object::create();
inliner->setString("name"_s, String::fromUTF8(machineLocation->second->inferredName()));
inliner->setString("location"_s, descriptionForLocation(machineLocation->first, std::nullopt, BytecodeIndex()));
inliner->setString("category"_s, tierName(stackFrame));
result->setValue("inliner"_s, WTFMove(inliner));
}
return result;
};

Expand Down
4 changes: 4 additions & 0 deletions Tools/Scripts/display-sampling-profiler-output
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def reportTopBytecodes database
next if stackTrace["frames"].empty?
frame = stackTrace["frames"][0]
description = "#{frame["name"]}#{frame["location"]}"
inliner = frame["inliner"]
unless inliner.nil?
description = "#{description} <-- #{inliner["name"]}#{inliner["location"]}"
end
bytecodeCounts[description] += 1
tierCounts[frame["category"]] += 1
totalSamples += 1
Expand Down

0 comments on commit 612cb56

Please sign in to comment.