tor-browser

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

commit 11f2a88ae4ad882f5bfd93d4723eaa9e710a5944
parent 12327d5a5c7c9a6e4b803ce39d3b04bd9a91bf6a
Author: Nazım Can Altınova <canaltinova@gmail.com>
Date:   Wed,  3 Dec 2025 19:24:24 +0000

Bug 2002982 - Add a shell function to query profiler script source count r=iain

This patch adds getGeckoProfilingScriptSourcesCount() to the JS shell,
which returns the number of script sources currently registered with the
Gecko Profiler. This will be used inside a jit-test on the following
commit to verify that script sources are properly registered across
consecutive profiler runs.

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

Diffstat:
Mjs/src/shell/js.cpp | 12++++++++++++
Mjs/src/vm/GeckoProfiler.h | 2++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp @@ -8085,6 +8085,14 @@ static bool DisableGeckoProfiling(JSContext* cx, unsigned argc, Value* vp) { return true; } +static bool GetGeckoProfilingScriptSourcesCount(JSContext* cx, unsigned argc, + Value* vp) { + CallArgs args = CallArgsFromVp(argc, vp); + size_t count = cx->runtime()->geckoProfiler().scriptSourcesCount(); + args.rval().setNumber(static_cast<double>(count)); + return true; +} + // Global mailbox that is used to communicate a shareable object value from one // worker to another. // @@ -10575,6 +10583,10 @@ JS_FN_HELP("createUserArrayBuffer", CreateUserArrayBuffer, 1, 0, "disableGeckoProfiling()", " Disables Gecko Profiler instrumentation"), + JS_FN_HELP("getGeckoProfilingScriptSourcesCount", GetGeckoProfilingScriptSourcesCount, 0, 0, +"getGeckoProfilingScriptSourcesCount()", +" Returns the number of script sources registered with the Gecko Profiler"), + JS_FN_HELP("isLatin1", IsLatin1, 1, 0, "isLatin1(s)", " Return true iff the string's characters are stored as Latin1."), diff --git a/js/src/vm/GeckoProfiler.h b/js/src/vm/GeckoProfiler.h @@ -199,6 +199,8 @@ class GeckoProfilerRuntime { js::ProfilerJSSources getProfilerScriptSources(); + size_t scriptSourcesCount() { return scriptSources_.readLock()->count(); } + const uint32_t* addressOfEnabled() const { return &enabled_; } void fixupStringsMapAfterMovingGC();