Bug 1138620 - Allow external binary modules to ignore thread status monitoring for Nuwa process stabilization. r=nfroyd, a=bajaj
authorChih-Kai (Patrick) Wang <kk1fff@ckwang.info>, Cervantes Yu <cyu@mozilla.com>
Fri, 24 Apr 2015 14:11:10 +0800
changeset 238259 07e3ecc6786f4f40fdb54a9eac620c38c914fd79
parent 238258 ed10c7a4ddd857544b42ed09b38baebcbb478855
child 238260 e79c19bf19bf2308308e15db5bc248310e966b3c
push id540
push userryanvm@gmail.com
push dateMon, 27 Apr 2015 21:12:44 +0000
treeherdermozilla-b2g37_v2_2@07e3ecc6786f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd, bajaj
bugs1138620
milestone37.0
Bug 1138620 - Allow external binary modules to ignore thread status monitoring for Nuwa process stabilization. r=nfroyd, a=bajaj
xpcom/threads/nsIThreadManager.idl
xpcom/threads/nsThreadManager.cpp
xpcom/threads/nsThreadManager.h
--- a/xpcom/threads/nsIThreadManager.idl
+++ b/xpcom/threads/nsIThreadManager.idl
@@ -8,17 +8,17 @@
 
 [ptr] native PRThread(PRThread);
 
 interface nsIThread;
 
 /**
  * An interface for creating and locating nsIThread instances.
  */
-[scriptable, uuid(1be89eca-e2f7-453b-8d38-c11ba247f6f3)]
+[scriptable, uuid(04092259-4498-4c82-ac52-f9225eb114d0)]
 interface nsIThreadManager : nsISupports
 {
   /**
    * Default number of bytes reserved for a thread's stack, if no stack size
    * is specified in newThread(). 0 means use platform default.
    */
   const unsigned long DEFAULT_STACK_SIZE = 0;
 
@@ -60,9 +60,16 @@ interface nsIThreadManager : nsISupports
    */
   readonly attribute nsIThread currentThread;
 
   /**
    * This attribute is true if the calling thread is the main thread of the
    * application process.
    */
   readonly attribute boolean isMainThread;
+
+  /**
+   * Informs the thread manager to not monitor the status of the current thread.
+   * This method only works on platforms with Nuwa enabled; on other platforms,
+   * it throws an error.
+   */
+  [noscript] void setIgnoreThreadStatus();
 };
--- a/xpcom/threads/nsThreadManager.cpp
+++ b/xpcom/threads/nsThreadManager.cpp
@@ -438,23 +438,28 @@ nsThreadManager::GetIsMainThread(bool* a
 
 uint32_t
 nsThreadManager::GetHighestNumberOfThreads()
 {
   OffTheBooksMutexAutoLock lock(mLock);
   return mHighestNumberOfThreads;
 }
 
-#ifdef MOZ_NUWA_PROCESS
-void
+NS_IMETHODIMP
 nsThreadManager::SetIgnoreThreadStatus()
 {
+#ifdef MOZ_NUWA_PROCESS
   GetCurrentThreadStatusInfo()->mIgnored = true;
+  return NS_OK;
+#else
+  return NS_ERROR_NOT_IMPLEMENTED;
+#endif
 }
 
+#ifdef MOZ_NUWA_PROCESS
 void
 nsThreadManager::SetThreadIdle(nsIRunnable **aReturnRunnable)
 {
   SetThreadIsWorking(GetCurrentThreadStatusInfo(), false, aReturnRunnable);
 }
 
 void
 nsThreadManager::SetThreadWorking()
--- a/xpcom/threads/nsThreadManager.h
+++ b/xpcom/threads/nsThreadManager.h
@@ -67,18 +67,16 @@ public:
 
   // This needs to be public in order to support static instantiation of this
   // class with older compilers (e.g., egcs-2.91.66).
   ~nsThreadManager()
   {
   }
 
 #ifdef MOZ_NUWA_PROCESS
-  void SetIgnoreThreadStatus();
-
   // |SetThreadWorking| and |SetThreadIdle| set status of thread that is
   // currently running. They get thread status information from TLS and pass
   // the information to |SetThreadIsWorking|.
   void SetThreadIdle(nsIRunnable** aReturnRunnable);
   void SetThreadWorking();
 
   // |SetThreadIsWorking| is where is status actually changed. Thread status
   // information is passed as a argument so caller must obtain the structure