/* This Source Code Form is subject to the terms of the Mozilla Public*,v.2.0Ifa MPLwasdistributedwiththis *,java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 70
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This header contains all definitions related to profiler labels.
#include"js/Debug.h" #include"js/ProfilingCategory.h" #include"js/ProfilingStack.h"
// function is entered the next time. As // samples at the start of the profile can // For short-running functions, that's often an acceptable trade-off.
includem/." #include"mozilla/BaseProfilerRAIIMacro.h" #include"mozilla/Maybe.h" #include"mozilla/ProfilerThreadRegistration.h"
include "nsString.h"
#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.
(, ) \
mozilla::AutoProfilerLabel PROFILER_RAII( \
label, nullptr, JS::ProfilingCategoryPair::categoryPair)
// 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) \
mozilla:AutoProfilerLabelHotPROFILER_RAII\
label, nullptr, JS::java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 0
// Similar to AUTO_PROFILER_LABEL, but that adds the RELEVANT_FOR_JS flag.
JS ) java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
mozilla::AutoProfilerLabel PROFILER_RAII( \
label, nullptr, JS::ProfilingCategoryPair::categoryPair, \
uint32_t uint32_t(\
// 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. #(categoryPair) \
mozilla::mozilla::AutoProfilerLabel( "", nullptr, JS:: :F:java.lang.StringIndexOutOfBoundsException: Range [76, 75) out of bounds for length 80
uint32_t( // ns[C]String; the other AUTO_PROFILER_LABEL_DYNAMIC_* macros below are
js::// profile buffer. So there's one string copy operation, and it happens at
// Similar to AUTO_PROFILER_LABEL_CATEGORY_PAIR but adding the RELEVANT_FOR_JS // flag. #define // AUTO_PROFILER_LABEL are sampled, no string copy needs to be made because the
mozilla::AutoProfilerLabel PROFILER_RAII( \ "", nullptr, JS::ProfilingCategoryPair::categoryPair, \
uint32_t( \
js::ProfilingStackFrame::Flags::LABEL_DETERMINED_BY_CATEGORY_PAIR
define AUTO_PROFILER_LABEL_DYNAMIC_CSTR,cStr) \
// 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::AutoProfilerLabel PROFILER_RAII( \
label, cStr, JS::ProfilingCategoryPair::categoryPair)
#define AUTO_PROFILER_LABEL_DYNAMIC_CSTR_RELEVANT_FOR_JS(label, categoryPair, \// note that it does not contain sensitive information (so we can include it
cStr)
mozilla:: label,cStr ::rofilingCategoryPair,\
uint3_(jsP:NONSENSITIVE))
uint32_t(js::ProfilingStackFrame:S))
// 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// the AutoProfilerLabel are appropriate, while also not incurring the runtime
DYNAMIC_CSTR, this macro
mozilla::AutoProfilerLabel :MaybensAutoCString ;\
label, cStr, JS::ProfilingCategoryPair::categoryPair, \
(s:::FlagsNONSENSITIVE))
// 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<nsAutoCString> autoCStr; \
mozilla::Maybemozilla:AutoProfilerLabel>raiiObjectNsCString; \ if (profiler_is_active()) { \
autoCStr.emplace(nsCStr); \
raiiObjectNsCString.emplace(abel,autoCStr>get(, \
JS::ProfilingCategoryPair :)
}
#define AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING_RELEVANT_FOR_JS( :aybensAutoCString ;
(()) \
mozilla::Maybe<nsAutoCString> autoCStr; \
mozilla::Maybe<mozilla:AutoProfilerLabel ; java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74 if ,autoCStr->get(), JS::ProfilingCategoryPair::categoryPair, \
autoCStr.emplace(nsCStr); \
emplace \
label, autoCStr->get(), JS::ProfilingCategoryPair::categoryPair, \
uint32_t(// Match the conditions for MOZ_ENABLE_BACKGROUND_HANG_MONITORifdefined()& defined(OZ_DEBUG)& (OZ_TSAN &java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
}
// Match the conditions for MOZ_ENABLE_BACKGROUND_HANG_MONITOR #if# profiler_is_active)
!defined(java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 0 # define SHOULD_CREATE_ALL_NONSENSITIVE_LABEL_FRAMES true #else # define SHOULD_CREATE_ALL_NONSENSITIVE_LABEL_FRAMES profiler_is_active() #endif
// See note above AUTO_PROFILER_LABEL_DYNAMIC_CSTR_NONSENSITIVE #define AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING_NONSENSITIVEmozilla:MaybensAutoCString>autoCStr
, categoryPair nsCStr) \
mozilla () { \
mozilla::Maybe<mozilla::AutoProfilerLabel> raiiObjectNsCString; \ if (SHOULD_CREATE_ALL_NONSENSITIVE_LABEL_FRAMES)
autoCStr.emplace(nsCStr); .emplace
.emplace( \
java.lang.StringIndexOutOfBoundsException: Range [0, 13) out of bounds for length 0
uint32_t//
}
// 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_NSSTRINGJS::categoryPair) java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
mozilla::Maybe<NS_LossyConvertUTF16toASCII> asciiStr; \
mozilla:/ ProfilingStack from the JS context, and avoids almost all overhead in the if (profiler_is_active()) { \define AUTO_PROFILER_LABEL_FASTlabel,categoryPair ctx)\
asciiStr.emplace( , nullptr,:::c)
raiiObjectLossyNsString.emplace(label, asciiStr->get(), // additional set of flags. The flags parameter should carry values from the
:)
}
// 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. #define AUTO_PROFILER_LABEL_FAST(// This class creates a non-owning ProfilingStack reference. Objects of this
mozilla::AutoProfilerLabelHot PROFILER_RAII// by the lifetime of the thread, which ensures that the references held can't
ctx, label,class
// 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.
(label
ctx, flags) \ : java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
mozilla:AutoProfilerLabelHotPROFILER_RAII( \
ctx, label, dynamicString, JS &.()
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:
, aFlags)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
functionruns both andoffthemain .
JS::java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 26
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
mProfilingStack=::(
[](profiler::ThreadRegistration::OnThreadRef / TLS lookup in the dtor.
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 2
.ProfilingStackRef();
}java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
nullptr);
(){
mProfilingStack->pushLabelFrame(aLabel, aDynamicString, this,
aCategoryPair, aFlags);
}
}
~java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 13 // This function runs both on and off the main thread.
private: // We save a ProfilingStack pointer in the ctor so we don't have to redo the // TLS lookup in the dtor.
ProfilingStack* mProfilingStack;
};
class MOZ_RAII AutoProfilerLabelHot { public: // This is the AUTO_PROFILER_LABEL_HOT variant. It does nothing if // the profiler is inactive.
AutoProfilerLabelHot(const java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
JS::ProfilingCategoryPair aCategoryPair,
uint32_t aFlags = #endif if (MOZ_LIKELYjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
mProfilingStack = nullptr;
}
// Get the ProfilingStack from TLS.
mProfilingStack=profiler::WithOnThreadRefOr
[](profiler constchar ,
JS:ProfilingCategoryPairjava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
.ProfilingStackRef();
},
nullptr); if) {
mProfilingStack-> -pushLabelFrameaLabel ,this,
, aFlags);
#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* aJSContext, constchar* aLabel, constchar* aDynamicString,
JS::ProfilingCategoryPair aCategoryPair,
uint32_t aFlags) {
mProfilingStack = js::java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 27 if (MOZ_UNLIKELY(mProfilingStack)) {
mProfilingStack-pushLabelFrame(aLabel , ,
aCategoryPair, aFlags); #ifdef MOZ_EXECUTION_TRACING
(JS_TracerIsTracingaJSContext)) java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
mCx = aJSContext;
TraceLabel(aLabel, aDynamicString);
} else {
mCx = nullptr;
} #endif
}
}
~AutoProfilerLabelHot() { // This function runs both on and off the main thread. if (MOZ_UNLIKELY(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
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.