tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 477afbe49a7133e97af0a73f21a99a0a77ebfbc5
parent bb661aeb498c6809b82c7b90d7ddad47ffc33577
Author: Nazım Can Altınova <canaltinova@gmail.com>
Date:   Fri, 28 Nov 2025 09:42:32 +0000

Bug 2002825 - Wire the sourceId of JIT frames of marker stacks to the buffer r=mstange,profiler-reviewers

This was not wired correctly initially due to the confusing name of
CollectWasmFrame. It turned out it can collect a wasm frame or a async
JIT frame. In the previous patch we renamed it to reflect that it can
also collect sync JIT frames. And this patch passes the sourceId as an
argument, so we can serialize this in the buffer properly.

Differential Revision: https://phabricator.services.mozilla.com/D274329

Diffstat:
Mtoolkit/components/backgroundhangmonitor/ThreadStackHelper.cpp | 3++-
Mtoolkit/components/backgroundhangmonitor/ThreadStackHelper.h | 3++-
Mtools/profiler/core/ProfileBuffer.cpp | 5+++--
Mtools/profiler/core/ProfileBuffer.h | 3++-
Mtools/profiler/core/platform.cpp | 2+-
Mtools/profiler/public/GeckoProfiler.h | 3++-
Mtools/profiler/tests/gtest/GeckoProfiler.cpp | 3++-
7 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/toolkit/components/backgroundhangmonitor/ThreadStackHelper.cpp b/toolkit/components/backgroundhangmonitor/ThreadStackHelper.cpp @@ -202,7 +202,8 @@ void ThreadStackHelper::CollectJitReturnAddr(void* aAddr) { } void ThreadStackHelper::CollectWasmOrSyncJITFrame( - JS::ProfilingCategoryPair aCategory, const char* aLabel) { + JS::ProfilingCategoryPair aCategory, const char* aLabel, + uint32_t aSourceId) { MOZ_RELEASE_ASSERT(mStackToFill); // BHR performs asynchronous sampling as the stack collection happens on the // "BHMgr Monitor" thread. That's why, this method only receives WASM frames, diff --git a/toolkit/components/backgroundhangmonitor/ThreadStackHelper.h b/toolkit/components/backgroundhangmonitor/ThreadStackHelper.h @@ -93,7 +93,8 @@ class ThreadStackHelper : public ProfilerStackCollector { virtual void CollectNativeLeafAddr(void* aAddr) override; virtual void CollectJitReturnAddr(void* aAddr) override; virtual void CollectWasmOrSyncJITFrame(JS::ProfilingCategoryPair aCategory, - const char* aLabel) override; + const char* aLabel, + uint32_t aSourceId) override; virtual void CollectProfilingStackFrame( const js::ProfilingStackFrame& aEntry) override; diff --git a/tools/profiler/core/ProfileBuffer.cpp b/tools/profiler/core/ProfileBuffer.cpp @@ -197,8 +197,9 @@ void ProfileBufferCollector::CollectJitReturnAddr(void* aAddr) { } void ProfileBufferCollector::CollectWasmOrSyncJITFrame( - JS::ProfilingCategoryPair aCategory, const char* aLabel) { - mBuf.CollectCodeLocation("", aLabel, 0, 0, 0, Nothing(), Nothing(), + JS::ProfilingCategoryPair aCategory, const char* aLabel, + uint32_t aSourceId) { + mBuf.CollectCodeLocation("", aLabel, 0, 0, aSourceId, Nothing(), Nothing(), Some(aCategory)); } diff --git a/tools/profiler/core/ProfileBuffer.h b/tools/profiler/core/ProfileBuffer.h @@ -268,7 +268,8 @@ class ProfileBufferCollector final : public ProfilerStackCollector { virtual void CollectNativeLeafAddr(void* aAddr) override; virtual void CollectJitReturnAddr(void* aAddr) override; virtual void CollectWasmOrSyncJITFrame(JS::ProfilingCategoryPair aCategory, - const char* aLabel) override; + const char* aLabel, + uint32_t aSourceId) override; virtual void CollectProfilingStackFrame( const js::ProfilingStackFrame& aFrame) override; diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp @@ -2476,7 +2476,7 @@ static void MergeStacks( jsFrame.kind == JS::ProfilingFrameIterator::Frame_WasmBaseline || jsFrame.kind == JS::ProfilingFrameIterator::Frame_WasmOther) { aCollector.CollectWasmOrSyncJITFrame(jsFrame.profilingCategory(), - jsFrame.label); + jsFrame.label, jsFrame.sourceId); } else if (jsFrame.kind == JS::ProfilingFrameIterator::Frame_BaselineInterpreter) { // Materialize a ProfilingStackFrame similar to the C++ Interpreter. We diff --git a/tools/profiler/public/GeckoProfiler.h b/tools/profiler/public/GeckoProfiler.h @@ -262,7 +262,8 @@ class ProfilerStackCollector { virtual void CollectJitReturnAddr(void* aAddr) = 0; virtual void CollectWasmOrSyncJITFrame(JS::ProfilingCategoryPair aCategory, - const char* aLabel) = 0; + const char* aLabel, + uint32_t aSourceId) = 0; virtual void CollectProfilingStackFrame( const js::ProfilingStackFrame& aFrame) = 0; diff --git a/tools/profiler/tests/gtest/GeckoProfiler.cpp b/tools/profiler/tests/gtest/GeckoProfiler.cpp @@ -4095,7 +4095,8 @@ class GTestStackCollector final : public ProfilerStackCollector { virtual void CollectNativeLeafAddr(void* aAddr) { mFrames++; } virtual void CollectJitReturnAddr(void* aAddr) { mFrames++; } virtual void CollectWasmOrSyncJITFrame(JS::ProfilingCategoryPair aCategory, - const char* aLabel) { + const char* aLabel, + uint32_t aSourceId) { mFrames++; } virtual void CollectProfilingStackFrame(