Commit 5730f863 authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan Committed by Marge Bot

Minor refactoring in copy array primops:

- `emitCopySmallArray` now checks size before generating code and
  doesn't generate any code when size is 0. `emitCopyArray` already does
  this so this makes small/large array cases the same in argument
  checking.

- In both `emitCopySmallArray` and `emitCopyArray` read the `dflags`
  after checking the argument.
parent 3dec527a
...@@ -2174,9 +2174,10 @@ emitCopyArray :: (CmmExpr -> CmmExpr -> CmmExpr -> CmmExpr -> ByteOff ...@@ -2174,9 +2174,10 @@ emitCopyArray :: (CmmExpr -> CmmExpr -> CmmExpr -> CmmExpr -> ByteOff
-> CmmExpr -- ^ offset in destination array -> CmmExpr -- ^ offset in destination array
-> WordOff -- ^ number of elements to copy -> WordOff -- ^ number of elements to copy
-> FCode () -> FCode ()
emitCopyArray copy src0 src_off dst0 dst_off0 n = do emitCopyArray copy src0 src_off dst0 dst_off0 n =
dflags <- getDynFlags
when (n /= 0) $ do when (n /= 0) $ do
dflags <- getDynFlags
-- Passed as arguments (be careful) -- Passed as arguments (be careful)
src <- assignTempE src0 src <- assignTempE src0
dst <- assignTempE dst0 dst <- assignTempE dst0
...@@ -2236,23 +2237,24 @@ emitCopySmallArray :: (CmmExpr -> CmmExpr -> CmmExpr -> CmmExpr -> ByteOff ...@@ -2236,23 +2237,24 @@ emitCopySmallArray :: (CmmExpr -> CmmExpr -> CmmExpr -> CmmExpr -> ByteOff
-> CmmExpr -- ^ offset in destination array -> CmmExpr -- ^ offset in destination array
-> WordOff -- ^ number of elements to copy -> WordOff -- ^ number of elements to copy
-> FCode () -> FCode ()
emitCopySmallArray copy src0 src_off dst0 dst_off n = do emitCopySmallArray copy src0 src_off dst0 dst_off n =
dflags <- getDynFlags when (n /= 0) $ do
dflags <- getDynFlags
-- Passed as arguments (be careful) -- Passed as arguments (be careful)
src <- assignTempE src0 src <- assignTempE src0
dst <- assignTempE dst0 dst <- assignTempE dst0
-- Set the dirty bit in the header. -- Set the dirty bit in the header.
emit (setInfo dst (CmmLit (CmmLabel mkSMAP_DIRTY_infoLabel))) emit (setInfo dst (CmmLit (CmmLabel mkSMAP_DIRTY_infoLabel)))
dst_p <- assignTempE $ cmmOffsetExprW dflags dst_p <- assignTempE $ cmmOffsetExprW dflags
(cmmOffsetB dflags dst (smallArrPtrsHdrSize dflags)) dst_off (cmmOffsetB dflags dst (smallArrPtrsHdrSize dflags)) dst_off
src_p <- assignTempE $ cmmOffsetExprW dflags src_p <- assignTempE $ cmmOffsetExprW dflags
(cmmOffsetB dflags src (smallArrPtrsHdrSize dflags)) src_off (cmmOffsetB dflags src (smallArrPtrsHdrSize dflags)) src_off
let bytes = wordsToBytes dflags n let bytes = wordsToBytes dflags n
copy src dst dst_p src_p bytes copy src dst dst_p src_p bytes
-- | Takes an info table label, a register to return the newly -- | Takes an info table label, a register to return the newly
-- allocated array in, a source array, an offset in the source array, -- allocated array in, a source array, an offset in the source array,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment