|
1 | 1 | -- editorconfig-checker-disable-file |
2 | 2 | {-# LANGUAGE FlexibleInstances #-} |
3 | | -{-# LANGUAGE MagicHash #-} |
4 | 3 | {-# LANGUAGE TypeApplications #-} |
5 | 4 | {-# LANGUAGE TypeOperators #-} |
6 | 5 | {-# LANGUAGE UndecidableInstances #-} |
@@ -36,9 +35,6 @@ import Data.Text qualified as T |
36 | 35 | import Data.Vector.Strict (Vector) |
37 | 36 | import Data.Vector.Strict qualified as Vector |
38 | 37 | import Data.Word |
39 | | -import GHC.Exts (Int (I#), quotInt#) |
40 | | -import GHC.Integer |
41 | | -import GHC.Integer.Logarithms |
42 | 38 | import GHC.Natural |
43 | 39 | import GHC.Num.Integer (integerLog2) |
44 | 40 | import Universe |
@@ -237,12 +233,12 @@ instance ExMemoryUsage () where |
237 | 233 | 64-bit words. This is the default size measure for `Integer`s. |
238 | 234 | -} |
239 | 235 | memoryUsageInteger :: Integer -> CostingInteger |
240 | | --- integerLog2# is unspecified for 0 (but in practice returns -1) |
| 236 | +-- integerLog2 is unspecified for 0 (but in practice returns -1) |
241 | 237 | -- ^ This changed with GHC 9.2: it now returns 0. It's probably safest if we |
242 | 238 | -- keep this special case for the time being though. |
243 | 239 | memoryUsageInteger 0 = 1 |
244 | | --- Assume 64 Int |
245 | | -memoryUsageInteger i = fromIntegral $ I# (integerLog2# (abs i) `quotInt#` integerToInt 64) + 1 |
| 240 | +-- Assume 64-bit words |
| 241 | +memoryUsageInteger i = fromIntegral (integerLog2 (abs i) `div` 64 + 1) |
246 | 242 | -- So that the produced GHC Core doesn't explode in size, we don't win anything by inlining this |
247 | 243 | -- function anyway. |
248 | 244 | {-# OPAQUE memoryUsageInteger #-} |
|
0 commit comments