From 827432ffaa40d16a8f6fa33a289a8fd2b6386cff Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Tue, 15 Oct 2024 11:29:49 +0000 Subject: [PATCH] Backed out 9 changesets (bug 1911021) for causing failures at ExecutionTracer.cpp. CLOSED TREE Backed out changeset 3df922f26c68 (bug 1911021) Backed out changeset 5ae948b4c4cb (bug 1911021) Backed out changeset b3b69ca7a7e2 (bug 1911021) Backed out changeset addef9853a2b (bug 1911021) Backed out changeset aed1adb7245b (bug 1911021) Backed out changeset 285922033e2b (bug 1911021) Backed out changeset 217454e2cedc (bug 1911021) Backed out changeset c7365fc6d4ab (bug 1911021) Backed out changeset 6d1accf8bf38 (bug 1911021) UltraBlame original commit: f8229eb11c8571108c176fdc2308a6566b1912e0 --- .../client/performance-new/shared/utils.js | 73 +- devtools/server/actors/tracer.js | 7 + devtools/server/tracer/tracer.sys.mjs | 182 ++ dom/debugger/CallbackDebuggerNotification.h | 40 +- .../EventCallbackDebuggerNotification.cpp | 14 - .../EventCallbackDebuggerNotification.h | 9 + dom/events/EventListenerManager.cpp | 5 - dom/workers/RuntimeService.cpp | 6 +- js/moz.configure | 93 - js/public/Debug.h | 209 -- js/public/friend/ErrorNumbers.msg | 18 + js/src/debugger/Debugger.cpp | 548 ++++- js/src/debugger/Debugger.h | 3 + js/src/debugger/ExecutionTracer.cpp | 1894 +++++++++-------- js/src/debugger/ExecutionTracer.h | 908 +++----- js/src/debugger/moz.build | 23 +- js/src/doc/Debugger/Debugger.md | 585 +++++ .../ExecutionTracer-collectNativeTrace.js | 379 ++++ .../debug/ExecutionTracer-discard-trace.js | 272 +++ .../tests/debug/ExecutionTracer-oomTest.js | 77 + .../debug/ExecutionTracer-properties-exist.js | 152 ++ .../tests/debug/ExecutionTracer-utf8.js | 91 + js/src/vm/Caches.h | 15 - js/src/vm/JSContext.cpp | 137 +- js/src/vm/JSContext.h | 113 +- js/src/vm/MutexIDs.h | 12 - js/src/vm/Realm.cpp | 49 +- js/src/vm/Realm.h | 59 - js/xpconnect/src/XPCJSContext.cpp | 2 +- .../extensions/schemas/geckoProfiler.json | 3 - tools/profiler/core/ProfileBuffer.h | 22 - tools/profiler/core/ProfileBufferEntry.cpp | 1429 ++----------- .../core/ProfilerThreadRegistrationData.cpp | 97 +- tools/profiler/core/platform.cpp | 215 +- tools/profiler/public/GeckoProfiler.h | 12 +- tools/profiler/public/ProfilerState.h | 38 +- .../public/ProfilerThreadRegistrationData.h | 33 +- tools/profiler/tests/browser/browser.toml | 40 - .../browser/browser_test_feature_jstracing.js | 1072 ---------- tools/profiler/tests/browser/tracing.html | 158 -- tools/profiler/tests/gtest/GeckoProfiler.cpp | 15 +- xpcom/base/CycleCollectedJSContext.cpp | 137 -- xpcom/base/CycleCollectedJSContext.h | 10 - 43 files changed, 4000 insertions(+), 5256 deletions(-) create mode 100644 js/src/jit-test/tests/debug/ExecutionTracer-collectNativeTrace.js create mode 100644 js/src/jit-test/tests/debug/ExecutionTracer-discard-trace.js create mode 100644 js/src/jit-test/tests/debug/ExecutionTracer-oomTest.js create mode 100644 js/src/jit-test/tests/debug/ExecutionTracer-properties-exist.js create mode 100644 js/src/jit-test/tests/debug/ExecutionTracer-utf8.js delete mode 100644 tools/profiler/tests/browser/browser_test_feature_jstracing.js delete mode 100644 tools/profiler/tests/browser/tracing.html diff --git a/devtools/client/performance-new/shared/utils.js b/devtools/client/performance-new/shared/utils.js index b7692cd63a71b..2675c5103020a 100644 --- a/devtools/client/performance-new/shared/utils.js +++ b/devtools/client/performance-new/shared/utils.js @@ -1788,6 +1788,45 @@ windows name : " +JSTracer +" +value +: +" +jstracer +" +title +: +" +Trace +JS +engine +" +experimental +: +true +disabledReason +: +" +JS +Tracer +is +currently +disabled +due +to +crashes +. +See +Bug +1565788 +. +" +} +{ +name +: +" IPC Messages " @@ -2369,40 +2408,6 @@ sample . " } -{ -name -: -" -JS -Execution -Tracing -" -value -: -" -tracing -" -title -: -" -Disable -periodic -stack -sampling -and -capture -information -about -every -JS -function -executed -. -" -experimental -: -true -} ] ; module diff --git a/devtools/server/actors/tracer.js b/devtools/server/actors/tracer.js index 583f19389acbc..69e5e9ccfc332 100644 --- a/devtools/server/actors/tracer.js +++ b/devtools/server/actors/tracer.js @@ -770,6 +770,13 @@ tracingListener . stop ( +lazy +. +JSTracer +. +maybeGetNativeTrace +( +) ) ; this diff --git a/devtools/server/tracer/tracer.sys.mjs b/devtools/server/tracer/tracer.sys.mjs index aa30e26e2cac3..a9fbeb1d61b61 100644 --- a/devtools/server/tracer/tracer.sys.mjs +++ b/devtools/server/tracer/tracer.sys.mjs @@ -1182,6 +1182,24 @@ throws * param { +Boolean +} +options +. +useNativeTracing +* +Optional +setting +to +enable +the +native +tracing +implementation +. +* +param +{ String } options @@ -1817,6 +1835,16 @@ traceFunctionReturn ; this . +useNativeTracing += +! +! +options +. +useNativeTracing +; +this +. maxDepth = options @@ -2388,6 +2416,24 @@ isTracing = true ; +if +( +this +. +useNativeTracing +) +{ +this +. +dbg +. +nativeTracing += +true +; +} +else +{ this . dbg @@ -2398,6 +2444,7 @@ this . onEnterFrame ; +} if ( this @@ -2669,6 +2716,16 @@ g ; this . +dbg +. +nativeTracing += +this +. +useNativeTracing +; +this +. debuggerNotificationObserver . connect @@ -3704,6 +3761,49 @@ null * * * +If +native +tracing +is +enabled +get +the +trace +from +the +native +tracer +* +/ +maybeGetNativeTrace +( +) +{ +if +( +this +. +useNativeTracing +) +{ +return +this +. +dbg +. +collectNativeTrace +( +) +; +} +return +null +; +} +/ +* +* +* Stop observing execution @@ -3768,6 +3868,25 @@ dbg return ; } +if +( +! +this +. +useNativeTracing +) +{ +this +. +dbg +. +nativeTracing += +false +; +} +else +{ this . dbg @@ -3776,6 +3895,7 @@ onEnterFrame = undefined ; +} this . dbg @@ -6974,6 +7094,67 @@ tracing * * * +If +native +tracing +is +enabled +get +the +trace +from +the +native +tracer +* +/ +function +maybeGetNativeTrace +( +) +{ +if +( +activeTracer +) +{ +return +activeTracer +. +maybeGetNativeTrace +( +) +; +} +console +. +warn +( +" +Can +' +t +get +a +native +trace +as +we +were +not +tracing +. +" +) +; +return +null +; +} +/ +* +* +* Listen for tracing @@ -7629,6 +7810,7 @@ JSTracer { startTracing stopTracing +maybeGetNativeTrace addTracingListener removeTracingListener NEXT_INTERACTION_MESSAGE diff --git a/dom/debugger/CallbackDebuggerNotification.h b/dom/debugger/CallbackDebuggerNotification.h index a34d01787e756..8000bc58ba3bc 100644 --- a/dom/debugger/CallbackDebuggerNotification.h +++ b/dom/debugger/CallbackDebuggerNotification.h @@ -234,16 +234,22 @@ CallbackDebuggerNotificationPhase aPhase ) { -# -ifdef -MOZ_EXECUTION_TRACING +auto +manager += +DebuggerNotificationManager +: +: +ForDispatch +( +mDebuggeeGlobal +) +; if ( MOZ_UNLIKELY ( -profiler_is_active -( -) +manager ) ) { @@ -456,28 +462,6 @@ typeStr ; } } -} -# -endif -auto -manager -= -DebuggerNotificationManager -: -: -ForDispatch -( -mDebuggeeGlobal -) -; -if -( -MOZ_UNLIKELY -( -manager -) -) -{ manager - > diff --git a/dom/debugger/EventCallbackDebuggerNotification.cpp b/dom/debugger/EventCallbackDebuggerNotification.cpp index 2b97b293ebf2d..1c5d32787c4cc 100644 --- a/dom/debugger/EventCallbackDebuggerNotification.cpp +++ b/dom/debugger/EventCallbackDebuggerNotification.cpp @@ -234,9 +234,6 @@ if notificationType ) { -# -ifdef -MOZ_EXECUTION_TRACING CycleCollectedJSContext * ccjcx @@ -310,16 +307,6 @@ get ; } } -# -endif -if -( -MOZ_UNLIKELY -( -aManager -) -) -{ aManager - > @@ -344,4 +331,3 @@ aPhase } } } -} diff --git a/dom/debugger/EventCallbackDebuggerNotification.h b/dom/debugger/EventCallbackDebuggerNotification.h index 03b89c29532e2..8a1058548b78b 100644 --- a/dom/debugger/EventCallbackDebuggerNotification.h +++ b/dom/debugger/EventCallbackDebuggerNotification.h @@ -322,6 +322,14 @@ ForDispatch mDebuggeeGlobal ) ; +if +( +MOZ_UNLIKELY +( +manager +) +) +{ DispatchToManager ( manager @@ -329,6 +337,7 @@ aPhase ) ; } +} MOZ_CAN_RUN_SCRIPT void DispatchToManager diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp index 0009c69f2f2b0..8a811c6bfcbc2 100644 --- a/dom/events/EventListenerManager.cpp +++ b/dom/events/EventListenerManager.cpp @@ -6858,11 +6858,6 @@ ChromeUtils IsDevToolsOpened ( ) -| -| -profiler_is_active -( -) ) { dbgGuard diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 151d95067a15c..650b5be7e7348 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -10202,11 +10202,7 @@ true { PROFILER_SET_JS_CONTEXT ( -context -. -get -( -) +cx ) ; { diff --git a/js/moz.configure b/js/moz.configure index 5df78ff60f420..61b38db902376 100644 --- a/js/moz.configure +++ b/js/moz.configure @@ -2172,99 +2172,6 @@ enable profiling " ) -depends -( -milestone -) -def -enable_execution_tracing -( -milestone -) -: -return -milestone -. -is_nightly -option -( -" -- -- -enable -- -execution -- -tracing -" -env -= -" -MOZ_EXECUTION_TRACING -" -default -= -enable_execution_tracing -help -= -" -{ -Set -| -Do -not -set -} -compile -flags -necessary -for -running -the -JS -" -" -execution -tracer -" -) -depends -( -" -- -- -enable -- -execution -- -tracing -" -) -def -execution_tracing -( -value -) -: -if -value -: -return -True -set_config -( -" -MOZ_EXECUTION_TRACING -" -execution_tracing -) -set_define -( -" -MOZ_EXECUTION_TRACING -" -execution_tracing -) option ( " diff --git a/js/public/Debug.h b/js/public/Debug.h index 583de1a9b3d93..2a082162aa4cc 100644 --- a/js/public/Debug.h +++ b/js/public/Debug.h @@ -27,30 +27,12 @@ include " mozilla / -BaseProfilerUtils -. -h -" -# -include -" -mozilla -/ MemoryReporting . h " # include -" -mozilla -/ -Vector -. -h -" -# -include < utility > @@ -166,197 +148,6 @@ char16_t label ) ; -# -ifdef -MOZ_EXECUTION_TRACING -extern -JS_PUBLIC_API -bool -JS_TracerBeginTracing -( -JSContext -* -cx -) -; -extern -JS_PUBLIC_API -bool -JS_TracerEndTracing -( -JSContext -* -cx -) -; -namespace -JS -{ -struct -ExecutionTrace -{ -enum -class -EventKind -: -uint8_t -{ -FunctionEnter -= -0 -FunctionLeave -= -1 -LabelEnter -= -2 -LabelLeave -= -3 -} -; -enum -class -ImplementationType -: -uint8_t -{ -Interpreter -= -0 -Baseline -= -1 -Ion -= -2 -Wasm -= -3 -} -; -struct -TracedEvent -{ -EventKind -kind -; -union -{ -struct -{ -ImplementationType -implementation -; -uint32_t -lineNumber -; -uint32_t -column -; -uint32_t -scriptId -; -uint32_t -functionNameId -; -} -functionEvent -; -struct -{ -size_t -label -; -} -labelEvent -; -} -; -double -time -; -} -; -struct -TracedJSContext -{ -mozilla -: -: -baseprofiler -: -: -BaseProfilerThreadId -id -; -mozilla -: -: -HashMap -< -uint32_t -size_t -> -scriptUrls -; -mozilla -: -: -HashMap -< -uint32_t -size_t -> -atoms -; -mozilla -: -: -Vector -< -TracedEvent -> -events -; -} -; -mozilla -: -: -Vector -< -char -> -stringBuffer -; -mozilla -: -: -Vector -< -TracedJSContext -> -contexts -; -} -; -} -extern -JS_PUBLIC_API -bool -JS_TracerSnapshotTrace -( -JS -: -: -ExecutionTrace -& -trace -) -; -# -endif namespace JS { diff --git a/js/public/friend/ErrorNumbers.msg b/js/public/friend/ErrorNumbers.msg index ba6f858119481..6ef372c0fa233 100644 --- a/js/public/friend/ErrorNumbers.msg +++ b/js/public/friend/ErrorNumbers.msg @@ -8960,6 +8960,24 @@ buffer ) MSG_DEF ( +JSMSG_NATIVE_TRACING_MUST_BE_ENABLED +0 +JSEXN_ERR +" +Cannot +collect +a +native +trace +without +setting +nativeTracing +to +true +" +) +MSG_DEF +( JSMSG_TESTING_SCRIPTS_ONLY 0 JSEXN_TYPEERR diff --git a/js/src/debugger/Debugger.cpp b/js/src/debugger/Debugger.cpp index ac1471e83143a..b9de9cbb68603 100644 --- a/js/src/debugger/Debugger.cpp +++ b/js/src/debugger/Debugger.cpp @@ -218,9 +218,6 @@ Environment h " # -ifdef -MOZ_EXECUTION_TRACING -# include " debugger @@ -230,8 +227,6 @@ ExecutionTracer h " # -endif -# include " debugger @@ -3229,6 +3224,10 @@ shouldAvoidSideEffects ( false ) +nativeTracing +( +false +) observedGCs ( cx @@ -5186,9 +5185,6 @@ AbstractFramePtr frame ) { -# -ifdef -MOZ_EXECUTION_TRACING if ( cx @@ -5221,8 +5217,6 @@ false ; } } -# -endif return Debugger : @@ -5306,9 +5300,6 @@ AbstractFramePtr frame ) { -# -ifdef -MOZ_EXECUTION_TRACING if ( cx @@ -5341,8 +5332,6 @@ false ; } } -# -endif MOZ_ASSERT ( frame @@ -6254,9 +6243,6 @@ bool frameOk ) { -# -ifdef -MOZ_EXECUTION_TRACING if ( cx @@ -6289,8 +6275,6 @@ false ; } } -# -endif MOZ_ASSERT_IF ( ! @@ -18576,6 +18560,15 @@ const { if ( +nativeTracing +) +{ +return +Observing +; +} +if +( ! ! getHook @@ -22193,6 +22186,16 @@ dbg { } bool +getNativeTracing +( +) +; +bool +setNativeTracing +( +) +; +bool getOnDebuggerStatement ( ) @@ -22452,6 +22455,11 @@ disableUnlimitedStacksCapturing ( ) ; +bool +collectNativeTrace +( +) +; using Method = @@ -23102,6 +23110,307 @@ Debugger CallData : : +getNativeTracing +( +) +{ +args +. +rval +( +) +. +set +( +BooleanValue +( +dbg +- +> +nativeTracing +) +) +; +return +true +; +} +bool +Debugger +: +: +CallData +: +: +collectNativeTrace +( +) +{ +if +( +! +dbg +- +> +nativeTracing +) +{ +JS_ReportErrorNumberASCII +( +cx +GetErrorMessage +nullptr +JSMSG_NATIVE_TRACING_MUST_BE_ENABLED +) +; +return +false +; +} +RootedObject +result +( +cx +NewPlainObject +( +cx +) +) +; +if +( +! +result +) +{ +return +false +; +} +if +( +cx +- +> +hasExecutionTracer +( +) +) +{ +if +( +! +cx +- +> +getExecutionTracer +( +) +. +getTrace +( +cx +result +) +) +{ +return +false +; +} +} +dbg +- +> +nativeTracing += +false +; +cx +- +> +removeExecutionTracingConsumer +( +dbg +) +; +if +( +! +dbg +- +> +updateObservesAllExecutionOnDebuggees +( +cx +dbg +- +> +observesAllExecution +( +) +) +) +{ +return +false +; +} +args +. +rval +( +) +. +setObject +( +* +result +) +; +return +true +; +} +bool +Debugger +: +: +CallData +: +: +setNativeTracing +( +) +{ +if +( +! +args +. +requireAtLeast +( +cx +" +Debugger +. +nativeTracing +" +1 +) +) +{ +return +false +; +} +bool +wasEnabled += +dbg +- +> +nativeTracing +; +dbg +- +> +nativeTracing += +ToBoolean +( +args +[ +0 +] +) +; +if +( +wasEnabled +! += +dbg +- +> +nativeTracing +) +{ +if +( +dbg +- +> +nativeTracing +) +{ +if +( +! +cx +- +> +addExecutionTracingConsumer +( +dbg +) +) +{ +ReportOutOfMemory +( +cx +) +; +return +false +; +} +} +else +{ +cx +- +> +removeExecutionTracingConsumer +( +dbg +) +; +} +} +if +( +! +dbg +- +> +updateObservesAllExecutionOnDebuggees +( +cx +dbg +- +> +observesAllExecution +( +) +) +) +{ +return +false +; +} +return +true +; +} +bool +Debugger +: +: +CallData +: +: getOnDebuggerStatement ( ) @@ -27503,20 +27812,6 @@ realm hasDebuggers ( ) -& -& -! -global -- -> -realm -( -) -- -> -isTracingExecution -( -) ) { global @@ -35491,6 +35786,14 @@ properties JS_DEBUG_PSGS ( " +nativeTracing +" +getNativeTracing +setNativeTracing +) +JS_DEBUG_PSGS +( +" onDebuggerStatement " getOnDebuggerStatement @@ -35804,10 +36107,182 @@ disableUnlimitedStacksCapturing disableUnlimitedStacksCapturing 1 ) +JS_DEBUG_FN +( +" +collectNativeTrace +" +collectNativeTrace +0 +) JS_FS_END } ; const +JSPropertySpec +Debugger +: +: +static_properties +[ +] +{ +JS_INT32_PS +( +" +TRACING_EVENT_KIND_FUNCTION_ENTER +" +int32_t +( +ExecutionTracer +: +: +EventKind +: +: +FunctionEnter +) +JSPROP_READONLY +| +JSPROP_PERMANENT +) +JS_INT32_PS +( +" +TRACING_EVENT_KIND_FUNCTION_LEAVE +" +int32_t +( +ExecutionTracer +: +: +EventKind +: +: +FunctionLeave +) +JSPROP_READONLY +| +JSPROP_PERMANENT +) +JS_INT32_PS +( +" +TRACING_EVENT_KIND_LABEL_ENTER +" +int32_t +( +ExecutionTracer +: +: +EventKind +: +: +LabelEnter +) +JSPROP_READONLY +| +JSPROP_PERMANENT +) +JS_INT32_PS +( +" +TRACING_EVENT_KIND_LABEL_LEAVE +" +int32_t +( +ExecutionTracer +: +: +EventKind +: +: +LabelLeave +) +JSPROP_READONLY +| +JSPROP_PERMANENT +) +JS_INT32_PS +( +" +IMPLEMENTATION_INTERPRETER +" +int32_t +( +ExecutionTracer +: +: +ImplementationType +: +: +Interpreter +) +JSPROP_READONLY +| +JSPROP_PERMANENT +) +JS_INT32_PS +( +" +IMPLEMENTATION_BASELINE +" +int32_t +( +ExecutionTracer +: +: +ImplementationType +: +: +Baseline +) +JSPROP_READONLY +| +JSPROP_PERMANENT +) +JS_INT32_PS +( +" +IMPLEMENTATION_ION +" +int32_t +( +ExecutionTracer +: +: +ImplementationType +: +: +Ion +) +JSPROP_READONLY +| +JSPROP_PERMANENT +) +JS_INT32_PS +( +" +IMPLEMENTATION_WASM +" +int32_t +( +ExecutionTracer +: +: +ImplementationType +: +: +Wasm +) +JSPROP_READONLY +| +JSPROP_PERMANENT +) +JS_PS_END +} +; +const JSFunctionSpec Debugger : @@ -38108,7 +38583,10 @@ Debugger : : methods -nullptr +Debugger +: +: +static_properties Debugger : : diff --git a/js/src/debugger/Debugger.h b/js/src/debugger/Debugger.h index f1ff9d98cd538..fd8c5d2ef9546 100644 --- a/js/src/debugger/Debugger.h +++ b/js/src/debugger/Debugger.h @@ -2527,6 +2527,9 @@ collectCoverageInfo bool shouldAvoidSideEffects ; +bool +nativeTracing +; template < typename diff --git a/js/src/debugger/ExecutionTracer.cpp b/js/src/debugger/ExecutionTracer.cpp index 26ada31515fe5..5c183423118a7 100644 --- a/js/src/debugger/ExecutionTracer.cpp +++ b/js/src/debugger/ExecutionTracer.cpp @@ -82,36 +82,8 @@ LabelEnter LabelLeave } ; -mozilla -: -: -Vector -< -ExecutionTracer -* -> -ExecutionTracer -: -: -globalInstances -; -Mutex -ExecutionTracer -: -: -globalInstanceLock -( -mutexid -: -: -ExecutionTracerGlobalLock -) -; static -JS -: -: -ExecutionTrace +ExecutionTracer : : ImplementationType @@ -131,10 +103,7 @@ isBaselineFrame ) { return -JS -: -: -ExecutionTrace +ExecutionTracer : : ImplementationType @@ -153,10 +122,7 @@ isRematerializedFrame ) { return -JS -: -: -ExecutionTrace +ExecutionTracer : : ImplementationType @@ -175,10 +141,7 @@ isWasmDebugFrame ) { return -JS -: -: -ExecutionTrace +ExecutionTracer : : ImplementationType @@ -188,10 +151,7 @@ Wasm ; } return -JS -: -: -ExecutionTrace +ExecutionTracer : : ImplementationType @@ -365,40 +325,6 @@ return true ; } -static -double -GetNowMilliseconds -( -) -{ -return -( -mozilla -: -: -TimeStamp -: -: -Now -( -) -- -mozilla -: -: -TimeStamp -: -: -ProcessCreation -( -) -) -. -ToMilliseconds -( -) -; -} void ExecutionTracer : @@ -952,7 +878,7 @@ inlineData_ . write ( -GetNowMilliseconds +PRMJ_Now ( ) ) @@ -974,15 +900,6 @@ AbstractFramePtr frame ) { -LockGuard -< -Mutex -> -guard -( -bufferLock_ -) -; DebuggerFrameType type = @@ -1009,19 +926,6 @@ frame isFunctionFrame ( ) -& -& -! -frame -. -callee -( -) -- -> -isSelfHostedBuiltin -( -) ) { inlineData_ @@ -1082,15 +986,6 @@ AbstractFramePtr frame ) { -LockGuard -< -Mutex -> -guard -( -bufferLock_ -) -; DebuggerFrameType type = @@ -1117,19 +1012,6 @@ frame isFunctionFrame ( ) -& -& -! -frame -. -callee -( -) -- -> -isSelfHostedBuiltin -( -) ) { inlineData_ @@ -1196,15 +1078,6 @@ CharType eventType ) { -LockGuard -< -Mutex -> -guard -( -bufferLock_ -) -; inlineData_ . beginWritingEntry @@ -1239,7 +1112,7 @@ inlineData_ . write ( -GetNowMilliseconds +PRMJ_Now ( ) ) @@ -1270,15 +1143,6 @@ CharType eventType ) { -LockGuard -< -Mutex -> -guard -( -bufferLock_ -) -; inlineData_ . beginWritingEntry @@ -1313,7 +1177,7 @@ inlineData_ . write ( -GetNowMilliseconds +PRMJ_Now ( ) ) @@ -1325,29 +1189,47 @@ finishWritingEntry ) ; } +static +bool +ThrowTracingReadFailed +( +JSContext +* +cx +) +{ +JS_ReportErrorNumberASCII +( +cx +GetErrorMessage +nullptr +JSMSG_NATIVE_TRACING_BUFFER_MALFORMED +) +; +return +false +; +} bool ExecutionTracer : : readFunctionFrame ( +JSContext +* +cx JS : : -ExecutionTrace -: -: +Handle +< +JSObject +* +> +result EventKind kind -JS -: -: -ExecutionTrace -: -: -TracedEvent -& -event ) { MOZ_ASSERT @@ -1355,12 +1237,6 @@ MOZ_ASSERT kind = = -JS -: -: -ExecutionTrace -: -: EventKind : : @@ -1370,37 +1246,36 @@ FunctionEnter kind = = -JS -: -: -ExecutionTrace -: -: EventKind : : FunctionLeave ) ; -event -. -kind -= -kind +uint32_t +lineno +; +uint32_t +column +; +uint32_t +url +; +uint32_t +functionName ; uint8_t implementation ; +uint64_t +time +; inlineData_ . read ( & -event -. -functionEvent -. -lineNumber +lineno ) ; inlineData_ @@ -1408,10 +1283,6 @@ inlineData_ read ( & -event -. -functionEvent -. column ) ; @@ -1420,11 +1291,7 @@ inlineData_ read ( & -event -. -functionEvent -. -scriptId +url ) ; inlineData_ @@ -1432,11 +1299,7 @@ inlineData_ read ( & -event -. -functionEvent -. -functionNameId +functionName ) ; inlineData_ @@ -1452,121 +1315,645 @@ inlineData_ read ( & -event -. time ) ; -event -. -functionEvent -. -implementation -= -JS -: -: -ExecutionTrace -: -: -ImplementationType +if ( -implementation +! +NewbornArrayPush +( +cx +result +Int32Value +( +int32_t +( +kind ) -; +) +) +) +{ return -true +false ; } -bool -ExecutionTracer -: -: -readLabel +if ( -JS -: -: -ExecutionTrace -: -: -EventKind -kind -JS -: -: -ExecutionTrace -: -: -TracedEvent -& -event -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector -< -char -> -& -stringBuffer +! +NewbornArrayPush +( +cx +result +Int32Value +( +lineno +) +) ) { -MOZ_ASSERT +return +false +; +} +if ( -kind -= -= -JS -: -: -ExecutionTrace -: -: -EventKind -: -: +! +NewbornArrayPush +( +cx +result +Int32Value +( +column +) +) +) +{ +return +false +; +} +if +( +! +NewbornArrayPush +( +cx +result +Int32Value +( +url +) +) +) +{ +return +false +; +} +if +( +! +NewbornArrayPush +( +cx +result +Int32Value +( +functionName +) +) +) +{ +return +false +; +} +if +( +! +NewbornArrayPush +( +cx +result +Int32Value +( +implementation +) +) +) +{ +return +false +; +} +double +timeDouble += +time +/ +double +( +PRMJ_USEC_PER_MSEC +) +; +if +( +! +NewbornArrayPush +( +cx +result +DoubleValue +( +timeDouble +) +) +) +{ +return +false +; +} +return +true +; +} +bool +ExecutionTracer +: +: +readStackFunctionEnter +( +JSContext +* +cx +JS +: +: +Handle +< +JSObject +* +> +events +) +{ +JS +: +: +Rooted +< +JSObject +* +> +obj +( +cx +NewDenseEmptyArray +( +cx +) +) +; +if +( +! +obj +) +{ +return +false +; +} +if +( +! +readFunctionFrame +( +cx +obj +EventKind +: +: +FunctionEnter +) +) +{ +return +false +; +} +JS +: +: +Rooted +< +JS +: +: +Value +> +objVal +( +cx +ObjectValue +( +* +obj +) +) +; +if +( +! +NewbornArrayPush +( +cx +events +objVal +) +) +{ +return +false +; +} +return +true +; +} +bool +ExecutionTracer +: +: +readStackFunctionLeave +( +JSContext +* +cx +JS +: +: +Handle +< +JSObject +* +> +events +) +{ +JS +: +: +Rooted +< +JSObject +* +> +obj +( +cx +NewDenseEmptyArray +( +cx +) +) +; +if +( +! +obj +) +{ +return +false +; +} +if +( +! +readFunctionFrame +( +cx +obj +EventKind +: +: +FunctionLeave +) +) +{ +return +false +; +} +JS +: +: +Rooted +< +JS +: +: +Value +> +objVal +( +cx +ObjectValue +( +* +obj +) +) +; +if +( +! +NewbornArrayPush +( +cx +events +objVal +) +) +{ +return +false +; +} +return +true +; +} +bool +ExecutionTracer +: +: +readScriptURLEntry +( +JSContext +* +cx +JS +: +: +Handle +< +JSObject +* +> +scriptUrls +) +{ +uint32_t +id +; +outOfLineData_ +. +read +( +& +id +) +; +JS +: +: +Rooted +< +JSString +* +> +url +( +cx +) +; +if +( +! +outOfLineData_ +. +readString +( +cx +& +url +) +) +{ +return +false +; +} +JS +: +: +Rooted +< +JS +: +: +Value +> +urlVal +( +cx +StringValue +( +url +) +) +; +if +( +! +DefineDataElement +( +cx +scriptUrls +id +urlVal +JSPROP_ENUMERATE +) +) +{ +return +false +; +} +return +true +; +} +bool +ExecutionTracer +: +: +readAtomEntry +( +JSContext +* +cx +JS +: +: +Handle +< +JSObject +* +> +atoms +) +{ +uint32_t +id +; +outOfLineData_ +. +read +( +& +id +) +; +JS +: +: +Rooted +< +JSString +* +> +url +( +cx +) +; +if +( +! +outOfLineData_ +. +readString +( +cx +& +url +) +) +{ +return +false +; +} +JS +: +: +Rooted +< +JS +: +: +Value +> +atom +( +cx +StringValue +( +url +) +) +; +if +( +! +DefineDataElement +( +cx +atoms +id +atom +JSPROP_ENUMERATE +) +) +{ +return +false +; +} +return +true +; +} +bool +ExecutionTracer +: +: +readLabel +( +JSContext +* +cx +JS +: +: +Handle +< +JSObject +* +> +events +EventKind +kind +) +{ +MOZ_ASSERT +( +kind += += +EventKind +: +: LabelEnter | | kind = = -JS -: -: -ExecutionTrace -: -: EventKind : : LabelLeave ) ; -event -. -kind -= -kind +JS +: +: +Rooted +< +JSObject +* +> +obj +( +cx +NewDenseEmptyArray +( +cx +) +) ; -size_t -index +if +( +! +obj +) +{ +return +false ; +} if ( ! -inlineData_ -. -readString +NewbornArrayPush ( -scratchBuffer -stringBuffer -& -index +cx +obj +Int32Value +( +int32_t +( +kind +) +) ) ) { @@ -1574,192 +1961,121 @@ return false ; } -event -. -labelEvent -. -label -= -index -; -double -time +JS +: +: +Rooted +< +JSString +* +> +eventType +( +cx +) ; +if +( +! inlineData_ . -read +readString ( +cx & -time +eventType ) -; -event -. -time -= -time -; +) +{ return -true +false ; } -bool -ExecutionTracer -: -: -readInlineEntry +if ( -mozilla -: -: -Vector -< -JS -: -: -ExecutionTrace -: -: -TracedEvent -> -& -events -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector -< -char -> -& -stringBuffer +! +NewbornArrayPush +( +cx +obj +StringValue +( +eventType +) +) ) { -uint8_t -entryType +return +false +; +} +uint64_t +time ; inlineData_ . read ( & -entryType +time ) ; -switch -( -InlineEntryType +double +timeDouble += +time +/ +double ( -entryType +PRMJ_USEC_PER_MSEC ) -) -{ -case -InlineEntryType -: -: -StackFunctionEnter -: -case -InlineEntryType -: -: -StackFunctionLeave -: -{ -JS -: -: -ExecutionTrace -: -: -EventKind -kind ; if ( -InlineEntryType +! +NewbornArrayPush ( -entryType +cx +obj +DoubleValue +( +timeDouble +) ) -= -= -InlineEntryType -: -: -StackFunctionEnter ) { -kind -= -JS -: -: -ExecutionTrace -: -: -EventKind -: -: -FunctionEnter +return +false ; } -else -{ -kind -= JS : : -ExecutionTrace -: -: -EventKind -: -: -FunctionLeave -; -} +Rooted +< JS : : -ExecutionTrace -: -: -TracedEvent -event -; -if +Value +> +objVal ( -! -readFunctionFrame +cx +ObjectValue ( -kind -event +* +obj ) ) -{ -return -false ; -} if ( ! -events -. -append -( -std -: -: -move +NewbornArrayPush ( -event -) +cx +events +objVal ) ) { @@ -1771,126 +2087,112 @@ return true ; } -case -InlineEntryType -: -: -LabelEnter -: -case -InlineEntryType -: +bool +ExecutionTracer : -LabelLeave : -{ +readInlineEntry +( +JSContext +* +cx JS : : -ExecutionTrace -: -: -EventKind -kind +Handle +< +JSObject +* +> +events +) +{ +uint8_t +entryType ; -if -( -InlineEntryType +inlineData_ +. +read ( +& entryType ) -= -= +; +switch +( InlineEntryType -: -: -LabelEnter +( +entryType +) ) { -kind -= -JS +case +InlineEntryType : : -ExecutionTrace +StackFunctionEnter : +return +readStackFunctionEnter +( +cx +events +) +; +case +InlineEntryType : -EventKind : +StackFunctionLeave : -LabelEnter +return +readStackFunctionLeave +( +cx +events +) ; -} -else -{ -kind -= -JS -: +case +InlineEntryType : -ExecutionTrace : +LabelEnter : +return +readLabel +( +cx +events EventKind : : -LabelLeave +LabelEnter +) ; -} -JS -: +case +InlineEntryType : -ExecutionTrace : +LabelLeave : -TracedEvent -event -; -if -( -! -readLabel -( -kind -event -scratchBuffer -stringBuffer -) -) -{ return -false -; -} -if +readLabel ( -! +cx events -. -append -( -std +EventKind : : -move -( -event -) -) +LabelLeave ) -{ -return -false -; -} -return -true ; -} default : return -false +ThrowTracingReadFailed +( +cx +) ; } } @@ -1900,38 +2202,27 @@ ExecutionTracer : readOutOfLineEntry ( -mozilla +JSContext +* +cx +JS : : -HashMap +Handle < -uint32_t -size_t +JSObject +* > -& scriptUrls -mozilla +JS : : -HashMap +Handle < -uint32_t -size_t +JSObject +* > -& atoms -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector -< -char -> -& -stringBuffer ) { uint8_t @@ -1959,127 +2250,35 @@ OutOfLineEntryType : ScriptURL : -{ -uint32_t -id -; -outOfLineData_ -. -read -( -& -id -) -; -size_t -index -; -if -( -! -outOfLineData_ -. -readString -( -scratchBuffer -stringBuffer -& -index -) -) -{ return -false -; -} -if +readScriptURLEntry ( -! +cx scriptUrls -. -put -( -id -index -) ) -{ -return -false -; -} -return -true ; -} case OutOfLineEntryType : : Atom : -{ -uint32_t -id -; -outOfLineData_ -. -read -( -& -id -) -; -size_t -index -; -if -( -! -outOfLineData_ -. -readString -( -scratchBuffer -stringBuffer -& -index -) -) -{ return -false -; -} -if +readAtomEntry ( -! +cx atoms -. -put -( -id -index -) ) -{ -return -false -; -} -return -true ; -} default : return -false +ThrowTracingReadFailed +( +cx +) ; } -return -true -; } bool ExecutionTracer @@ -2087,33 +2286,18 @@ ExecutionTracer : readInlineEntries ( -mozilla -: -: -Vector -< +JSContext +* +cx JS : : -ExecutionTrace -: -: -TracedEvent -> -& -events -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector +Handle < -char +JSObject +* > -& -stringBuffer +events ) { while @@ -2136,9 +2320,8 @@ if ! readInlineEntry ( +cx events -scratchBuffer -stringBuffer ) ) { @@ -2169,38 +2352,27 @@ ExecutionTracer : readOutOfLineEntries ( -mozilla +JSContext +* +cx +JS : : -HashMap +Handle < -uint32_t -size_t +JSObject +* > -& scriptUrls -mozilla +JS : : -HashMap +Handle < -uint32_t -size_t +JSObject +* > -& atoms -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector -< -char -> -& -stringBuffer ) { while @@ -2223,10 +2395,9 @@ if ! readOutOfLineEntry ( +cx scriptUrls atoms -scratchBuffer -stringBuffer ) ) { @@ -2255,70 +2426,81 @@ bool ExecutionTracer : : -getNativeTrace +getTrace ( +JSContext +* +cx JS : : -ExecutionTrace -: -: -TracedJSContext -& -context -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector +Handle < -char +JSObject +* > -& -stringBuffer +result ) { -LockGuard +JS +: +: +Rooted < -Mutex +JSObject +* > -guard +scriptUrls ( -bufferLock_ +cx +NewPlainObject +( +cx +) ) ; if ( ! -readOutOfLineEntries -( -context -. scriptUrls -context -. -atoms -scratchBuffer -stringBuffer -) ) { return false ; } +JS +: +: +Rooted +< +JS +: +: +Value +> +scriptUrlsVal +( +cx +ObjectValue +( +* +scriptUrls +) +) +; if ( ! -readInlineEntries +JS_DefineProperty ( -context -. -events -scratchBuffer -stringBuffer +cx +result +" +scriptURLs +" +scriptUrlsVal +JSPROP_ENUMERATE ) ) { @@ -2326,120 +2508,131 @@ return false ; } -return -true -; -} -bool -ExecutionTracer -: -: -getNativeTraceForAllContexts -( JS : : -ExecutionTrace -& -trace -) -{ -LockGuard +Rooted < -Mutex +JSObject +* > -guard +atoms +( +cx +NewPlainObject ( -globalInstanceLock +cx +) ) ; -TracingScratchBuffer -scratchBuffer -; -for +if ( -ExecutionTracer -* -tracer -: -globalInstances +! +atoms ) { +return +false +; +} JS : : -ExecutionTrace +Rooted +< +JS : : -TracedJSContext +Value +> +atomsVal +( +cx +ObjectValue +( * -context -= -nullptr +atoms +) +) ; -for +if +( +! +JS_DefineProperty ( +cx +result +" +atoms +" +atomsVal +JSPROP_ENUMERATE +) +) +{ +return +false +; +} JS : : -ExecutionTrace -: -: -TracedJSContext -& -t -: -trace -. -contexts -) -{ -if -( -t -. -id -= -= -tracer -- +Rooted +< +JSObject +* > -threadId_ +events +( +cx +NewDenseEmptyArray +( +cx +) ) -{ -context -= -& -t -; -break ; -} -} if ( ! -context +events ) { -if -( -! -trace -. -contexts -. -append -( +return +false +; +} JS : : -ExecutionTrace +Rooted +< +JS : : -TracedJSContext +Value +> +eventsVal +( +cx +ObjectValue ( +* +events +) ) +; +if +( +! +JS_DefineProperty +( +cx +result +" +events +" +eventsVal +JSPROP_ENUMERATE ) ) { @@ -2447,49 +2640,28 @@ return false ; } -context -= -& -trace -. -contexts -[ -trace -. -contexts -. -length +if +( +! +readOutOfLineEntries ( +cx +scriptUrls +atoms ) -- -1 -] -; -context -- -> -id -= -tracer -- -> -threadId_ +) +{ +return +false ; } if ( ! -tracer -- -> -getNativeTrace +readInlineEntries ( -* -context -scratchBuffer -trace -. -stringBuffer +cx +events ) ) { @@ -2497,7 +2669,6 @@ return false ; } -} return true ; @@ -2514,11 +2685,6 @@ char16_t label ) { -CHECK_THREAD -( -cx -) -; if ( cx @@ -2562,11 +2728,6 @@ char label ) { -CHECK_THREAD -( -cx -) -; if ( cx @@ -2610,11 +2771,6 @@ char16_t label ) { -CHECK_THREAD -( -cx -) -; if ( cx @@ -2658,11 +2814,6 @@ char label ) { -CHECK_THREAD -( -cx -) -; if ( cx @@ -2694,70 +2845,3 @@ label ; } } -bool -JS_TracerBeginTracing -( -JSContext -* -cx -) -{ -CHECK_THREAD -( -cx -) -; -return -cx -- -> -enableExecutionTracing -( -) -; -} -bool -JS_TracerEndTracing -( -JSContext -* -cx -) -{ -CHECK_THREAD -( -cx -) -; -cx -- -> -disableExecutionTracing -( -) -; -return -true -; -} -bool -JS_TracerSnapshotTrace -( -JS -: -: -ExecutionTrace -& -trace -) -{ -return -ExecutionTracer -: -: -getNativeTraceForAllContexts -( -trace -) -; -} diff --git a/js/src/debugger/ExecutionTracer.h b/js/src/debugger/ExecutionTracer.h index 5dab5a283e2c6..427065e6b721f 100644 --- a/js/src/debugger/ExecutionTracer.h +++ b/js/src/debugger/ExecutionTracer.h @@ -18,15 +18,6 @@ include " mozilla / -BaseProfilerUtils -. -h -" -# -include -" -mozilla -/ MathAlgorithms . h @@ -51,15 +42,6 @@ h " # include -" -mozilla -/ -TimeStamp -. -h -" -# -include < limits > @@ -91,15 +73,6 @@ include " js / -Debug -. -h -" -# -include -" -js -/ RootingAPI . h @@ -152,18 +125,6 @@ TwoByte UTF8 } ; -using -TracingScratchBuffer -= -mozilla -: -: -Vector -< -char -512 -> -; template < size_t @@ -228,47 +189,6 @@ uncommittedReadHead_ = 0 ; -bool -ensureScratchBufferSize -( -TracingScratchBuffer -& -scratchBuffer -size_t -requiredSize -) -{ -if -( -scratchBuffer -. -length -( -) -> -= -requiredSize -) -{ -return -true -; -} -return -scratchBuffer -. -growByUninitialized -( -requiredSize -- -scratchBuffer -. -length -( -) -) -; -} public : ~ @@ -1172,21 +1092,18 @@ T bool readString ( -TracingScratchBuffer -& -scratchBuffer -mozilla +JSContext +* +cx +JS : : -Vector +MutableHandle < -char -> -& -stringBuffer -size_t +JSString * -index +> +result ) { uint8_t @@ -1215,15 +1132,6 @@ read length ) ; -* -index -= -stringBuffer -. -length -( -) -; if ( length @@ -1232,28 +1140,26 @@ length 0 ) { -if -( -! -stringBuffer +result . -append +set ( -' -\ -0 -' +JS_GetEmptyString +( +cx ) ) -{ -return -false ; -} return true ; } +JSLinearString +* +str += +nullptr +; if ( encoding @@ -1263,86 +1169,48 @@ TracerStringEncoding : : UTF8 -) -{ -size_t -reserveLength +| +| +encoding = -length -+ -1 -; -if -( -! -stringBuffer -. -growByUninitialized -( -reserveLength -) += +TracerStringEncoding +: +: +Latin1 ) { -return -false -; -} +UniquePtr +< +unsigned char -* -writePtr -= -stringBuffer -. -end +[ +] +JS +: +: +FreePolicy +> +chars ( -) +cx - -reserveLength -; -readBytes -( -reinterpret_cast +> +make_pod_arena_array < -uint8_t -* +unsigned +char > ( -writePtr -) +StringBufferArena length ) -; -writePtr -[ -length -] -= -' -\ -0 -' -; -} -else -if -( -encoding -= -= -TracerStringEncoding -: -: -Latin1 ) -{ +; if ( ! -ensureScratchBufferSize -( -scratchBuffer -length -) +chars ) { return @@ -1357,114 +1225,72 @@ uint8_t * > ( -scratchBuffer +chars . -begin +get ( ) ) length ) ; -size_t -reserveLength -= -length -* -2 -+ -1 -; if ( -! -stringBuffer -. -reserve -( -stringBuffer -. -length -( -) -+ -reserveLength -) -) -{ -return -false -; -} -char -* -writePtr +encoding = -stringBuffer -. -end -( -) -; -size_t -convertedLength = -mozilla +TracerStringEncoding : : -ConvertLatin1toUtf8 +UTF8 +) +{ +str += +NewStringCopyUTF8N ( -mozilla +cx +JS : : -Span +UTF8Chars +( +reinterpret_cast < -const char +* > ( -scratchBuffer +chars . -begin +get ( ) -length ) -mozilla -: -: -Span -< -char -> -( -writePtr -reserveLength +length ) ) ; -writePtr -[ -convertedLength -] +} +else +{ +str = -0 -; -if +NewString +< +CanGC +> ( -! -stringBuffer -. -growByUninitialized +cx +std +: +: +move ( -convertedLength -+ -1 +chars ) +length ) -{ -return -false ; } } @@ -1481,19 +1307,35 @@ TracerStringEncoding TwoByte ) ; -if -( -! -ensureScratchBufferSize -( -scratchBuffer -length -* -sizeof +UniquePtr +< +char16_t +[ +] +JS +: +: +FreePolicy +> +chars ( +cx +- +> +make_pod_arena_array +< char16_t +> +( +StringBufferArena +length ) ) +; +if +( +! +chars ) { return @@ -1502,18 +1344,15 @@ false } readBytes ( -reinterpret_cast -< +( uint8_t * -> -( -scratchBuffer +) +chars . -begin +get ( ) -) length * sizeof @@ -1522,115 +1361,42 @@ char16_t ) ) ; -size_t -reserveLength -= -length -* -3 -+ -1 -; -if -( -! -stringBuffer -. -reserve -( -stringBuffer -. -length -( -) -+ -reserveLength -) -) -{ -return -false -; -} -char -* -writePtr -= -stringBuffer -. -end -( -) -; -size_t -convertedLength +str = -mozilla -: -: -ConvertUtf16toUtf8 -( -mozilla -: -: -Span -< -const -char16_t -> -( -reinterpret_cast +NewString < -char16_t -* +CanGC > ( -scratchBuffer -. -begin -( -) -) -length -) -mozilla +cx +std : : -Span -< -char -> +move ( -writePtr -reserveLength +chars ) +length ) ; -writePtr -[ -convertedLength -] -= -0 -; +} if ( ! -stringBuffer -. -growByUninitialized -( -convertedLength -+ -1 -) +str ) { return false ; } -} +result +. +set +( +str +) +; return true ; @@ -1662,43 +1428,54 @@ TracingBuffer class ExecutionTracer { -private +public : -static -Mutex -globalInstanceLock -MOZ_UNANNOTATED +enum +class +EventKind +{ +FunctionEnter += +0 +FunctionLeave += +1 +LabelEnter += +2 +LabelLeave += +3 +} ; -static -mozilla -: +enum +class +ImplementationType : -Vector -< -ExecutionTracer -* -> -globalInstances -; -Mutex -bufferLock_ -MOZ_UNANNOTATED +uint8_t +{ +Interpreter += +0 +Baseline += +1 +Ion += +2 +Wasm += +3 +} ; +private +: InlineDataBuffer inlineData_ ; OutOfLineDataBuffer outOfLineData_ ; -mozilla -: -: -baseprofiler -: -: -BaseProfilerThreadId -threadId_ -; void writeScriptUrl ( @@ -1739,285 +1516,202 @@ frame bool readFunctionFrame ( +JSContext +* +cx JS : : -ExecutionTrace -: -: +Handle +< +JSObject +* +> +result EventKind kind -JS -: -: -ExecutionTrace -: -: -TracedEvent -& -event ) ; bool -readLabel +readStackFunctionEnter ( +JSContext +* +cx JS : : -ExecutionTrace -: -: -EventKind -kind -JS -: -: -ExecutionTrace -: -: -TracedEvent -& -event -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector +Handle < -char +JSObject +* > -& -stringBuffer +events ) ; bool -readInlineEntry +readStackFunctionLeave ( -mozilla -: -: -Vector -< +JSContext +* +cx JS : : -ExecutionTrace -: -: -TracedEvent -> -& -events -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector +Handle < -char +JSObject +* > -& -stringBuffer +events ) ; bool -readOutOfLineEntry +readScriptURLEntry ( -mozilla +JSContext +* +cx +JS : : -HashMap +Handle < -uint32_t -size_t +JSObject +* > -& scriptUrls -mozilla +) +; +bool +readAtomEntry +( +JSContext +* +cx +JS : : -HashMap +Handle < -uint32_t -size_t +JSObject +* > -& atoms -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector -< -char -> -& -stringBuffer ) ; bool -readInlineEntries +readLabel ( -mozilla -: -: -Vector -< +JSContext +* +cx JS : : -ExecutionTrace -: -: -TracedEvent +Handle +< +JSObject +* > -& events -TracingScratchBuffer -& -scratchBuffer -mozilla +EventKind +kind +) +; +bool +readInlineEntry +( +JSContext +* +cx +JS : : -Vector +Handle < -char +JSObject +* > -& -stringBuffer +events ) ; bool -readOutOfLineEntries +readOutOfLineEntry ( -mozilla +JSContext +* +cx +JS : : -HashMap +Handle < -uint32_t -size_t +JSObject +* > -& scriptUrls -mozilla +JS : : -HashMap +Handle < -uint32_t -size_t +JSObject +* > -& atoms -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector -< -char -> -& -stringBuffer ) ; -public -: -ExecutionTracer -( -) -: -bufferLock_ +bool +readInlineEntries ( -mutexid +JSContext +* +cx +JS : : -ExecutionTracerInstanceLock -) -{ -} -~ -ExecutionTracer -( -) -{ -LockGuard +Handle < -Mutex +JSObject +* > -guard -( -globalInstanceLock +events ) ; -globalInstances -. -eraseIfEqual +bool +readOutOfLineEntries ( -this -) -; -} -mozilla -: -: -baseprofiler +JSContext +* +cx +JS : : -BaseProfilerThreadId -threadId -( -) -const -{ -return -threadId_ -; -} -bool -init -( -) -{ -LockGuard +Handle < -Mutex +JSObject +* > -guard -( -globalInstanceLock -) -; -LockGuard +scriptUrls +JS +: +: +Handle < -Mutex +JSObject +* > -guard2 -( -bufferLock_ +atoms ) ; -threadId_ -= -mozilla -: -: -baseprofiler -: +public : -profiler_current_thread_id +bool +init ( ) -; +{ if ( ! @@ -2046,21 +1740,6 @@ return false ; } -if -( -! -globalInstances -. -append -( -this -) -) -{ -return -false -; -} return true ; @@ -2118,41 +1797,20 @@ eventType ) ; bool -getNativeTrace +getTrace ( +JSContext +* +cx JS : : -ExecutionTrace -: -: -TracedJSContext -& -context -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector +Handle < -char +JSObject +* > -& -stringBuffer -) -; -static -bool -getNativeTraceForAllContexts -( -JS -: -: -ExecutionTrace -& -trace +result ) ; } diff --git a/js/src/debugger/moz.build b/js/src/debugger/moz.build index 5d717f729017f..bbb5efa294b95 100644 --- a/js/src/debugger/moz.build +++ b/js/src/debugger/moz.build @@ -67,6 +67,11 @@ Environment cpp " " +ExecutionTracer +. +cpp +" +" Frame . cpp @@ -92,21 +97,3 @@ Source cpp " ] -if -CONFIG -[ -" -MOZ_EXECUTION_TRACING -" -] -: -UNIFIED_SOURCES -+ -= -[ -" -ExecutionTracer -. -cpp -" -] diff --git a/js/src/doc/Debugger/Debugger.md b/js/src/doc/Debugger/Debugger.md index 6755393e2b2b2..172c50c5cc690 100644 --- a/js/src/doc/Debugger/Debugger.md +++ b/js/src/doc/Debugger/Debugger.md @@ -804,6 +804,62 @@ evaluation . # # +# +nativeTracing +A +boolean +value +used +to +enable +the +native +tracing +which +will +collect +information +about +frames +entered +and +left +and +provide +them +via +collectNativeTrace +( +see +below +) +. +Setting +this +to +false +will +clear +the +trace +if +no +other +debuggers +are +tracing +the +context +otherwise +the +trace +will +be +left +running +. +# +# Debugger Handler Functions @@ -5256,6 +5312,535 @@ debuggee . # # +# +collectNativeTrace +( +) +. +. +container +: +: +blockIndicator +note +Note +: +collectNativeTrace +( +) +and +all +related +native +tracing +members +are +being +actively +developed +and +experimented +with +and +should +be +considered +in +the +prototyping +phase +. +The +long +- +term +goal +for +this +project +is +for +Firefox +to +have +both +a +live +tracer +which +can +be +used +to +see +the +structure +of +a +program +as +it +executes +in +real +time +( +bug +1910182 +tracks +the +development +of +the +native +backend +for +this +) +as +well +as +a +recorded +trace +which +is +covered +by +this +method +. +Collects +all +of +the +tracing +data +collected +by +the +native +tracer +returns +it +as +a +JS +object +and +sets +nativeTracing +to +false +The +table +is +structured +as +follows +: +js +{ +/ +/ +a +dictionary +of +strings +which +can +be +referenced +from +events +" +atoms +" +: +{ +. +. +. +} +/ +/ +a +dictionary +of +script +URLs +keyed +by +script +source +id +" +scriptURLs +" +: +{ +. +. +. +} +/ +/ +an +array +of +TracingEvent +detailed +below +" +events +" +: +[ +. +. +. +] +} +. +. +container +: +: +blockIndicator +note +Note +: +Both +atoms +and +scriptURLs +are +populated +from +a +ring +buffer +which +can +wrap +around +and +overwrite +old +data +. +In +practice +this +case +tends +to +not +occur +but +it +should +be +noted +that +entries +in +the +events +array +may +reference +entries +in +in +atoms +and +scriptURLs +which +do +not +exist +. +events +itself +also +comes +from +a +separate +ring +buffer +so +after +a +certain +amount +of +activity +old +events +will +be +overwritten +. +A +TracingEvent +is +just +a +plain +JS +array +. +The +first +element +specifies +the +kind +of +the +event +and +the +rest +of +the +array +is +structured +differently +based +on +that +kind +. +The +event +kind +is +one +of +the +following +: +- +Debugger +. +TRACING_EVENT_KIND_FUNCTION_ENTER +( +event +is +a +FunctionFrameInfo +) +- +Debugger +. +TRACING_EVENT_KIND_FUNCTION_LEAVE +( +event +is +a +FunctionFrameInfo +) +- +Debugger +. +TRACING_EVENT_KIND_LABEL_ENTER +( +event +is +a +LabelFrameInfo +) +- +Debugger +. +TRACING_EVENT_KIND_LABEL_LEAVE +( +event +is +a +LabelFrameInfo +) +Events +may +also +contain +information +about +the +implementation +of +the +function +executing +. +This +references +one +of +the +following +values +: +- +Debugger +. +IMPLEMENTATION_INTERPRETER +- +Debugger +. +IMPLEMENTATION_BASELINE +- +Debugger +. +IMPLEMENTATION_ION +- +Debugger +. +IMPLEMENTATION_WASM +js +/ +/ +FunctionFrameInfo +: +[ +kind +/ +/ +The +kind +of +the +entry +( +see +above +) +lineNumber +/ +/ +The +line +number +of +the +function +in +the +script +source +column +/ +/ +The +1 +- +based +column +of +the +function +in +the +script +source +scriptId +/ +/ +The +ID +of +the +script +source +. +Indexes +into +the +scriptURLs +array +( +0 +means +the +script +was +missing +) +functionName +/ +/ +The +function +name +as +an +index +into +the +atoms +array +implementation +/ +/ +See +the +IMPLEMENTATION_ +* +constants +above +time +/ +/ +When +this +entry +was +recorded +in +milliseconds +since +the +Epoch +] +/ +/ +LabelFrameInfo +: +[ +kind +/ +/ +See +above +label +/ +/ +A +string +( +the +label +) +time +/ +/ +When +this +entry +was +recorded +in +milliseconds +since +the +Epoch +] +# +# Static methods of diff --git a/js/src/jit-test/tests/debug/ExecutionTracer-collectNativeTrace.js b/js/src/jit-test/tests/debug/ExecutionTracer-collectNativeTrace.js new file mode 100644 index 0000000000000..c2b52bfe7e35f --- /dev/null +++ b/js/src/jit-test/tests/debug/ExecutionTracer-collectNativeTrace.js @@ -0,0 +1,379 @@ +var +g += +newGlobal +( +{ +newCompartment +: +true +} +) +; +var +dbg += +Debugger +( +g +) +; +dbg +. +nativeTracing += +true +; +var +start += +performance +. +now +( +) +; +g +. +eval +( +function +bar +( +) +{ +} +function +foo +( +) +{ +bar +( +) +; +} +foo +( +) +; +) +; +var +end += +performance +. +now +( +) +; +var +trace += +dbg +. +collectNativeTrace +( +) +; +assertEq +( +dbg +. +nativeTracing +false +) +; +assertEq +( +trace +. +events +[ +0 +] +[ +0 +] +Debugger +. +TRACING_EVENT_KIND_FUNCTION_ENTER +) +; +assertEq +( +trace +. +events +[ +1 +] +[ +0 +] +Debugger +. +TRACING_EVENT_KIND_FUNCTION_ENTER +) +; +assertEq +( +trace +. +events +[ +2 +] +[ +0 +] +Debugger +. +TRACING_EVENT_KIND_FUNCTION_LEAVE +) +; +assertEq +( +trace +. +events +[ +3 +] +[ +0 +] +Debugger +. +TRACING_EVENT_KIND_FUNCTION_LEAVE +) +; +assertEq +( +trace +. +events +[ +0 +] +[ +1 +] +4 +) +; +assertEq +( +trace +. +events +[ +1 +] +[ +1 +] +2 +) +; +assertEq +( +trace +. +events +[ +0 +] +[ +2 +] +13 +) +; +assertEq +( +trace +. +events +[ +1 +] +[ +2 +] +13 +) +; +assertEq +( +trace +. +atoms +[ +trace +. +events +[ +0 +] +[ +4 +] +] +" +foo +" +) +; +assertEq +( +trace +. +atoms +[ +trace +. +events +[ +1 +] +[ +4 +] +] +" +bar +" +) +; +assertEq +( +trace +. +events +[ +2 +] +[ +4 +] +trace +. +events +[ +1 +] +[ +4 +] +) +; +assertEq +( +trace +. +events +[ +3 +] +[ +4 +] +trace +. +events +[ +0 +] +[ +4 +] +) +; +assertEq +( +[ +Debugger +. +IMPLEMENTATION_INTERPRETER +Debugger +. +IMPLEMENTATION_BASELINE +] +. +includes +( +trace +. +events +[ +0 +] +[ +5 +] +) +true +) +; +assertEq +( +[ +Debugger +. +IMPLEMENTATION_INTERPRETER +Debugger +. +IMPLEMENTATION_BASELINE +] +. +includes +( +trace +. +events +[ +1 +] +[ +5 +] +) +true +) +; +assertEq +( +trace +. +events +[ +0 +] +[ +6 +] +> += +start +true +) +; +assertEq +( +trace +. +events +[ +0 +] +[ +6 +] +< += +end +true +) +; diff --git a/js/src/jit-test/tests/debug/ExecutionTracer-discard-trace.js b/js/src/jit-test/tests/debug/ExecutionTracer-discard-trace.js new file mode 100644 index 0000000000000..48f457d9a0635 --- /dev/null +++ b/js/src/jit-test/tests/debug/ExecutionTracer-discard-trace.js @@ -0,0 +1,272 @@ +var +g += +newGlobal +( +{ +newCompartment +: +true +} +) +; +var +dbg += +Debugger +( +g +) +; +dbg +. +nativeTracing += +true +; +g +. +eval +( +function +foo +( +) +{ +} +foo +( +) +; +) +; +dbg +. +nativeTracing += +false +; +dbg +. +nativeTracing += +true +; +g +. +eval +( +function +bar +( +) +{ +} +function +foo +( +) +{ +bar +( +) +; +} +foo +( +) +; +) +; +var +trace += +dbg +. +collectNativeTrace +( +) +; +assertEq +( +dbg +. +nativeTracing +false +) +; +assertEq +( +trace +. +events +. +length +4 +) +; +assertEq +( +trace +. +events +[ +0 +] +[ +0 +] +Debugger +. +TRACING_EVENT_KIND_FUNCTION_ENTER +) +; +assertEq +( +trace +. +events +[ +1 +] +[ +0 +] +Debugger +. +TRACING_EVENT_KIND_FUNCTION_ENTER +) +; +assertEq +( +trace +. +events +[ +2 +] +[ +0 +] +Debugger +. +TRACING_EVENT_KIND_FUNCTION_LEAVE +) +; +assertEq +( +trace +. +events +[ +3 +] +[ +0 +] +Debugger +. +TRACING_EVENT_KIND_FUNCTION_LEAVE +) +; +assertEq +( +Object +. +keys +( +trace +. +atoms +) +. +length +2 +) +; +assertEq +( +trace +. +atoms +[ +trace +. +events +[ +0 +] +[ +4 +] +] +" +foo +" +) +; +assertEq +( +trace +. +atoms +[ +trace +. +events +[ +1 +] +[ +4 +] +] +" +bar +" +) +; +assertEq +( +trace +. +events +[ +2 +] +[ +4 +] +trace +. +events +[ +1 +] +[ +4 +] +) +; +assertEq +( +trace +. +events +[ +3 +] +[ +4 +] +trace +. +events +[ +0 +] +[ +4 +] +) +; diff --git a/js/src/jit-test/tests/debug/ExecutionTracer-oomTest.js b/js/src/jit-test/tests/debug/ExecutionTracer-oomTest.js new file mode 100644 index 0000000000000..0f726cd229639 --- /dev/null +++ b/js/src/jit-test/tests/debug/ExecutionTracer-oomTest.js @@ -0,0 +1,77 @@ +var +g += +newGlobal +( +{ +newCompartment +: +true +} +) +; +var +dbg += +new +Debugger +( +) +; +function +test +( +) +{ +dbg +. +nativeTracing += +true +; +g +. +eval +( +function +bar +( +) +{ +} +function +foo +( +) +{ +bar +( +) +; +} +foo +( +) +; +) +; +dbg +. +collectNativeTrace +( +) +; +} +oomTest +( +( +) += +> +{ +test +( +) +} +) +; diff --git a/js/src/jit-test/tests/debug/ExecutionTracer-properties-exist.js b/js/src/jit-test/tests/debug/ExecutionTracer-properties-exist.js new file mode 100644 index 0000000000000..1be407ed06404 --- /dev/null +++ b/js/src/jit-test/tests/debug/ExecutionTracer-properties-exist.js @@ -0,0 +1,152 @@ +var +g += +newGlobal +( +{ +newCompartment +: +true +} +) +; +var +dbg += +Debugger +( +g +) +; +assertEq +( +dbg +. +nativeTracing +false +) +; +dbg +. +nativeTracing += +true +; +assertEq +( +dbg +. +nativeTracing +true +) +; +dbg +. +nativeTracing += +false +; +assertEq +( +dbg +. +nativeTracing +false +) +; +assertEq +( +Debugger +. +TRACING_EVENT_KIND_FUNCTION_ENTER +! += += +undefined +true +) +; +assertEq +( +Debugger +. +TRACING_EVENT_KIND_FUNCTION_LEAVE +! += += +undefined +true +) +; +assertEq +( +Debugger +. +TRACING_EVENT_KIND_LABEL_ENTER +! += += +undefined +true +) +; +assertEq +( +Debugger +. +TRACING_EVENT_KIND_LABEL_LEAVE +! += += +undefined +true +) +; +assertEq +( +Debugger +. +IMPLEMENTATION_INTERPRETER +! += += +undefined +true +) +; +assertEq +( +Debugger +. +IMPLEMENTATION_BASELINE +! += += +undefined +true +) +; +assertEq +( +Debugger +. +IMPLEMENTATION_ION +! += += +undefined +true +) +; +assertEq +( +Debugger +. +IMPLEMENTATION_WASM +! += += +undefined +true +) +; diff --git a/js/src/jit-test/tests/debug/ExecutionTracer-utf8.js b/js/src/jit-test/tests/debug/ExecutionTracer-utf8.js new file mode 100644 index 0000000000000..8819acdfc4947 --- /dev/null +++ b/js/src/jit-test/tests/debug/ExecutionTracer-utf8.js @@ -0,0 +1,91 @@ +var +g += +newGlobal +( +{ +newCompartment +: +true +} +) +; +var +dbg += +Debugger +( +g +) +; +var +debuggee += +dbg +. +getDebuggees +( +) +[ +0 +] +; +dbg +. +nativeTracing += +true +; +debuggee +. +executeInGlobal +( +" +( +( +) += +> +{ +} +) +( +) +" +{ +url +: +" +" +} +) +; +var +trace += +dbg +. +collectNativeTrace +( +) +; +assertEq +( +trace +. +scriptURLs +[ +trace +. +events +[ +0 +] +[ +3 +] +] +" +" +) +; diff --git a/js/src/vm/Caches.h b/js/src/vm/Caches.h index 467b9a475873f..2c98f567d8c73 100644 --- a/js/src/vm/Caches.h +++ b/js/src/vm/Caches.h @@ -2356,9 +2356,6 @@ Clear } } ; -# -ifdef -MOZ_EXECUTION_TRACING class TracingCaches { @@ -2715,8 +2712,6 @@ NewlyAdded } } ; -# -endif class RuntimeCaches { @@ -2740,14 +2735,9 @@ evalCache StringToAtomCache stringToAtomCache ; -# -ifdef -MOZ_EXECUTION_TRACING TracingCaches tracingCaches ; -# -endif frontend : : @@ -2822,17 +2812,12 @@ purge ( ) ; -# -ifdef -MOZ_EXECUTION_TRACING tracingCaches . clearOnCompaction ( ) ; -# -endif } void purgeStencils diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp index f185bace366c9..74853dd9c7e80 100644 --- a/js/src/vm/JSContext.cpp +++ b/js/src/vm/JSContext.cpp @@ -128,9 +128,6 @@ RegExp h " # -ifdef -MOZ_EXECUTION_TRACING -# include " debugger @@ -140,8 +137,6 @@ ExecutionTracer h " # -endif -# include " frontend @@ -162,15 +157,6 @@ h # include " -gc -/ -PublicIterators -. -h -" -# -include -" irregexp / RegExpAPI @@ -6969,15 +6955,19 @@ ExternalValueArray ; } } -# -ifdef -MOZ_EXECUTION_TRACING bool JSContext : : -enableExecutionTracing +addExecutionTracingConsumer ( +const +js +: +: +Debugger +* +dbg ) { if @@ -7027,114 +7017,69 @@ return false ; } -for -( -RealmsIter -realm -( -runtime +if ( -) -) -; ! -realm -. -done -( -) -; -realm +executionTracingConsumers_ . -next +put ( +dbg ) ) { -if -( -realm -- -> -isSystem -( -) -) -{ -continue +executionTracer_ += +nullptr ; -} -realm -- -> -enableExecutionTracing -( -) +return +false ; } -} return true ; } +return +executionTracingConsumers_ +. +put +( +dbg +) +; +} void JSContext : : -disableExecutionTracing +removeExecutionTracingConsumer ( +const +js +: +: +Debugger +* +dbg ) { -if -( -executionTracer_ -) -{ -for -( -RealmsIter -realm -( -runtime -( -) -) -; -! -realm +executionTracingConsumers_ . -done +remove ( +dbg ) ; -realm -. -next -( -) -) -{ if ( -realm -- -> -isSystem +executionTracingConsumers_ +. +empty ( ) ) { -continue -; -} -realm -- -> -disableExecutionTracing -( -) -; -} caches ( ) @@ -7152,8 +7097,6 @@ nullptr } } # -endif -# ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI AutoUnsafeCallWithABI diff --git a/js/src/vm/JSContext.h b/js/src/vm/JSContext.h index 74cbeac84e293..968e1c5cb64ba 100644 --- a/js/src/vm/JSContext.h +++ b/js/src/vm/JSContext.h @@ -9,15 +9,6 @@ include " mozilla / -BaseProfilerUtils -. -h -" -# -include -" -mozilla -/ Maybe . h @@ -246,17 +237,12 @@ AutoMaybeLeaveAtomsZone class AutoRealm ; -struct -PortableBaselineStack -; -# -ifdef -MOZ_EXECUTION_TRACING class ExecutionTracer ; -# -endif +struct +PortableBaselineStack +; namespace jit { @@ -4088,9 +4074,6 @@ Debugger > insideExclusiveDebuggerOnEval ; -# -ifdef -MOZ_EXECUTION_TRACING js : : @@ -4106,11 +4089,54 @@ executionTracer_ js : : +HashSet +< +const +js +: +: +Debugger +* +js +: +: +PointerHasher +< +const +js +: +: +Debugger +* +> +js +: +: +SystemAllocPolicy +> +executionTracingConsumers_ +; +bool +hasExecutionTracer +( +) +const +{ +return +! +! +executionTracer_ +; +} +js +: +: ExecutionTracer & getExecutionTracer ( ) +const { MOZ_ASSERT ( @@ -4124,46 +4150,31 @@ return executionTracer_ ; } -[ -[ -nodiscard -] -] bool -enableExecutionTracing +addExecutionTracingConsumer ( +const +js +: +: +Debugger +* +dbg ) ; void -disableExecutionTracing -( -) -; -bool -hasExecutionTracer -( -) -{ -return -! -! -executionTracer_ -; -} -# -else -bool -hasExecutionTracer +removeExecutionTracingConsumer ( +const +js +: +: +Debugger +* +dbg ) -{ -return -false ; } -# -endif -} ; inline JSContext diff --git a/js/src/vm/MutexIDs.h b/js/src/vm/MutexIDs.h index 3ccfdb9fbc372..a6c751753ec1c 100644 --- a/js/src/vm/MutexIDs.h +++ b/js/src/vm/MutexIDs.h @@ -22,12 +22,6 @@ _ \ _ ( -ExecutionTracerGlobalLock -100 -) -\ -_ -( TestMutex 100 ) @@ -59,12 +53,6 @@ WellKnownParserAtomsInit \ _ ( -ExecutionTracerInstanceLock -250 -) -\ -_ -( WasmInitBuiltinThunks 250 ) diff --git a/js/src/vm/Realm.cpp b/js/src/vm/Realm.cpp index 6f33ae354ff5e..fbdc4216b7b0c 100644 --- a/js/src/vm/Realm.cpp +++ b/js/src/vm/Realm.cpp @@ -402,15 +402,15 @@ hasBeenEnteredIgnoringJit MOZ_ASSERT ( ! -localAllocSite -) -; -MOZ_ASSERT_IF -( isDebuggee ( ) -isTracingExecution_ +) +; +MOZ_ASSERT +( +! +localAllocSite ) ; if @@ -442,16 +442,6 @@ forgetAllocationMetadataBuilder ) ; } -if -( -isTracingExecution_ -) -{ -disableExecutionTracing -( -) -; -} MOZ_ASSERT ( runtime_ @@ -529,25 +519,6 @@ principals_ principals ; } -if -( -! -isSystem_ -& -& -cx -- -> -hasExecutionTracer -( -) -) -{ -enableExecutionTracing -( -) -; -} } bool JSRuntime @@ -2103,10 +2074,6 @@ DebuggerObservesAllExecution { observes = -( -global -& -& DebugAPI : : @@ -2114,10 +2081,6 @@ debuggerObservesAllExecution ( global ) -) -| -| -isTracingExecution_ ; } else diff --git a/js/src/vm/Realm.h b/js/src/vm/Realm.h index 76f5a7d5445f7..66d5fc889559b 100644 --- a/js/src/vm/Realm.h +++ b/js/src/vm/Realm.h @@ -1461,11 +1461,6 @@ initializingGlobal_ = true ; -bool -isTracingExecution_ -= -false -; js : : @@ -2378,60 +2373,6 @@ unsetIsDebuggee ( ) ; -bool -isTracingExecution -( -) -{ -return -isTracingExecution_ -; -} -void -enableExecutionTracing -( -) -{ -isTracingExecution_ -= -true -; -setIsDebuggee -( -) -; -updateDebuggerObservesAllExecution -( -) -; -} -void -disableExecutionTracing -( -) -{ -isTracingExecution_ -= -false -; -updateDebuggerObservesAllExecution -( -) -; -if -( -! -hasDebuggers -( -) -) -{ -unsetIsDebuggee -( -) -; -} -} DebuggerVector & getDebuggers diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp index 3c678bd1cdc39..05a6fba757c66 100644 --- a/js/xpconnect/src/XPCJSContext.cpp +++ b/js/xpconnect/src/XPCJSContext.cpp @@ -5801,7 +5801,7 @@ kTrustedScriptBuffer ; PROFILER_SET_JS_CONTEXT ( -this +cx ) ; JS_AddInterruptCallback diff --git a/toolkit/components/extensions/schemas/geckoProfiler.json b/toolkit/components/extensions/schemas/geckoProfiler.json index 6bfaa59748b8c..dfbd532de1adc 100644 --- a/toolkit/components/extensions/schemas/geckoProfiler.json +++ b/toolkit/components/extensions/schemas/geckoProfiler.json @@ -180,9 +180,6 @@ bandwidth " memory " -" -tracing -" ] } { diff --git a/tools/profiler/core/ProfileBuffer.h b/tools/profiler/core/ProfileBuffer.h index 4b4afbcbd1cd8..a8d9f09424890 100644 --- a/tools/profiler/core/ProfileBuffer.h +++ b/tools/profiler/core/ProfileBuffer.h @@ -672,28 +672,6 @@ return mMaybeWorkerChunkManager ; } -# -ifdef -MOZ_EXECUTION_TRACING -template -< -typename -GetStreamingParametersForThreadCallback -> -void -MaybeStreamExecutionTraceToJSON -( -GetStreamingParametersForThreadCallback -& -& -aGetStreamingParametersForThreadCallback -double -aSinceTime -) -const -; -# -endif template < typename diff --git a/tools/profiler/core/ProfileBufferEntry.cpp b/tools/profiler/core/ProfileBufferEntry.cpp index 39031af439323..de6707c00c1ce 100644 --- a/tools/profiler/core/ProfileBufferEntry.cpp +++ b/tools/profiler/core/ProfileBufferEntry.cpp @@ -77,15 +77,6 @@ include " mozilla / -CycleCollectedJSContext -. -h -" -# -include -" -mozilla -/ Logging . h @@ -4662,65 +4653,199 @@ aPreviousStack } } ; -# -ifdef -MOZ_EXECUTION_TRACING template < typename GetStreamingParametersForThreadCallback > -void +ProfilerThreadId ProfileBuffer : : -MaybeStreamExecutionTraceToJSON +DoStreamSamplesAndMarkersToJSON ( +mozilla +: +: +FailureLatch +& +aFailureLatch GetStreamingParametersForThreadCallback & & aGetStreamingParametersForThreadCallback double aSinceTime +ProcessStreamingContext +* +aStreamingContextForMarkers +mozilla +: +: +ProgressLogger +aProgressLogger ) const { -JS +UniquePtr +< +char +[ +] +> +dynStrBuf += +MakeUnique +< +char +[ +] +> +( +kMaxFrameKeyLength +) +; +return +mEntries +. +Read +( +[ +& +] +( +ProfileChunkedBuffer +: +: +Reader +* +aReader +) +{ +MOZ_ASSERT +( +aReader +" +ProfileChunkedBuffer +cannot +be +out +- +of +- +session +when +sampler +is +" +" +running +" +) +; +ProfilerThreadId +processedThreadId +; +EntryGetter +e +( +* +aReader +aFailureLatch +std : : -ExecutionTrace -trace +move +( +aProgressLogger +) +0 +aStreamingContextForMarkers +) +; +for +( ; +; +) +{ +while +( +e +. +Has +( +) +) +{ if ( -! -JS_TracerSnapshotTrace +e +. +Get +( +) +. +IsThreadId ( -trace ) ) { -return +break ; } -for +e +. +Next ( -const -JS -: -: -ExecutionTrace -: -: -TracedJSContext -& -context -: -trace +) +; +} +if +( +! +e . -contexts +Has +( +) ) { +break +; +} +MOZ_ASSERT +( +e +. +Get +( +) +. +IsThreadId +( +) +) +; +ProfilerThreadId +threadId += +e +. +Get +( +) +. +GetThreadId +( +) +; +e +. +Next +( +) +; Maybe < StreamingParametersForThread @@ -4738,9 +4863,7 @@ GetStreamingParametersForThreadCallback aGetStreamingParametersForThreadCallback ) ( -context -. -id +threadId ) ; if @@ -4770,18 +4893,66 @@ streamingParameters > mUniqueStacks ; -mozilla +ThreadStreamingContext : : -Vector +PreviousStackState +& +previousStackState += +streamingParameters +- +> +mPreviousStackState +; +uint32_t +& +previousStack += +streamingParameters +- +> +mPreviousStack +; +auto +ReadStack += +[ +& +] +( +EntryGetter +& +e +double +time +uint64_t +entryPosition +const +Maybe < -UniqueStacks -: -: -StackKey +double > -frameStack +& +unresponsiveDuration +const +RunningTimes +& +runningTimes +) +{ +if +( +writer +. +Failed +( +) +) +{ +return ; +} Maybe < UniqueStacks @@ -4824,7 +4995,7 @@ failure " ) ; -continue +return ; } UniqueStacks @@ -4836,1126 +5007,12 @@ stack * maybeStack ; -if -( -! -frameStack -. -append -( -stack -) -) -{ -writer -. -SetFailure -( -" -frameStack -append -failure -" -) -; -continue -; -} -for -( -const -JS -: -: -ExecutionTrace -: -: -TracedEvent -& -event -: -context -. -events -) -{ -if -( -event -. -time -< -aSinceTime -) -{ -continue -; -} -if -( -event -. -kind -= -= -JS -: -: -ExecutionTrace -: -: -EventKind -: -: -FunctionEnter -) -{ -HashMap -< -uint32_t -size_t -> -: -: -Ptr -functionName -= -context -. -atoms -. -lookup -( -event -. -functionEvent -. -functionNameId -) -; -const -char -* -functionNameStr -= -" -< -expired -> -" -; -if -( -functionName -) -{ -functionNameStr -= -& -trace -. -stringBuffer -[ -functionName -- -> -value -( -) -] -; -} -HashMap -< -uint32_t -size_t -> -: -: -Ptr -scriptUrl -= -context -. -scriptUrls -. -lookup -( -event -. -functionEvent -. -scriptId -) -; -const -char -* -scriptUrlStr -= -" -< -expired -> -" -; -if -( -scriptUrl -) -{ -scriptUrlStr -= -& -trace -. -stringBuffer -[ -scriptUrl -- -> -value -( -) -] -; -} -nsAutoCStringN -< -1024 -> -name -( -functionNameStr -) -; -name -. -AppendPrintf -( -" -( -% -s -: -% -u -: -% -u -) -" -scriptUrlStr -event -. -functionEvent -. -lineNumber -event -. -functionEvent -. -column -) -; -JS -: -: -ProfilingCategoryPair -categoryPair -; -switch -( -event -. -functionEvent -. -implementation -) -{ -case -JS -: -: -ExecutionTrace -: -: -ImplementationType -: -: -Interpreter -: -categoryPair -= -JS -: -: -ProfilingCategoryPair -: -: -JS -; -break -; -case -JS -: -: -ExecutionTrace -: -: -ImplementationType -: -: -Baseline -: -categoryPair -= -JS -: -: -ProfilingCategoryPair -: -: -JS_Baseline -; -break -; -case -JS -: -: -ExecutionTrace -: -: -ImplementationType -: -: -Ion -: -categoryPair -= -JS -: -: -ProfilingCategoryPair -: -: -JS_IonMonkey -; -break -; -case -JS -: -: -ExecutionTrace -: -: -ImplementationType -: -: -Wasm -: -categoryPair -= -JS -: -: -ProfilingCategoryPair -: -: -JS_WasmOther -; -break -; -} -UniqueStacks -: -: -FrameKey -newFrame -( -nsCString -( -name -. -get -( -) -) -true -false -0 -Nothing -{ -} -Nothing -{ -} -Some -( -categoryPair -) -) -; -maybeStack -= -uniqueStacks -. -AppendFrame -( -stack -newFrame -) -; -if -( -! -maybeStack -) -{ -writer -. -SetFailure -( -" -AppendFrame -failure -" -) -; -continue -; -} -stack -= -* -maybeStack -; -if -( -! -frameStack -. -append -( -stack -) -) -{ -writer -. -SetFailure -( -" -frameStack -append -failure -" -) -; -continue -; -} -} -else -if -( -event -. -kind -= -= -JS -: -: -ExecutionTrace -: -: -EventKind -: -: -LabelEnter -) -{ -UniqueStacks -: -: -FrameKey -newFrame -( -nsCString -( -& -trace -. -stringBuffer -[ -event -. -labelEvent -. -label -] -) -true -false -0 -Nothing -{ -} -Nothing -{ -} -Some -( -JS -: -: -ProfilingCategoryPair -: -: -DOM -) -) -; -maybeStack -= -uniqueStacks -. -AppendFrame -( -stack -newFrame -) -; -if -( -! -maybeStack -) -{ -writer -. -SetFailure -( -" -AppendFrame -failure -" -) -; -continue -; -} -stack -= -* -maybeStack -; -if -( -! -frameStack -. -append -( -stack -) -) -{ -writer -. -SetFailure -( -" -frameStack -append -failure -" -) -; -continue -; -} -} -else -{ -MOZ_ASSERT -( -event -. -kind -= -= -JS -: -: -ExecutionTrace -: -: -EventKind -: -: -LabelLeave -| -| -event -. -kind -= -= -JS -: -: -ExecutionTrace -: -: -EventKind -: -: -FunctionLeave -) -; -if -( -frameStack -. -length -( -) -> -0 -) -{ -frameStack -. -popBack -( -) -; -} -if -( -frameStack -. -length -( -) -> -0 -) -{ -stack -= -frameStack -[ -frameStack -. -length -( -) -- -1 -] -; -} -else -{ -maybeStack -= -uniqueStacks -. -BeginStack -( -UniqueStacks -: -: -FrameKey -( -" -( -root -) -" -) -) -; -if -( -! -maybeStack -) -{ -writer -. -SetFailure -( -" -BeginStack -failure -" -) -; -continue -; -} -stack -= -* -maybeStack -; -if -( -! -frameStack -. -append -( -stack -) -) -{ -writer -. -SetFailure -( -" -frameStack -append -failure -" -) -; -continue -; -} -} -} -const -Maybe -< -uint32_t -> -stackIndex -= -uniqueStacks -. -GetOrAddStackIndex -( -stack -) -; -if -( -! -stackIndex -) -{ -writer -. -SetFailure -( -" -Can -' -t -add -unique -string -for -stack -" -) -; -continue -; -} -WriteSample -( -writer -ProfileSample -{ -* -stackIndex -event -. -time -Nothing -{ -} -RunningTimes -{ -} -} -) -; -} -} -} -# -endif -template -< -typename -GetStreamingParametersForThreadCallback -> -ProfilerThreadId -ProfileBuffer -: -: -DoStreamSamplesAndMarkersToJSON -( -mozilla -: -: -FailureLatch -& -aFailureLatch -GetStreamingParametersForThreadCallback -& -& -aGetStreamingParametersForThreadCallback -double -aSinceTime -ProcessStreamingContext -* -aStreamingContextForMarkers -mozilla -: -: -ProgressLogger -aProgressLogger -) -const -{ -UniquePtr -< -char -[ -] -> -dynStrBuf -= -MakeUnique -< -char -[ -] -> -( -kMaxFrameKeyLength -) -; -return -mEntries -. -Read -( -[ -& -] -( -ProfileChunkedBuffer -: -: -Reader -* -aReader -) -{ -MOZ_ASSERT -( -aReader -" -ProfileChunkedBuffer -cannot -be -out -- -of -- -session -when -sampler -is -" -" -running -" -) -; -ProfilerThreadId -processedThreadId -; -EntryGetter -e -( -* -aReader -aFailureLatch -std -: -: -move -( -aProgressLogger -) -0 -aStreamingContextForMarkers -) -; -for -( -; -; -) -{ -while -( -e -. -Has -( -) -) -{ -if -( -e -. -Get -( -) -. -IsThreadId -( -) -) -{ -break -; -} -e -. -Next -( -) -; -} -if -( -! -e -. -Has -( -) -) -{ -break -; -} -MOZ_ASSERT -( -e -. -Get -( -) -. -IsThreadId -( -) -) -; -ProfilerThreadId -threadId -= -e -. -Get -( -) -. -GetThreadId -( -) -; -e -. -Next -( -) -; -Maybe -< -StreamingParametersForThread -> -streamingParameters -= -std -: -: -forward -< -GetStreamingParametersForThreadCallback -> -( -aGetStreamingParametersForThreadCallback -) -( -threadId -) -; -if -( -! -streamingParameters -) -{ -continue -; -} -SpliceableJSONWriter -& -writer -= -streamingParameters -- -> -mWriter -; -UniqueStacks -& -uniqueStacks -= -streamingParameters -- -> -mUniqueStacks -; -ThreadStreamingContext -: -: -PreviousStackState -& -previousStackState -= -streamingParameters -- -> -mPreviousStackState -; -uint32_t -& -previousStack -= -streamingParameters -- -> -mPreviousStack -; -auto -ReadStack -= -[ -& -] -( -EntryGetter -& -e -double -time -uint64_t -entryPosition -const -Maybe -< -double -> -& -unresponsiveDuration -const -RunningTimes -& -runningTimes -) -{ -if -( -writer -. -Failed -( -) -) -{ -return -; -} -Maybe -< -UniqueStacks -: -: -StackKey -> -maybeStack -= -uniqueStacks -. -BeginStack -( -UniqueStacks -: -: -FrameKey -( -" -( -root -) -" -) -) -; -if -( -! -maybeStack -) -{ -writer -. -SetFailure -( -" -BeginStack -failure -" -) -; -return -; -} -UniqueStacks -: -: -StackKey -stack -= -* -maybeStack -; -int -numFrames -= -0 -; -while +int +numFrames += +0 +; +while ( e . @@ -7913,9 +6970,16 @@ aProgressLogger ) const { -auto -getStreamingParamsCallback -= +( +void +) +DoStreamSamplesAndMarkersToJSON +( +aProcessStreamingContext +. +SourceFailureLatch +( +) [ & ] @@ -7974,33 +7038,6 @@ return streamingParameters ; } -; -# -ifdef -MOZ_EXECUTION_TRACING -MaybeStreamExecutionTraceToJSON -( -getStreamingParamsCallback -aProcessStreamingContext -. -GetSinceTime -( -) -) -; -# -endif -( -void -) -DoStreamSamplesAndMarkersToJSON -( -aProcessStreamingContext -. -SourceFailureLatch -( -) -getStreamingParamsCallback aProcessStreamingContext . GetSinceTime diff --git a/tools/profiler/core/ProfilerThreadRegistrationData.cpp b/tools/profiler/core/ProfilerThreadRegistrationData.cpp index b53e6d7479b1f..9d7a30ebb9a73 100644 --- a/tools/profiler/core/ProfilerThreadRegistrationData.cpp +++ b/tools/profiler/core/ProfilerThreadRegistrationData.cpp @@ -777,35 +777,6 @@ inNursery ) ; } -JSContext -* -ThreadRegistrationUnlockedReaderAndAtomicRWOnThread -: -: -GetJSContext -( -) -const -{ -if -( -! -mCCJSContext -) -{ -return -nullptr -; -} -return -mCCJSContext -- -> -Context -( -) -; -} void ThreadRegistrationLockedRWFromAnyThread : @@ -854,7 +825,7 @@ aProfiledThreadData ; if ( -mCCJSContext +mJSContext ) { MOZ_ASSERT @@ -893,7 +864,7 @@ mProfiledThreadData MOZ_ASSERT ( ( -mCCJSContext +mJSContext & & ( @@ -972,7 +943,7 @@ mProfiledThreadData MOZ_ASSERT ( ( -mCCJSContext +mJSContext & & ( @@ -997,35 +968,25 @@ void ThreadRegistrationLockedRWOnThread : : -SetCycleCollectedJSContext +SetJSContext ( -CycleCollectedJSContext +JSContext * -aCx +aJSContext ) { MOZ_ASSERT ( -aCx +aJSContext & & ! -mCCJSContext +mJSContext ) ; -MOZ_ASSERT -( -aCx -- -> -Context -( -) -) -; -mCCJSContext +mJSContext = -aCx +aJSContext ; if ( @@ -1070,12 +1031,7 @@ js : SetContextProfilingStack ( -aCx -- -> -Context -( -) +aJSContext & ProfilingStackRef ( @@ -1085,7 +1041,7 @@ ProfilingStackRef MOZ_ASSERT ( ( -mCCJSContext +mJSContext & & ( @@ -1110,11 +1066,11 @@ void ThreadRegistrationLockedRWOnThread : : -ClearCycleCollectedJSContext +ClearJSContext ( ) { -mCCJSContext +mJSContext = nullptr ; @@ -1136,7 +1092,7 @@ nullptr MOZ_ASSERT ( ( -mCCJSContext +mJSContext & & ( @@ -1167,20 +1123,9 @@ PollJSSampling { if ( -mCCJSContext +mJSContext ) { -JSContext -* -cx -= -mCCJSContext -- -> -Context -( -) -; if ( mJSSampling @@ -1198,7 +1143,7 @@ js : EnableContextProfilingStack ( -cx +mJSContext true ) ; @@ -1214,7 +1159,7 @@ JS : EnableRecordingAllocations ( -cx +mJSContext profiler_add_js_allocation_marker 0 . @@ -1227,7 +1172,7 @@ js : RegisterContextProfilingEventMarker ( -cx +mJSContext profiler_add_js_marker ) ; @@ -1250,7 +1195,7 @@ js : EnableContextProfilingStack ( -cx +mJSContext false ) ; @@ -1266,7 +1211,7 @@ JS : DisableRecordingAllocations ( -cx +mJSContext ) ; } diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index d576a832147f5..686d756c6ceac 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -261,15 +261,6 @@ include " mozilla / -CycleCollectedJSContext -. -h -" -# -include -" -mozilla -/ ExtensionPolicyService . h @@ -4194,51 +4185,6 @@ ProfilerFeature CPUUtilization ; } -if -( -aFeatures -& -ProfilerFeature -: -: -Tracing -) -{ -aFeatures -& -= -~ -ProfilerFeature -: -: -CPUUtilization -; -aFeatures -& -= -~ -ProfilerFeature -: -: -Memory -; -aFeatures -| -= -ProfilerFeature -: -: -NoStackSampling -; -aFeatures -| -= -ProfilerFeature -: -: -JS -; -} return aFeatures ; @@ -24529,36 +24475,6 @@ BufferRangeEnd ) ) ; -if -( -ActivePS -: -: -FeatureTracing -( -aLock -) -) -{ -CycleCollectedJSContext -* -ctx -= -lockedRWFromAnyThread -- -> -GetCycleCollectedJSContext -( -) -; -ctx -- -> -BeginExecutionTracingAsync -( -) -; -} } } } @@ -30160,36 +30076,6 @@ NotifyReceivedJSContext 0 ) ; -if -( -ActivePS -: -: -FeatureTracing -( -aLock -) -) -{ -CycleCollectedJSContext -* -ctx -= -lockedThreadData -- -> -GetCycleCollectedJSContext -( -) -; -ctx -- -> -BeginExecutionTracingAsync -( -) -; -} } } } @@ -31095,42 +30981,6 @@ aLock ) ) { -if -( -ActivePS -: -: -FeatureTracing -( -aLock -) -) -{ -CycleCollectedJSContext -* -ctx -= -lockedThreadData -- -> -GetCycleCollectedJSContext -( -) -; -if -( -ctx -) -{ -ctx -- -> -EndExecutionTracingAsync -( -) -; -} -} lockedThreadData - > @@ -35346,7 +35196,7 @@ IsLockedOnCurrentThread void profiler_set_js_context ( -CycleCollectedJSContext +JSContext * aCx ) @@ -35393,7 +35243,7 @@ aThreadData { aThreadData . -SetCycleCollectedJSContext +SetJSContext ( aCx ) @@ -35457,25 +35307,6 @@ BufferRangeEnd ) ) ; -if -( -ActivePS -: -: -FeatureTracing -( -lock -) -) -{ -aCx -- -> -BeginExecutionTracingAsync -( -) -; -} } } ) @@ -35518,9 +35349,9 @@ OnThreadRef aOnThreadRef ) { -CycleCollectedJSContext +JSContext * -cccx +cx = aOnThreadRef . @@ -35528,30 +35359,19 @@ UnlockedReaderAndAtomicRWOnThreadCRef ( ) . -GetCycleCollectedJSContext +GetJSContext ( ) ; if ( ! -cccx +cx ) { return ; } -JSContext -* -cx -= -cccx -- -> -Context -( -) -; { PSAutoLock lock @@ -35612,7 +35432,7 @@ lock lockedThreadData - > -ClearCycleCollectedJSContext +ClearJSContext ( ) ; @@ -35640,25 +35460,6 @@ lock ) ) ; -if -( -ActivePS -: -: -FeatureTracing -( -lock -) -) -{ -cccx -- -> -EndExecutionTracingAsync -( -) -; -} lockedThreadData - > @@ -35693,7 +35494,7 @@ GetLockedRWOnThread lockedThreadData - > -ClearCycleCollectedJSContext +ClearJSContext ( ) ; diff --git a/tools/profiler/public/GeckoProfiler.h b/tools/profiler/public/GeckoProfiler.h index 2bdfec3fbf8a6..7111beda6b204 100644 --- a/tools/profiler/public/GeckoProfiler.h +++ b/tools/profiler/public/GeckoProfiler.h @@ -144,13 +144,6 @@ define PROFILER_CLEAR_JS_CONTEXT ( ) -namespace -mozilla -{ -class -CycleCollectedJSContext -; -} struct ProfilerBacktrace { @@ -699,10 +692,7 @@ profiler_clear_js_context void profiler_set_js_context ( -mozilla -: -: -CycleCollectedJSContext +JSContext * aCx ) diff --git a/tools/profiler/public/ProfilerState.h b/tools/profiler/public/ProfilerState.h index c04650a7523e3..6fc1e5ea55117 100644 --- a/tools/profiler/public/ProfilerState.h +++ b/tools/profiler/public/ProfilerState.h @@ -739,9 +739,9 @@ sample " ) \ -\ MACRO ( +\ 24 " memory @@ -758,46 +758,10 @@ deallocations per process over -" -\ -" time . " ) -\ -\ -MACRO -( -25 -" -tracing -" -Tracing -\ -" -Instead -of -sampling -periodically -captures -information -about -" -\ -" -every -function -executed -for -the -duration -( -JS -only -) -" -) struct ProfilerFeature { diff --git a/tools/profiler/public/ProfilerThreadRegistrationData.h b/tools/profiler/public/ProfilerThreadRegistrationData.h index 609661760bbed..56357ff8af461 100644 --- a/tools/profiler/public/ProfilerThreadRegistrationData.h +++ b/tools/profiler/public/ProfilerThreadRegistrationData.h @@ -369,13 +369,6 @@ NotProfiled } namespace mozilla -{ -class -CycleCollectedJSContext -; -} -namespace -mozilla : : profiler @@ -526,9 +519,9 @@ nsIThread > mThread ; -CycleCollectedJSContext +JSContext * -mCCJSContext +mJSContext = nullptr ; @@ -1135,21 +1128,9 @@ GetJSContext ( ) const -; -[ -[ -nodiscard -] -] -CycleCollectedJSContext -* -GetCycleCollectedJSContext -( -) -const { return -mCCJSContext +mJSContext ; } protected @@ -1405,15 +1386,15 @@ ThreadRegistrationLockedRWFromAnyThread public : void -SetCycleCollectedJSContext +SetJSContext ( -CycleCollectedJSContext +JSContext * -aCCJSContext +aJSContext ) ; void -ClearCycleCollectedJSContext +ClearJSContext ( ) ; diff --git a/tools/profiler/tests/browser/browser.toml b/tools/profiler/tests/browser/browser.toml index 8f332b779dedc..e6f6c4c9d9215 100644 --- a/tools/profiler/tests/browser/browser.toml +++ b/tools/profiler/tests/browser/browser.toml @@ -83,46 +83,6 @@ html ] [ " -browser_test_feature_jstracing -. -js -" -] -support -- -files -= -[ -" -tracing -. -html -" -] -skip -- -if -= -[ -# -This -features -is -only -enabled -on -nightly -via -MOZ_EXECUTION_TRACING -build -flag -" -! -nightly_build -" -] -[ -" browser_test_feature_multiprocess_capture_with_signal . js diff --git a/tools/profiler/tests/browser/browser_test_feature_jstracing.js b/tools/profiler/tests/browser/browser_test_feature_jstracing.js deleted file mode 100644 index 13116c6b21a86..0000000000000 --- a/tools/profiler/tests/browser/browser_test_feature_jstracing.js +++ /dev/null @@ -1,1072 +0,0 @@ -add_task -( -async -function -test_profile_feature_jstracing -( -) -{ -Assert -. -ok -( -! -Services -. -profiler -. -IsActive -( -) -" -The -profiler -is -not -currently -active -" -) -; -await -startProfiler -( -{ -features -: -[ -" -tracing -" -] -} -) -; -const -url -= -BASE_URL_HTTPS -+ -" -tracing -. -html -" -; -await -BrowserTestUtils -. -withNewTab -( -url -async -contentBrowser -= -> -{ -const -contentPid -= -await -SpecialPowers -. -spawn -( -contentBrowser -[ -] -( -) -= -> -Services -. -appinfo -. -processID -) -; -{ -const -{ -contentThread -} -= -await -stopProfilerNowAndGetThreads -( -contentPid -) -; -const -functionAFrameStringIdx -= -contentThread -. -stringTable -. -indexOf -( -a -( -{ -url -} -: -7 -: -15 -) -) -; -Assert -. -greater -( -functionAFrameStringIdx -0 -" -Found -string -for -' -a -' -method -call -" -) -; -const -functionBFrameStringIdx -= -contentThread -. -stringTable -. -indexOf -( -b -( -{ -url -} -: -10 -: -15 -) -) -; -Assert -. -greater -( -functionBFrameStringIdx -0 -" -Found -string -for -' -b -' -method -call -" -) -; -const -clickEventStringIdx -= -contentThread -. -stringTable -. -indexOf -( -click -) -; -Assert -. -greater -( -clickEventStringIdx -0 -" -Found -string -for -' -click -' -DOM -event -" -) -; -const -customEventStringIdx -= -contentThread -. -stringTable -. -indexOf -( -CustomEvent -) -; -Assert -. -greater -( -customEventStringIdx -0 -" -Found -string -for -' -CustomEvent -' -DOM -event -" -) -; -const -customEventHandlerStringIdx -= -contentThread -. -stringTable -. -indexOf -( -customEventHandler -( -{ -url -} -: -18 -: -71 -) -) -; -Assert -. -greater -( -customEventHandlerStringIdx -0 -" -Found -string -for -' -customEventHandler -' -method -call -" -) -; -const -{ -frameTable -} -= -contentThread -; -const -FRAME_LOCATION_SLOT -= -frameTable -. -schema -. -location -; -const -FRAME_CATEGORY_SLOT -= -frameTable -. -schema -. -category -; -const -FUNCTION_CALL_CATEGORY -= -4 -; -const -EVENT_CATEGORY -= -8 -; -const -functionAFrameIdx -= -frameTable -. -data -. -findIndex -( -frame -= -> -frame -[ -FRAME_LOCATION_SLOT -] -= -= -functionAFrameStringIdx -) -; -Assert -. -greater -( -functionAFrameIdx -0 -" -Found -frame -for -' -a -' -method -call -" -) -; -Assert -. -equal -( -frameTable -. -data -[ -functionAFrameIdx -] -[ -FRAME_CATEGORY_SLOT -] -FUNCTION_CALL_CATEGORY -) -; -const -functionBFrameIdx -= -frameTable -. -data -. -findIndex -( -frame -= -> -frame -[ -FRAME_LOCATION_SLOT -] -= -= -functionBFrameStringIdx -) -; -Assert -. -greater -( -functionBFrameIdx -0 -" -Found -frame -for -' -b -' -method -call -" -) -; -Assert -. -equal -( -frameTable -. -data -[ -functionBFrameIdx -] -[ -FRAME_CATEGORY_SLOT -] -FUNCTION_CALL_CATEGORY -) -; -const -clickEventFrameIdx -= -frameTable -. -data -. -findIndex -( -frame -= -> -frame -[ -FRAME_LOCATION_SLOT -] -= -= -clickEventStringIdx -) -; -Assert -. -greater -( -clickEventFrameIdx -0 -" -Found -frame -for -' -click -' -DOM -event -" -) -; -Assert -. -equal -( -frameTable -. -data -[ -clickEventFrameIdx -] -[ -FRAME_CATEGORY_SLOT -] -EVENT_CATEGORY -) -; -const -customEventFrameIdx -= -frameTable -. -data -. -findIndex -( -frame -= -> -frame -[ -FRAME_LOCATION_SLOT -] -= -= -customEventStringIdx -) -; -Assert -. -greater -( -customEventFrameIdx -0 -" -Found -frame -for -' -CustomEvent -' -DOM -event -" -) -; -Assert -. -equal -( -frameTable -. -data -[ -customEventFrameIdx -] -[ -FRAME_CATEGORY_SLOT -] -EVENT_CATEGORY -) -; -const -customEventHandlerFrameIdx -= -frameTable -. -data -. -findIndex -( -frame -= -> -frame -[ -FRAME_LOCATION_SLOT -] -= -= -customEventHandlerStringIdx -) -; -Assert -. -greater -( -customEventHandlerFrameIdx -0 -" -Found -frame -for -' -b -' -method -call -" -) -; -Assert -. -equal -( -frameTable -. -data -[ -customEventHandlerFrameIdx -] -[ -FRAME_CATEGORY_SLOT -] -FUNCTION_CALL_CATEGORY -) -; -const -{ -stackTable -} -= -contentThread -; -const -STACK_FRAME_SLOT -= -stackTable -. -schema -. -frame -; -const -STACK_PREFIX_SLOT -= -stackTable -. -schema -. -prefix -; -const -functionAFrame -= -stackTable -. -data -. -find -( -stack -= -> -stack -[ -STACK_FRAME_SLOT -] -= -= -functionAFrameIdx -) -; -const -functionBFrame -= -stackTable -. -data -. -find -( -stack -= -> -stack -[ -STACK_FRAME_SLOT -] -= -= -functionBFrameIdx -) -; -const -clickEventFrame -= -stackTable -. -data -. -find -( -stack -= -> -stack -[ -STACK_FRAME_SLOT -] -= -= -clickEventFrameIdx -) -; -const -customEventFrame -= -stackTable -. -data -. -find -( -stack -= -> -stack -[ -STACK_FRAME_SLOT -] -= -= -customEventFrameIdx -) -; -const -customEventHandlerEventFrame -= -stackTable -. -data -. -find -( -stack -= -> -stack -[ -STACK_FRAME_SLOT -] -= -= -customEventHandlerFrameIdx -) -; -Assert -. -equal -( -getCallerNameFromStackIdx -( -contentThread -functionAFrame -[ -STACK_PREFIX_SLOT -] -) -" -load -" -" -' -a -' -was -called -from -' -load -' -" -) -; -Assert -. -equal -( -functionBFrame -[ -STACK_PREFIX_SLOT -] -stackTable -. -data -. -indexOf -( -functionAFrame -) -" -' -b -' -was -called -from -' -a -' -" -) -; -Assert -. -equal -( -clickEventFrame -[ -STACK_PREFIX_SLOT -] -stackTable -. -data -. -indexOf -( -functionBFrame -) -" -' -click -' -event -fired -from -' -b -( -) -' -method -call -" -) -; -Assert -. -equal -( -customEventFrame -[ -STACK_PREFIX_SLOT -] -stackTable -. -data -. -indexOf -( -functionBFrame -) -" -' -CustomEvent -' -event -fired -from -' -b -( -) -' -method -call -" -) -; -Assert -. -equal -( -customEventHandlerEventFrame -[ -STACK_PREFIX_SLOT -] -stackTable -. -data -. -indexOf -( -customEventFrame -) -" -' -customEventHandler -' -function -is -called -because -of -the -CustomEvent -Event -" -) -; -} -} -) -; -} -) -; -function -getCallerNameFromStackIdx -( -thread -stackIdx -) -{ -const -{ -stackTable -frameTable -} -= -thread -; -const -frameIdx -= -stackTable -. -data -[ -stackIdx -] -[ -stackTable -. -schema -. -frame -] -; -return -thread -. -stringTable -[ -frameTable -. -data -[ -frameIdx -] -[ -frameTable -. -schema -. -location -] -] -; -} -function -getInflatedStackLocations -( -thread -sample -) -{ -let -stackTable -= -thread -. -stackTable -; -let -frameTable -= -thread -. -frameTable -; -let -stringTable -= -thread -. -stringTable -; -let -SAMPLE_STACK_SLOT -= -thread -. -samples -. -schema -. -stack -; -let -STACK_PREFIX_SLOT -= -stackTable -. -schema -. -prefix -; -let -STACK_FRAME_SLOT -= -stackTable -. -schema -. -frame -; -let -FRAME_LOCATION_SLOT -= -frameTable -. -schema -. -location -; -let -stackIndex -= -sample -[ -SAMPLE_STACK_SLOT -] -; -let -locations -= -[ -] -; -while -( -stackIndex -! -= -= -null -) -{ -let -stackEntry -= -stackTable -. -data -[ -stackIndex -] -; -let -frame -= -frameTable -. -data -[ -stackEntry -[ -STACK_FRAME_SLOT -] -] -; -locations -. -push -( -stringTable -[ -frame -[ -FRAME_LOCATION_SLOT -] -] -) -; -stackIndex -= -stackEntry -[ -STACK_PREFIX_SLOT -] -; -} -return -locations -. -reverse -( -) -; -} diff --git a/tools/profiler/tests/browser/tracing.html b/tools/profiler/tests/browser/tracing.html deleted file mode 100644 index e174895e8c8a5..0000000000000 --- a/tools/profiler/tests/browser/tracing.html +++ /dev/null @@ -1,158 +0,0 @@ -< -! -DOCTYPE -html -> -< -html -> -< -head -> -< -meta -charset -= -" -utf -- -8 -" -> -< -title -> -Do -some -naive -JS -executions -< -/ -title -> -< -script -> -function -a -( -) -{ -b -( -) -; -} -function -b -( -) -{ -document -. -body -. -setAttribute -( -" -foo -" -" -bar -" -) -; -navigator -. -userAgent -; -window -. -dispatchEvent -( -new -Event -( -" -CustomEvent -" -) -) -; -document -. -body -. -click -( -) -; -} -window -. -onload -= -a -; -window -. -onclick -= -( -) -= -> -console -. -log -( -" -click -! -" -) -; -window -. -addEventListener -( -" -CustomEvent -" -function -customEventHandler -( -) -{ -} -) -; -< -/ -script -> -< -/ -head -> -< -body -> -Execute -some -naive -code -which -should -be -traced -. -< -/ -body -> -< -/ -html -> diff --git a/tools/profiler/tests/gtest/GeckoProfiler.cpp b/tools/profiler/tests/gtest/GeckoProfiler.cpp index ba4341f25d555..471950f84e563 100644 --- a/tools/profiler/tests/gtest/GeckoProfiler.cpp +++ b/tools/profiler/tests/gtest/GeckoProfiler.cpp @@ -2656,14 +2656,14 @@ decltype ( aData . -SetCycleCollectedJSContext +SetJSContext ( std : : declval < -CycleCollectedJSContext +JSContext * > ( @@ -2676,7 +2676,7 @@ void ; aData . -ClearCycleCollectedJSContext +ClearJSContext ( ) ; @@ -9784,15 +9784,6 @@ filters " } ; -availableFeatures -& -= -~ -ProfilerFeature -: -: -Tracing -; profiler_start ( PowerOfTwo32 diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp index 36c5834a96de9..fbcd990835ecc 100644 --- a/xpcom/base/CycleCollectedJSContext.cpp +++ b/xpcom/base/CycleCollectedJSContext.cpp @@ -3865,143 +3865,6 @@ return NS_OK ; } -# -ifdef -MOZ_EXECUTION_TRACING -void -CycleCollectedJSContext -: -: -BeginExecutionTracingAsync -( -) -{ -mOwningThread -- -> -Dispatch -( -NS_NewRunnableFunction -( -" -CycleCollectedJSContext -: -: -BeginExecutionTracingAsync -" -[ -] -{ -CycleCollectedJSContext -* -ccjs -= -CycleCollectedJSContext -: -: -Get -( -) -; -if -( -ccjs -) -{ -JS_TracerBeginTracing -( -ccjs -- -> -Context -( -) -) -; -} -} -) -) -; -} -void -CycleCollectedJSContext -: -: -EndExecutionTracingAsync -( -) -{ -mOwningThread -- -> -Dispatch -( -NS_NewRunnableFunction -( -" -CycleCollectedJSContext -: -: -EndExecutionTracingAsync -" -[ -] -{ -CycleCollectedJSContext -* -ccjs -= -CycleCollectedJSContext -: -: -Get -( -) -; -if -( -ccjs -) -{ -JS_TracerEndTracing -( -ccjs -- -> -Context -( -) -) -; -} -} -) -) -; -} -# -else -void -CycleCollectedJSContext -: -: -BeginExecutionTracingAsync -( -) -{ -} -void -CycleCollectedJSContext -: -: -EndExecutionTracingAsync -( -) -{ -} -# -endif class FinalizationRegistryCleanup : diff --git a/xpcom/base/CycleCollectedJSContext.h b/xpcom/base/CycleCollectedJSContext.h index 59a5879547286..1bc99556c2c6b 100644 --- a/xpcom/base/CycleCollectedJSContext.h +++ b/xpcom/base/CycleCollectedJSContext.h @@ -967,16 +967,6 @@ supported ) ; } -void -BeginExecutionTracingAsync -( -) -; -void -EndExecutionTracingAsync -( -) -; private : JSObject