diff --git a/memory/build/mozjemalloc.cpp b/memory/build/mozjemalloc.cpp
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -137,16 +137,17 @@
 #include "mozilla/TaggedAnonymousMemory.h"
 #include "mozilla/ThreadLocal.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/Unused.h"
 #include "mozilla/fallible.h"
 #include "rb.h"
 #include "Mutex.h"
 #include "Utils.h"
+#include "mozilla/SSE.h"
 
 using namespace mozilla;
 
 // On Linux, we use madvise(MADV_DONTNEED) to release memory back to the
 // operating system.  If we release 1MB of live pages with MADV_DONTNEED, our
 // RSS will decrease by 1MB (almost) immediately.
 //
 // On Mac, we use madvise(MADV_FREE).  Unlike MADV_DONTNEED on Linux, MADV_FREE
@@ -2931,16 +2932,21 @@ arena_t::MallocSmall(size_t aSize, bool 
                    (FloorLog2(aSize / kMaxQuantumClass) - 1)];
       break;
     default:
       MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Unexpected size class type");
   }
   MOZ_DIAGNOSTIC_ASSERT(aSize == bin->mSizeClass);
 
   {
+#ifdef MOZILLA_MAY_SUPPORT_SSE
+    if (mozilla::supports_sse()) {
+      _mm_prefetch((char *)bin, _MM_HINT_NTA);
+    }
+#endif
     MutexAutoLock lock(mLock);
     run = bin->mCurrentRun;
     if (MOZ_UNLIKELY(!run || run->mNumFree == 0)) {
       run = bin->mCurrentRun = GetNonFullBinRun(bin);
     }
     if (MOZ_UNLIKELY(!run)) {
       return nullptr;
     }
@@ -2948,16 +2954,23 @@ arena_t::MallocSmall(size_t aSize, bool 
     MOZ_DIAGNOSTIC_ASSERT(run->mNumFree > 0);
     ret = arena_run_reg_alloc(run, bin);
     MOZ_DIAGNOSTIC_ASSERT(ret);
     run->mNumFree--;
     if (!ret) {
       return nullptr;
     }
 
+#ifdef MOZILLA_MAY_SUPPORT_SSE
+    if (mozilla::supports_sse()) {
+      _mm_prefetch((char *)ret, _MM_HINT_NTA);
+      _mm_prefetch((char *)ret + 64, _MM_HINT_NTA);
+    }
+#endif
+
     mStats.allocated_small += aSize;
   }
 
   if (!aZero) {
     ApplyZeroOrJunk(ret, aSize);
   } else {
     memset(ret, 0, aSize);
   }
@@ -2974,16 +2987,22 @@ arena_t::MallocLarge(size_t aSize, bool 
   aSize = PAGE_CEILING(aSize);
 
   {
     MutexAutoLock lock(mLock);
     ret = AllocRun(aSize, true, aZero);
     if (!ret) {
       return nullptr;
     }
+#ifdef MOZILLA_MAY_SUPPORT_SSE
+    if (mozilla::supports_sse()) {
+      _mm_prefetch((char *)ret, _MM_HINT_NTA);
+      _mm_prefetch((char *)ret + 64, _MM_HINT_NTA);
+    }
+#endif
     mStats.allocated_large += aSize;
   }
 
   if (!aZero) {
     ApplyZeroOrJunk(ret, aSize);
   }
 
   return ret;
@@ -4919,8 +4938,42 @@ void*
 }
 
 size_t
 _msize(void* aPtr)
 {
   return DefaultMalloc::malloc_usable_size(aPtr);
 }
 #endif
+
+#ifdef XP_WIN
+#include <math.h>
+
+extern "C" double __cdecl floor_tt(double x)
+{
+#ifdef MOZILLA_MAY_SUPPORT_SSE4_1
+  if (mozilla::supports_sse4_1()) {
+    __m128d xd = _mm_load_sd(&x);
+    double d;
+
+    xd = _mm_floor_sd(xd, xd);
+    _mm_store_sd(&d, xd);
+    return d;
+  }
+#endif
+  return floor(x);
+}
+
+extern "C" double __cdecl ceil_tt(double x)
+{
+#ifdef MOZILLA_MAY_SUPPORT_SSE4_1
+  if (mozilla::supports_sse4_1()) {
+    __m128d xd = _mm_load_sd(&x);
+    double d;
+
+    xd = _mm_ceil_sd(xd, xd);
+    _mm_store_sd(&d, xd);
+    return d;
+  }
+#endif
+  return ceil(x);
+}
+#endif
