Refactor Unique to be represented by Word64
Fixes #22010 (closed)
I haven't touched FastMutInt
and related uniques such as those used by FastString
.
I'm using fromIntegral
in a lot of places to convert Int
to Word64
. It might be good to use a function with a more specific type to avoid accidents. I'm also using fromIntegral
to convert Word64
to Int
in some places where I believe it is harmless.
There are three big todos left:
-
genSym
should generateWord64
.This will probably require using unboxed primitives and probably even a newI just fallback to C on non-64-bit systems.fetchAddWord64Addr#
primitive. -
The dominator Graph
type needs to be changed fromIntMap IntSet
toWord64Map Word64Set
. -
The EvalBreak constructor in the interpreter carries around and unboxed unique which needs to be boxed in withBreakAction
.
Current problems:
-
darwin builds still don't like how I define atomic_inc64
-
tests are failing due to unknown known-key uniques. -
i386 build is failing with a weird panic #23537: iselExpr64(i386) _so3n::I64 - 16 :: W64
(fixed with workaround; true fix would require new GHC release)
-
JS build is failing with "ReferenceError: h$genSym is not defined" https://gitlab.haskell.org/ghc/ghc/-/jobs/1567116 -
Release build is failing due to performance degradation on MultiLayerModulesTH_OneShot (+4.2%) and T13719 (+2.3%). !10568 (comment 505751)
Long-term todos:
-
Make Dominators.hs prettier using type synonyms. -
See if some uses of Word64
should be replaced byUnique
(andWord64Set
byUniqueSet
). (probably not worth it for now) -
Check if other uniques also need to change such as the uniques associated with FastStrings. -
Upstream Word64Map
andWord64Set
intocontainers
. -
Re-evaluate changes in compiler/GHC/Types/Var.hs