Bug 1333436 - Add assertions about overlaps to the safe-for-races memcpy blocks. r=bbouvier a=lizzard
authorLars T Hansen <lhansen@mozilla.com>
Tue, 24 Jan 2017 18:39:21 +0100
changeset 378056 47435662c2ca1787eb996a827d789a57e1a4a392
parent 378055 0d5fd88afc55a306466f7d98f895ea9181cc5526
child 378057 005919b0717191c77f6a11b1d4facd659cb4368e
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier, lizzard
bugs1333436
milestone53.0a2
Bug 1333436 - Add assertions about overlaps to the safe-for-races memcpy blocks. r=bbouvier a=lizzard
js/src/jit/arm/AtomicOperations-arm.h
js/src/jit/arm64/AtomicOperations-arm64.h
js/src/jit/mips-shared/AtomicOperations-mips-shared.h
js/src/jit/none/AtomicOperations-none.h
js/src/jit/none/AtomicOperations-ppc.h
js/src/jit/none/AtomicOperations-sparc.h
js/src/jit/x86-shared/AtomicOperations-x86-shared.h
--- a/js/src/jit/arm/AtomicOperations-arm.h
+++ b/js/src/jit/arm/AtomicOperations-arm.h
@@ -192,16 +192,18 @@ inline void
 js::jit::AtomicOperations::storeSafeWhenRacy(T* addr, T val)
 {
     *addr = val;                // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memcpySafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
+    MOZ_ASSERT(!((char*)dest <= (char*)src && (char*)src < (char*)dest+nbytes));
+    MOZ_ASSERT(!((char*)src <= (char*)dest && (char*)dest < (char*)src+nbytes));
     memcpy(dest, src, nbytes); // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memmoveSafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
     memmove(dest, src, nbytes); // FIXME (1208663): not yet safe
 }
--- a/js/src/jit/arm64/AtomicOperations-arm64.h
+++ b/js/src/jit/arm64/AtomicOperations-arm64.h
@@ -117,16 +117,18 @@ js::jit::AtomicOperations::storeSafeWhen
 {
     *addr = val; // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memcpySafeWhenRacy(void* dest, const void* src,
                                               size_t nbytes)
 {
+    MOZ_ASSERT(!((char*)dest <= (char*)src && (char*)src < (char*)dest+nbytes));
+    MOZ_ASSERT(!((char*)src <= (char*)dest && (char*)dest < (char*)src+nbytes));
     memcpy(dest, src, nbytes); // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memmoveSafeWhenRacy(void* dest, const void* src,
                                                size_t nbytes)
 {
     memmove(dest, src, nbytes); // FIXME (1208663): not yet safe
--- a/js/src/jit/mips-shared/AtomicOperations-mips-shared.h
+++ b/js/src/jit/mips-shared/AtomicOperations-mips-shared.h
@@ -167,16 +167,18 @@ inline void
 js::jit::AtomicOperations::storeSafeWhenRacy(T* addr, T val)
 {
     *addr = val;                // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memcpySafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
+    MOZ_ASSERT(!((char*)dest <= (char*)src && (char*)src < (char*)dest+nbytes));
+    MOZ_ASSERT(!((char*)src <= (char*)dest && (char*)dest < (char*)src+nbytes));
     ::memcpy(dest, src, nbytes); // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memmoveSafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
     ::memmove(dest, src, nbytes); // FIXME (1208663): not yet safe
 }
--- a/js/src/jit/none/AtomicOperations-none.h
+++ b/js/src/jit/none/AtomicOperations-none.h
@@ -102,16 +102,18 @@ inline void
 js::jit::AtomicOperations::storeSafeWhenRacy(T* addr, T val)
 {
     MOZ_CRASH();
 }
 
 inline void
 js::jit::AtomicOperations::memcpySafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
+    MOZ_ASSERT(!((char*)dest <= (char*)src && (char*)src < (char*)dest+nbytes));
+    MOZ_ASSERT(!((char*)src <= (char*)dest && (char*)dest < (char*)src+nbytes));
     MOZ_CRASH();
 }
 
 inline void
 js::jit::AtomicOperations::memmoveSafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
     MOZ_CRASH();
 }
--- a/js/src/jit/none/AtomicOperations-ppc.h
+++ b/js/src/jit/none/AtomicOperations-ppc.h
@@ -168,16 +168,18 @@ inline void
 js::jit::AtomicOperations::storeSafeWhenRacy(T* addr, T val)
 {
     *addr = val;                // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memcpySafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
+    MOZ_ASSERT(!((char*)dest <= (char*)src && (char*)src < (char*)dest+nbytes));
+    MOZ_ASSERT(!((char*)src <= (char*)dest && (char*)dest < (char*)src+nbytes));
     ::memcpy(dest, src, nbytes); // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memmoveSafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
     ::memmove(dest, src, nbytes); // FIXME (1208663): not yet safe
 }
--- a/js/src/jit/none/AtomicOperations-sparc.h
+++ b/js/src/jit/none/AtomicOperations-sparc.h
@@ -177,16 +177,18 @@ inline void
 js::jit::AtomicOperations::storeSafeWhenRacy(T* addr, T val)
 {
     *addr = val;                // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memcpySafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
+    MOZ_ASSERT(!((char*)dest <= (char*)src && (char*)src < (char*)dest+nbytes));
+    MOZ_ASSERT(!((char*)src <= (char*)dest && (char*)dest < (char*)src+nbytes));
     ::memcpy(dest, src, nbytes); // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memmoveSafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
     ::memmove(dest, src, nbytes); // FIXME (1208663): not yet safe
 }
--- a/js/src/jit/x86-shared/AtomicOperations-x86-shared.h
+++ b/js/src/jit/x86-shared/AtomicOperations-x86-shared.h
@@ -334,16 +334,18 @@ inline void
 js::jit::AtomicOperations::storeSafeWhenRacy(T* addr, T val)
 {
     *addr = val;                // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memcpySafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
+    MOZ_ASSERT(!((char*)dest <= (char*)src && (char*)src < (char*)dest+nbytes));
+    MOZ_ASSERT(!((char*)src <= (char*)dest && (char*)dest < (char*)src+nbytes));
     ::memcpy(dest, src, nbytes); // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memmoveSafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
     ::memmove(dest, src, nbytes); // FIXME (1208663): not yet safe
 }
@@ -561,16 +563,18 @@ inline void
 js::jit::AtomicOperations::storeSafeWhenRacy(T* addr, T val)
 {
     *addr = val;                // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memcpySafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
+    MOZ_ASSERT(!((char*)dest <= (char*)src && (char*)src < (char*)dest+nbytes));
+    MOZ_ASSERT(!((char*)src <= (char*)dest && (char*)dest < (char*)src+nbytes));
     ::memcpy(dest, src, nbytes); // FIXME (1208663): not yet safe
 }
 
 inline void
 js::jit::AtomicOperations::memmoveSafeWhenRacy(void* dest, const void* src, size_t nbytes)
 {
     ::memmove(dest, src, nbytes); // FIXME (1208663): not yet safe
 }