diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2019-08-15 07:40:56 +0100 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2019-08-15 07:40:56 +0100 |
commit | c79fac8eb00c36f24699f0e4b9ad94d25c7d85d1 (patch) | |
tree | ede6cc06e21bf3ab2a97996cb9fd6b56805a69c6 | |
parent | af07c6a2ce2ac6184c8610897bce4abd881ff8de (diff) | |
download | haskell-c79fac8eb00c36f24699f0e4b9ad94d25c7d85d1.tar.gz |
Undo changes
-rw-r--r-- | compiler/main/PackageConfig.hs | 8 | ||||
-rw-r--r-- | compiler/utils/FastString.hs | 16 | ||||
-rw-r--r-- | ghc/Main.hs | 2 |
3 files changed, 13 insertions, 13 deletions
diff --git a/compiler/main/PackageConfig.hs b/compiler/main/PackageConfig.hs index cb36fb4c94..bd21c6283c 100644 --- a/compiler/main/PackageConfig.hs +++ b/compiler/main/PackageConfig.hs @@ -68,11 +68,11 @@ instance BinaryStringRep PackageName where fromStringRep = PackageName . mkFastStringByteString toStringRep (PackageName s) = bytesFS s -instance Uniquable SourcePackageId where - getUnique (SourcePackageId n) = unsafeFastStringUnique n +instance HasFastString SourcePackageId where + getFastString (SourcePackageId n) = n -instance Uniquable PackageName where - getUnique (PackageName n) = unsafeFastStringUnique n +instance HasFastString PackageName where + getFastString (PackageName n) = n instance Outputable SourcePackageId where ppr (SourcePackageId str) = ftext str diff --git a/compiler/utils/FastString.hs b/compiler/utils/FastString.hs index d737e487cd..1f98327a35 100644 --- a/compiler/utils/FastString.hs +++ b/compiler/utils/FastString.hs @@ -267,7 +267,7 @@ data FastStringTable = FastStringTable data FastStringTableSegment = FastStringTableSegment {-# UNPACK #-} !(MVar ()) -- the lock for write in each segment {-# UNPACK #-} !(IORef Int) -- the number of elements - (MutableArray# RealWorld [Weak FastString]) -- buckets in this segment + (MutableArray# RealWorld [Either FastString (Weak FastString)]) -- buckets in this segment {- Following parameters are determined based on: @@ -287,7 +287,7 @@ hashToSegment# hash# = hash# `andI#` segmentMask# where !(I# segmentMask#) = segmentMask -hashToIndex# :: MutableArray# RealWorld [Weak FastString] -> Int# -> Int# +hashToIndex# :: MutableArray# RealWorld [Either FastString (Weak FastString)] -> Int# -> Int# hashToIndex# buckets# hash# = (hash# `uncheckedIShiftRL#` segmentBits#) `remInt#` size# where @@ -309,7 +309,7 @@ maybeResizeSegment segmentRef = do forM_ [0 .. (I# oldSize#) - 1] $ \(I# i#) -> do fsList <- IO $ readArray# old# i# forM_ fsList $ \wfs -> do - mfs <- deRefWeak wfs + mfs <- either (return . Just) deRefWeak wfs case mfs of Just fs -> do let -- Shall we store in hash value in FastString instead? @@ -452,9 +452,9 @@ mkFastStringWith mk_fs !ptr !len = do -- before we acquired the write lock. Just found -> return found Nothing -> do - v <- mkWeakPtr fs (Just $ atomicModifyIORef' fastStringGcCounter (\x -> (x +1, ()))) + v <- mkWeak fs_bs fs (Just $ atomicModifyIORef' fastStringGcCounter (\x -> (x +1, ()))) IO $ \s1# -> - case writeArray# buckets# idx# (v: bucket) s1# of + case writeArray# buckets# idx# (Left fs: bucket) s1# of s2# -> (# s2#, () #) modifyIORef' counter succ let u = uniqueOfFS fs @@ -470,10 +470,10 @@ mkFastStringWith mk_fs !ptr !len = do s2# -> (# s2#, () #) -} -bucket_match :: [Weak FastString] -> Int -> Ptr Word8 -> IO (Maybe FastString) +bucket_match :: [Either FastString (Weak FastString)] -> Int -> Ptr Word8 -> IO (Maybe FastString) bucket_match [] _ _ = return Nothing bucket_match (v:ls) len ptr = do - mv <- deRefWeak v + mv <- either (return . Just) deRefWeak v case mv of Just fs@(FastString _ _ bs _) | len == BS.length bs -> do @@ -645,7 +645,7 @@ isUnderscoreFS fs = fs == fsLit "_" -- ----------------------------------------------------------------------------- -- Stats -getFastStringTable :: IO [[[Weak FastString]]] +getFastStringTable :: IO [[[Either FastString (Weak FastString)]]] getFastStringTable = forM [0 .. numSegments - 1] $ \(I# i#) -> do let (# segmentRef #) = indexArray# segments# i# diff --git a/ghc/Main.hs b/ghc/Main.hs index 1f4f13a469..bc16e8782d 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -818,7 +818,7 @@ dumpFinalStats dflags = do dumpFastStringStats :: DynFlags -> IO () dumpFastStringStats dflags = do - segments <- traverse (traverse (traverse deRefWeak)) =<< getFastStringTable + segments <- traverse (traverse (traverse (either (return . Just) deRefWeak))) =<< getFastStringTable gcCount <- readIORef fastStringGcCounter let buckets = concat segments bucketsPerSegment = map length segments |