[commit: ghc] master: Use memcpy in cloneArray (228d467)

git at git.haskell.org git at git.haskell.org
Fri Apr 28 18:19:09 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/228d4670e98e4fd998c847aac38c11ad85aa35a7/ghc

>---------------------------------------------------------------

commit 228d4670e98e4fd998c847aac38c11ad85aa35a7
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Fri Apr 28 13:24:47 2017 -0400

    Use memcpy in cloneArray
    
    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


>---------------------------------------------------------------

228d4670e98e4fd998c847aac38c11ad85aa35a7
 includes/Cmm.h | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/includes/Cmm.h b/includes/Cmm.h
index 779416b..3c90307 100644
--- a/includes/Cmm.h
+++ b/includes/Cmm.h
@@ -849,14 +849,7 @@
                                                                \
     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);
 
@@ -931,13 +924,6 @@
                                                                \
     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);



More information about the ghc-commits mailing list