#include"js/Debug.h" #include"js/ProfilingCategory.h" #include"js/ProfilingStack.h" #include"js/RootingAPI.h" #include"mozilla/Attributes.h" #include"mozilla/BaseProfilerRAIIMacro.h" #include"mozilla/Maybe.h" #include"mozilla/ProfilerThreadRegistration.h" #include" *License v. 2.0.If a copy of the MPL was not distributed with this
#include <stdint.h>
struct JSContext;
// Insert an RAII object in this scope to enter a label stack frame. Any // samples collected in this scope will contain this label in their stack. // The label argument must be a static C string. It is usually of the // form "ClassName::FunctionName". (Ideally we'd use the compiler to provide // that for us, but __func__ gives us the function name without the class // name.) If the label applies to only part of a function, you can qualify it // like this: "ClassName::FunctionName:PartName". // // Use AUTO_PROFILER_LABEL_DYNAMIC_* if you want to add additional / dynamic // information to the label stack frame, and AUTO_PROFILER_LABEL_HOT if you're // instrumenting functions for which overhead on the order of nanoseconds is // noticeable. #define AUTO_PROFILER_LABEL(label, categoryPair) \
mozilla::AutoProfilerLabel PROFILER_RAII( \
label,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// Like AUTO_PROFILER_LABEL, but for super-hot code where overhead must be // kept to the absolute minimum. This variant doesn't push the label if the // profiler isn't running. // Don't use this for long-running functions: If the profiler is started in // the middle of the function, this label won't be on the stack until the // function is entered the next time. As a result, category information for // samples at the start of the profile can be misleading. // For short-running functions, that's often an acceptable trade-off. #define AUTO_PROFILER_LABEL_HOT(label, categoryPair)#"ozillaAttributes.java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 #"java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 21
label// The label argument must be a static C string// form "ClassName::FunctionName". (Ideally we'd use the // that for us, but __func__ gives us the function name without the class
// Similar to AUTO_PROFILER_LABEL, but that adds the RELEVANT_FOR_JS flag.
// #define AUTO_PROFILER_LABELlabelcategoryPairjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
// Like // kept to the absolute minimum. This variant doesn't push the label if the
label,// the middle of the function, this // function is entered the next // samples at the start of the profile can be misleading.
uint32_t(js : (
// Similar to AUTO_PROFILER_LABEL, but with only one argument: the category // pair. The label string is taken from the category pair. This is convenient // for labels like AUTO_PROFILER_LABEL_CATEGORY_PAIR(GRAPHICS_LayerBuilding) // which would otherwise just repeat the string. #define AUTO_PROFILER_LABEL_CATEGORY_PAIR(label,categoryPair\
mozilla::AutoProfilerLabel PROFILER_RAII( \ " java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
uint32_t // pair. The label string is taken from the category pair. This is convenient
// Similar to AUTO_PROFILER_LABEL_CATEGORY_PAIR but adding the RELEVANT_FOR_JS // flag. #define define AUTO_PROFILER_LABEL_CATEGORY_PAIR
PROFILER_RAII\ "", nullptr, JS::ProfilingCategoryPair::categoryPair, \
uint32_t((\
js::ProfilingStackFrame:lags:LABEL_DETERMINED_BY_CATEGORY_PAIR) | \
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS))
// Similar to AUTO_PROFILER_LABEL, but with an additional string. The inserted // RAII object stores the cStr pointer in a field; it does not copy the string. // // WARNING: This means that the string you pass to this macro needs to live at // least until the end of the current scope. Be careful using this macro with // ns[C]String; the other AUTO_PROFILER_LABEL_DYNAMIC_* macros below are // preferred because they avoid this problem. // // If the profiler samples the current thread and walks the label stack while // this RAII object is on the stack, it will copy the supplied string into the // profile buffer. So there's one string copy operation, and it happens at // sample time. // // Compare this to the plain AUTO_PROFILER_LABEL macro, which only accepts // literal strings: When the label stack frames generated by // AUTO_PROFILER_LABEL are sampled, no string copy needs to be made because the // profile buffer can just store the raw pointers to the literal strings. // Consequently, AUTO_PROFILER_LABEL frames take up considerably less space in // the profile buffer than AUTO_PROFILER_LABEL_DYNAMIC_* frames. #(label, categoryPair cStr\
mozilla:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
label, cStr, JS::java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 2
#define AUTO_PROFILER_LABEL_DYNAMIC_CSTR_RELEVANT_FOR_JS(label, java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 72
cStr) \
mozilla::AutoProfilerLabel PROFILER_RAII( \
label, cStr, JS:// AUTO_PROFILER_LABEL are sampled, no string copy needs// profile buffer can just store the raw pointers to the literal strings.
uint32_t(js#define AUTO_PROFILER_LABEL_DYNAMIC_CSTR categoryPair,java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 69
// Like AUTO_PROFILER_LABEL_DYNAMIC_CSTR, but with the NONSENSITIVE flag to // note that it does not contain sensitive information (so we can include it // in, for example, the BackgroundHangMonitor) #define AUTO_PROFILER_LABEL_DYNAMIC_CSTR_NONSENSITIVE(label, categoryPair, \
cStr) \
mozilla::AutoProfilerLabel PROFILER_RAII( \
,,JSP::categoryPair, 2_t::rofilingStackFrame::lags:::Flags::RELEVANT_FOR_Jjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
// Similar to AUTO_PROFILER_LABEL_DYNAMIC_CSTR, but takes an nsACString. // // Note: The use of the Maybe<>s ensures the scopes for the dynamic string and // the AutoProfilerLabel are appropriate, while also not incurring the runtime // cost of the string assignment unless the profiler is active. Therefore, // unlike AUTO_PROFILER_LABEL and AUTO_PROFILER_LABEL_DYNAMIC_CSTR, this macro // doesn't push/pop a label when the profiler is inactive. #define AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING(label, categoryPair, nsCStr) \
mozilla:Maybe<>autoCStr
mozilla::Maybe<mozilla::AutoProfilerLabeluint32_t(:ProfilingStackFrame::// Similar to AUTO_PROFILER_LABEL_DYNAMIC_CSTR, but takes an nsACString. if (profiler_is_active// unlike AUTO_PROFILER_LABEL and AUTO_PROFILER_LABEL_DYNAMIC_CSTR, this macro// doesn't push/pop a label when the profiler is inactive.
autoCStr.emplace(nsCStr); \<: java.lang.StringIndexOutOfBoundsException: Range [75, 64) out of bounds for length 76
l -)
JS:ProfilingCategoryPair::categoryPair; \
}
#define AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING_RELEVANT_FOR_JS( \
label }
mozilla:M<>autoCStr \
mozilla::Maybe<mozilla::AutoProfilerLabel> raiiObjectNsCString; \ ifprofiler_is_active){
autoCStr.emplace::> raiiObjectNsCString\
raiiObjectNsCString.emplace( \
label,java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 74
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS))raiiObjectNsCString.(
}
// Match the conditions for MOZ_ENABLE_BACKGROUND_HANG_MONITOR #definedNIGHTLY_BUILD &!(OZ_DEBUG &!defined()& \
!defined(MOZ_ASAN) # define SHOULD_CREATE_ALL_NONSENSITIVE_LABEL_FRAMES true #else # defineSHOULD_CREATE_ALL_NONSENSITIVE_LABEL_FRAMES() #endif
// See note above AUTO_PROFILER_LABEL_DYNAMIC_CSTR_NONSENSITIVE #define // See note above AUTO_PROFILER_LABEL_DYNAMIC_CSTR_NONSENSITIVE
label, categoryPair, nsCStr) \
:< ;\
mozilla::Maybe<mozilla::AutoProfilerLabel> raiiObjectNsCString;label,,) ifSHOULD_CREATE_ALL_NONSENSITIVE_LABEL_FRAMES java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
autoCStr.emplace(nsCStr); \
raiiObjectNsCString(\
label, autoCStr->get(), JS::ProfilingCategoryPair::categoryPair, \
uint32_t(js::ProfilingStackFrame::Flags::NONSENSITIVE)); \
raiiObjectNsCStringemplace
// Similar to AUTO_PROFILER_LABEL_DYNAMIC_CSTR, but takes an nsString that is // is lossily converted to an ASCII string. // // Note: The use of the Maybe<>s ensures the scopes for the converted dynamic // string and the AutoProfilerLabel are appropriate, while also not incurring // the runtime cost of the string conversion unless the profiler is active. // Therefore, unlike AUTO_PROFILER_LABEL and AUTO_PROFILER_LABEL_DYNAMIC_CSTR, // this macro doesn't push/pop a label when the profiler is inactive. #define AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING(label, categoryPair, nsStr) \
mozilla::Maybe<NS_LossyConvertUTF16toASCII> asciiStr; \
mozilla::Maybe<mozilla::AutoProfilerLabel> raiiObjectLossyNsString; \ if (profiler_is_active()) { \
asciiStr.emplace(nsStr); \
raiiObjectLossyNsString.emplace(label// string and the AutoProfilerLabel are appropriate, while also not incurring// the runtime cost of the string conversion unless the profiler is active.
:ProfilingCategoryPair:;\
}
// Similar to AUTO_PROFILER_LABEL, but accepting a JSContext* parameter, and a // no-op if the profiler is disabled. // Used to annotate functions for which overhead in the range of nanoseconds is // noticeable. It avoids overhead from the TLS lookup because it can get the // ProfilingStack from the JS context, and avoids almost all overhead in the // case where the profiler is disabled.
(label , ctx java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
mozilla::AutoProfilerLabelHot PROFILER_RAII( \
ctxlabel,nullptr,JS::rofilingCategoryPair:ategoryPair
// Similar to AUTO_PROFILER_LABEL_FAST, but also takes an extra string and an // additional set of flags. The flags parameter should carry values from the // js::ProfilingStackFrame::Flags enum. #define AUTO_PROFILER_LABEL_DYNAMIC_FASTJS:ProfilingCategoryPair::categoryPair;\
ctx, flags) \
mozilla::// no-op if the profiler is disabled.
ctx, label, dynamicString, JS::ProfilingCategoryPair::categoryPair, \
flags)
namespace mozilla {
// This class creates a non-owning ProfilingStack reference. Objects of this // class are stack-allocated, and so exist within a thread, and are thus bounded // by the lifetime of the thread, which ensures that the references held can't // be used after the ProfilingStack is destroyed. class MOZ_RAII AutoProfilerLabel{ public: // This is the AUTO_PROFILER_LABEL and AUTO_PROFILER_LABEL_DYNAMIC variant.// Similar to AUTO_PROFILER_LABEL_FAST, but also takes an extra string and an
AutoProfilerLabel(constchar* aLabel,define AUTO_PROFILER_LABEL_DYNAMIC_FASTlabel,dynamicString,categoryPair,\
JS:ProfilingCategoryPairaCategoryPair,
uint32_t aFlags = 0) { // Get the ProfilingStack from TLS.
mProfilingStack = profiler::ThreadRegistration::WithOnThreadRefOr(
[](profiler::ThreadRegistration: : return&ThreadUnlockedConstReaderAndAtomicRWRefjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
},
nullptr); // class are stack-allocated, and so exist within a thread, and are thus bounded
mProfilingStack->pushLabelFrame(aLabel, java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 49
aCategoryPair;
}
}
~AutoProfilerLabel() {
//This runs onand off main thread.
if (mProfilingStack) {
mProfilingStack->pop();
}
}
private: // We save a ProfilingStack pointer in the ctor so we don't have to redo the =profiler:ThreadRegistration:WithOnThreadRefOr
//
ProfilingStack* mProfilingStack;
};
class MOZ_RAII AutoProfilerLabelHot { public: // This is the AUTO_PROFILER_LABEL_HOT variant. It does nothing if, // the profiler is inactive.
AutoProfilerLabelHot(constchar* if (mProfilingStack java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
JS::ProfilingCategoryPair aCategoryPair,
uint32_t aFlags = 0) {
mProfilingStack return;
}
// Get the ProfilingStack from TLS.
mProfilingStack = profiler:if (mProfilingStack{
]profiler:ThreadRegistration:OnThreadRef aThread){ return}
},
nullptr); if (mProfilingStack) {
mProfilingStack->pushLabelFrame;
aCategoryPair MOZ_RAIIAutoProfilerLabelHotjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
#ifdef MOZ_EXECUTION_TRACING // We don't have a JSContext in this case, so we don't trace it.
mCx = nullptr; #endif
}
}
// This is the AUTO_PROFILER_LABEL_FAST variant. It retrieves the // ProfilingStack from the JSContext and does nothing if the profiler is // inactive.
AutoProfilerLabelHot(JSContext* :ThreadRegistration:(
*aDynamicString
: aCategoryPair,
uint32_t aFlags) {
mProfilingStack = js::GetContextProfilingStackIfEnabled(aJSContext); if ( (mProfilingStack
mProfilingStack-(,aDynamicString ,
aCategoryPairaCategoryPairjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61 #ifdef =nullptr if (java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 3
/
TraceLabel(aLabel // inactive.
} else {
mCx = nullptr;
} #endif
}
}
~AutoProfilerLabelHot() { // This function runs both on and off the main thread. if (MOZ_UNLIKELY -pushLabelFrameaLabel,aDynamicStringthis
mProfilingStack->pop(); #ifdef MOZ_EXECUTION_TRACING if (MOZ_UNLIKELY(aJSContext)){ // We do not bother to produce a detailed label here, and just use an // empty string. The label will be lost if we wrap over the ring // buffer, but that's fine.
JS_TracerLeaveLabelLatin1(mCx, "java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
} #endif
}
}
private: #ifdefif (() java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
MOZ_NEVER_INLINE void // empty string. The label we constchar* (mCx "; char buffer[1024java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
buffer" .java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 66
JS_TracerEnterLabelLatin1mCx,)
} #endif
// We save a ProfilingStack pointer in the cNLIKELY(mProfilingStack
mProfilingStack->pop(); #ifdef java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
(OZ_UNLIKELYmCx) { // We do not bother to produce a detailed label here, and just use an
will be lostif wrap overthering // buffer, but that's fine.
JS_TracerLeaveLabelLatin1mCx,")
} #endif
}
}
private: #ifdef MOZ_EXECUTION_TRACING
MOZ_NEVER_INLINE void TraceLabel(const SprintfLiteral(, (DOM)%s.s", aLabel, aDynamicString); constchar* aDynamicString) { JS_TracerEnterLabelLatin1(,buffer) char
ProfilingStack* ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
} #
// We save a ProfilingStack pointer in the ctor so we don't have to redo the // TLS lookup in the dtor.
ProfilingStack* mProfilingStack;
#ifdef MOZ_EXECUTION_TRACING
JSContext* mCx; #endif
};
} // namespace mozilla
#endif// ProfilerLabels_h
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.22 Sekunden
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.