Bug 1275999 part 2. Change XPCJSContextStack to just store JSContext*. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 27 May 2016 09:53:20 -0400
changeset 338341 ed57ef99f5e189f671ec09e54f9ccfa2d7980445
parent 338340 8c17c414e300f4d1acdd346006f9afb0ce8ec524
child 338342 1d9e42ddcd59520042665e769c46c8d2a50a5981
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1275999
milestone49.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 1275999 part 2. Change XPCJSContextStack to just store JSContext*. r=bholley
js/xpconnect/src/XPCJSContextStack.cpp
js/xpconnect/src/xpcprivate.h
--- a/js/xpconnect/src/XPCJSContextStack.cpp
+++ b/js/xpconnect/src/XPCJSContextStack.cpp
@@ -29,44 +29,43 @@ XPCJSContextStack::~XPCJSContextStack()
 
 JSContext*
 XPCJSContextStack::Pop()
 {
     MOZ_ASSERT(!mStack.IsEmpty());
 
     uint32_t idx = mStack.Length() - 1; // The thing we're popping
 
-    JSContext* cx = mStack[idx].cx;
+    JSContext* cx = mStack[idx];
 
     mStack.RemoveElementAt(idx);
+    JSContext* newTop;
+    // We _could_ probably use mStack.SafeElementAt(idx-1, nullptr) here....
     if (idx == 0) {
-        js::Debug_SetActiveJSContext(mRuntime->Runtime(), nullptr);
-        return cx;
+        newTop = nullptr;
+    } else {
+        newTop = mStack[idx-1];
     }
-
-    --idx; // Advance to new top of the stack
-
-    XPCJSContextInfo& e = mStack[idx];
-    js::Debug_SetActiveJSContext(mRuntime->Runtime(), e.cx);
+    js::Debug_SetActiveJSContext(mRuntime->Runtime(), newTop);
     return cx;
 }
 
 bool
 XPCJSContextStack::Push(JSContext* cx)
 {
     js::Debug_SetActiveJSContext(mRuntime->Runtime(), cx);
     mStack.AppendElement(cx);
     return true;
 }
 
 bool
 XPCJSContextStack::HasJSContext(JSContext* cx)
 {
     for (uint32_t i = 0; i < mStack.Length(); i++)
-        if (cx == mStack[i].cx)
+        if (cx == mStack[i])
             return true;
     return false;
 }
 
 JSContext*
 XPCJSContextStack::GetSafeJSContext()
 {
     MOZ_ASSERT(mSafeJSContext);
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -2761,26 +2761,16 @@ private:
 private:
     RefPtr<nsJSID> mDetails;
 };
 
 
 /***************************************************************************/
 // XPCJSContextStack is not actually an xpcom object, but xpcom calls are
 // delegated to it as an implementation detail.
-struct XPCJSContextInfo {
-    explicit XPCJSContextInfo(JSContext* aCx) :
-        cx(aCx),
-        savedFrameChain(false)
-    {}
-    JSContext* cx;
-
-    // Whether the frame chain was saved
-    bool savedFrameChain;
-};
 
 namespace xpc {
 bool PushNullJSContext();
 void PopNullJSContext();
 
 } /* namespace xpc */
 
 namespace mozilla {
@@ -2803,37 +2793,34 @@ public:
 
     uint32_t Count()
     {
         return mStack.Length();
     }
 
     JSContext* Peek()
     {
-        return mStack.IsEmpty() ? nullptr : mStack[mStack.Length() - 1].cx;
+        return mStack.IsEmpty() ? nullptr : mStack[mStack.Length() - 1];
     }
 
     JSContext* InitSafeJSContext();
     JSContext* GetSafeJSContext();
     bool HasJSContext(JSContext* cx);
 
-    const InfallibleTArray<XPCJSContextInfo>* GetStack()
-    { return &mStack; }
-
 private:
     friend class mozilla::dom::danger::AutoCxPusher;
     friend bool xpc::PushNullJSContext();
     friend void xpc::PopNullJSContext();
 
     // We make these private so that stack manipulation can only happen
     // through one of the above friends.
     JSContext* Pop();
     bool Push(JSContext* cx);
 
-    AutoTArray<XPCJSContextInfo, 16> mStack;
+    AutoTArray<JSContext*, 16> mStack;
     XPCJSRuntime* mRuntime;
     JSContext*  mSafeJSContext;
 };
 
 /***************************************************************************/
 // 'Components' object implementations. nsXPCComponentsBase has the
 // less-privileged stuff that we're willing to expose to XBL.