diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2015-08-18 18:38:28 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-08-18 18:42:12 +0200 |
commit | 3849dac59209cc2608636ae120eac54237d882c5 (patch) | |
tree | df6a9cb2fc80dcfde31785188641b4b193016d16 /compiler/utils/StringBuffer.hs | |
parent | e43350573b7a6f233bc7ef2a8badaeb15fb46f34 (diff) | |
download | haskell-wip/d1141.tar.gz |
Refactor: delete most of the module FastTypeswip/d1141
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/StringBuffer.hs')
-rw-r--r-- | compiler/utils/StringBuffer.hs | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/compiler/utils/StringBuffer.hs b/compiler/utils/StringBuffer.hs index 570282da57..2e339d8d75 100644 --- a/compiler/utils/StringBuffer.hs +++ b/compiler/utils/StringBuffer.hs @@ -6,8 +6,8 @@ Buffers for scanning string input stored in external arrays. -} -{-# LANGUAGE BangPatterns, CPP, MagicHash, UnboxedTuples #-} -{-# OPTIONS_GHC -O -funbox-strict-fields #-} +{-# LANGUAGE CPP, MagicHash, UnboxedTuples #-} +{-# OPTIONS_GHC -O #-} -- We always optimise this, otherwise performance of a non-optimised -- compiler is severely affected @@ -45,7 +45,6 @@ module StringBuffer import Encoding import FastString -import FastTypes import FastFunctions import Outputable import Util @@ -232,26 +231,10 @@ lexemeToFastString (StringBuffer buf _ cur) len = -- ----------------------------------------------------------------------------- -- Parsing integer strings in various bases -{- -byteOff :: StringBuffer -> Int -> Char -byteOff (StringBuffer buf _ cur) i = - inlinePerformIO $ withForeignPtr buf $ \ptr -> do --- return $! cBox (indexWord8OffFastPtrAsFastChar --- (pUnbox ptr) (iUnbox (cur+i))) ---or --- w <- peek (ptr `plusPtr` (cur+i)) --- return (unsafeChr (fromIntegral (w::Word8))) --} --- | XXX assumes ASCII digits only (by using byteOff) parseUnsignedInteger :: StringBuffer -> Int -> Integer -> (Char->Int) -> Integer parseUnsignedInteger (StringBuffer buf _ cur) len radix char_to_int = inlinePerformIO $ withForeignPtr buf $ \ptr -> return $! let - --LOL, in implementations where the indexing needs slow unsafePerformIO, - --this is less (not more) efficient than using the IO monad explicitly - --here. - !ptr' = pUnbox ptr - byteOff i = cBox (indexWord8OffFastPtrAsFastChar ptr' (iUnbox (cur + i))) go i x | i == len = x - | otherwise = case byteOff i of + | otherwise = case fst (utf8DecodeChar (ptr `plusPtr` (cur + i))) of char -> go (i + 1) (x * radix + toInteger (char_to_int char)) in go 0 0 |