From 2c6edfdde834147853faf13f4b3f841c28152827 Mon Sep 17 00:00:00 2001 From: Narcis Beleuzu Date: Mon, 5 Nov 2018 21:48:11 +0200 Subject: [PATCH] Backed out 9 changesets (bug 1499507) for bustages on ProfileBuffer.cpp . CLOSED TREE Backed out changeset 541186291b88 (bug 1499507) Backed out changeset 8a3f4acbad3b (bug 1499507) Backed out changeset f427afc392b0 (bug 1499507) Backed out changeset 58dc19fb2b76 (bug 1499507) Backed out changeset 9225e9aea377 (bug 1499507) Backed out changeset ca23a517da63 (bug 1499507) Backed out changeset 16d6c90333de (bug 1499507) Backed out changeset bc134fe1722a (bug 1499507) Backed out changeset 4a9c9a91182c (bug 1499507) --- dom/base/nsJSUtils.cpp | 2 +- dom/bindings/Codegen.py | 94 ++++------ dom/script/ScriptSettings.cpp | 2 +- js/public/ProfilingStack.h | 171 +++++++------------ js/public/RootingAPI.h | 8 +- js/src/vm/GeckoProfiler-inl.h | 1 + js/src/vm/GeckoProfiler.cpp | 24 ++- js/src/vm/HelperThreads.cpp | 5 +- js/src/vm/HelperThreads.h | 1 + js/src/vm/ProfilingStack.cpp | 10 +- mozglue/build/WindowsDllBlocklist.cpp | 3 +- mozglue/misc/AutoProfilerLabel.cpp | 5 +- mozglue/misc/AutoProfilerLabel.h | 6 +- tools/profiler/core/ProfileBuffer.cpp | 15 +- tools/profiler/core/ProfileBuffer.h | 2 +- tools/profiler/core/ProfileBufferEntry.cpp | 62 +++---- tools/profiler/core/ProfileBufferEntry.h | 5 +- tools/profiler/core/platform.cpp | 12 +- tools/profiler/public/GeckoProfiler.h | 45 +++-- tools/profiler/tests/gtest/GeckoProfiler.cpp | 4 +- 20 files changed, 188 insertions(+), 289 deletions(-) diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp index a96605ce1b81..a7725711ef6a 100644 --- a/dom/base/nsJSUtils.cpp +++ b/dom/base/nsJSUtils.cpp @@ -125,7 +125,7 @@ nsJSUtils::ExecutionContext::ExecutionContext(JSContext* aCx, : #ifdef MOZ_GECKO_PROFILER mAutoProfilerLabel("nsJSUtils::ExecutionContext", /* dynamicStr */ nullptr, - js::ProfilingStackFrame::Category::JS), + __LINE__, js::ProfilingStackFrame::Category::JS), #endif mCx(aCx) , mRealm(aCx, aGlobal) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index e45fa8492fdc..e71dcfd028dc 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -1586,6 +1586,12 @@ class CGAbstractMethod(CGThing): maybeNewline = " " if self.inline else "\n" return ' '.join(decorators) + maybeNewline + def _auto_profiler_label(self): + profiler_label_and_jscontext = self.profiler_label_and_jscontext() + if profiler_label_and_jscontext: + return 'AUTO_PROFILER_LABEL_FAST("%s", DOM, %s);' % profiler_label_and_jscontext + return None + def declare(self): if self.inline: return self._define(True) @@ -1610,9 +1616,9 @@ class CGAbstractMethod(CGThing): def definition_prologue(self, fromDeclare): prologue = "%s%s%s(%s)\n{\n" % (self._template(), self._decorators(), self.name, self._argstring(fromDeclare)) - profiler_label = self.auto_profiler_label() + profiler_label = self._auto_profiler_label() if profiler_label: - prologue += indent(profiler_label) + "\n" + prologue += " %s\n\n" % profiler_label return prologue @@ -1626,7 +1632,7 @@ class CGAbstractMethod(CGThing): Override this method to return a pair of (descriptive string, name of a JSContext* variable) in order to generate a profiler label for this method. """ - def auto_profiler_label(self): + def profiler_label_and_jscontext(self): return None # Override me! class CGAbstractStaticMethod(CGAbstractMethod): @@ -1869,17 +1875,13 @@ class CGClassConstructor(CGAbstractStaticMethod): constructorName=ctorName) return preamble + "\n" + callGenerator.define() - def auto_profiler_label(self): + def profiler_label_and_jscontext(self): name = self._ctor.identifier.name if name != "constructor": ctorName = name else: ctorName = self.descriptor.interface.identifier.name - return fill( - """ - AUTO_PROFILER_LABEL_DYNAMIC_FAST("${ctorName}", "constructor", DOM, cx, 0); - """, - ctorName=ctorName) + return ("%s constructor" % ctorName, "cx") # Encapsulate the constructor in a helper method to share genConstructorBody with CGJSImplMethod. class CGConstructNavigatorObject(CGAbstractMethod): @@ -8669,9 +8671,17 @@ class CGAbstractStaticBindingMethod(CGAbstractStaticMethod): """) return unwrap + self.generate_code().define() + def profiler_label_and_jscontext(self): + # Our args are JSNativeArguments() which contain a "JSContext* cx" + # argument. We let our subclasses choose the label. + return (self.profiler_label(), "cx") + def generate_code(self): assert False # Override me + def profiler_label(self): + assert False # Override me + def MakeNativeName(name): return name[0].upper() + IDLToCIdentifier(name[1:]) @@ -8698,17 +8708,10 @@ class CGSpecializedMethod(CGAbstractStaticMethod): return CGMethodCall(nativeName, self.method.isStatic(), self.descriptor, self.method).define() - def auto_profiler_label(self): + def profiler_label_and_jscontext(self): interface_name = self.descriptor.interface.identifier.name method_name = self.method.identifier.name - return fill( - """ - AUTO_PROFILER_LABEL_DYNAMIC_FAST( - "${interface_name}", "${method_name}", DOM, cx, - uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD)); - """, - interface_name=interface_name, - method_name=method_name) + return ("%s.%s" % (interface_name, method_name), "cx") @staticmethod def makeNativeName(descriptor, method): @@ -8965,17 +8968,10 @@ class CGStaticMethod(CGAbstractStaticBindingMethod): self.method) return CGMethodCall(nativeName, True, self.descriptor, self.method) - def auto_profiler_label(self): + def profiler_label(self): interface_name = self.descriptor.interface.identifier.name method_name = self.method.identifier.name - return fill( - """ - AUTO_PROFILER_LABEL_DYNAMIC_FAST( - "${interface_name}", "${method_name}", DOM, cx, - uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD)); - """, - interface_name=interface_name, - method_name=method_name) + return "%s.%s" % (interface_name, method_name) class CGSpecializedGetter(CGAbstractStaticMethod): @@ -9079,17 +9075,10 @@ class CGSpecializedGetter(CGAbstractStaticMethod): cgGetterCall(self.attr.type, nativeName, self.descriptor, self.attr).define()) - def auto_profiler_label(self): + def profiler_label_and_jscontext(self): interface_name = self.descriptor.interface.identifier.name attr_name = self.attr.identifier.name - return fill( - """ - AUTO_PROFILER_LABEL_DYNAMIC_FAST( - "${interface_name}", "${attr_name}", DOM, cx, - uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER)); - """, - interface_name=interface_name, - attr_name=attr_name) + return ("get %s.%s" % (interface_name, attr_name), "cx") @staticmethod def makeNativeName(descriptor, attr): @@ -9149,17 +9138,10 @@ class CGStaticGetter(CGAbstractStaticBindingMethod): return CGGetterCall(self.attr.type, nativeName, self.descriptor, self.attr) - def auto_profiler_label(self): + def profiler_label(self): interface_name = self.descriptor.interface.identifier.name attr_name = self.attr.identifier.name - return fill( - """ - AUTO_PROFILER_LABEL_DYNAMIC_FAST( - "${interface_name}", "${attr_name}", DOM, cx, - uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER)); - """, - interface_name=interface_name, - attr_name=attr_name) + return "get %s.%s" % (interface_name, attr_name) class CGSpecializedSetter(CGAbstractStaticMethod): @@ -9183,17 +9165,10 @@ class CGSpecializedSetter(CGAbstractStaticMethod): return CGSetterCall(self.attr.type, nativeName, self.descriptor, self.attr).define() - def auto_profiler_label(self): + def profiler_label_and_jscontext(self): interface_name = self.descriptor.interface.identifier.name attr_name = self.attr.identifier.name - return fill( - """ - AUTO_PROFILER_LABEL_DYNAMIC_FAST( - "${interface_name}", "${attr_name}", DOM, cx, - uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER)); - """, - interface_name=interface_name, - attr_name=attr_name) + return ("set %s.%s" % (interface_name, attr_name), "cx") @staticmethod def makeNativeName(descriptor, attr): @@ -9224,17 +9199,10 @@ class CGStaticSetter(CGAbstractStaticBindingMethod): self.attr) return CGList([checkForArg, call]) - def auto_profiler_label(self): + def profiler_label(self): interface_name = self.descriptor.interface.identifier.name attr_name = self.attr.identifier.name - return fill( - """ - AUTO_PROFILER_LABEL_DYNAMIC_FAST( - "${interface_name}", "${attr_name}", DOM, cx, - uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER)); - """, - interface_name=interface_name, - attr_name=attr_name) + return "set %s.%s" % (interface_name, attr_name) class CGSpecializedForwardingSetter(CGSpecializedSetter): diff --git a/dom/script/ScriptSettings.cpp b/dom/script/ScriptSettings.cpp index 578447828262..29e6f1b40be2 100644 --- a/dom/script/ScriptSettings.cpp +++ b/dom/script/ScriptSettings.cpp @@ -645,7 +645,7 @@ AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject, // ran. , mCallerOverride(cx()) #ifdef MOZ_GECKO_PROFILER - , mAutoProfilerLabel("AutoEntryScript", aReason, + , mAutoProfilerLabel("AutoEntryScript", aReason, __LINE__, js::ProfilingStackFrame::Category::JS) #endif { diff --git a/js/public/ProfilingStack.h b/js/public/ProfilingStack.h index 73cb3fc70d76..fde10ad148de 100644 --- a/js/public/ProfilingStack.h +++ b/js/public/ProfilingStack.h @@ -145,16 +145,13 @@ class ProfilingStackFrame mozilla::Atomic spOrScript; - // The bytecode offset for JS stack frames. - // Must not be used on non-JS frames; it'll contain either the default 0, - // or a leftover value from a previous JS stack frame that was using this - // ProfilingStackFrame object. + // Line number for non-JS stack frames, the bytecode offset otherwise. mozilla::Atomic pcOffsetIfJS_; + mozilla::recordreplay::Behavior::DontPreserve> lineOrPcOffset; - // Bits 0...6 hold the Flags. Bits 7...31 hold the category. + // Bits 0...1 hold the Kind. Bits 2...31 hold the category. mozilla::Atomic flagsAndCategory_; + mozilla::recordreplay::Behavior::DontPreserve> kindAndCategory_; static int32_t pcToOffset(JSScript* aScript, jsbytecode* aPc); @@ -166,49 +163,34 @@ class ProfilingStackFrame dynamicString_ = other.dynamicString(); void* spScript = other.spOrScript; spOrScript = spScript; - int32_t offsetIfJS = other.pcOffsetIfJS_; - pcOffsetIfJS_ = offsetIfJS; - uint32_t flagsAndCategory = other.flagsAndCategory_; - flagsAndCategory_ = flagsAndCategory; + int32_t offset = other.lineOrPcOffset; + lineOrPcOffset = offset; + uint32_t kindAndCategory = other.kindAndCategory_; + kindAndCategory_ = kindAndCategory; return *this; } - // 7 bits for the flags. - // That leaves 32 - 7 = 25 bits for the category. - enum class Flags : uint32_t { - // The first three flags describe the kind of the frame and are - // mutually exclusive. (We still give them individual bits for - // simplicity.) - + enum class Kind : uint32_t { // A regular label frame. These usually come from AutoProfilerLabel. - IS_LABEL_FRAME = 1 << 0, + LABEL = 0, // A special frame indicating the start of a run of JS profiling stack - // frames. IS_SP_MARKER_FRAME frames are ignored, except for the sp - // field. These frames are needed to get correct ordering between JS - // and LABEL frames because JS frames don't carry sp information. + // frames. SP_MARKER frames are ignored, except for the sp field. + // These frames are needed to get correct ordering between JS and LABEL + // frames because JS frames don't carry sp information. // SP is short for "stack pointer". - IS_SP_MARKER_FRAME = 1 << 1, + SP_MARKER = 1, - // A JS frame. - IS_JS_FRAME = 1 << 2, + // A normal JS frame. + JS_NORMAL = 2, - // An interpreter JS frame that has OSR-ed into baseline. IS_JS_FRAME - // frames can have this flag set and unset during their lifetime. - // JS_OSR frames are ignored. - JS_OSR = 1 << 3, + // An interpreter JS frame that has OSR-ed into baseline. JS_NORMAL + // frames can be converted to JS_OSR and back. JS_OSR frames are + // ignored. + JS_OSR = 3, - // The next three are mutually exclusive. - // By default, for profiling stack frames that have both a label and a - // dynamic string, the two strings are combined into one string of the - // form "