[commit: ghc] master: CMM: add a mechanism to import C .data labels (d82f592)

git at git.haskell.org git at git.haskell.org
Mon Jan 19 22:25:49 UTC 2015


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

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

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

commit d82f592522eb8e063276a8a8c87ab93e18353c6b
Author: Sergei Trofimovich <siarheit at google.com>
Date:   Mon Jan 19 16:27:06 2015 -0600

    CMM: add a mechanism to import C .data labels
    
    Summary:
    This introduces new .cmm syntax for import:
    
        'import' 'CLOSURE' <identifier>;
    
    Currently cmm syntax allows importing only function labels:
    
        import pthread_mutex_lock;
    
    but sometimes ghc needs to import global gariables
    or haskell closures:
    
        import ghczmprim_GHCziTypes_True_closure;
        import base_ControlziExceptionziBase_nestedAtomically_closure;
        import ghczmprim_GHCziTypes_False_closure;
        import sm_mutex;
    
    It breaks on ia64 where there is a difference in
    pointers to data and pointer to functions.
    
    Patch fixes threaded runtime on ia64 where
    dereference of 'sm_mutex' from CMM led to
    incurrect location.
    
    Exact breakage machanics are the same as in e18525fae273f4c1ad8d6cbe1dea4fc074cac721
    
    Merge into the 7.10 branch
    
    Signed-off-by: Sergei Trofimovich <siarheit at google.com>
    
    Test Plan: passes ./validate, makes ghci work on ghc-7.8.4
    
    Reviewers: simonmar, simonpj, austin
    
    Reviewed By: austin
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D622


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

d82f592522eb8e063276a8a8c87ab93e18353c6b
 compiler/cmm/CmmParse.y | 4 ++++
 rts/Exception.cmm       | 2 +-
 rts/PrimOps.cmm         | 6 +++---
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/compiler/cmm/CmmParse.y b/compiler/cmm/CmmParse.y
index 6b51e51..fd9489b 100644
--- a/compiler/cmm/CmmParse.y
+++ b/compiler/cmm/CmmParse.y
@@ -575,6 +575,10 @@ importName
         : NAME  
         { ($1, mkForeignLabel $1 Nothing ForeignLabelInExternalPackage IsFunction) }
 
+        -- as previous 'NAME', but 'IsData'
+        | 'CLOSURE' NAME
+        { ($2, mkForeignLabel $2 Nothing ForeignLabelInExternalPackage IsData) }
+
         -- A label imported with an explicit packageId.
         | STRING NAME
         { ($2, mkCmmCodeLabel (fsToPackageKey (mkFastString $1)) $2) }
diff --git a/rts/Exception.cmm b/rts/Exception.cmm
index 5007ef3..8d19c14 100644
--- a/rts/Exception.cmm
+++ b/rts/Exception.cmm
@@ -13,7 +13,7 @@
 #include "Cmm.h"
 #include "RaiseAsync.h"
 
-import ghczmprim_GHCziTypes_True_closure;
+import CLOSURE ghczmprim_GHCziTypes_True_closure;
 
 /* -----------------------------------------------------------------------------
    Exception Primitives
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index 3e8612c..2e6ca46 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -28,12 +28,12 @@
 import pthread_mutex_lock;
 import pthread_mutex_unlock;
 #endif
-import base_ControlziExceptionziBase_nestedAtomically_closure;
+import CLOSURE base_ControlziExceptionziBase_nestedAtomically_closure;
 import EnterCriticalSection;
 import LeaveCriticalSection;
-import ghczmprim_GHCziTypes_False_closure;
+import CLOSURE ghczmprim_GHCziTypes_False_closure;
 #if defined(USE_MINIINTERPRETER) || !defined(mingw32_HOST_OS)
-import sm_mutex;
+import CLOSURE sm_mutex;
 #endif
 
 /*-----------------------------------------------------------------------------



More information about the ghc-commits mailing list