summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2020-02-18 09:38:27 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-02-29 05:08:36 -0500
commitb5fb58fd1a4a24b9273d9d2de65b6347e1654e98 (patch)
treeeec82775f0414f77d5444cd9e25a2885ba378a6e /compiler
parenta999ee96a22650b59855609f84e2808b4133e9e0 (diff)
downloadhaskell-b5fb58fd1a4a24b9273d9d2de65b6347e1654e98.tar.gz
Document and refactor a few things around bitmap scavenging
- Added a few comments in StgPAP - Added a few comments and assertions in scavenge_small_bitmap and walk_large_bitmap - Did tiny refactor in GHC.Data.Bitmap: added some comments, deleted dead code, used PlatformWordSize type.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Data/Bitmap.hs43
1 files changed, 7 insertions, 36 deletions
diff --git a/compiler/GHC/Data/Bitmap.hs b/compiler/GHC/Data/Bitmap.hs
index 1b93d6000d..985e74deb9 100644
--- a/compiler/GHC/Data/Bitmap.hs
+++ b/compiler/GHC/Data/Bitmap.hs
@@ -10,16 +10,15 @@
module GHC.Data.Bitmap (
Bitmap, mkBitmap,
- intsToBitmap, intsToReverseBitmap,
+ intsToReverseBitmap,
mAX_SMALL_BITMAP_SIZE,
- seqBitmap,
) where
import GhcPrelude
+import GHC.Platform
import GHC.Runtime.Heap.Layout
import GHC.Driver.Session
-import Util
import Data.Bits
@@ -43,31 +42,6 @@ chunkToBitmap dflags chunk =
oneAt :: Int -> StgWord
oneAt i = toStgWord dflags 1 `shiftL` i
--- | Make a bitmap where the slots specified are the /ones/ in the bitmap.
--- eg. @[0,1,3], size 4 ==> 0xb@.
---
--- The list of @Int@s /must/ be already sorted.
-intsToBitmap :: DynFlags
- -> Int -- ^ size in bits
- -> [Int] -- ^ sorted indices of ones
- -> Bitmap
-intsToBitmap dflags size = go 0
- where
- word_sz = wORD_SIZE_IN_BITS dflags
- oneAt :: Int -> StgWord
- oneAt i = toStgWord dflags 1 `shiftL` i
-
- -- It is important that we maintain strictness here.
- -- See Note [Strictness when building Bitmaps].
- go :: Int -> [Int] -> Bitmap
- go !pos slots
- | size <= pos = []
- | otherwise =
- (foldl' (.|.) (toStgWord dflags 0) (map (\i->oneAt (i - pos)) these)) :
- go (pos + word_sz) rest
- where
- (these,rest) = span (< (pos + word_sz)) slots
-
-- | Make a bitmap where the slots specified are the /zeros/ in the bitmap.
-- eg. @[0,1,3], size 4 ==> 0x4@ (we leave any bits outside the size as zero,
-- just to make the bitmap easier to read).
@@ -101,7 +75,7 @@ intsToReverseBitmap dflags size = go 0
{-
Note [Strictness when building Bitmaps]
-========================================
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
One of the places where @Bitmap@ is used is in in building Static Reference
Tables (SRTs) (in @GHC.Cmm.Info.Build.procpointSRT@). In #7450 it was noticed
@@ -125,10 +99,7 @@ large. This value represents the largest size of bitmap that can be
packed into a single word.
-}
mAX_SMALL_BITMAP_SIZE :: DynFlags -> Int
-mAX_SMALL_BITMAP_SIZE dflags
- | wORD_SIZE dflags == 4 = 27
- | otherwise = 58
-
-seqBitmap :: Bitmap -> a -> a
-seqBitmap = seqList
-
+mAX_SMALL_BITMAP_SIZE dflags =
+ case platformWordSize (targetPlatform dflags) of
+ PW4 -> 27 -- On 32-bit: 5 bits for size, 27 bits for bitmap
+ PW8 -> 58 -- On 64-bit: 6 bits for size, 58 bits for bitmap