diff --git a/devtools/client/performance-new/shared/utils.js b/devtools/client/performance-new/shared/utils.js index 0ee620274c105..0399131828413 100644 --- a/devtools/client/performance-new/shared/utils.js +++ b/devtools/client/performance-new/shared/utils.js @@ -3245,6 +3245,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 " @@ -3826,40 +3865,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 eae8292a1dbf8..8a58cc0fe1011 100644 --- a/devtools/server/actors/tracer.js +++ b/devtools/server/actors/tracer.js @@ -1314,6 +1314,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 3953c2c74afed..fde9179e4a92d 100644 --- a/dom/debugger/CallbackDebuggerNotification.h +++ b/dom/debugger/CallbackDebuggerNotification.h @@ -353,16 +353,22 @@ CallbackDebuggerNotificationPhase aPhase ) { -# -ifdef -MOZ_EXECUTION_TRACING +auto +manager += +DebuggerNotificationManager +: +: +ForDispatch +( +mDebuggeeGlobal +) +; if ( MOZ_UNLIKELY ( -profiler_is_active -( -) +manager ) ) { @@ -575,28 +581,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 a5c848e6ba1c6..157106e2713b5 100644 --- a/dom/debugger/EventCallbackDebuggerNotification.cpp +++ b/dom/debugger/EventCallbackDebuggerNotification.cpp @@ -350,9 +350,6 @@ if notificationType ) { -# -ifdef -MOZ_EXECUTION_TRACING CycleCollectedJSContext * ccjcx @@ -426,16 +423,6 @@ get ; } } -# -endif -if -( -MOZ_UNLIKELY -( -aManager -) -) -{ aManager - > @@ -473,7 +460,6 @@ aPhase } } } -} / / namespace diff --git a/dom/debugger/EventCallbackDebuggerNotification.h b/dom/debugger/EventCallbackDebuggerNotification.h index 00a946ccbf85e..2f1726339b8fe 100644 --- a/dom/debugger/EventCallbackDebuggerNotification.h +++ b/dom/debugger/EventCallbackDebuggerNotification.h @@ -441,6 +441,14 @@ ForDispatch mDebuggeeGlobal ) ; +if +( +MOZ_UNLIKELY +( +manager +) +) +{ DispatchToManager ( manager @@ -448,6 +456,7 @@ aPhase ) ; } +} MOZ_CAN_RUN_SCRIPT void DispatchToManager diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp index c1be226da7242..3689b4ea01b34 100644 --- a/dom/events/EventListenerManager.cpp +++ b/dom/events/EventListenerManager.cpp @@ -8152,11 +8152,6 @@ ChromeUtils IsDevToolsOpened ( ) -| -| -profiler_is_active -( -) ) { dbgGuard diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 35828e6825012..edc658a755e31 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -12220,11 +12220,7 @@ true { PROFILER_SET_JS_CONTEXT ( -context -. -get -( -) +cx ) ; { diff --git a/js/moz.configure b/js/moz.configure index 02864b8431df6..4ee0e9a600a5f 100644 --- a/js/moz.configure +++ b/js/moz.configure @@ -2961,99 +2961,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 e32049a0334ac..91851e3c13890 100644 --- a/js/public/Debug.h +++ b/js/public/Debug.h @@ -151,30 +151,12 @@ include " mozilla / -BaseProfilerUtils -. -h -" -# -include -" -mozilla -/ MemoryReporting . h " # include -" -mozilla -/ -Vector -. -h -" -# -include < utility > @@ -432,586 +414,6 @@ char16_t label ) ; -# -ifdef -MOZ_EXECUTION_TRACING -/ -/ -This -will -begin -execution -tracing -for -the -JSContext -i -. -e -. -this -will -begin -/ -/ -recording -every -entrance -into -/ -exit -from -a -function -for -the -given -context -. -/ -/ -The -trace -can -be -read -via -JS_TracerSnapshotTrace -and -populates -the -/ -/ -ExecutionTrace -struct -defined -below -. -extern -JS_PUBLIC_API -bool -JS_TracerBeginTracing -( -JSContext -* -cx -) -; -/ -/ -This -ends -execution -tracing -for -the -JSContext -discards -the -tracing -/ -/ -buffers -and -clears -some -caches -used -for -tracing -. -JS_TracerSnapshotTrace -/ -/ -should -be -called -* -before -* -JS_TracerEndTracing -if -you -want -to -read -the -trace -/ -/ -data -for -this -JSContext -. -extern -JS_PUBLIC_API -bool -JS_TracerEndTracing -( -JSContext -* -cx -) -; -namespace -JS -{ -/ -/ -This -is -populated -by -JS_TracerSnapshotTrace -and -just -represent -a -minimal -/ -/ -structure -for -natively -representing -an -execution -trace -across -a -range -of -/ -/ -JSContexts -( -see -below -) -. -The -core -of -the -trace -is -an -array -of -events -each -of -/ -/ -which -is -a -tagged -union -with -data -corresponding -to -that -event -. -Events -can -/ -/ -also -point -into -various -tables -and -store -all -of -their -string -data -in -a -/ -/ -contiguous -UTF -- -8 -stringBuffer -( -each -string -is -null -- -terminated -within -the -/ -/ -buffer -. -) -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 -{ -/ -/ -For -FunctionEnter -/ -FunctionLeave -struct -{ -ImplementationType -implementation -; -/ -/ -1 -- -origin -line -number -of -the -function -uint32_t -lineNumber -; -/ -/ -1 -- -origin -column -of -the -function -uint32_t -column -; -/ -/ -Keys -into -the -thread -' -s -scriptUrls -HashMap -. -This -key -can -be -missing -/ -/ -from -the -HashMap -although -ideally -that -situation -is -rare -( -it -is -/ -/ -more -likely -in -long -running -traces -with -* -many -* -unique -functions -/ -/ -and -/ -or -scripts -) -uint32_t -scriptId -; -/ -/ -Keys -into -the -thread -' -s -atoms -HashMap -. -This -key -can -be -missing -from -/ -/ -the -HashMap -as -well -( -see -comment -above -scriptId -) -uint32_t -functionNameId -; -} -functionEvent -; -/ -/ -For -LabelEnter -/ -LabelLeave -struct -{ -size_t -label -; -/ -/ -Indexes -directly -into -the -trace -' -s -stringBuffer -} -labelEvent -; -} -; -/ -/ -Milliseconds -since -process -creation -double -time -; -} -; -struct -TracedJSContext -{ -mozilla -: -: -baseprofiler -: -: -BaseProfilerThreadId -id -; -/ -/ -Maps -ids -to -indices -into -the -trace -' -s -stringBuffer -mozilla -: -: -HashMap -< -uint32_t -size_t -> -scriptUrls -; -/ -/ -Similar -to -scriptUrls -mozilla -: -: -HashMap -< -uint32_t -size_t -> -atoms -; -mozilla -: -: -Vector -< -TracedEvent -> -events -; -} -; -mozilla -: -: -Vector -< -char -> -stringBuffer -; -/ -/ -This -will -be -populated -with -an -entry -for -each -context -which -had -tracing -/ -/ -enabled -via -JS_TracerBeginTracing -. -mozilla -: -: -Vector -< -TracedJSContext -> -contexts -; -} -; -} -/ -/ -namespace -JS -/ -/ -Captures -the -trace -for -all -JSContexts -in -the -process -which -are -currently -/ -/ -tracing -. -extern -JS_PUBLIC_API -bool -JS_TracerSnapshotTrace -( -JS -: -: -ExecutionTrace -& -trace -) -; -# -endif -/ -* -MOZ_EXECUTION_TRACING -* -/ namespace JS { diff --git a/js/public/friend/ErrorNumbers.msg b/js/public/friend/ErrorNumbers.msg index 2f8297ddbd353..725e0753a2e5b 100644 --- a/js/public/friend/ErrorNumbers.msg +++ b/js/public/friend/ErrorNumbers.msg @@ -9434,6 +9434,24 @@ tracing buffer " ) +MSG_DEF +( +JSMSG_NATIVE_TRACING_MUST_BE_ENABLED +0 +JSEXN_ERR +" +Cannot +collect +a +native +trace +without +setting +nativeTracing +to +true +" +) / / Testing diff --git a/js/src/debugger/Debugger.cpp b/js/src/debugger/Debugger.cpp index 5aa17756bd7fd..f4701841c4bfa 100644 --- a/js/src/debugger/Debugger.cpp +++ b/js/src/debugger/Debugger.cpp @@ -472,9 +472,6 @@ h for DebuggerEnvironment # -ifdef -MOZ_EXECUTION_TRACING -# include " debugger @@ -487,15 +484,6 @@ h / for ExecutionTracer -: -: -onEnterFrame -ExecutionTracer -: -: -onLeaveFrame -# -endif # include " @@ -4365,6 +4353,10 @@ shouldAvoidSideEffects ( false ) +nativeTracing +( +false +) observedGCs ( cx @@ -7124,9 +7116,6 @@ AbstractFramePtr frame ) { -# -ifdef -MOZ_EXECUTION_TRACING if ( cx @@ -7159,8 +7148,6 @@ false ; } } -# -endif return Debugger : @@ -7249,9 +7236,6 @@ AbstractFramePtr frame ) { -# -ifdef -MOZ_EXECUTION_TRACING if ( cx @@ -7284,8 +7268,6 @@ false ; } } -# -endif / / Don @@ -8732,9 +8714,6 @@ bool frameOk ) { -# -ifdef -MOZ_EXECUTION_TRACING if ( cx @@ -8767,8 +8746,6 @@ false ; } } -# -endif MOZ_ASSERT_IF ( ! @@ -25207,6 +25184,15 @@ const { if ( +nativeTracing +) +{ +return +Observing +; +} +if +( ! ! getHook @@ -30755,6 +30741,16 @@ dbg { } bool +getNativeTracing +( +) +; +bool +setNativeTracing +( +) +; +bool getOnDebuggerStatement ( ) @@ -31014,6 +31010,11 @@ disableUnlimitedStacksCapturing ( ) ; +bool +collectNativeTrace +( +) +; using Method = @@ -31799,6 +31800,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 ( ) @@ -37262,20 +37564,6 @@ realm hasDebuggers ( ) -& -& -! -global -- -> -realm -( -) -- -> -isTracingExecution -( -) ) { global @@ -47956,6 +48244,14 @@ properties JS_DEBUG_PSGS ( " +nativeTracing +" +getNativeTracing +setNativeTracing +) +JS_DEBUG_PSGS +( +" onDebuggerStatement " getOnDebuggerStatement @@ -48269,10 +48565,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 : @@ -51394,7 +51862,10 @@ Debugger : : methods -nullptr +Debugger +: +: +static_properties Debugger : : diff --git a/js/src/debugger/Debugger.h b/js/src/debugger/Debugger.h index 93ca01874a10a..a4957fe84e2d6 100644 --- a/js/src/debugger/Debugger.h +++ b/js/src/debugger/Debugger.h @@ -4482,6 +4482,20 @@ ShouldAvoidSideEffects bool shouldAvoidSideEffects ; +/ +/ +Whether +to +enable +native +tracing +on +the +Debuggee +. +bool +nativeTracing +; template < typename diff --git a/js/src/debugger/ExecutionTracer.cpp b/js/src/debugger/ExecutionTracer.cpp index 4485dd32ad1e1..d7b21b763b29b 100644 --- a/js/src/debugger/ExecutionTracer.cpp +++ b/js/src/debugger/ExecutionTracer.cpp @@ -198,36 +198,8 @@ LabelEnter LabelLeave } ; -mozilla -: -: -Vector -< -ExecutionTracer -* -> -ExecutionTracer -: -: -globalInstances -; -Mutex -ExecutionTracer -: -: -globalInstanceLock -( -mutexid -: -: -ExecutionTracerGlobalLock -) -; static -JS -: -: -ExecutionTrace +ExecutionTracer : : ImplementationType @@ -247,10 +219,7 @@ isBaselineFrame ) { return -JS -: -: -ExecutionTrace +ExecutionTracer : : ImplementationType @@ -269,10 +238,7 @@ isRematerializedFrame ) { return -JS -: -: -ExecutionTrace +ExecutionTracer : : ImplementationType @@ -291,10 +257,7 @@ isWasmDebugFrame ) { return -JS -: -: -ExecutionTrace +ExecutionTracer : : ImplementationType @@ -304,10 +267,7 @@ Wasm ; } return -JS -: -: -ExecutionTrace +ExecutionTracer : : ImplementationType @@ -506,40 +466,6 @@ return true ; } -static -double -GetNowMilliseconds -( -) -{ -return -( -mozilla -: -: -TimeStamp -: -: -Now -( -) -- -mozilla -: -: -TimeStamp -: -: -ProcessCreation -( -) -) -. -ToMilliseconds -( -) -; -} void ExecutionTracer : @@ -1215,7 +1141,7 @@ inlineData_ . write ( -GetNowMilliseconds +PRMJ_Now ( ) ) @@ -1237,15 +1163,6 @@ AbstractFramePtr frame ) { -LockGuard -< -Mutex -> -guard -( -bufferLock_ -) -; DebuggerFrameType type = @@ -1272,19 +1189,6 @@ frame isFunctionFrame ( ) -& -& -! -frame -. -callee -( -) -- -> -isSelfHostedBuiltin -( -) ) { inlineData_ @@ -1345,15 +1249,6 @@ AbstractFramePtr frame ) { -LockGuard -< -Mutex -> -guard -( -bufferLock_ -) -; DebuggerFrameType type = @@ -1380,19 +1275,6 @@ frame isFunctionFrame ( ) -& -& -! -frame -. -callee -( -) -- -> -isSelfHostedBuiltin -( -) ) { inlineData_ @@ -1459,15 +1341,6 @@ CharType eventType ) { -LockGuard -< -Mutex -> -guard -( -bufferLock_ -) -; inlineData_ . beginWritingEntry @@ -1502,7 +1375,7 @@ inlineData_ . write ( -GetNowMilliseconds +PRMJ_Now ( ) ) @@ -1533,15 +1406,6 @@ CharType eventType ) { -LockGuard -< -Mutex -> -guard -( -bufferLock_ -) -; inlineData_ . beginWritingEntry @@ -1576,7 +1440,7 @@ inlineData_ . write ( -GetNowMilliseconds +PRMJ_Now ( ) ) @@ -1588,29 +1452,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 @@ -1618,12 +1500,6 @@ MOZ_ASSERT kind = = -JS -: -: -ExecutionTrace -: -: EventKind : : @@ -1633,37 +1509,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_ @@ -1671,10 +1546,6 @@ inlineData_ read ( & -event -. -functionEvent -. column ) ; @@ -1683,11 +1554,7 @@ inlineData_ read ( & -event -. -functionEvent -. -scriptId +url ) ; inlineData_ @@ -1695,11 +1562,7 @@ inlineData_ read ( & -event -. -functionEvent -. -functionNameId +functionName ) ; inlineData_ @@ -1715,80 +1578,589 @@ 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 -: +! +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 : : @@ -1798,38 +2170,175 @@ LabelEnter kind = = +EventKind +: +: +LabelLeave +) +; +JS +: +: +Rooted +< +JSObject +* +> +obj +( +cx +NewDenseEmptyArray +( +cx +) +) +; +if +( +! +obj +) +{ +return +false +; +} +if +( +! +NewbornArrayPush +( +cx +obj +Int32Value +( +int32_t +( +kind +) +) +) +) +{ +return +false +; +} +JS +: +: +Rooted +< +JSString +* +> +eventType +( +cx +) +; +if +( +! +inlineData_ +. +readString +( +cx +& +eventType +) +) +{ +return +false +; +} +if +( +! +NewbornArrayPush +( +cx +obj +StringValue +( +eventType +) +) +) +{ +return +false +; +} +uint64_t +time +; +inlineData_ +. +read +( +& +time +) +; +double +timeDouble += +time +/ +double +( +PRMJ_USEC_PER_MSEC +) +; +if +( +! +NewbornArrayPush +( +cx +obj +DoubleValue +( +timeDouble +) +) +) +{ +return +false +; +} JS : : -ExecutionTrace -: -: -EventKind +Rooted +< +JS : : -LabelLeave +Value +> +objVal +( +cx +ObjectValue +( +* +obj +) ) -; -event -. -kind -= -kind -; -size_t -index ; if ( ! -inlineData_ -. -readString +NewbornArrayPush ( -scratchBuffer -stringBuffer -& -index +cx +events +objVal ) ) { @@ -1837,31 +2346,6 @@ return false ; } -event -. -labelEvent -. -label -= -index -; -double -time -; -inlineData_ -. -read -( -& -time -) -; -event -. -time -= -time -; return true ; @@ -1872,33 +2356,18 @@ ExecutionTracer : readInlineEntry ( -mozilla -: -: -Vector -< +JSContext +* +cx JS : : -ExecutionTrace -: -: -TracedEvent -> -& -events -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector +Handle < -char +JSObject +* > -& -stringBuffer +events ) { uint8_t @@ -1926,234 +2395,67 @@ InlineEntryType : StackFunctionEnter : -case -InlineEntryType -: -: -StackFunctionLeave -: -{ -JS -: -: -ExecutionTrace -: -: -EventKind -kind -; -if -( -InlineEntryType +return +readStackFunctionEnter ( -entryType -) -= -= -InlineEntryType -: -: -StackFunctionEnter +cx +events ) -{ -kind -= -JS -: -: -ExecutionTrace -: -: -EventKind -: -: -FunctionEnter -; -} -else -{ -kind -= -JS -: -: -ExecutionTrace -: -: -EventKind -: -: -FunctionLeave ; -} -JS -: +case +InlineEntryType : -ExecutionTrace : +StackFunctionLeave : -TracedEvent -event -; -if -( -! -readFunctionFrame -( -kind -event -) -) -{ return -false -; -} -if +readStackFunctionLeave ( -! +cx events -. -append -( -std -: -: -move -( -event ) -) -) -{ -return -false -; -} -return -true ; -} case InlineEntryType : : LabelEnter : -case -InlineEntryType -: -: -LabelLeave -: -{ -JS -: -: -ExecutionTrace -: -: -EventKind -kind -; -if -( -InlineEntryType +return +readLabel ( -entryType -) -= -= -InlineEntryType -: -: -LabelEnter -) -{ -kind -= -JS -: -: -ExecutionTrace -: -: +cx +events EventKind : : LabelEnter +) ; -} -else -{ -kind -= -JS -: -: -ExecutionTrace -: -: -EventKind +case +InlineEntryType : : LabelLeave -; -} -JS -: -: -ExecutionTrace : -: -TracedEvent -event -; -if -( -! -readLabel -( -kind -event -scratchBuffer -stringBuffer -) -) -{ return -false -; -} -if +readLabel ( -! +cx events -. -append -( -std +EventKind : : -move -( -event -) -) -) -{ -return -false -; -} -return -true +LabelLeave +) ; -} default : return -false +ThrowTracingReadFailed +( +cx +) ; } } @@ -2163,38 +2465,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 @@ -2222,127 +2513,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 @@ -2350,33 +2549,18 @@ ExecutionTracer : readInlineEntries ( -mozilla -: -: -Vector -< +JSContext +* +cx JS : : -ExecutionTrace -: -: -TracedEvent -> -& -events -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector +Handle < -char +JSObject +* > -& -stringBuffer +events ) { while @@ -2399,9 +2583,8 @@ if ! readInlineEntry ( +cx events -scratchBuffer -stringBuffer ) ) { @@ -2432,38 +2615,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 @@ -2486,10 +2658,9 @@ if ! readOutOfLineEntry ( +cx scriptUrls atoms -scratchBuffer -stringBuffer ) ) { @@ -2518,53 +2689,178 @@ bool ExecutionTracer : : -getNativeTrace +getTrace ( +JSContext +* +cx +JS +: +: +Handle +< +JSObject +* +> +result +) +{ +/ +/ +TODO +: +the +long +term +goal +for +traces +is +to +be +able +to +collect +this +data +/ +/ +live +while +the +tracer +is +still +capturing +as +well +as +all +at +once +which +/ +/ +this +method +covers +. +Bug +1910182 +tracks +the +next +step +for +the +live +tracing +/ +/ +case +which +may +in +the +end +involve +a +similar +method +to +this +being +called +/ +/ +from +a +separate +process +than +the +process +containing +the +traced +JSContext +. +/ +/ +If +we +go +down +that +route +the +buffer +would +be +shared +via +a +shmem +. JS : : -ExecutionTrace +Rooted +< +JSObject +* +> +scriptUrls +( +cx +NewPlainObject +( +cx +) +) +; +if +( +! +scriptUrls +) +{ +return +false +; +} +JS : : -TracedJSContext -& -context -TracingScratchBuffer -& -scratchBuffer -mozilla +Rooted +< +JS : : -Vector -< -char -> -& -stringBuffer -) -{ -LockGuard -< -Mutex +Value > -guard +scriptUrlsVal ( -bufferLock_ +cx +ObjectValue +( +* +scriptUrls +) ) ; if ( ! -readOutOfLineEntries +JS_DefineProperty ( -context -. -scriptUrls -context -. -atoms -scratchBuffer -stringBuffer +cx +result +" +scriptURLs +" +scriptUrlsVal +JSPROP_ENUMERATE ) ) { @@ -2572,137 +2868,131 @@ return false ; } -if +JS +: +: +Rooted +< +JSObject +* +> +atoms ( -! -readInlineEntries +cx +NewPlainObject ( -context -. -events -scratchBuffer -stringBuffer +cx +) ) +; +if +( +! +atoms ) { return false ; } -return -true -; -} -bool -ExecutionTracer +JS : : -getNativeTraceForAllContexts -( +Rooted +< JS : : -ExecutionTrace -& -trace -) -{ -LockGuard -< -Mutex +Value > -guard +atomsVal +( +cx +ObjectValue ( -globalInstanceLock +* +atoms +) ) ; -TracingScratchBuffer -scratchBuffer -; -for +if ( -ExecutionTracer -* -tracer -: -globalInstances +! +JS_DefineProperty +( +cx +result +" +atoms +" +atomsVal +JSPROP_ENUMERATE +) ) { +return +false +; +} JS : : -ExecutionTrace -: -: -TracedJSContext +Rooted +< +JSObject * -context -= -nullptr -; -for +> +events ( -JS -: -: -ExecutionTrace -: -: -TracedJSContext -& -t -: -trace -. -contexts -) -{ -if +cx +NewDenseEmptyArray ( -t -. -id -= -= -tracer -- -> -threadId_ +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 ) ) { @@ -2710,49 +3000,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 ) ) { @@ -2760,7 +3029,6 @@ return false ; } -} return true ; @@ -2777,11 +3045,6 @@ char16_t label ) { -CHECK_THREAD -( -cx -) -; if ( cx @@ -2825,11 +3088,6 @@ char label ) { -CHECK_THREAD -( -cx -) -; if ( cx @@ -2873,11 +3131,6 @@ char16_t label ) { -CHECK_THREAD -( -cx -) -; if ( cx @@ -2921,11 +3174,6 @@ char label ) { -CHECK_THREAD -( -cx -) -; if ( cx @@ -2957,70 +3205,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 13c11be8981f4..a0170f0faabc3 100644 --- a/js/src/debugger/ExecutionTracer.h +++ b/js/src/debugger/ExecutionTracer.h @@ -132,18 +132,6 @@ include " mozilla / -BaseProfilerUtils -. -h -" -/ -/ -profiler_current_thread_id -# -include -" -mozilla -/ MathAlgorithms . h @@ -188,15 +176,6 @@ h " # include -" -mozilla -/ -TimeStamp -. -h -" -# -include < limits > @@ -247,21 +226,6 @@ include " js / -Debug -. -h -" -/ -/ -JS -: -: -ExecutionTrace -# -include -" -js -/ RootingAPI . h @@ -339,18 +303,6 @@ TwoByte UTF8 } ; -using -TracingScratchBuffer -= -mozilla -: -: -Vector -< -char -512 -> -; / / TODO @@ -686,47 +638,6 @@ uncommittedReadHead_ = 0 ; -bool -ensureScratchBufferSize -( -TracingScratchBuffer -& -scratchBuffer -size_t -requiredSize -) -{ -if -( -scratchBuffer -. -length -( -) -> -= -requiredSize -) -{ -return -true -; -} -return -scratchBuffer -. -growByUninitialized -( -requiredSize -- -scratchBuffer -. -length -( -) -) -; -} public : ~ @@ -1739,47 +1650,21 @@ T ) ; } -/ -/ -Reads -a -string -from -our -buffer -into -the -stringBuffer -. -Converts -everything -/ -/ -to -null -- -terminated -UTF -- -8 bool readString ( -TracingScratchBuffer -& -scratchBuffer -mozilla +JSContext +* +cx +JS : : -Vector +MutableHandle < -char -> -& -stringBuffer -size_t +JSString * -index +> +result ) { uint8_t @@ -1808,15 +1693,6 @@ read length ) ; -* -index -= -stringBuffer -. -length -( -) -; if ( length @@ -1825,28 +1701,26 @@ length 0 ) { -if -( -! -stringBuffer +result . -append +set ( -' -\ -0 -' +JS_GetEmptyString +( +cx ) ) -{ -return -false ; -} return true ; } +JSLinearString +* +str += +nullptr +; if ( encoding @@ -1856,42 +1730,54 @@ TracerStringEncoding : : UTF8 +| +| +encoding += += +TracerStringEncoding +: +: +Latin1 ) { -size_t -reserveLength -= +UniquePtr +< +unsigned +char +[ +] +JS +: +: +FreePolicy +> +chars +( +cx +- +> +make_pod_arena_array +< +unsigned +char +> +( +StringBufferArena length -+ -1 +) +) ; if ( ! -stringBuffer -. -growByUninitialized -( -reserveLength -) +chars ) { return false ; } -char -* -writePtr -= -stringBuffer -. -end -( -) -- -reserveLength -; readBytes ( reinterpret_cast @@ -1900,23 +1786,15 @@ uint8_t * > ( -writePtr +chars +. +get +( ) -length ) -; -writePtr -[ length -] -= -' -\ -0 -' +) ; -} -else if ( encoding @@ -1925,196 +1803,55 @@ encoding TracerStringEncoding : : -Latin1 +UTF8 ) { -if -( -! -ensureScratchBufferSize +str += +NewStringCopyUTF8N ( -scratchBuffer -length -) -) -{ -return -false -; -} -readBytes +cx +JS +: +: +UTF8Chars ( reinterpret_cast < -uint8_t +char * > ( -scratchBuffer +chars . -begin +get ( ) ) length ) +) ; -/ -/ -A -single -latin -- -1 -code -point -maps -to -either -1 -or -2 -UTF -- -8 -code -units -. -/ -/ -The -+ -1 -is -for -the -null -terminator -. -size_t -reserveLength +} +else +{ +str = -length -* -2 -+ -1 -; -if +NewString +< +CanGC +> ( -! -stringBuffer -. -reserve +cx +std +: +: +move ( -stringBuffer -. +chars +) length -( ) -+ -reserveLength -) -) -{ -return -false -; -} -char -* -writePtr -= -stringBuffer -. -end -( -) -; -size_t -convertedLength -= -mozilla -: -: -ConvertLatin1toUtf8 -( -mozilla -: -: -Span -< -const -char -> -( -scratchBuffer -. -begin -( -) -length -) -mozilla -: -: -Span -< -char -> -( -writePtr -reserveLength -) -) -; -writePtr -[ -convertedLength -] -= -0 -; -/ -/ -We -reserved -above -which -just -grows -the -capacity -but -not -the -length -. -/ -/ -This -just -commits -the -exact -length -increase -. -if -( -! -stringBuffer -. -growByUninitialized -( -convertedLength -+ -1 -) -) -{ -return -false ; } } @@ -2131,19 +1868,35 @@ TracerStringEncoding TwoByte ) ; -if +UniquePtr +< +char16_t +[ +] +JS +: +: +FreePolicy +> +chars ( -! -ensureScratchBufferSize +cx +- +> +make_pod_arena_array +< +char16_t +> ( -scratchBuffer +StringBufferArena length -* -sizeof -( -char16_t ) ) +; +if +( +! +chars ) { return @@ -2152,18 +1905,15 @@ false } readBytes ( -reinterpret_cast -< +( uint8_t * -> -( -scratchBuffer +) +chars . -begin +get ( ) -) length * sizeof @@ -2172,186 +1922,42 @@ char16_t ) ) ; -/ -/ -Non -- -surrogate -- -paired -single -UTF -- -16 -code -unit -maps -to -1 -to -3 -UTF -- -8 -/ -/ -code -units -. -Surrogate -paired -UTF -- -16 -code -units -map -to -4 -to -6 -UTF -- -8 -/ -/ -code -units -. -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 -; -/ -/ -We -reserved -above -which -just -grows -the -capacity -but -not -the -length -. -/ -/ -This -just -commits -the -exact -length -increase -. +} if ( ! -stringBuffer -. -growByUninitialized -( -convertedLength -+ -1 -) +str ) { return false ; } -} +result +. +set +( +str +) +; return true ; @@ -2552,58 +2158,48 @@ details class ExecutionTracer { -private +public : -/ -/ -The -fields -below -should -only -be -accessed -while -we -hold -the -lock -. -static -Mutex -globalInstanceLock -MOZ_UNANNOTATED -; -static -mozilla -: -: -Vector -< -ExecutionTracer -* -> -globalInstances +enum +class +EventKind +{ +FunctionEnter += +0 +FunctionLeave += +1 +LabelEnter += +2 +LabelLeave += +3 +} ; -/ -/ -The -buffers -below -should -only -be -accessed -while -we -hold -the -lock -. -Mutex -bufferLock_ -MOZ_UNANNOTATED +enum +class +ImplementationType +: +uint8_t +{ +Interpreter += +0 +Baseline += +1 +Ion += +2 +Wasm += +3 +} ; +private +: / / This @@ -2704,86 +2300,6 @@ outOfLineData_ OutOfLineDataBuffer outOfLineData_ ; -/ -/ -This -is -just -an -ID -that -allows -the -profiler -to -easily -correlate -the -trace -/ -/ -for -a -given -context -with -the -correct -thread -in -the -output -profile -. -/ -/ -We -' -re -operating -on -the -assumption -that -there -is -one -JSContext -per -thread -/ -/ -which -should -be -true -enough -for -our -uses -in -Firefox -but -doesn -' -t -have -to -/ -/ -be -true -everywhere -. -mozilla -: -: -baseprofiler -: -: -BaseProfilerThreadId -threadId_ -; void writeScriptUrl ( @@ -2873,318 +2389,205 @@ AbstractFramePtr frame ) ; -/ -/ -The -below -functions -read -data -from -the -inlineData_ -and -outOfLineData_ -ring -/ -/ -buffers -into -structs -to -be -consumed -by -clients -of -the -/ -/ -JS_TracerSnapshotTrace -API -. 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 ( ! @@ -3213,21 +2616,6 @@ return false ; } -if -( -! -globalInstances -. -append -( -this -) -) -{ -return -false -; -} return true ; @@ -3302,81 +2690,44 @@ it / into a -native -struct +JS +object . For -more -information -about +the +format +of this -struct +object see / / js / -public +src +/ +doc / -Debug +Debugger +/ +Debugger . -h +md bool -getNativeTrace +getTrace ( +JSContext +* +cx JS : : -ExecutionTrace -: -: -TracedJSContext -& -context -TracingScratchBuffer -& -scratchBuffer -mozilla -: -: -Vector +Handle < -char +JSObject +* > -& -stringBuffer -) -; -/ -/ -Calls -getNativeTrace -for -every -JSContext -in -the -process -populating -the -/ -/ -provided -ExecutionTrace -with -the result -. -static -bool -getNativeTraceForAllContexts -( -JS -: -: -ExecutionTrace -& -trace ) ; } diff --git a/js/src/debugger/moz.build b/js/src/debugger/moz.build index b00bf82e958b1..e8b55ed56008a 100644 --- a/js/src/debugger/moz.build +++ b/js/src/debugger/moz.build @@ -243,6 +243,11 @@ Environment cpp " " +ExecutionTracer +. +cpp +" +" Frame . cpp @@ -268,21 +273,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..9ac80abdedb08 --- /dev/null +++ b/js/src/jit-test/tests/debug/ExecutionTracer-collectNativeTrace.js @@ -0,0 +1,431 @@ +/ +/ +Test +that +collectNativeTrace +returns +a +well +formed +execution +trace +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 +) +; +/ +/ +foo +line +number +assertEq +( +trace +. +events +[ +1 +] +[ +1 +] +2 +) +; +/ +/ +bar +line +number +assertEq +( +trace +. +events +[ +0 +] +[ +2 +] +13 +) +; +/ +/ +foo +column +assertEq +( +trace +. +events +[ +1 +] +[ +2 +] +13 +) +; +/ +/ +bar +column +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 +] +) +; +/ +/ +Ion +should +be +disabled +as +an +implementation +but +if +we +' +re +jit +testing +/ +/ +we +can +hit +baseline +here +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..35eaeba8a6d77 --- /dev/null +++ b/js/src/jit-test/tests/debug/ExecutionTracer-discard-trace.js @@ -0,0 +1,313 @@ +/ +/ +Test +that +collectNativeTrace +discards +the +trace +when +setting +nativeTracing +/ +/ +to +false +var +g += +newGlobal +( +{ +newCompartment +: +true +} +) +; +var +dbg += +Debugger +( +g +) +; +dbg +. +nativeTracing += +true +; +g +. +eval +( +function +foo +( +) +{ +} +foo +( +) +; +) +; +/ +/ +This +should +discard +the +trace +dbg +. +nativeTracing += +false +; +dbg +. +nativeTracing += +true +; +g +. +eval +( +function +bar +( +) +{ +} +function +foo +( +) +{ +bar +( +) +; +} +foo +( +) +; +) +; +var +trace += +dbg +. +collectNativeTrace +( +) +; +assertEq +( +dbg +. +nativeTracing +false +) +; +/ +/ +if +the +trace +were +not +discarded +earlier +we +would +see +more +than +4 +entries +/ +/ +here +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..96622654e7f3f --- /dev/null +++ b/js/src/jit-test/tests/debug/ExecutionTracer-utf8.js @@ -0,0 +1,102 @@ +/ +/ +Test +that +collectNativeTrace +properly +handles +utf8 +in +script +URLs +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 84e081b17ba70..fb04a957ff3bd 100644 --- a/js/src/vm/Caches.h +++ b/js/src/vm/Caches.h @@ -3311,9 +3311,6 @@ Clear } } ; -# -ifdef -MOZ_EXECUTION_TRACING / / Holds @@ -3803,13 +3800,6 @@ NewlyAdded } } ; -# -endif -/ -* -MOZ_EXECUTION_TRACING -* -/ class RuntimeCaches { @@ -3833,14 +3823,9 @@ evalCache StringToAtomCache stringToAtomCache ; -# -ifdef -MOZ_EXECUTION_TRACING TracingCaches tracingCaches ; -# -endif / / Delazification @@ -3986,17 +3971,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 2f8a5a42d9e13..4251437699529 100644 --- a/js/src/vm/JSContext.cpp +++ b/js/src/vm/JSContext.cpp @@ -268,9 +268,6 @@ js : RegExpSearcherLastLimitSentinel # -ifdef -MOZ_EXECUTION_TRACING -# include " debugger @@ -280,8 +277,6 @@ ExecutionTracer h " # -endif -# include " frontend @@ -302,21 +297,6 @@ h # include " -gc -/ -PublicIterators -. -h -" -/ -/ -js -: -: -RealmsIter -# -include -" irregexp / RegExpAPI @@ -8385,15 +8365,19 @@ ExternalValueArray ; } } -# -ifdef -MOZ_EXECUTION_TRACING bool JSContext : : -enableExecutionTracing +addExecutionTracingConsumer ( +const +js +: +: +Debugger +* +dbg ) { if @@ -8443,114 +8427,69 @@ return false ; } -for -( -RealmsIter -realm -( -runtime +if ( -) -) -; ! -realm +executionTracingConsumers_ . -done -( -) -; -realm -. -next +put ( +dbg ) ) { -if -( -realm -- -> -isSystem -( -) -) -{ -continue +executionTracer_ += +nullptr ; -} -realm -- -> -enableExecutionTracing -( -) +return +false ; } -} return true ; } +return +executionTracingConsumers_ +. +put +( +dbg +) +; +} void JSContext : : -disableExecutionTracing -( -) -{ -if +removeExecutionTracingConsumer ( -executionTracer_ +const +js +: +: +Debugger +* +dbg ) { -for -( -RealmsIter -realm -( -runtime -( -) -) -; -! -realm +executionTracingConsumers_ . -done +remove ( +dbg ) ; -realm -. -next -( -) -) -{ if ( -realm -- -> -isSystem +executionTracingConsumers_ +. +empty ( ) ) { -continue -; -} -realm -- -> -disableExecutionTracing -( -) -; -} caches ( ) @@ -8568,8 +8507,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 b3bb04e8ca226..978e384ecea96 100644 --- a/js/src/vm/JSContext.h +++ b/js/src/vm/JSContext.h @@ -127,18 +127,6 @@ include " mozilla / -BaseProfilerUtils -. -h -" -/ -/ -BaseProfilerThreadId -# -include -" -mozilla -/ Maybe . h @@ -392,17 +380,12 @@ AutoMaybeLeaveAtomsZone class AutoRealm ; -struct -PortableBaselineStack -; -# -ifdef -MOZ_EXECUTION_TRACING class ExecutionTracer ; -# -endif +struct +PortableBaselineStack +; namespace jit { @@ -6514,9 +6497,6 @@ Debugger > insideExclusiveDebuggerOnEval ; -# -ifdef -MOZ_EXECUTION_TRACING / / This @@ -6565,76 +6545,103 @@ ExecutionTracer > executionTracer_ ; +/ +/ +Holds +all +of +the +consumers +of +the +trace +- +each +consumer +is +a +Debugger +/ +/ +object +- +when +the +first +consumer +is +added +the +tracer +will +be +initialized +/ +/ +and +when +the +last +consumer +is +removed +the +tracer +will +be +cleaned +up +. js : : -ExecutionTracer -& -getExecutionTracer -( -) -{ -MOZ_ASSERT -( -hasExecutionTracer -( -) -) -; -return +HashSet +< +const +js +: +: +Debugger * -executionTracer_ +js +: +: +PointerHasher +< +const +js +: +: +Debugger +* +> +js +: +: +SystemAllocPolicy +> +executionTracingConsumers_ ; -} / / -See +For the -latter -clause -of +following +methods +see the -comment +comments over executionTracer_ -[ -[ -nodiscard -] -] -bool -enableExecutionTracing -( -) -; -void -disableExecutionTracing -( -) -; -/ -/ -Returns -true -if -there -is -currently -an -ExecutionTracer -tracing -this +and / / -context -' -s -execution -. +executionTracingConsumers_ bool hasExecutionTracer ( ) +const { return ! @@ -6642,19 +6649,52 @@ return executionTracer_ ; } -# -else -bool -hasExecutionTracer +js +: +: +ExecutionTracer +& +getExecutionTracer ( ) +const { +MOZ_ASSERT +( +hasExecutionTracer +( +) +) +; return -false +* +executionTracer_ ; } -# -endif +bool +addExecutionTracingConsumer +( +const +js +: +: +Debugger +* +dbg +) +; +void +removeExecutionTracingConsumer +( +const +js +: +: +Debugger +* +dbg +) +; } ; / diff --git a/js/src/vm/MutexIDs.h b/js/src/vm/MutexIDs.h index b87607333554e..856c9f0ebf68f 100644 --- a/js/src/vm/MutexIDs.h +++ b/js/src/vm/MutexIDs.h @@ -184,12 +184,6 @@ _ \ _ ( -ExecutionTracerGlobalLock -100 -) -\ -_ -( TestMutex 100 ) @@ -221,12 +215,6 @@ WellKnownParserAtomsInit \ _ ( -ExecutionTracerInstanceLock -250 -) -\ -_ -( WasmInitBuiltinThunks 250 ) diff --git a/js/src/vm/Realm.cpp b/js/src/vm/Realm.cpp index 380bc3b259e7f..177193060dacb 100644 --- a/js/src/vm/Realm.cpp +++ b/js/src/vm/Realm.cpp @@ -535,15 +535,15 @@ hasBeenEnteredIgnoringJit MOZ_ASSERT ( ! -localAllocSite -) -; -MOZ_ASSERT_IF -( isDebuggee ( ) -isTracingExecution_ +) +; +MOZ_ASSERT +( +! +localAllocSite ) ; / @@ -586,16 +586,6 @@ forgetAllocationMetadataBuilder ) ; } -if -( -isTracingExecution_ -) -{ -disableExecutionTracing -( -) -; -} MOZ_ASSERT ( runtime_ @@ -756,25 +746,6 @@ principals_ principals ; } -if -( -! -isSystem_ -& -& -cx -- -> -hasExecutionTracer -( -) -) -{ -enableExecutionTracing -( -) -; -} } bool JSRuntime @@ -2901,10 +2872,6 @@ DebuggerObservesAllExecution { observes = -( -global -& -& DebugAPI : : @@ -2912,10 +2879,6 @@ debuggerObservesAllExecution ( global ) -) -| -| -isTracingExecution_ ; } else diff --git a/js/src/vm/Realm.h b/js/src/vm/Realm.h index f4be15f39230b..e43d91245357b 100644 --- a/js/src/vm/Realm.h +++ b/js/src/vm/Realm.h @@ -2579,58 +2579,6 @@ initializingGlobal_ = true ; -/ -/ -Indicates -that -we -are -tracing -all -execution -within -this -realm -i -. -e -. -/ -/ -recording -every -entrance -into -exit -from -each -function -among -other -/ -/ -things -. -See -ExecutionTracer -. -h -for -where -the -bulk -of -this -work -/ -/ -happens -. -bool -isTracingExecution_ -= -false -; js : : @@ -4585,83 +4533,6 @@ unsetIsDebuggee ( ) ; -bool -isTracingExecution -( -) -{ -return -isTracingExecution_ -; -} -void -enableExecutionTracing -( -) -{ -isTracingExecution_ -= -true -; -setIsDebuggee -( -) -; -updateDebuggerObservesAllExecution -( -) -; -} -void -disableExecutionTracing -( -) -{ -isTracingExecution_ -= -false -; -/ -/ -updateDebuggerObservesAllExecution -always -wants -isDebuggee -to -be -true -/ -/ -so -we -just -have -weird -ordering -here -to -play -nicely -with -it -updateDebuggerObservesAllExecution -( -) -; -if -( -! -hasDebuggers -( -) -) -{ -unsetIsDebuggee -( -) -; -} -} DebuggerVector & getDebuggers diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp index 0116f9758a890..01acb6f72e453 100644 --- a/js/xpconnect/src/XPCJSContext.cpp +++ b/js/xpconnect/src/XPCJSContext.cpp @@ -9156,7 +9156,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 f7f1c9f309a2b..1e703229e7b2b 100644 --- a/tools/profiler/core/ProfileBuffer.h +++ b/tools/profiler/core/ProfileBuffer.h @@ -1516,28 +1516,6 @@ return mMaybeWorkerChunkManager ; } -# -ifdef -MOZ_EXECUTION_TRACING -template -< -typename -GetStreamingParametersForThreadCallback -> -void -MaybeStreamExecutionTraceToJSON -( -GetStreamingParametersForThreadCallback -& -& -aGetStreamingParametersForThreadCallback -double -aSinceTime -) -const -; -# -endif / / GetStreamingParametersForThreadCallback diff --git a/tools/profiler/core/ProfileBufferEntry.cpp b/tools/profiler/core/ProfileBufferEntry.cpp index 2e852149c4901..75cf57d8f5a75 100644 --- a/tools/profiler/core/ProfileBufferEntry.cpp +++ b/tools/profiler/core/ProfileBufferEntry.cpp @@ -193,15 +193,6 @@ include " mozilla / -CycleCollectedJSContext -. -h -" -# -include -" -mozilla -/ Logging . h @@ -6884,1117 +6875,140 @@ aPreviousStack } } ; -# -ifdef -MOZ_EXECUTION_TRACING +/ +/ +GetStreamingParametersForThreadCallback +: +/ +/ +( +ProfilerThreadId +) +- +> +Maybe +< +StreamingParametersForThread +> template < typename GetStreamingParametersForThreadCallback > -void +ProfilerThreadId ProfileBuffer : : -MaybeStreamExecutionTraceToJSON +DoStreamSamplesAndMarkersToJSON ( +mozilla +: +: +FailureLatch +& +aFailureLatch GetStreamingParametersForThreadCallback & & aGetStreamingParametersForThreadCallback double aSinceTime -) -const -{ -JS +ProcessStreamingContext +* +aStreamingContextForMarkers +mozilla : : -ExecutionTrace -trace -; -if -( -! -JS_TracerSnapshotTrace -( -trace -) +ProgressLogger +aProgressLogger ) -{ -return -; -} -for -( const -JS -: -: -ExecutionTrace -: -: -TracedJSContext -& -context -: -trace -. -contexts -) { -Maybe +UniquePtr < -StreamingParametersForThread +char +[ +] > -streamingParameters +dynStrBuf = -std -: -: -forward +MakeUnique < -GetStreamingParametersForThreadCallback +char +[ +] > ( -aGetStreamingParametersForThreadCallback -) -( -context -. -id +kMaxFrameKeyLength ) ; -/ -/ -Ignore -samples -that -are -for -the -wrong -thread +return +mEntries . -if +Read ( -! -streamingParameters -) -{ -continue -; -} -SpliceableJSONWriter -& -writer -= -streamingParameters -- -> -mWriter -; -UniqueStacks +[ & -uniqueStacks -= -streamingParameters -- -> -mUniqueStacks -; -mozilla -: -: -Vector -< -UniqueStacks -: -: -StackKey -> -frameStack -; -Maybe -< -UniqueStacks -: -: -StackKey -> -maybeStack -= -uniqueStacks -. -BeginStack +] ( -UniqueStacks +ProfileChunkedBuffer : : -FrameKey -( -" -( -root -) -" -) -) -; -if -( -! -maybeStack +Reader +* +aReader ) { -writer -. -SetFailure +MOZ_ASSERT ( +aReader " -BeginStack -failure +ProfileChunkedBuffer +cannot +be +out +- +of +- +session +when +sampler +is +" +" +running " ) ; -continue +ProfilerThreadId +processedThreadId ; -} -UniqueStacks +EntryGetter +e +( +* +aReader +aFailureLatch +std : : -StackKey -stack -= -* -maybeStack -; -if -( -! -frameStack -. -append +move ( -stack -) +aProgressLogger ) -{ -writer -. -SetFailure -( -" -frameStack -append -failure -" +/ +* +aInitialReadPos +* +/ +0 +aStreamingContextForMarkers ) ; -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 -) -; -/ -/ -This -is -uncommon -but -if -one -of -our -ring -buffers -wraps -around -we -/ -/ -can -end -up -with -missing -function -name -entries -const -char -* -functionNameStr -= -" -< -expired -> -" -; -if -( -functionName -) -{ -functionNameStr -= -& -trace -. -stringBuffer -[ -functionName -- -> -value -( -) -] -; -} -HashMap -< -uint32_t -size_t -> -: -: -Ptr -scriptUrl -= -context -. -scriptUrls -. -lookup -( -event -. -functionEvent -. -scriptId -) -; -/ -/ -See -the -comment -above -functionNameStr -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 -/ -/ -GetStreamingParametersForThreadCallback -: -/ -/ -( -ProfilerThreadId -) -- -> -Maybe -< -StreamingParametersForThread -> -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 -) -/ -* -aInitialReadPos -* -/ -0 -aStreamingContextForMarkers -) -; -for -( -; -; +; +; ) { / @@ -10777,9 +9791,16 @@ aProgressLogger ) const { -auto -getStreamingParamsCallback -= +( +void +) +DoStreamSamplesAndMarkersToJSON +( +aProcessStreamingContext +. +SourceFailureLatch +( +) [ & ] @@ -10838,33 +9859,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 2aa8391d03f84..2a5cf4fbdd933 100644 --- a/tools/profiler/core/ProfilerThreadRegistrationData.cpp +++ b/tools/profiler/core/ProfilerThreadRegistrationData.cpp @@ -955,35 +955,6 @@ inNursery ) ; } -JSContext -* -ThreadRegistrationUnlockedReaderAndAtomicRWOnThread -: -: -GetJSContext -( -) -const -{ -if -( -! -mCCJSContext -) -{ -return -nullptr -; -} -return -mCCJSContext -- -> -Context -( -) -; -} void ThreadRegistrationLockedRWFromAnyThread : @@ -1032,7 +1003,7 @@ aProfiledThreadData ; if ( -mCCJSContext +mJSContext ) { / @@ -1105,7 +1076,7 @@ mProfiledThreadData MOZ_ASSERT ( ( -mCCJSContext +mJSContext & & ( @@ -1189,7 +1160,7 @@ mProfiledThreadData MOZ_ASSERT ( ( -mCCJSContext +mJSContext & & ( @@ -1214,35 +1185,25 @@ void ThreadRegistrationLockedRWOnThread : : -SetCycleCollectedJSContext +SetJSContext ( -CycleCollectedJSContext +JSContext * -aCx +aJSContext ) { MOZ_ASSERT ( -aCx +aJSContext & & ! -mCCJSContext +mJSContext ) ; -MOZ_ASSERT -( -aCx -- -> -Context -( -) -) -; -mCCJSContext +mJSContext = -aCx +aJSContext ; if ( @@ -1352,12 +1313,7 @@ js : SetContextProfilingStack ( -aCx -- -> -Context -( -) +aJSContext & ProfilingStackRef ( @@ -1372,7 +1328,7 @@ invariants MOZ_ASSERT ( ( -mCCJSContext +mJSContext & & ( @@ -1397,11 +1353,11 @@ void ThreadRegistrationLockedRWOnThread : : -ClearCycleCollectedJSContext +ClearJSContext ( ) { -mCCJSContext +mJSContext = nullptr ; @@ -1428,7 +1384,7 @@ invariants MOZ_ASSERT ( ( -mCCJSContext +mJSContext & & ( @@ -1478,7 +1434,7 @@ JSContext . if ( -mCCJSContext +mJSContext ) { / @@ -1545,17 +1501,6 @@ that . / / -JSContext -* -cx -= -mCCJSContext -- -> -Context -( -) -; if ( mJSSampling @@ -1573,7 +1518,7 @@ js : EnableContextProfilingStack ( -cx +mJSContext true ) ; @@ -1604,7 +1549,7 @@ JS : EnableRecordingAllocations ( -cx +mJSContext profiler_add_js_allocation_marker 0 . @@ -1617,7 +1562,7 @@ js : RegisterContextProfilingEventMarker ( -cx +mJSContext profiler_add_js_marker ) ; @@ -1640,7 +1585,7 @@ js : EnableContextProfilingStack ( -cx +mJSContext false ) ; @@ -1656,7 +1601,7 @@ JS : DisableRecordingAllocations ( -cx +mJSContext ) ; } diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index 364c10039299d..a17987ad06a82 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -642,15 +642,6 @@ include " mozilla / -CycleCollectedJSContext -. -h -" -# -include -" -mozilla -/ ExtensionPolicyService . h @@ -8100,51 +8091,6 @@ ProfilerFeature CPUUtilization ; } -if -( -aFeatures -& -ProfilerFeature -: -: -Tracing -) -{ -aFeatures -& -= -~ -ProfilerFeature -: -: -CPUUtilization -; -aFeatures -& -= -~ -ProfilerFeature -: -: -Memory -; -aFeatures -| -= -ProfilerFeature -: -: -NoStackSampling -; -aFeatures -| -= -ProfilerFeature -: -: -JS -; -} return aFeatures ; @@ -40759,36 +40705,6 @@ BufferRangeEnd ) ) ; -if -( -ActivePS -: -: -FeatureTracing -( -aLock -) -) -{ -CycleCollectedJSContext -* -ctx -= -lockedRWFromAnyThread -- -> -GetCycleCollectedJSContext -( -) -; -ctx -- -> -BeginExecutionTracingAsync -( -) -; -} } } } @@ -48599,36 +48515,6 @@ NotifyReceivedJSContext 0 ) ; -if -( -ActivePS -: -: -FeatureTracing -( -aLock -) -) -{ -CycleCollectedJSContext -* -ctx -= -lockedThreadData -- -> -GetCycleCollectedJSContext -( -) -; -ctx -- -> -BeginExecutionTracingAsync -( -) -; -} } } } @@ -49905,42 +49791,6 @@ aLock ) ) { -if -( -ActivePS -: -: -FeatureTracing -( -aLock -) -) -{ -CycleCollectedJSContext -* -ctx -= -lockedThreadData -- -> -GetCycleCollectedJSContext -( -) -; -if -( -ctx -) -{ -ctx -- -> -EndExecutionTracingAsync -( -) -; -} -} lockedThreadData - > @@ -55512,7 +55362,7 @@ IsLockedOnCurrentThread void profiler_set_js_context ( -CycleCollectedJSContext +JSContext * aCx ) @@ -55573,7 +55423,7 @@ aThreadData { aThreadData . -SetCycleCollectedJSContext +SetJSContext ( aCx ) @@ -55637,25 +55487,6 @@ BufferRangeEnd ) ) ; -if -( -ActivePS -: -: -FeatureTracing -( -lock -) -) -{ -aCx -- -> -BeginExecutionTracingAsync -( -) -; -} } } ) @@ -55721,9 +55552,9 @@ OnThreadRef aOnThreadRef ) { -CycleCollectedJSContext +JSContext * -cccx +cx = aOnThreadRef . @@ -55731,30 +55562,19 @@ UnlockedReaderAndAtomicRWOnThreadCRef ( ) . -GetCycleCollectedJSContext +GetJSContext ( ) ; if ( ! -cccx +cx ) { return ; } -JSContext -* -cx -= -cccx -- -> -Context -( -) -; / / The @@ -55853,7 +55673,7 @@ pointer lockedThreadData - > -ClearCycleCollectedJSContext +ClearJSContext ( ) ; @@ -55881,25 +55701,6 @@ lock ) ) ; -if -( -ActivePS -: -: -FeatureTracing -( -lock -) -) -{ -cccx -- -> -EndExecutionTracingAsync -( -) -; -} / / Notify @@ -55956,7 +55757,7 @@ happen before / / -ClearCycleCollectedJSContext +ClearJSContext below . PollJSSamplingForCurrentThread @@ -55985,7 +55786,7 @@ GetLockedRWOnThread lockedThreadData - > -ClearCycleCollectedJSContext +ClearJSContext ( ) ; diff --git a/tools/profiler/public/GeckoProfiler.h b/tools/profiler/public/GeckoProfiler.h index b32e09b303d05..04d9befcb5b5a 100644 --- a/tools/profiler/public/GeckoProfiler.h +++ b/tools/profiler/public/GeckoProfiler.h @@ -476,13 +476,6 @@ define PROFILER_CLEAR_JS_CONTEXT ( ) -namespace -mozilla -{ -class -CycleCollectedJSContext -; -} / / Function @@ -1842,10 +1835,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 d9856eca3492e..d81320a1c507d 100644 --- a/tools/profiler/public/ProfilerState.h +++ b/tools/profiler/public/ProfilerState.h @@ -1161,9 +1161,9 @@ sample " ) \ -\ MACRO ( +\ 24 " memory @@ -1180,46 +1180,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 -) -" -) / / * diff --git a/tools/profiler/public/ProfilerThreadRegistrationData.h b/tools/profiler/public/ProfilerThreadRegistrationData.h index cffc96cf1a16f..a48d569b7fe47 100644 --- a/tools/profiler/public/ProfilerThreadRegistrationData.h +++ b/tools/profiler/public/ProfilerThreadRegistrationData.h @@ -926,13 +926,6 @@ NotProfiled } namespace mozilla -{ -class -CycleCollectedJSContext -; -} -namespace -mozilla : : profiler @@ -1311,16 +1304,16 @@ and suspended thread . -CycleCollectedJSContext +JSContext * -mCCJSContext +mJSContext = nullptr ; / / If -mCCJSContext +mJSContext is not null @@ -1332,9 +1325,9 @@ being profiled this points +at / / -at the start of @@ -1348,8 +1341,6 @@ on - thread synchronous -/ -/ sampling . JsFrame @@ -3389,21 +3380,9 @@ GetJSContext ( ) const -; -[ -[ -nodiscard -] -] -CycleCollectedJSContext -* -GetCycleCollectedJSContext -( -) -const { return -mCCJSContext +mJSContext ; } protected @@ -4039,15 +4018,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 cdcaa744e8c46..0000000000000 --- a/tools/profiler/tests/browser/browser_test_feature_jstracing.js +++ /dev/null @@ -1,1306 +0,0 @@ -/ -* -This -Source -Code -Form -is -subject -to -the -terms -of -the -Mozilla -Public -* -License -v -. -2 -. -0 -. -If -a -copy -of -the -MPL -was -not -distributed -with -this -* -file -You -can -obtain -one -at -http -: -/ -/ -mozilla -. -org -/ -MPL -/ -2 -. -0 -/ -. -* -/ -/ -* -* -* -Test -the -JS -Tracing -feature -. -* -/ -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 -) -; -/ -/ -First -lookup -for -all -our -expected -symbols -in -the -string -table -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 -" -) -; -/ -/ -Then -lookup -for -the -matching -frame -based -on -the -string -index -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 -) -; -/ -/ -Finally -assert -that -the -stacks -are -correct -. -/ -/ -Each -symbol -' -s -frame -is -visible -in -a -stack -and -the -stack -tree -is -valid -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 -] -] -; -} -/ -* -* -* -This -function -takes -a -thread -and -a -sample -tuple -from -the -" -data -" -array -and -* -inflates -the -frame -to -be -an -array -of -strings -. -* -* -param -{ -Object -} -thread -- -The -thread -from -the -profile -. -* -param -{ -Array -} -sample -- -The -tuple -from -the -thread -. -samples -. -data -array -. -* -returns -{ -Array -< -string -> -} -An -array -of -function -names -. -* -/ -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 -; -/ -/ -Build -the -stack -from -the -raw -data -and -accumulate -the -locations -in -/ -/ -an -array -. -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 -] -; -} -/ -/ -The -profiler -tree -is -inverted -so -reverse -the -array -. -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 58fbbc87f03ea..298978db8dc6e 100644 --- a/tools/profiler/tests/gtest/GeckoProfiler.cpp +++ b/tools/profiler/tests/gtest/GeckoProfiler.cpp @@ -3206,14 +3206,14 @@ want to really call -SetCycleCollectedJSContext +SetJSContext here so just -/ -/ verify that +/ +/ the call would @@ -3235,14 +3235,14 @@ decltype ( aData . -SetCycleCollectedJSContext +SetJSContext ( std : : declval < -CycleCollectedJSContext +JSContext * > ( @@ -3255,7 +3255,7 @@ void ; aData . -ClearCycleCollectedJSContext +ClearJSContext ( ) ; @@ -11563,26 +11563,6 @@ filters " } ; -/ -/ -Turn -off -tracing -because -it -mucks -with -other -features -availableFeatures -& -= -~ -ProfilerFeature -: -: -Tracing -; profiler_start ( PowerOfTwo32 diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp index 1b8b4fd915157..40cdd17d01621 100644 --- a/xpcom/base/CycleCollectedJSContext.cpp +++ b/xpcom/base/CycleCollectedJSContext.cpp @@ -5352,143 +5352,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 5d2c4512dc087..45032468fffd1 100644 --- a/xpcom/base/CycleCollectedJSContext.h +++ b/xpcom/base/CycleCollectedJSContext.h @@ -1611,140 +1611,6 @@ supported ) ; } -/ -/ -These -two -functions -control -a -special -flag -variable -which -lets -us -turn -/ -/ -tracing -on -and -off -from -a -thread -other -than -this -JSContext -' -s -main -thread -. -/ -/ -This -is -useful -because -we -want -to -be -able -to -start -tracing -many -threads -/ -/ -all -at -once -from -the -Gecko -Profiler -in -Firefox -. -/ -/ -/ -/ -NOTE -: -the -caller -must -ensure -that -this -CycleCollectedJSContext -is -not -/ -/ -being -destroyed -when -this -is -called -. -At -the -time -of -this -API -being -added -/ -/ -the -only -consumer -is -the -Gecko -Profiler -which -guarantees -this -via -a -mutex -/ -/ -around -unregistering -the -context -which -always -occurs -before -the -context -/ -/ -is -destroyed -. -void -BeginExecutionTracingAsync -( -) -; -void -EndExecutionTracingAsync -( -) -; private : /