Bug 1409441 part 1 - Inline ActivationEntryMonitor constructor/destructor. r=fitzgen
☠☠ backed out by 60cadd8c8b54 ☠ ☠
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 18 Oct 2017 17:11:41 +0100
changeset 386895 88c4af1d92d0c2fe1a167758512e26cceb174495
parent 386894 82ca05dc42e91a1be20877314541b57d13ec51a9
child 386896 714bd2c7dbc7d625dc5a3df8b48dc5505bbae593
push id96327
push userjandemooij@gmail.com
push dateWed, 18 Oct 2017 16:14:14 +0000
treeherdermozilla-inbound@acb5cba79c55 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs1409441
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1409441 part 1 - Inline ActivationEntryMonitor constructor/destructor. r=fitzgen
js/src/vm/Stack-inl.h
js/src/vm/Stack.cpp
js/src/vm/Stack.h
--- a/js/src/vm/Stack-inl.h
+++ b/js/src/vm/Stack-inl.h
@@ -874,16 +874,36 @@ AbstractFramePtr::newTarget() const
 inline bool
 AbstractFramePtr::debuggerNeedsCheckPrimitiveReturn() const
 {
     if (isWasmDebugFrame())
         return false;
     return script()->isDerivedClassConstructor();
 }
 
+ActivationEntryMonitor::ActivationEntryMonitor(JSContext* cx)
+  : cx_(cx), entryMonitor_(cx->entryMonitor)
+{
+    cx->entryMonitor = nullptr;
+}
+
+ActivationEntryMonitor::ActivationEntryMonitor(JSContext* cx, InterpreterFrame* entryFrame)
+  : ActivationEntryMonitor(cx)
+{
+    if (MOZ_UNLIKELY(entryMonitor_))
+        init(cx, entryFrame);
+}
+
+ActivationEntryMonitor::ActivationEntryMonitor(JSContext* cx, jit::CalleeToken entryToken)
+  : ActivationEntryMonitor(cx)
+{
+    if (MOZ_UNLIKELY(entryMonitor_))
+        init(cx, entryToken);
+}
+
 ActivationEntryMonitor::~ActivationEntryMonitor()
 {
     if (entryMonitor_)
         entryMonitor_->Exit(cx_);
 
     cx_->entryMonitor = entryMonitor_;
 }
 
--- a/js/src/vm/Stack.cpp
+++ b/js/src/vm/Stack.cpp
@@ -1447,63 +1447,57 @@ void
 NonBuiltinScriptFrameIter::settle()
 {
     if (!SelfHostedFramesVisible()) {
         while (!done() && script()->selfHosted())
             ScriptFrameIter::operator++();
     }
 }
 
-ActivationEntryMonitor::ActivationEntryMonitor(JSContext* cx)
-  : cx_(cx), entryMonitor_(cx->entryMonitor)
-{
-    cx->entryMonitor = nullptr;
-}
-
 Value
 ActivationEntryMonitor::asyncStack(JSContext* cx)
 {
     RootedValue stack(cx, ObjectOrNullValue(cx->asyncStackForNewActivations()));
     if (!cx->compartment()->wrap(cx, &stack)) {
         cx->clearPendingException();
         return UndefinedValue();
     }
     return stack;
 }
 
-ActivationEntryMonitor::ActivationEntryMonitor(JSContext* cx, InterpreterFrame* entryFrame)
-  : ActivationEntryMonitor(cx)
+void
+ActivationEntryMonitor::init(JSContext* cx, InterpreterFrame* entryFrame)
 {
-    if (entryMonitor_) {
-        // The InterpreterFrame is not yet part of an Activation, so it won't
-        // be traced if we trigger GC here. Suppress GC to avoid this.
-        gc::AutoSuppressGC suppressGC(cx);
-        RootedValue stack(cx, asyncStack(cx));
-        const char* asyncCause = cx->asyncCauseForNewActivations;
-        if (entryFrame->isFunctionFrame())
-            entryMonitor_->Entry(cx, &entryFrame->callee(), stack, asyncCause);
-        else
-            entryMonitor_->Entry(cx, entryFrame->script(), stack, asyncCause);
-    }
+    MOZ_ASSERT(entryMonitor_);
+
+    // The InterpreterFrame is not yet part of an Activation, so it won't
+    // be traced if we trigger GC here. Suppress GC to avoid this.
+    gc::AutoSuppressGC suppressGC(cx);
+    RootedValue stack(cx, asyncStack(cx));
+    const char* asyncCause = cx->asyncCauseForNewActivations;
+    if (entryFrame->isFunctionFrame())
+        entryMonitor_->Entry(cx, &entryFrame->callee(), stack, asyncCause);
+    else
+        entryMonitor_->Entry(cx, entryFrame->script(), stack, asyncCause);
 }
 
