diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2015-08-21 10:44:54 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-08-21 15:44:21 +0200 |
commit | 2f29ebbb6f8c914f2bba624f3edcc259274df8af (patch) | |
tree | c523018ed23dd32e45697fe177d6df5ad4b59b50 /compiler/utils/FastString.hs | |
parent | 3452473b4bb180ba327520067b8c6f2a8d6c4f4b (diff) | |
download | haskell-2f29ebbb6f8c914f2bba624f3edcc259274df8af.tar.gz |
Refactor: delete most of the module FastTypes
This reverses some of the work done in #1405, and goes back to the
assumption that the bootstrap compiler understands GHC-haskell.
In particular:
* use MagicHash instead of _ILIT and _CLIT
* pattern matching on I# if possible, instead of using iUnbox
unnecessarily
* use Int#/Char#/Addr# instead of the following type synonyms:
- type FastInt = Int#
- type FastChar = Char#
- type FastPtr a = Addr#
* inline the following functions:
- iBox = I#
- cBox = C#
- fastChr = chr#
- fastOrd = ord#
- eqFastChar = eqChar#
- shiftLFastInt = uncheckedIShiftL#
- shiftR_FastInt = uncheckedIShiftRL#
- shiftRLFastInt = uncheckedIShiftRL#
* delete the following unused functions:
- minFastInt
- maxFastInt
- uncheckedIShiftRA#
- castFastPtr
- panicDocFastInt and pprPanicFastInt
* rename panicFastInt back to panic#
These functions remain, since they actually do something:
* iUnbox
* bitAndFastInt
* bitOrFastInt
Test Plan: validate
Reviewers: austin, bgamari
Subscribers: rwbarton
Differential Revision: https://phabricator.haskell.org/D1141
GHC Trac Issues: #1405
Diffstat (limited to 'compiler/utils/FastString.hs')
-rw-r--r-- | compiler/utils/FastString.hs | 41 |
1 files changed, 5 insertions, 36 deletions
diff --git a/compiler/utils/FastString.hs b/compiler/utils/FastString.hs index 40c3882b87..32482ccb0b 100644 --- a/compiler/utils/FastString.hs +++ b/compiler/utils/FastString.hs @@ -93,7 +93,6 @@ module FastString #include "HsVersions.h" import Encoding -import FastTypes import FastFunctions import Panic import Util @@ -531,8 +530,8 @@ tailFS (FastString _ _ bs _) = consFS :: Char -> FastString -> FastString consFS c fs = mkFastString (c : unpackFS fs) -uniqueOfFS :: FastString -> FastInt -uniqueOfFS (FastString u _ _ _) = iUnbox u +uniqueOfFS :: FastString -> Int +uniqueOfFS (FastString u _ _ _) = u nilFS :: FastString nilFS = mkFastString "" @@ -561,23 +560,14 @@ hPutFS handle fs = BS.hPut handle $ fastStringToByteString fs -- ----------------------------------------------------------------------------- -- LitStrings, here for convenience only. --- hmm, not unboxed (or rather FastPtr), interesting ---a.k.a. Ptr CChar, Ptr Word8, Ptr (), hmph. We don't ---really care about C types in naming, where we can help it. type LitString = Ptr Word8 --Why do we recalculate length every time it's requested? --If it's commonly needed, we should perhaps have ---data LitString = LitString {-#UNPACK#-}!(FastPtr Word8) {-#UNPACK#-}!FastInt +--data LitString = LitString {-#UNPACK#-}!Addr# {-#UNPACK#-}!Int# mkLitString# :: Addr# -> LitString mkLitString# a# = Ptr a# ---can/should we use FastTypes here? ---Is this likely to be memory-preserving if only used on constant strings? ---should we inline it? If lucky, that would make a CAF that wouldn't ---be computationally repeated... although admittedly we're not ---really intending to use mkLitString when __GLASGOW_HASKELL__... ---(I wonder, is unicode / multi-byte characters allowed in LitStrings --- at all?) + {-# INLINE mkLitString #-} mkLitString :: String -> LitString mkLitString s = @@ -594,32 +584,11 @@ mkLitString s = ) unpackLitString :: LitString -> String -unpackLitString p_ = case pUnbox p_ of - p -> unpack (_ILIT(0)) - where - unpack n = case indexWord8OffFastPtrAsFastChar p n of - ch -> if ch `eqFastChar` _CLIT('\0') - then [] else cBox ch : unpack (n +# _ILIT(1)) +unpackLitString (Ptr p) = unpackCString# p lengthLS :: LitString -> Int lengthLS = ptrStrLength --- for now, use a simple String representation ---no, let's not do that right now - it's work in other places -#if 0 -type LitString = String - -mkLitString :: String -> LitString -mkLitString = id - -unpackLitString :: LitString -> String -unpackLitString = id - -lengthLS :: LitString -> Int -lengthLS = length - -#endif - -- ----------------------------------------------------------------------------- -- under the carpet |