X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcodeGen%2FCgPrimOp.hs;h=d0da575cf627b44de0d41370d24deb09b7b1ad33;hb=83d563cb9ede0ba792836e529b1e2929db926355;hp=ef154adccac64799d06dc3bd868bb4ac89c8c55b;hpb=33333a340c7d7f37281b8f8b8092602cfc041d44;p=ghc-hetmet.git diff --git a/compiler/codeGen/CgPrimOp.hs b/compiler/codeGen/CgPrimOp.hs index ef154ad..d0da575 100644 --- a/compiler/codeGen/CgPrimOp.hs +++ b/compiler/codeGen/CgPrimOp.hs @@ -23,6 +23,7 @@ import CLabel import CmmUtils import PrimOp import SMRep +import Module import Constants import Outputable import FastString @@ -122,7 +123,7 @@ emitPrimOp [res] ParOp [arg] live NoC_SRT -- No SRT b/c we do PlayRisky CmmMayReturn where - newspark = CmmLit (CmmLabel (mkRtsCodeLabel (sLit "newSpark"))) + newspark = CmmLit (CmmLabel (mkCmmCodeLabel rtsPackageId (fsLit "newSpark"))) emitPrimOp [res] ReadMutVarOp [mutv] _ = stmtC (CmmAssign (CmmLocal res) (cmmLoadIndexW mutv fixedHdrSize gcWord)) @@ -142,16 +143,13 @@ emitPrimOp [] WriteMutVarOp [mutv,var] live CmmMayReturn -- #define sizzeofByteArrayzh(r,a) \ --- r = (((StgArrWords *)(a))->words * sizeof(W_)) +-- r = ((StgArrWords *)(a))->bytes emitPrimOp [res] SizeofByteArrayOp [arg] _ = stmtC $ - CmmAssign (CmmLocal res) (CmmMachOp mo_wordMul [ - cmmLoadIndexW arg fixedHdrSize bWord, - CmmLit (mkIntCLit wORD_SIZE) - ]) + CmmAssign (CmmLocal res) (cmmLoadIndexW arg fixedHdrSize bWord) -- #define sizzeofMutableByteArrayzh(r,a) \ --- r = (((StgArrWords *)(a))->words * sizeof(W_)) +-- r = ((StgArrWords *)(a))->bytes emitPrimOp [res] SizeofMutableByteArrayOp [arg] live = emitPrimOp [res] SizeofByteArrayOp [arg] live @@ -570,9 +568,21 @@ doWriteByteArrayOp _ _ _ _ doWritePtrArrayOp :: CmmExpr -> CmmExpr -> CmmExpr -> Code doWritePtrArrayOp addr idx val - = do stmtC (setInfo addr (CmmLit (CmmLabel mkMAP_DIRTY_infoLabel))) - mkBasicIndexedWrite arrPtrsHdrSize Nothing bWord addr idx val - + = do mkBasicIndexedWrite arrPtrsHdrSize Nothing bWord addr idx val + stmtC (setInfo addr (CmmLit (CmmLabel mkMAP_DIRTY_infoLabel))) + -- the write barrier. We must write a byte into the mark table: + -- bits8[a + header_size + StgMutArrPtrs_size(a) + x >> N] + stmtC $ CmmStore ( + cmmOffsetExpr + (cmmOffsetExprW (cmmOffsetB addr arrPtrsHdrSize) + (loadArrPtrsSize addr)) + (CmmMachOp mo_wordUShr [idx, + CmmLit (mkIntCLit mUT_ARR_PTRS_CARD_BITS)]) + ) (CmmLit (CmmInt 1 W8)) + +loadArrPtrsSize :: CmmExpr -> CmmExpr +loadArrPtrsSize addr = CmmLoad (cmmOffsetB addr off) bWord + where off = fixedHdrSize*wORD_SIZE + oFFSET_StgMutArrPtrs_ptrs mkBasicIndexedRead :: ByteOff -> Maybe MachOp -> CmmType -> LocalReg -> CmmExpr -> CmmExpr -> Code