Use memcpy in cloneArray
authorBen Gamari <bgamari.foss@gmail.com>
Fri, 28 Apr 2017 17:24:47 +0000 (13:24 -0400)
committerBen Gamari <ben@smart-cactus.org>
Fri, 28 Apr 2017 18:18:40 +0000 (14:18 -0400)
While looking at #13615 I noticed that there was this strange open-coded
memcpy in the definition of the cloneArray macro. I don't see why this
should be preferable to memcpy.

Test Plan: Validate, particularly focusing on array operations

Reviewers: simonmar, tibbe, austin, alexbiehl

Reviewed By: tibbe, alexbiehl

Subscribers: alexbiehl, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3504

includes/Cmm.h

index 779416b..3c90307 100644 (file)
                                                                \
     dst_p = dst + SIZEOF_StgMutArrPtrs;                        \
     src_p = src + SIZEOF_StgMutArrPtrs + WDS(offset);          \
-  while:                                                       \
-    if (n != 0) {                                              \
-        n = n - 1;                                             \
-        W_[dst_p] = W_[src_p];                                 \
-        dst_p = dst_p + WDS(1);                                \
-        src_p = src_p + WDS(1);                                \
-        goto while;                                            \
-    }                                                          \
+    prim %memcpy(dst_p, src_p, n * SIZEOF_W, SIZEOF_W);        \
                                                                \
     return (dst);
 
                                                                \
     dst_p = dst + SIZEOF_StgSmallMutArrPtrs;                   \
     src_p = src + SIZEOF_StgSmallMutArrPtrs + WDS(offset);     \
-  while:                                                       \
-    if (n != 0) {                                              \
-        n = n - 1;                                             \
-        W_[dst_p] = W_[src_p];                                 \
-        dst_p = dst_p + WDS(1);                                \
-        src_p = src_p + WDS(1);                                \
-        goto while;                                            \
-    }                                                          \
+    prim %memcpy(dst_p, src_p, n * SIZEOF_W, SIZEOF_W);        \
                                                                \
     return (dst);