Bug 1487109 - use a more portable idiom for pausing in SamplerThread::SleepMicro; r=mstange
authorNathan Froyd <froydnj@mozilla.com>
Wed, 29 Aug 2018 17:24:34 -0400
changeset 482270 b7248bb3f017188a9dc6bf0d0ab3e4e8699d5183
parent 482269 cd7292d051a05ce83b421aada6e8e0e6598cdfb9
child 482271 b4dc5ede8f5655c5e1033b5ad2e50fe3e6fe3f3d
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersmstange
bugs1487109
milestone63.0a1
Bug 1487109 - use a more portable idiom for pausing in SamplerThread::SleepMicro; r=mstange YieldProcessor() is just _mm_pause in disguise, but it works on more platforms than the Intel-specific intrinsic.
tools/profiler/core/platform-win32.cpp
--- a/tools/profiler/core/platform-win32.cpp
+++ b/tools/profiler/core/platform-win32.cpp
@@ -27,20 +27,16 @@
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 // SUCH DAMAGE.
 
 #include <windows.h>
 #include <mmsystem.h>
 #include <process.h>
 
-#ifdef __MINGW32__
-#include <immintrin.h> // for _mm_pause
-#endif
-
 #include "nsWindowsDllInterceptor.h"
 #include "mozilla/StackWalk_windows.h"
 #include "mozilla/WindowsVersion.h"
 
 /* static */ int
 Thread::GetCurrentId()
 {
   DWORD threadId = GetCurrentThreadId();
@@ -257,17 +253,17 @@ SamplerThread::SleepMicro(uint32_t aMicr
 
     // First, sleep for as many whole milliseconds as possible.
     if (aMicroseconds >= 1000) {
       ::Sleep(aMicroseconds / 1000);
     }
 
     // Then, spin until enough time has passed.
     while (TimeStamp::Now() < end) {
-      _mm_pause();
+      YieldProcessor();
     }
   }
 }
 
 void
 SamplerThread::Stop(PSLockRef aLock)
 {
   // Disable any timer resolution changes we've made. Do it now while