import SMRep
import ForeignCall
import Constants
-import StaticFlags ( opt_SccProfilingOn )
+import StaticFlags ( opt_SccProfilingOn, opt_SMP )
import Outputable
import Monad ( when )
vols <- getVolatileRegs live
id <- newTemp wordRep
emitSaveThreadState
- stmtC (CmmCall (CmmForeignCall suspendThread CCallConv) [(id,NoHint)]
+ stmtC (CmmCall (CmmForeignCall suspendThread CCallConv)
+ [(id,PtrHint)]
[ (CmmReg (CmmGlobal BaseReg), PtrHint) ]
(Just vols)
)
stmtC (the_call vols)
- stmtC (CmmCall (CmmForeignCall resumeThread CCallConv) []
- [ (CmmReg id, NoHint) ] (Just vols)
+ stmtC (CmmCall (CmmForeignCall resumeThread CCallConv)
+ (if opt_SMP then [(CmmGlobal BaseReg, PtrHint)] else [])
+ -- Assign the result to BaseReg: we might now have
+ -- a different Capability! Small optimisation:
+ -- only do this in SMP mode, where there are >1
+ -- Capabilities.
+ [ (CmmReg id, PtrHint) ]
+ (Just vols)
)
emitLoadThreadState
-- -----------------------------------------------------------------------------
-- For certain types passed to foreign calls, we adjust the actual
--- value passed to the call. Two main cases: for ForeignObj# we pass
--- the pointer inside the ForeignObj# closure, and for ByteArray#/Array# we
--- pass the address of the actual array, not the address of the heap object.
+-- value passed to the call. For ByteArray#/Array# we pass the
+-- address of the actual array, not the address of the heap object.
shimForeignCallArg :: StgArg -> CmmExpr -> CmmExpr
shimForeignCallArg arg expr
- | tycon == foreignObjPrimTyCon
- = cmmLoadIndexW expr fixedHdrSize
-
| tycon == arrayPrimTyCon || tycon == mutableArrayPrimTyCon
= cmmOffsetB expr arrPtrsHdrSize