Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Almost working

  • Loading branch information...
commit 9366fa12e6fae45d16bdf5d8b71f3ce958616e4f 1 parent 09a06b3
@tibbe authored
Showing with 14 additions and 9 deletions.
  1. +14 −9 compiler/codeGen/StgCmmPrim.hs
View
23 compiler/codeGen/StgCmmPrim.hs
@@ -1564,24 +1564,29 @@ doNewArrayOp res_r n init = do
emit $ mkAssign (CmmLocal arr_r) base
let arr = CmmLocal arr_r
- dst_p <- assignTempE $ cmmOffsetB dflags (CmmReg arr)
- (arrPtrsHdrSize dflags)
-
-- Initialise all elements of the the array
- loop_id <- newLabelC
- emitLabel loop_id
- emit =<< mkCmmIfThen (cmmNeWord dflags n (mkIntExpr dflags 0))
- (mkBranch loop_id) -- TODO: Add element copy
- -- before branch
+ p <- assignTemp $ cmmOffsetB dflags (CmmReg arr) (arrPtrsHdrSize dflags)
+ for <- newLabelC
+ emitLabel for
+ let loopBody =
+ [ mkStore (CmmReg (CmmLocal p)) init
+ , mkAssign (CmmLocal p) (cmmOffsetW dflags (CmmReg (CmmLocal p)) 1)
+ , mkBranch for ]
+ emit =<< mkCmmIfThen
+ (cmmULtWord dflags (CmmReg (CmmLocal p))
+ (cmmOffsetW dflags (CmmReg arr) (fromInteger n)))
+ (catAGraphs loopBody)
-- Initialise the mark bits with 0
+ dst_p <- assignTempE $ cmmOffsetB dflags (CmmReg arr)
+ (arrPtrsHdrSize dflags)
emitMemsetCall (cmmOffsetExprW dflags dst_p (mkIntExpr dflags (fromInteger n)))
(mkIntExpr dflags 0)
(mkIntExpr dflags card_bytes)
(mkIntExpr dflags (wORD_SIZE dflags))
emit $ mkAssign (CmmLocal res_r) (CmmReg arr)
--- TODO: Add wordcopy as a equivalent to memcpy for whole words?
+-- TODO: Add wordset as a equivalent to memset for whole words?
-- | The inline allocation limit is 128 bytes, expressed in words.
maxInlineAllocThreshold :: DynFlags -> Integer
Please sign in to comment.
Something went wrong with that request. Please try again.