Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Another checkpoint

  • Loading branch information...
commit 8239116adae1915c342abc71f4291f9b0138c945 1 parent 8f544f8
@tibbe authored
Showing with 15 additions and 8 deletions.
  1. +15 −8 compiler/codeGen/StgCmmPrim.hs
View
23 compiler/codeGen/StgCmmPrim.hs
@@ -132,10 +132,11 @@ shouldInlinePrimOp :: DynFlags
-> [CmmExpr] -- ^ The primop arguments
-> Maybe ([LocalReg] -> FCode ())
shouldInlinePrimOp dflags NewArrayOp [(CmmLit (CmmInt n _)), init]
- | n <= inlineAllocLimit dflags = Just $ \ [res] -> doNewArrayOp res n init
+ | n <= maxInlineAllocThreshold dflags =
+ Just $ \ [res] -> doNewArrayOp res n init
shouldInlinePrimOp dflags primop args
| primOpOutOfLine primop = Nothing
- | otherwise = Just $ \ regs -> emitPrimOp dflags regs primop args
+ | otherwise = Just $ \ regs -> emitPrimOp dflags regs primop args
-- TODO: Several primops, such as 'copyArray#', only have an inline
-- implementation (below) but could possibly have both an inline
@@ -1525,7 +1526,7 @@ doSetByteArrayOp ba off len c
-- ----------------------------------------------------------------------------
-- Allocating arrays
--- Takes a register to return the newly allocated array in, the size
+-- | Takes a register to return the newly allocated array in, the size
-- of the new array, and an initial value for the elements. Allocates
-- a new 'MutableArray#'.
doNewArrayOp :: CmmFormal -> Integer -> CmmExpr -> FCode ()
@@ -1567,18 +1568,24 @@ doNewArrayOp res_r n init = do
(arrPtrsHdrSize dflags)
-- Initialise all elements of the the array
- -- TODO: Continue here
+ loop_id <- newLabelC
+ emitLabel loop_id
+ emit =<< mkCmmIfThen (cmmNeWord dflags n (mkIntExpr dflags 0))
+ (mkBranch loop_id) -- TODO: Add element copy
+ -- before branch
-- Initialise the mark bits with 0
emitMemsetCall (cmmOffsetExprW dflags dst_p (mkIntExpr dflags (fromInteger n)))
- (mkIntExpr dflags 1)
+ (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?
+
-- | The inline allocation limit is 128 bytes, expressed in words.
-inlineAllocLimit :: DynFlags -> Integer
-inlineAllocLimit dflags = toInteger (128 `quot` wORD_SIZE dflags)
+maxInlineAllocThreshold :: DynFlags -> Integer
+maxInlineAllocThreshold dflags = toInteger (128 `quot` wORD_SIZE dflags)
-- | Takes an info table label, a register to return the newly
-- allocated array in, the size of the array. Allocates a new array
@@ -1617,7 +1624,7 @@ emitNewUninitializedArray :: DynFlags
-> CmmExpr -- ^ Size
-> FCode (CmmReg, CmmExpr, CmmExpr)
emitNewUninitializedArray dflags info_p (CmmLit (CmmInt n _))
- | n <= inlineAllocLimit dflags = do
+ | n <= maxInlineAllocThreshold dflags = do
-- If the allocation is of small, statically-known size, we reuse
-- the existing heap check to allocate inline.
virt_hp <- getVirtHp
Please sign in to comment.
Something went wrong with that request. Please try again.