Bug 1097253. r=mjrosenb, a=abillings
authorJeff Walden <jwalden@mit.edu>
Tue, 18 Nov 2014 17:54:15 -0800
changeset 233956 476779d0d240ecc305924df2feb437cfb0e30987
parent 233955 44cfd6a0019ac6459d1d9c0905bfd970551781a1
child 233957 3e38373768ad6cac30296dd363ea50a167c9e344
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmjrosenb, abillings
bugs1097253
milestone35.0a2
Bug 1097253. r=mjrosenb, a=abillings
js/src/vm/TypedArrayCommon.h
--- a/js/src/vm/TypedArrayCommon.h
+++ b/js/src/vm/TypedArrayCommon.h
@@ -155,71 +155,87 @@ class ElementSpecific
         T *dest = static_cast<T*>(target->viewData()) + offset;
         uint32_t count = source->length();
 
         if (source->type() == target->type()) {
             mozilla::PodCopy(dest, static_cast<T*>(source->viewData()), count);
             return true;
         }
 
+#ifdef __arm__
+#  define JS_VOLATILE_ARM volatile // Inhibit unaligned accesses on ARM.
+#else
+#  define JS_VOLATILE_ARM /* nothing */
+#endif
+
         void *data = source->viewData();
         switch (source->type()) {
           case Scalar::Int8: {
+            JS_VOLATILE_ARM
             int8_t *src = static_cast<int8_t*>(data);
             for (uint32_t i = 0; i < count; ++i)
                 *dest++ = T(*src++);
             break;
           }
           case Scalar::Uint8:
           case Scalar::Uint8Clamped: {
+            JS_VOLATILE_ARM
             uint8_t *src = static_cast<uint8_t*>(data);
             for (uint32_t i = 0; i < count; ++i)
                 *dest++ = T(*src++);
             break;
           }
           case Scalar::Int16: {
+            JS_VOLATILE_ARM
             int16_t *src = static_cast<int16_t*>(data);
             for (uint32_t i = 0; i < count; ++i)
                 *dest++ = T(*src++);
             break;
           }
           case Scalar::Uint16: {
+            JS_VOLATILE_ARM
             uint16_t *src = static_cast<uint16_t*>(data);
             for (uint32_t i = 0; i < count; ++i)
                 *dest++ = T(*src++);
             break;
           }
           case Scalar::Int32: {
+            JS_VOLATILE_ARM
             int32_t *src = static_cast<int32_t*>(data);
             for (uint32_t i = 0; i < count; ++i)
                 *dest++ = T(*src++);
             break;
           }
           case Scalar::Uint32: {
+            JS_VOLATILE_ARM
             uint32_t *src = static_cast<uint32_t*>(data);
             for (uint32_t i = 0; i < count; ++i)
                 *dest++ = T(*src++);
             break;
           }
           case Scalar::Float32: {
+            JS_VOLATILE_ARM
             float *src = static_cast<float*>(data);
             for (uint32_t i = 0; i < count; ++i)
                 *dest++ = T(*src++);
             break;
           }
           case Scalar::Float64: {
+            JS_VOLATILE_ARM
             double *src = static_cast<double*>(data);
             for (uint32_t i = 0; i < count; ++i)
                 *dest++ = T(*src++);
             break;
           }
           default:
             MOZ_CRASH("setFromTypedArray with a typed array with bogus type");
         }
 
+#undef JS_VOLATILE_ARM
+
         return true;
     }
 
     /*
      * Copy |source[0]| to |source[len]| (exclusive) elements into the typed
      * array |target|, starting at index |offset|.  |source| must not be a
      * typed array.
      */