diff options
author | Nicolas Frisby <nicolas.frisby@gmail.com> | 2013-07-04 19:26:03 -0500 |
---|---|---|
committer | Nicolas Frisby <nicolas.frisby@gmail.com> | 2013-07-04 20:33:36 -0500 |
commit | 279ac9f66a83203448b279ea478b2cc1dafbd35d (patch) | |
tree | cadc018a0028387f2efacfdfedc3c34715dba9f2 /compiler/utils/FastString.lhs | |
parent | 163de25813d12764aa5ded1666af7c06fee0d67e (diff) | |
download | haskell-279ac9f66a83203448b279ea478b2cc1dafbd35d.tar.gz |
copy the plugin's FastStringTable changes back into the host compiler
Diffstat (limited to 'compiler/utils/FastString.lhs')
-rw-r--r-- | compiler/utils/FastString.lhs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler/utils/FastString.lhs b/compiler/utils/FastString.lhs index 0bdf0a04c4..5c6e7ff5c7 100644 --- a/compiler/utils/FastString.lhs +++ b/compiler/utils/FastString.lhs @@ -94,7 +94,7 @@ module FastString lengthLS, -- * Saving/restoring globals - saveFSTable, restoreFSTable, FastStringTable + saveFSTable, restoreFSTable, unsaveFSTable, FastStringTable ) where #include "HsVersions.h" @@ -480,7 +480,7 @@ nilFS = mkFastString "" getFastStringTable :: IO [[FastString]] getFastStringTable = do tbl <- readIORef string_table - buckets <- mapM (lookupTbl tbl) [0 .. hASH_TBL_SIZE] + buckets <- mapM (lookupTbl tbl) [0 .. hASH_TBL_SIZE - 1] return buckets -- ----------------------------------------------------------------------------- @@ -581,9 +581,19 @@ fsLit x = mkFastString x -------------------- -- for plugins; see Note [Initializing globals] in CoreMonad +-- called by host compiler saveFSTable :: IO FastStringTable saveFSTable = readIORef string_table +-- called by host compiler +unsaveFSTable :: IO () +unsaveFSTable = do + tbl@(FastStringTable _ arr#) <- readIORef string_table + buckets <- mapM (lookupTbl tbl) [0 .. hASH_TBL_SIZE - 1] + let size = sum $ map length $ buckets + writeIORef string_table (FastStringTable size arr#) + +-- called by plugin restoreFSTable :: FastStringTable -> IO () restoreFSTable = writeIORef string_table \end{code} |