Bug 1283616 - part 1 - micro-optimize removing microtask runnables from the queue; r=khuey
authorNathan Froyd <froydnj@gmail.com>
Tue, 05 Jul 2016 18:49:06 -0400
changeset 303700 72e450d5e17bf090ba786bf330c46d5baf20339c
parent 303699 ac08e5118aefd91b5ae005225dbf2094bd8cd1bd
child 303701 92f2f41c5f7e8893be52a9ee7aa939df40db1b37
push id79144
push usernfroyd@mozilla.com
push dateTue, 05 Jul 2016 14:50:44 +0000
treeherdermozilla-inbound@92f2f41c5f7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1283616
milestone50.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 1283616 - part 1 - micro-optimize removing microtask runnables from the queue; r=khuey We can just extract the reference we want from the queue since we're about to remove it; no sense in performing extra refcounting if we don't need to.
dom/promise/Promise.cpp
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -990,17 +990,17 @@ Promise::PerformMicroTaskCheckpoint()
 
   if (microtaskQueue.empty()) {
     return false;
   }
 
   AutoSafeJSContext cx;
 
   do {
-    nsCOMPtr<nsIRunnable> runnable = microtaskQueue.front();
+    nsCOMPtr<nsIRunnable> runnable = microtaskQueue.front().forget();
     MOZ_ASSERT(runnable);
 
     // This function can re-enter, so we remove the element before calling.
     microtaskQueue.pop();
     nsresult rv = runnable->Run();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return false;
     }
@@ -1027,17 +1027,17 @@ Promise::PerformWorkerMicroTaskCheckpoin
 
     if (microtaskQueue->empty()) {
       microtaskQueue = &runtime->GetPromiseMicroTaskQueue();
       if (microtaskQueue->empty()) {
         break;
       }
     }
 
-    nsCOMPtr<nsIRunnable> runnable = microtaskQueue->front();
+    nsCOMPtr<nsIRunnable> runnable = microtaskQueue->front().forget();
     MOZ_ASSERT(runnable);
 
     // This function can re-enter, so we remove the element before calling.
     microtaskQueue->pop();
     nsresult rv = runnable->Run();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return;
     }
@@ -1057,17 +1057,17 @@ Promise::PerformWorkerDebuggerMicroTaskC
     // queue.
     std::queue<nsCOMPtr<nsIRunnable>>* microtaskQueue =
       &runtime->GetDebuggerPromiseMicroTaskQueue();
 
     if (microtaskQueue->empty()) {
       break;
     }
 
-    nsCOMPtr<nsIRunnable> runnable = microtaskQueue->front();
+    nsCOMPtr<nsIRunnable> runnable = microtaskQueue->front().forget();
     MOZ_ASSERT(runnable);
 
     // This function can re-enter, so we remove the element before calling.
     microtaskQueue->pop();
     nsresult rv = runnable->Run();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return;
     }