[commit: ghc] master: Use new flushExec implementation on all operating systems (#8562) (95854ca)

git at git.haskell.org git at git.haskell.org
Thu Dec 5 00:16:59 UTC 2013


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/95854ca5276e3f4063ade7fe3a934bed46648270/ghc

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

commit 95854ca5276e3f4063ade7fe3a934bed46648270
Author: Christopher Rodrigues <cirodrig at illinois.edu>
Date:   Fri Nov 29 23:05:50 2013 -0600

    Use new flushExec implementation on all operating systems (#8562)
    
    An earlier patch fixes a bug in flushExec on linux only.  This
    patch uses the fixed code on all operating systems.
    
    Signed-off-by: Austin Seipp <austin at well-typed.com>


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

95854ca5276e3f4063ade7fe3a934bed46648270
 rts/sm/Storage.c |   56 ++++++++++++++++++------------------------------------
 1 file changed, 19 insertions(+), 37 deletions(-)

diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
index 0f28820..c7126fe 100644
--- a/rts/sm/Storage.c
+++ b/rts/sm/Storage.c
@@ -1152,24 +1152,6 @@ calcNeeded (rtsBool force_major, memcount *blocks_needed)
          should be modified to use allocateExec instead of VirtualAlloc.
    ------------------------------------------------------------------------- */
 
-#if defined(linux_HOST_OS)
-
-// On Linux we need to use libffi for allocating executable memory,
-// because it knows how to work around the restrictions put in place
-// by SELinux.
-
-AdjustorWritable allocateExec (W_ bytes, AdjustorExecutable *exec_ret)
-{
-    void **ret, **exec;
-    ACQUIRE_SM_LOCK;
-    ret = ffi_closure_alloc (sizeof(void *) + (size_t)bytes, (void**)&exec);
-    RELEASE_SM_LOCK;
-    if (ret == NULL) return ret;
-    *ret = ret; // save the address of the writable mapping, for freeExec().
-    *exec_ret = exec + 1;
-    return (ret + 1);
-}
-
 #if defined(arm_HOST_ARCH) && defined(ios_HOST_OS)
 void sys_icache_invalidate(void *start, size_t len);
 #endif
@@ -1195,6 +1177,24 @@ void flushExec (W_ len, AdjustorExecutable exec_addr)
 #endif
 }
 
+#if defined(linux_HOST_OS)
+
+// On Linux we need to use libffi for allocating executable memory,
+// because it knows how to work around the restrictions put in place
+// by SELinux.
+
+AdjustorWritable allocateExec (W_ bytes, AdjustorExecutable *exec_ret)
+{
+    void **ret, **exec;
+    ACQUIRE_SM_LOCK;
+    ret = ffi_closure_alloc (sizeof(void *) + (size_t)bytes, (void**)&exec);
+    RELEASE_SM_LOCK;
+    if (ret == NULL) return ret;
+    *ret = ret; // save the address of the writable mapping, for freeExec().
+    *exec_ret = exec + 1;
+    return (ret + 1);
+}
+
 // freeExec gets passed the executable address, not the writable address.
 void freeExec (AdjustorExecutable addr)
 {
@@ -1241,15 +1241,6 @@ AdjustorWritable execToWritable(AdjustorExecutable exec)
     return writ;
 }
 
-void flushExec (W_ len, AdjustorExecutable exec_addr)
-{
-  /* On ARM and other platforms, we need to flush the cache after
-     writing code into memory, so the processor reliably sees it. */
-  unsigned char* begin = (unsigned char*)exec_addr;
-  unsigned char* end   = begin + len;
-  __builtin___clear_cache(begin, end);
-}
-
 void freeExec(AdjustorExecutable exec)
 {
     AdjustorWritable writ;
@@ -1303,15 +1294,6 @@ AdjustorWritable allocateExec (W_ bytes, AdjustorExecutable *exec_ret)
     return ret;
 }
 
-void flushExec (W_ len, AdjustorExecutable exec_addr)
-{
-  /* On ARM and other platforms, we need to flush the cache after
-     writing code into memory, so the processor reliably sees it. */
-  unsigned char* begin = (unsigned char*)exec_addr;
-  unsigned char* end   = begin + len;
-  __builtin___clear_cache(begin, end);
-}
-
 void freeExec (void *addr)
 {
     StgPtr p = (StgPtr)addr - 1;
@@ -1346,7 +1328,7 @@ void freeExec (void *addr)
     RELEASE_SM_LOCK
 }
 
-#endif /* mingw32_HOST_OS */
+#endif /* switch(HOST_OS) */
 
 #ifdef DEBUG
 



More information about the ghc-commits mailing list