mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-27 01:27:30 +09:00
No issue - add API to tell Profile Timeline Recording state to JS engine
Based-on: m-c 1342070/5
This commit is contained in:
parent
1230808583
commit
531906eb87
3 changed files with 37 additions and 0 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
#include "TimelineConsumers.h"
|
#include "TimelineConsumers.h"
|
||||||
|
|
||||||
#include "mozilla/ClearOnShutdown.h"
|
#include "mozilla/ClearOnShutdown.h"
|
||||||
|
#include "jsapi.h"
|
||||||
#include "nsAppRunner.h" // for XRE_IsContentProcess, XRE_IsParentProcess
|
#include "nsAppRunner.h" // for XRE_IsContentProcess, XRE_IsParentProcess
|
||||||
#include "nsDocShell.h"
|
#include "nsDocShell.h"
|
||||||
|
|
||||||
|
|
@ -125,6 +126,9 @@ TimelineConsumers::AddConsumer(nsDocShell* aDocShell)
|
||||||
UniquePtr<ObservedDocShell>& observed = aDocShell->mObserved;
|
UniquePtr<ObservedDocShell>& observed = aDocShell->mObserved;
|
||||||
MOZ_ASSERT(!observed);
|
MOZ_ASSERT(!observed);
|
||||||
|
|
||||||
|
if (mActiveConsumers == 0) {
|
||||||
|
JS::SetProfileTimelineRecordingEnabled(true);
|
||||||
|
}
|
||||||
mActiveConsumers++;
|
mActiveConsumers++;
|
||||||
|
|
||||||
ObservedDocShell* obsDocShell = new ObservedDocShell(aDocShell);
|
ObservedDocShell* obsDocShell = new ObservedDocShell(aDocShell);
|
||||||
|
|
@ -144,6 +148,9 @@ TimelineConsumers::RemoveConsumer(nsDocShell* aDocShell)
|
||||||
MOZ_ASSERT(observed);
|
MOZ_ASSERT(observed);
|
||||||
|
|
||||||
mActiveConsumers--;
|
mActiveConsumers--;
|
||||||
|
if (mActiveConsumers == 0) {
|
||||||
|
JS::SetProfileTimelineRecordingEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
// Clear all markers from the `mTimelineMarkers` store.
|
// Clear all markers from the `mTimelineMarkers` store.
|
||||||
observed.get()->ClearMarkers();
|
observed.get()->ClearMarkers();
|
||||||
|
|
|
||||||
|
|
@ -1276,6 +1276,20 @@ JS::detail::ComputeThis(JSContext* cx, Value* vp)
|
||||||
return thisv;
|
return thisv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool gProfileTimelineRecordingEnabled = false;
|
||||||
|
|
||||||
|
JS_PUBLIC_API(void)
|
||||||
|
JS::SetProfileTimelineRecordingEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
gProfileTimelineRecordingEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
JS_PUBLIC_API(bool)
|
||||||
|
JS::IsProfileTimelineRecordingEnabled()
|
||||||
|
{
|
||||||
|
return gProfileTimelineRecordingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(void*)
|
JS_PUBLIC_API(void*)
|
||||||
JS_malloc(JSContext* cx, size_t nbytes)
|
JS_malloc(JSContext* cx, size_t nbytes)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1545,6 +1545,22 @@ JS_DefineProfilingFunctions(JSContext* cx, JS::HandleObject obj);
|
||||||
extern JS_PUBLIC_API(bool)
|
extern JS_PUBLIC_API(bool)
|
||||||
JS_DefineDebuggerObject(JSContext* cx, JS::HandleObject obj);
|
JS_DefineDebuggerObject(JSContext* cx, JS::HandleObject obj);
|
||||||
|
|
||||||
|
namespace JS {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell JS engine whether Profile Timeline Recording is enabled or not.
|
||||||
|
* If Profile Timeline Recording is enabled, data shown there like stack won't
|
||||||
|
* be optimized out.
|
||||||
|
* This is global state and not associated with specific runtime or context.
|
||||||
|
*/
|
||||||
|
extern JS_PUBLIC_API(void)
|
||||||
|
SetProfileTimelineRecordingEnabled(bool enabled);
|
||||||
|
|
||||||
|
extern JS_PUBLIC_API(bool)
|
||||||
|
IsProfileTimelineRecordingEnabled();
|
||||||
|
|
||||||
|
} // namespace JS
|
||||||
|
|
||||||
#ifdef JS_HAS_CTYPES
|
#ifdef JS_HAS_CTYPES
|
||||||
/**
|
/**
|
||||||
* Initialize the 'ctypes' object on a global variable 'obj'. The 'ctypes'
|
* Initialize the 'ctypes' object on a global variable 'obj'. The 'ctypes'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue