Bug 968335 - Use an AutoCxPusher directly in Auto{Entry,Incumbent}Global. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Fri, 14 Feb 2014 22:36:43 -0800
changeset 186106 feacaec8b46307db6ca68d8d5682513ab8cd2078
parent 186105 b4c42334f112acc44a8330bdeb098cfd1762bc41
child 186107 4e21b5c857cbc42972913c6f5767043728598def
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs968335
milestone30.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 968335 - Use an AutoCxPusher directly in Auto{Entry,Incumbent}Global. r=bz This will let us ask whether the AutoCxPusher is stack-top.
dom/base/ScriptSettings.cpp
dom/base/ScriptSettings.h
--- a/dom/base/ScriptSettings.cpp
+++ b/dom/base/ScriptSettings.cpp
@@ -172,17 +172,17 @@ AutoEntryScript::AutoEntryScript(nsIGlob
     if (sgo && sgo->GetScriptContext()) {
       aCx = sgo->GetScriptContext()->GetNativeContext();
     }
     if (!aCx) {
       aCx = nsContentUtils::GetSafeJSContext();
     }
   }
   if (aIsMainThread) {
-    mCxPusher.Push(aCx);
+    mCxPusher.construct(aCx);
   }
   mAc.construct(aCx, aGlobalObject->GetGlobalJSObject());
   mStack.Push(&mEntry);
 }
 
 AutoEntryScript::~AutoEntryScript()
 {
   MOZ_ASSERT(mStack.Incumbent() == &mEntry);
@@ -202,17 +202,18 @@ AutoIncumbentScript::~AutoIncumbentScrip
   MOZ_ASSERT(mStack.Incumbent() == &mEntry);
   mStack.Pop();
 }
 
 AutoSystemCaller::AutoSystemCaller(bool aIsMainThread)
   : mStack(ScriptSettingsStack::Ref())
 {
   if (aIsMainThread) {
-    mCxPusher.PushNull();
+    mCxPusher.construct(static_cast<JSContext*>(nullptr),
+                        /* aAllowNull = */ true);
   }
   mStack.PushSystem();
 }
 
 AutoSystemCaller::~AutoSystemCaller()
 {
   mStack.Pop();
 }
--- a/dom/base/ScriptSettings.h
+++ b/dom/base/ScriptSettings.h
@@ -77,17 +77,17 @@ public:
                   bool aIsMainThread = NS_IsMainThread(),
                   // Note: aCx is mandatory off-main-thread.
                   JSContext* aCx = nullptr);
   ~AutoEntryScript();
 
 private:
   dom::ScriptSettingsStack& mStack;
   dom::ScriptSettingsStackEntry mEntry;
-  nsCxPusher mCxPusher;
+  mozilla::Maybe<AutoCxPusher> mCxPusher;
   mozilla::Maybe<JSAutoCompartment> mAc; // This can de-Maybe-fy when mCxPusher
                                          // goes away.
 };
 
 /*
  * A class that can be used to force a particular incumbent script on the stack.
  */
 class AutoIncumbentScript {
@@ -106,15 +106,15 @@ private:
  * they were invoked "from C++".
  */
 class AutoSystemCaller {
 public:
   AutoSystemCaller(bool aIsMainThread = NS_IsMainThread());
   ~AutoSystemCaller();
 private:
   dom::ScriptSettingsStack& mStack;
-  nsCxPusher mCxPusher;
+  mozilla::Maybe<AutoCxPusher> mCxPusher;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_ScriptSettings_h