-ActivationEntryMonitor::ActivationEntryMonitor(JSContext* cx, jit::CalleeToken entryToken)
-  : ActivationEntryMonitor(cx)
+void
+ActivationEntryMonitor::init(JSContext* cx, jit::CalleeToken entryToken)
 {
-    if (entryMonitor_) {
-        // The CalleeToken is not traced at this point and we also don't want
-        // a GC to discard the code we're about to enter, so we suppress GC.
-        gc::AutoSuppressGC suppressGC(cx);
-        RootedValue stack(cx, asyncStack(cx));
-        const char* asyncCause = cx->asyncCauseForNewActivations;
-        if (jit::CalleeTokenIsFunction(entryToken))
-            entryMonitor_->Entry(cx_, jit::CalleeTokenToFunction(entryToken), stack, asyncCause);
-        else
-            entryMonitor_->Entry(cx_, jit::CalleeTokenToScript(entryToken), stack, asyncCause);
-    }
+    MOZ_ASSERT(entryMonitor_);
+
+    // The CalleeToken is not traced at this point and we also don't want
+    // a GC to discard the code we're about to enter, so we suppress GC.
+    gc::AutoSuppressGC suppressGC(cx);
+    RootedValue stack(cx, asyncStack(cx));
+    const char* asyncCause = cx->asyncCauseForNewActivations;
+    if (jit::CalleeTokenIsFunction(entryToken))
+        entryMonitor_->Entry(cx_, jit::CalleeTokenToFunction(entryToken), stack, asyncCause);
+    else
+        entryMonitor_->Entry(cx_, jit::CalleeTokenToScript(entryToken), stack, asyncCause);
 }
 
 /*****************************************************************************/
 
 jit::JitActivation::JitActivation(JSContext* cx)
   : Activation(cx, Jit),
     packedExitFP_(nullptr),
     prevJitActivation_(cx->jitActivation),
--- a/js/src/vm/Stack.h
+++ b/js/src/vm/Stack.h
@@ -1239,26 +1239,29 @@ namespace jit {
 class MOZ_RAII ActivationEntryMonitor
 {
     JSContext* cx_;
 
     // The entry point monitor that was set on cx_->runtime() when this
     // ActivationEntryMonitor was created.
     JS::dbg::AutoEntryMonitor* entryMonitor_;
 
-    explicit ActivationEntryMonitor(JSContext* cx);
+    explicit inline ActivationEntryMonitor(JSContext* cx);
 
     ActivationEntryMonitor(const ActivationEntryMonitor& other) = delete;
     void operator=(const ActivationEntryMonitor& other) = delete;
 
+    void init(JSContext* cx, jit::CalleeToken entryToken);
+    void init(JSContext* cx, InterpreterFrame* entryFrame);
+
     Value asyncStack(JSContext* cx);
 
   public:
-    ActivationEntryMonitor(JSContext* cx, InterpreterFrame* entryFrame);
-    ActivationEntryMonitor(JSContext* cx, jit::CalleeToken entryToken);
+    inline ActivationEntryMonitor(JSContext* cx, InterpreterFrame* entryFrame);
+    inline ActivationEntryMonitor(JSContext* cx, jit::CalleeToken entryToken);
     inline ~ActivationEntryMonitor();
 };
 
 class Activation
 {
   protected:
     JSContext* cx_;
     JSCompartment* compartment_;