Luite Stegeman pushed to branch wip/ubxsumtag at Glasgow Haskell Compiler / GHC
Commits:
-
e4515501
by Luite Stegeman at 2025-08-14T11:19:55+02:00
-
43efb285
by Luite Stegeman at 2025-08-14T11:21:43+02:00
-
bdcc6de9
by Luite Stegeman at 2025-08-14T11:35:22+02:00
10 changed files:
- compiler/GHC/Builtin/Uniques.hs
- compiler/GHC/Cmm/Utils.hs
- compiler/GHC/Stg/Unarise.hs
- compiler/GHC/Types/RepType.hs
- testsuite/tests/codeGen/should_compile/T25166.stdout → testsuite/tests/codeGen/should_compile/T25166.stdout-ws-32
- + testsuite/tests/codeGen/should_compile/T25166.stdout-ws-64
- + testsuite/tests/unboxedsums/UbxSumUnpackedSize.hs
- + testsuite/tests/unboxedsums/UbxSumUnpackedSize.stdout
- + testsuite/tests/unboxedsums/UbxSumUnpackedSize.stdout-ws-32
- testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs
Changes:
| ... | ... | @@ -97,37 +97,37 @@ Note [Unique layout for unboxed sums] |
| 97 | 97 | |
| 98 | 98 | Sum arities start from 2. The encoding is a bit funny: we break up the
|
| 99 | 99 | integral part into bitfields for the arity, an alternative index (which is
|
| 100 | -taken to be 0xfc in the case of the TyCon), and, in the case of a datacon, a
|
|
| 101 | -tag (used to identify the sum's TypeRep binding).
|
|
| 100 | +taken to be 0x1ffc in the case of the TyCon), and, in the case of a datacon,
|
|
| 101 | +a tag (used to identify the sum's TypeRep binding).
|
|
| 102 | 102 | |
| 103 | 103 | This layout is chosen to remain compatible with the usual unique allocation
|
| 104 | 104 | for wired-in data constructors described in GHC.Types.Unique
|
| 105 | 105 | |
| 106 | 106 | TyCon for sum of arity k:
|
| 107 | - 00000000 kkkkkkkk 11111100
|
|
| 107 | + kkkkkkkk kkk11111 11111100
|
|
| 108 | 108 | |
| 109 | 109 | TypeRep of TyCon for sum of arity k:
|
| 110 | - 00000000 kkkkkkkk 11111101
|
|
| 110 | + kkkkkkkk kkk11111 11111101
|
|
| 111 | 111 | |
| 112 | 112 | DataCon for sum of arity k and alternative n (zero-based):
|
| 113 | - 00000000 kkkkkkkk nnnnnn00
|
|
| 113 | + kkkkkkkk kkknnnnn nnnnnn00
|
|
| 114 | 114 | |
| 115 | 115 | TypeRep for sum DataCon of arity k and alternative n (zero-based):
|
| 116 | - 00000000 kkkkkkkk nnnnnn10
|
|
| 116 | + kkkkkkkk kkknnnnn nnnnnn10
|
|
| 117 | 117 | -}
|
| 118 | 118 | |
| 119 | 119 | mkSumTyConUnique :: Arity -> Unique
|
| 120 | 120 | mkSumTyConUnique arity =
|
| 121 | - assertPpr (arity <= 0x3f) (ppr arity) $
|
|
| 122 | - -- 0x3f since we only have 6 bits to encode the
|
|
| 121 | + assertPpr (arity <= 0x7ff) (ppr arity) $
|
|
| 122 | + -- 0x7ff since we only have 11 bits to encode the
|
|
| 123 | 123 | -- alternative
|
| 124 | - mkUniqueInt 'z' (arity `shiftL` 8 .|. 0xfc)
|
|
| 124 | + mkUniqueInt 'z' (arity `shiftL` 13 .|. 0x1ffc)
|
|
| 125 | 125 | |
| 126 | 126 | -- | Inverse of 'mkSumTyConUnique'
|
| 127 | 127 | isSumTyConUnique :: Unique -> Maybe Arity
|
| 128 | 128 | isSumTyConUnique u =
|
| 129 | - case (tag, n .&. 0xfc) of
|
|
| 130 | - ('z', 0xfc) -> Just (word64ToInt n `shiftR` 8)
|
|
| 129 | + case (tag, n .&. 0x1ffc) of
|
|
| 130 | + ('z', 0x1ffc) -> Just (word64ToInt n `shiftR` 13)
|
|
| 131 | 131 | _ -> Nothing
|
| 132 | 132 | where
|
| 133 | 133 | (tag, n) = unpkUnique u
|
| ... | ... | @@ -137,11 +137,11 @@ mkSumDataConUnique alt arity |
| 137 | 137 | | alt >= arity
|
| 138 | 138 | = panic ("mkSumDataConUnique: " ++ show alt ++ " >= " ++ show arity)
|
| 139 | 139 | | otherwise
|
| 140 | - = mkUniqueInt 'z' (arity `shiftL` 8 + alt `shiftL` 2) {- skip the tycon -}
|
|
| 140 | + = mkUniqueInt 'z' (arity `shiftL` 13 + alt `shiftL` 2) {- skip the tycon -}
|
|
| 141 | 141 | |
| 142 | 142 | getUnboxedSumName :: Int -> Name
|
| 143 | 143 | getUnboxedSumName n
|
| 144 | - | n .&. 0xfc == 0xfc
|
|
| 144 | + | n .&. 0x1ffc == 0x1ffc
|
|
| 145 | 145 | = case tag of
|
| 146 | 146 | 0x0 -> tyConName $ sumTyCon arity
|
| 147 | 147 | 0x1 -> getRep $ sumTyCon arity
|
| ... | ... | @@ -155,8 +155,8 @@ getUnboxedSumName n |
| 155 | 155 | | otherwise
|
| 156 | 156 | = pprPanic "getUnboxedSumName" (ppr n)
|
| 157 | 157 | where
|
| 158 | - arity = n `shiftR` 8
|
|
| 159 | - alt = (n .&. 0xfc) `shiftR` 2
|
|
| 158 | + arity = n `shiftR` 13
|
|
| 159 | + alt = (n .&. 0x1ffc) `shiftR` 2
|
|
| 160 | 160 | tag = 0x3 .&. n
|
| 161 | 161 | getRep tycon =
|
| 162 | 162 | fromMaybe (pprPanic "getUnboxedSumName(getRep)" (ppr tycon))
|
| ... | ... | @@ -115,6 +115,9 @@ slotCmmType platform = \case |
| 115 | 115 | PtrUnliftedSlot -> gcWord platform
|
| 116 | 116 | PtrLiftedSlot -> gcWord platform
|
| 117 | 117 | WordSlot -> bWord platform
|
| 118 | + Word8Slot -> b8
|
|
| 119 | + Word16Slot -> b16
|
|
| 120 | + Word32Slot -> b32
|
|
| 118 | 121 | Word64Slot -> b64
|
| 119 | 122 | FloatSlot -> f32
|
| 120 | 123 | DoubleSlot -> f64
|
| ... | ... | @@ -404,7 +404,6 @@ import GHC.Stg.Syntax |
| 404 | 404 | import GHC.Stg.Utils
|
| 405 | 405 | import GHC.Stg.Make
|
| 406 | 406 | import GHC.Core.Type
|
| 407 | -import GHC.Builtin.Types.Prim (intPrimTy)
|
|
| 408 | 407 | import GHC.Builtin.Types
|
| 409 | 408 | import GHC.Types.Unique.Supply
|
| 410 | 409 | import GHC.Types.Unique
|
| ... | ... | @@ -681,15 +680,15 @@ elimCase rho args bndr (MultiValAlt _) [GenStgAlt{ alt_con = _ |
| 681 | 680 | |
| 682 | 681 | elimCase rho args@(tag_arg : real_args) bndr (MultiValAlt _) alts
|
| 683 | 682 | | isUnboxedSumBndr bndr
|
| 684 | - = do tag_bndr <- mkId (mkFastString "tag") tagTy
|
|
| 683 | + = do tag_bndr <- mkId (mkFastString "tag") (tagTyArg tag_arg)
|
|
| 685 | 684 | -- this won't be used but we need a binder anyway
|
| 686 | 685 | let rho1 = extendRho rho bndr (MultiVal args)
|
| 687 | 686 | scrut' = case tag_arg of
|
| 688 | 687 | StgVarArg v -> StgApp v []
|
| 689 | 688 | StgLitArg l -> StgLit l
|
| 690 | - |
|
| 691 | - alts' <- unariseSumAlts rho1 real_args alts
|
|
| 692 | - return (StgCase scrut' tag_bndr tagAltTy alts')
|
|
| 689 | + alt_ty = (tagAltTyArg tag_arg)
|
|
| 690 | + alts' <- unariseSumAlts rho1 alt_ty real_args alts
|
|
| 691 | + return (StgCase scrut' tag_bndr alt_ty alts')
|
|
| 693 | 692 | |
| 694 | 693 | elimCase _ args bndr alt_ty alts
|
| 695 | 694 | = pprPanic "elimCase - unhandled case"
|
| ... | ... | @@ -732,8 +731,9 @@ unariseAlts rho (MultiValAlt _) bndr [GenStgAlt{ alt_con = DEFAULT |
| 732 | 731 | unariseAlts rho (MultiValAlt _) bndr alts
|
| 733 | 732 | | isUnboxedSumBndr bndr
|
| 734 | 733 | = do (rho_sum_bndrs, scrt_bndrs@(tag_bndr : real_bndrs)) <- unariseConArgBinder rho bndr
|
| 735 | - alts' <- unariseSumAlts rho_sum_bndrs (map StgVarArg real_bndrs) alts
|
|
| 736 | - let inner_case = StgCase (StgApp tag_bndr []) tag_bndr tagAltTy alts'
|
|
| 734 | + let alt_ty = tagAltTy tag_bndr
|
|
| 735 | + alts' <- unariseSumAlts rho_sum_bndrs alt_ty (map StgVarArg real_bndrs) alts
|
|
| 736 | + let inner_case = StgCase (StgApp tag_bndr []) tag_bndr alt_ty alts'
|
|
| 737 | 737 | return [GenStgAlt{ alt_con = DataAlt (tupleDataCon Unboxed (length scrt_bndrs))
|
| 738 | 738 | , alt_bndrs = scrt_bndrs
|
| 739 | 739 | , alt_rhs = inner_case
|
| ... | ... | @@ -753,21 +753,23 @@ unariseAlt rho alt@GenStgAlt{alt_con=_,alt_bndrs=xs,alt_rhs=e} |
| 753 | 753 | -- | Make alternatives that match on the tag of a sum
|
| 754 | 754 | -- (i.e. generate LitAlts for the tag)
|
| 755 | 755 | unariseSumAlts :: UnariseEnv
|
| 756 | + -> AltType
|
|
| 756 | 757 | -> [StgArg] -- sum components _excluding_ the tag bit.
|
| 757 | 758 | -> [StgAlt] -- original alternative with sum LHS
|
| 758 | 759 | -> UniqSM [StgAlt]
|
| 759 | -unariseSumAlts env args alts
|
|
| 760 | - = do alts' <- mapM (unariseSumAlt env args) alts
|
|
| 760 | +unariseSumAlts env tag_slot args alts
|
|
| 761 | + = do alts' <- mapM (unariseSumAlt env tag_slot args) alts
|
|
| 761 | 762 | return (mkDefaultLitAlt alts')
|
| 762 | 763 | |
| 763 | 764 | unariseSumAlt :: UnariseEnv
|
| 765 | + -> AltType
|
|
| 764 | 766 | -> [StgArg] -- sum components _excluding_ the tag bit.
|
| 765 | 767 | -> StgAlt -- original alternative with sum LHS
|
| 766 | 768 | -> UniqSM StgAlt
|
| 767 | -unariseSumAlt rho _ GenStgAlt{alt_con=DEFAULT,alt_bndrs=_,alt_rhs=e}
|
|
| 769 | +unariseSumAlt rho _ _ GenStgAlt{alt_con=DEFAULT,alt_bndrs=_,alt_rhs=e}
|
|
| 768 | 770 | = GenStgAlt DEFAULT mempty <$> unariseExpr rho e
|
| 769 | 771 | |
| 770 | -unariseSumAlt rho args alt@GenStgAlt{ alt_con = DataAlt sumCon
|
|
| 772 | +unariseSumAlt rho tag_slot args alt@GenStgAlt{ alt_con = DataAlt sumCon
|
|
| 771 | 773 | , alt_bndrs = bs
|
| 772 | 774 | , alt_rhs = e
|
| 773 | 775 | }
|
| ... | ... | @@ -776,10 +778,19 @@ unariseSumAlt rho args alt@GenStgAlt{ alt_con = DataAlt sumCon |
| 776 | 778 | [b] -> mapSumIdBinders b args e rho
|
| 777 | 779 | -- Sums must have one binder
|
| 778 | 780 | _ -> pprPanic "unariseSumAlt2" (ppr args $$ pprPanicAlt alt)
|
| 779 | - let lit_case = LitAlt (LitNumber LitNumInt (fromIntegral (dataConTag sumCon)))
|
|
| 781 | + let num_ty =
|
|
| 782 | + case tag_slot of
|
|
| 783 | + PrimAlt Int8Rep -> LitNumInt8
|
|
| 784 | + PrimAlt Word8Rep -> LitNumWord8
|
|
| 785 | + PrimAlt Int16Rep -> LitNumInt16
|
|
| 786 | + PrimAlt Word16Rep -> LitNumWord16
|
|
| 787 | + PrimAlt Int32Rep -> LitNumInt32
|
|
| 788 | + PrimAlt Word32Rep -> LitNumWord32
|
|
| 789 | + _ -> LitNumInt
|
|
| 790 | + lit_case = LitAlt (LitNumber num_ty (fromIntegral (dataConTag sumCon)))
|
|
| 780 | 791 | GenStgAlt lit_case mempty <$> unariseExpr rho' e'
|
| 781 | 792 | |
| 782 | -unariseSumAlt _ scrt alt
|
|
| 793 | +unariseSumAlt _ _ scrt alt
|
|
| 783 | 794 | = pprPanic "unariseSumAlt3" (ppr scrt $$ pprPanicAlt alt)
|
| 784 | 795 | |
| 785 | 796 | --------------------------------------------------------------------------------
|
| ... | ... | @@ -865,12 +876,6 @@ mapSumIdBinders alt_bndr args rhs rho0 |
| 865 | 876 | |
| 866 | 877 | typed_id_args = map StgVarArg typed_ids
|
| 867 | 878 | |
| 868 | - -- pprTrace "mapSumIdBinders"
|
|
| 869 | - -- (text "fld_reps" <+> ppr fld_reps $$
|
|
| 870 | - -- text "id_args" <+> ppr id_arg_exprs $$
|
|
| 871 | - -- text "rhs" <+> ppr rhs $$
|
|
| 872 | - -- text "rhs_with_casts" <+> ppr rhs_with_casts
|
|
| 873 | - -- ) $
|
|
| 874 | 879 | if isMultiValBndr alt_bndr
|
| 875 | 880 | then return (extendRho rho0 alt_bndr (MultiVal typed_id_args), rhs_with_casts rhs)
|
| 876 | 881 | else assert (typed_id_args `lengthIs` 1) $
|
| ... | ... | @@ -921,13 +926,19 @@ mkUbxSum |
| 921 | 926 | )
|
| 922 | 927 | mkUbxSum dc ty_args args0 us
|
| 923 | 928 | = let
|
| 924 | - _ :| sum_slots = ubxSumRepType ty_args
|
|
| 929 | + tag_slot :| sum_slots = ubxSumRepType ty_args
|
|
| 925 | 930 | -- drop tag slot
|
| 926 | 931 | field_slots = (mapMaybe (repSlotTy . stgArgRep) args0)
|
| 927 | 932 | tag = dataConTag dc
|
| 928 | 933 | layout' = layoutUbxSum sum_slots field_slots
|
| 929 | 934 | |
| 930 | - tag_arg = StgLitArg (LitNumber LitNumInt (fromIntegral tag))
|
|
| 935 | + tag_arg =
|
|
| 936 | + case tag_slot of
|
|
| 937 | + Word8Slot -> StgLitArg (LitNumber LitNumWord8 (fromIntegral tag))
|
|
| 938 | + Word16Slot -> StgLitArg (LitNumber LitNumWord16 (fromIntegral tag))
|
|
| 939 | + Word32Slot -> StgLitArg (LitNumber LitNumWord32 (fromIntegral tag))
|
|
| 940 | + WordSlot -> StgLitArg (LitNumber LitNumWord (fromIntegral tag))
|
|
| 941 | + _ -> pprPanic "mkUbxSum: unexpected tag slot: " (ppr tag_slot)
|
|
| 931 | 942 | arg_idxs = IM.fromList (zipEqual layout' args0)
|
| 932 | 943 | |
| 933 | 944 | ((_idx,_idx_map,_us,wrapper),slot_args)
|
| ... | ... | @@ -990,6 +1001,9 @@ ubxSumRubbishArg :: SlotTy -> StgArg |
| 990 | 1001 | ubxSumRubbishArg PtrLiftedSlot = StgVarArg aBSENT_SUM_FIELD_ERROR_ID
|
| 991 | 1002 | ubxSumRubbishArg PtrUnliftedSlot = StgVarArg aBSENT_SUM_FIELD_ERROR_ID
|
| 992 | 1003 | ubxSumRubbishArg WordSlot = StgLitArg (LitNumber LitNumWord 0)
|
| 1004 | +ubxSumRubbishArg Word8Slot = StgLitArg (LitNumber LitNumWord8 0)
|
|
| 1005 | +ubxSumRubbishArg Word16Slot = StgLitArg (LitNumber LitNumWord16 0)
|
|
| 1006 | +ubxSumRubbishArg Word32Slot = StgLitArg (LitNumber LitNumWord32 0)
|
|
| 993 | 1007 | ubxSumRubbishArg Word64Slot = StgLitArg (LitNumber LitNumWord64 0)
|
| 994 | 1008 | ubxSumRubbishArg FloatSlot = StgLitArg (LitFloat 0)
|
| 995 | 1009 | ubxSumRubbishArg DoubleSlot = StgLitArg (LitDouble 0)
|
| ... | ... | @@ -1166,11 +1180,18 @@ isUnboxedTupleBndr = isUnboxedTupleType . idType |
| 1166 | 1180 | mkTuple :: [StgArg] -> StgExpr
|
| 1167 | 1181 | mkTuple args = StgConApp (tupleDataCon Unboxed (length args)) NoNumber args []
|
| 1168 | 1182 | |
| 1169 | -tagAltTy :: AltType
|
|
| 1170 | -tagAltTy = PrimAlt IntRep
|
|
| 1183 | +tagAltTyArg :: StgArg -> AltType
|
|
| 1184 | +tagAltTyArg a
|
|
| 1185 | + | [pr] <- typePrimRep (stgArgType a) = PrimAlt pr
|
|
| 1186 | + | otherwise = pprPanic "tagAltTyArg" (ppr a)
|
|
| 1187 | + |
|
| 1188 | +tagAltTy :: Id -> AltType
|
|
| 1189 | +tagAltTy i
|
|
| 1190 | + | [pr] <- typePrimRep (idType i) = PrimAlt pr
|
|
| 1191 | + | otherwise = pprPanic "tagAltTy" (ppr $ idType i)
|
|
| 1171 | 1192 | |
| 1172 | -tagTy :: Type
|
|
| 1173 | -tagTy = intPrimTy
|
|
| 1193 | +tagTyArg :: StgArg -> Type
|
|
| 1194 | +tagTyArg x = stgArgType x
|
|
| 1174 | 1195 | |
| 1175 | 1196 | voidArg :: StgArg
|
| 1176 | 1197 | voidArg = StgVarArg voidPrimId
|
| ... | ... | @@ -197,12 +197,12 @@ type SortedSlotTys = [SlotTy] |
| 197 | 197 | -- of the list we have the slot for the tag.
|
| 198 | 198 | ubxSumRepType :: [[PrimRep]] -> NonEmpty SlotTy
|
| 199 | 199 | ubxSumRepType constrs0
|
| 200 | - -- These first two cases never classify an actual unboxed sum, which always
|
|
| 200 | + -- This first case never classifies an actual unboxed sum, which always
|
|
| 201 | 201 | -- has at least two disjuncts. But it could happen if a user writes, e.g.,
|
| 202 | 202 | -- forall (a :: TYPE (SumRep [IntRep])). ...
|
| 203 | 203 | -- which could never be instantiated. We still don't want to panic.
|
| 204 | 204 | | constrs0 `lengthLessThan` 2
|
| 205 | - = WordSlot :| []
|
|
| 205 | + = Word8Slot :| []
|
|
| 206 | 206 | |
| 207 | 207 | | otherwise
|
| 208 | 208 | = let
|
| ... | ... | @@ -230,8 +230,14 @@ ubxSumRepType constrs0 |
| 230 | 230 | rep :: [PrimRep] -> SortedSlotTys
|
| 231 | 231 | rep ty = sort (map primRepSlot ty)
|
| 232 | 232 | |
| 233 | - sumRep = WordSlot :| combine_alts (map rep constrs0)
|
|
| 234 | - -- WordSlot: for the tag of the sum
|
|
| 233 | + -- constructors start at 1 (XXX is this correct?)
|
|
| 234 | + tag_slot | length constrs0 < 256 = Word8Slot
|
|
| 235 | + | length constrs0 < 65536 = Word16Slot
|
|
| 236 | +-- | length constrs0 < 4294967296 = Word32Slot
|
|
| 237 | + | length constrs0 < 2147483647 = Word32Slot -- XXX temporary for 32 bit platforms
|
|
| 238 | + | otherwise = WordSlot
|
|
| 239 | + |
|
| 240 | + sumRep = tag_slot :| combine_alts (map rep constrs0)
|
|
| 235 | 241 | in
|
| 236 | 242 | sumRep
|
| 237 | 243 | |
| ... | ... | @@ -275,10 +281,17 @@ layoutUbxSum sum_slots0 arg_slots0 = |
| 275 | 281 | -- - Float slots: Shared between floating point types.
|
| 276 | 282 | --
|
| 277 | 283 | -- - Void slots: Shared between void types. Not used in sums.
|
| 278 | ---
|
|
| 279 | --- TODO(michalt): We should probably introduce `SlotTy`s for 8-/16-/32-bit
|
|
| 280 | --- values, so that we can pack things more tightly.
|
|
| 281 | -data SlotTy = PtrLiftedSlot | PtrUnliftedSlot | WordSlot | Word64Slot | FloatSlot | DoubleSlot | VecSlot Int PrimElemRep
|
|
| 284 | + |
|
| 285 | +data SlotTy = PtrLiftedSlot
|
|
| 286 | + | PtrUnliftedSlot
|
|
| 287 | + | Word8Slot
|
|
| 288 | + | Word16Slot
|
|
| 289 | + | Word32Slot
|
|
| 290 | + | WordSlot -- the order is important, later ones are bigger. this works for word sizes 32 and 64 bit (XXX fix this)
|
|
| 291 | + | Word64Slot
|
|
| 292 | + | FloatSlot
|
|
| 293 | + | DoubleSlot
|
|
| 294 | + | VecSlot Int PrimElemRep
|
|
| 282 | 295 | deriving (Eq, Ord)
|
| 283 | 296 | -- Constructor order is important! If slot A could fit into slot B
|
| 284 | 297 | -- then slot A must occur first. E.g. FloatSlot before DoubleSlot
|
| ... | ... | @@ -291,6 +304,9 @@ instance Outputable SlotTy where |
| 291 | 304 | ppr PtrUnliftedSlot = text "PtrUnliftedSlot"
|
| 292 | 305 | ppr Word64Slot = text "Word64Slot"
|
| 293 | 306 | ppr WordSlot = text "WordSlot"
|
| 307 | + ppr Word32Slot = text "Word32Slot"
|
|
| 308 | + ppr Word16Slot = text "Word16Slot"
|
|
| 309 | + ppr Word8Slot = text "Word8Slot"
|
|
| 294 | 310 | ppr DoubleSlot = text "DoubleSlot"
|
| 295 | 311 | ppr FloatSlot = text "FloatSlot"
|
| 296 | 312 | ppr (VecSlot n e) = text "VecSlot" <+> ppr n <+> ppr e
|
| ... | ... | @@ -307,14 +323,14 @@ primRepSlot (BoxedRep mlev) = case mlev of |
| 307 | 323 | Just Lifted -> PtrLiftedSlot
|
| 308 | 324 | Just Unlifted -> PtrUnliftedSlot
|
| 309 | 325 | primRepSlot IntRep = WordSlot
|
| 310 | -primRepSlot Int8Rep = WordSlot
|
|
| 311 | -primRepSlot Int16Rep = WordSlot
|
|
| 312 | -primRepSlot Int32Rep = WordSlot
|
|
| 326 | +primRepSlot Int8Rep = Word8Slot
|
|
| 327 | +primRepSlot Int16Rep = Word16Slot
|
|
| 328 | +primRepSlot Int32Rep = Word32Slot
|
|
| 313 | 329 | primRepSlot Int64Rep = Word64Slot
|
| 314 | 330 | primRepSlot WordRep = WordSlot
|
| 315 | -primRepSlot Word8Rep = WordSlot
|
|
| 316 | -primRepSlot Word16Rep = WordSlot
|
|
| 317 | -primRepSlot Word32Rep = WordSlot
|
|
| 331 | +primRepSlot Word8Rep = Word8Slot
|
|
| 332 | +primRepSlot Word16Rep = Word16Slot
|
|
| 333 | +primRepSlot Word32Rep = Word32Slot
|
|
| 318 | 334 | primRepSlot Word64Rep = Word64Slot
|
| 319 | 335 | primRepSlot AddrRep = WordSlot
|
| 320 | 336 | primRepSlot FloatRep = FloatSlot
|
| ... | ... | @@ -325,6 +341,9 @@ slotPrimRep :: SlotTy -> PrimRep |
| 325 | 341 | slotPrimRep PtrLiftedSlot = BoxedRep (Just Lifted)
|
| 326 | 342 | slotPrimRep PtrUnliftedSlot = BoxedRep (Just Unlifted)
|
| 327 | 343 | slotPrimRep Word64Slot = Word64Rep
|
| 344 | +slotPrimRep Word32Slot = Word32Rep
|
|
| 345 | +slotPrimRep Word16Slot = Word16Rep
|
|
| 346 | +slotPrimRep Word8Slot = Word8Rep
|
|
| 328 | 347 | slotPrimRep WordSlot = WordRep
|
| 329 | 348 | slotPrimRep DoubleSlot = DoubleRep
|
| 330 | 349 | slotPrimRep FloatSlot = FloatRep
|
| ... | ... | @@ -349,11 +368,12 @@ fitsIn ty1 ty2 |
| 349 | 368 | -- See Note [Casting slot arguments]
|
| 350 | 369 | where
|
| 351 | 370 | isWordSlot Word64Slot = True
|
| 371 | + isWordSlot Word32Slot = True
|
|
| 372 | + isWordSlot Word16Slot = True
|
|
| 373 | + isWordSlot Word8Slot = True
|
|
| 352 | 374 | isWordSlot WordSlot = True
|
| 353 | 375 | isWordSlot _ = False
|
| 354 | 376 | |
| 355 | - |
|
| 356 | - |
|
| 357 | 377 | {- **********************************************************************
|
| 358 | 378 | * *
|
| 359 | 379 | PrimRep
|
| ... | ... | @@ -2,5 +2,7 @@ |
| 2 | 2 | Test.foo_closure:
|
| 3 | 3 | const Test.D_con_info;
|
| 4 | 4 | const GHC.Internal.Types.True_closure+2;
|
| 5 | - const 2;
|
|
| 5 | + const 2 :: W8;
|
|
| 6 | + const 0 :: W16;
|
|
| 7 | + const 0 :: W8;
|
|
| 6 | 8 | const 3; |
| 1 | +[section ""data" . Test.foo_closure" {
|
|
| 2 | + Test.foo_closure:
|
|
| 3 | + const Test.D_con_info;
|
|
| 4 | + const GHC.Internal.Types.True_closure+2;
|
|
| 5 | + const 2 :: W8;
|
|
| 6 | + const 0 :: W32;
|
|
| 7 | + const 0 :: W16;
|
|
| 8 | + const 0 :: W8;
|
|
| 9 | + const 3; |
| 1 | +module Main where
|
|
| 2 | + |
|
| 3 | +import GHC.Exts.Heap.Closures
|
|
| 4 | +import Control.Exception (evaluate)
|
|
| 5 | +import Data.Word (Word32)
|
|
| 6 | + |
|
| 7 | +-- this should get a Word8 tag
|
|
| 8 | +data E1
|
|
| 9 | + = E1_1 | E1_2 | E1_3 | E1_4 | E1_5 | E1_6 | E1_7 | E1_8
|
|
| 10 | + | E1_9 | E1_10 | E1_11 | E1_12 | E1_13 | E1_14 | E1_15 | E1_16
|
|
| 11 | + | E1_17 | E1_18 | E1_19 | E1_20 | E1_21 | E1_22 | E1_23 | E1_24
|
|
| 12 | + | E1_25 | E1_26 | E1_27 | E1_28 | E1_29 | E1_30 | E1_31 | E1_32
|
|
| 13 | + | E1_33 | E1_34 | E1_35 | E1_36 | E1_37 | E1_38 | E1_39 | E1_40
|
|
| 14 | + | E1_41 | E1_42 | E1_43 | E1_44 | E1_45 | E1_46 | E1_47 | E1_48
|
|
| 15 | + | E1_49 | E1_50 | E1_51 | E1_52 | E1_53 | E1_54 | E1_55 | E1_56
|
|
| 16 | + | E1_57 | E1_58 | E1_59 | E1_60 | E1_61 | E1_62 | E1_63 | E1_64
|
|
| 17 | + | E1_65 | E1_66 | E1_67 | E1_68 | E1_69 | E1_70 | E1_71 | E1_72
|
|
| 18 | + | E1_73 | E1_74 | E1_75 | E1_76 | E1_77 | E1_78 | E1_79 | E1_80
|
|
| 19 | + | E1_81 | E1_82 | E1_83 | E1_84 | E1_85 | E1_86 | E1_87 | E1_88
|
|
| 20 | + | E1_89 | E1_90 | E1_91 | E1_92 | E1_93 | E1_94 | E1_95 | E1_96
|
|
| 21 | + | E1_97 | E1_98 | E1_99 | E1_100 | E1_101 | E1_102 | E1_103 | E1_104
|
|
| 22 | + | E1_105 | E1_106 | E1_107 | E1_108 | E1_109 | E1_110 | E1_111 | E1_112
|
|
| 23 | + | E1_113 | E1_114 | E1_115 | E1_116 | E1_117 | E1_118 | E1_119 | E1_120
|
|
| 24 | + | E1_121 | E1_122 | E1_123 | E1_124 | E1_125 | E1_126 | E1_127 | E1_128
|
|
| 25 | + | E1_129 | E1_130 | E1_131 | E1_132 | E1_133 | E1_134 | E1_135 | E1_136
|
|
| 26 | + | E1_137 | E1_138 | E1_139 | E1_140 | E1_141 | E1_142 | E1_143 | E1_144
|
|
| 27 | + | E1_145 | E1_146 | E1_147 | E1_148 | E1_149 | E1_150 | E1_151 | E1_152
|
|
| 28 | + | E1_153 | E1_154 | E1_155 | E1_156 | E1_157 | E1_158 | E1_159 | E1_160
|
|
| 29 | + | E1_161 | E1_162 | E1_163 | E1_164 | E1_165 | E1_166 | E1_167 | E1_168
|
|
| 30 | + | E1_169 | E1_170 | E1_171 | E1_172 | E1_173 | E1_174 | E1_175 | E1_176
|
|
| 31 | + | E1_177 | E1_178 | E1_179 | E1_180 | E1_181 | E1_182 | E1_183 | E1_184
|
|
| 32 | + | E1_185 | E1_186 | E1_187 | E1_188 | E1_189 | E1_190 | E1_191 | E1_192
|
|
| 33 | + | E1_193 | E1_194 | E1_195 | E1_196 | E1_197 | E1_198 | E1_199 | E1_200
|
|
| 34 | + | E1_201 | E1_202 | E1_203 | E1_204 | E1_205 | E1_206 | E1_207 | E1_208
|
|
| 35 | + | E1_209 | E1_210 | E1_211 | E1_212 | E1_213 | E1_214 | E1_215 | E1_216
|
|
| 36 | + | E1_217 | E1_218 | E1_219 | E1_220 | E1_221 | E1_222 | E1_223 | E1_224
|
|
| 37 | + | E1_225 | E1_226 | E1_227 | E1_228 | E1_229 | E1_230 | E1_231 | E1_232
|
|
| 38 | + | E1_233 | E1_234 | E1_235 | E1_236 | E1_237 | E1_238 | E1_239 | E1_240
|
|
| 39 | + | E1_241 | E1_242 | E1_243 | E1_244 | E1_245 | E1_246 | E1_247 | E1_248
|
|
| 40 | + | E1_249 | E1_250 | E1_251 | E1_252 | E1_253 | E1_254
|
|
| 41 | + deriving (Enum, Bounded, Show)
|
|
| 42 | + |
|
| 43 | +-- this should get a Word8 tag
|
|
| 44 | +data E2
|
|
| 45 | + = E2_1 | E2_2 | E2_3 | E2_4 | E2_5 | E2_6 | E2_7 | E2_8
|
|
| 46 | + | E2_9 | E2_10 | E2_11 | E2_12 | E2_13 | E2_14 | E2_15 | E2_16
|
|
| 47 | + | E2_17 | E2_18 | E2_19 | E2_20 | E2_21 | E2_22 | E2_23 | E2_24
|
|
| 48 | + | E2_25 | E2_26 | E2_27 | E2_28 | E2_29 | E2_30 | E2_31 | E2_32
|
|
| 49 | + | E2_33 | E2_34 | E2_35 | E2_36 | E2_37 | E2_38 | E2_39 | E2_40
|
|
| 50 | + | E2_41 | E2_42 | E2_43 | E2_44 | E2_45 | E2_46 | E2_47 | E2_48
|
|
| 51 | + | E2_49 | E2_50 | E2_51 | E2_52 | E2_53 | E2_54 | E2_55 | E2_56
|
|
| 52 | + | E2_57 | E2_58 | E2_59 | E2_60 | E2_61 | E2_62 | E2_63 | E2_64
|
|
| 53 | + | E2_65 | E2_66 | E2_67 | E2_68 | E2_69 | E2_70 | E2_71 | E2_72
|
|
| 54 | + | E2_73 | E2_74 | E2_75 | E2_76 | E2_77 | E2_78 | E2_79 | E2_80
|
|
| 55 | + | E2_81 | E2_82 | E2_83 | E2_84 | E2_85 | E2_86 | E2_87 | E2_88
|
|
| 56 | + | E2_89 | E2_90 | E2_91 | E2_92 | E2_93 | E2_94 | E2_95 | E2_96
|
|
| 57 | + | E2_97 | E2_98 | E2_99 | E2_100 | E2_101 | E2_102 | E2_103 | E2_104
|
|
| 58 | + | E2_105 | E2_106 | E2_107 | E2_108 | E2_109 | E2_110 | E2_111 | E2_112
|
|
| 59 | + | E2_113 | E2_114 | E2_115 | E2_116 | E2_117 | E2_118 | E2_119 | E2_120
|
|
| 60 | + | E2_121 | E2_122 | E2_123 | E2_124 | E2_125 | E2_126 | E2_127 | E2_128
|
|
| 61 | + | E2_129 | E2_130 | E2_131 | E2_132 | E2_133 | E2_134 | E2_135 | E2_136
|
|
| 62 | + | E2_137 | E2_138 | E2_139 | E2_140 | E2_141 | E2_142 | E2_143 | E2_144
|
|
| 63 | + | E2_145 | E2_146 | E2_147 | E2_148 | E2_149 | E2_150 | E2_151 | E2_152
|
|
| 64 | + | E2_153 | E2_154 | E2_155 | E2_156 | E2_157 | E2_158 | E2_159 | E2_160
|
|
| 65 | + | E2_161 | E2_162 | E2_163 | E2_164 | E2_165 | E2_166 | E2_167 | E2_168
|
|
| 66 | + | E2_169 | E2_170 | E2_171 | E2_172 | E2_173 | E2_174 | E2_175 | E2_176
|
|
| 67 | + | E2_177 | E2_178 | E2_179 | E2_180 | E2_181 | E2_182 | E2_183 | E2_184
|
|
| 68 | + | E2_185 | E2_186 | E2_187 | E2_188 | E2_189 | E2_190 | E2_191 | E2_192
|
|
| 69 | + | E2_193 | E2_194 | E2_195 | E2_196 | E2_197 | E2_198 | E2_199 | E2_200
|
|
| 70 | + | E2_201 | E2_202 | E2_203 | E2_204 | E2_205 | E2_206 | E2_207 | E2_208
|
|
| 71 | + | E2_209 | E2_210 | E2_211 | E2_212 | E2_213 | E2_214 | E2_215 | E2_216
|
|
| 72 | + | E2_217 | E2_218 | E2_219 | E2_220 | E2_221 | E2_222 | E2_223 | E2_224
|
|
| 73 | + | E2_225 | E2_226 | E2_227 | E2_228 | E2_229 | E2_230 | E2_231 | E2_232
|
|
| 74 | + | E2_233 | E2_234 | E2_235 | E2_236 | E2_237 | E2_238 | E2_239 | E2_240
|
|
| 75 | + | E2_241 | E2_242 | E2_243 | E2_244 | E2_245 | E2_246 | E2_247 | E2_248
|
|
| 76 | + | E2_249 | E2_250 | E2_251 | E2_252 | E2_253 | E2_254 | E2_255
|
|
| 77 | + deriving (Enum, Bounded, Show)
|
|
| 78 | + |
|
| 79 | +-- this needs a Word16 tag
|
|
| 80 | +data E3
|
|
| 81 | + = E3_1 | E3_2 | E3_3 | E3_4 | E3_5 | E3_6 | E3_7 | E3_8
|
|
| 82 | + | E3_9 | E3_10 | E3_11 | E3_12 | E3_13 | E3_14 | E3_15 | E3_16
|
|
| 83 | + | E3_17 | E3_18 | E3_19 | E3_20 | E3_21 | E3_22 | E3_23 | E3_24
|
|
| 84 | + | E3_25 | E3_26 | E3_27 | E3_28 | E3_29 | E3_30 | E3_31 | E3_32
|
|
| 85 | + | E3_33 | E3_34 | E3_35 | E3_36 | E3_37 | E3_38 | E3_39 | E3_40
|
|
| 86 | + | E3_41 | E3_42 | E3_43 | E3_44 | E3_45 | E3_46 | E3_47 | E3_48
|
|
| 87 | + | E3_49 | E3_50 | E3_51 | E3_52 | E3_53 | E3_54 | E3_55 | E3_56
|
|
| 88 | + | E3_57 | E3_58 | E3_59 | E3_60 | E3_61 | E3_62 | E3_63 | E3_64
|
|
| 89 | + | E3_65 | E3_66 | E3_67 | E3_68 | E3_69 | E3_70 | E3_71 | E3_72
|
|
| 90 | + | E3_73 | E3_74 | E3_75 | E3_76 | E3_77 | E3_78 | E3_79 | E3_80
|
|
| 91 | + | E3_81 | E3_82 | E3_83 | E3_84 | E3_85 | E3_86 | E3_87 | E3_88
|
|
| 92 | + | E3_89 | E3_90 | E3_91 | E3_92 | E3_93 | E3_94 | E3_95 | E3_96
|
|
| 93 | + | E3_97 | E3_98 | E3_99 | E3_100 | E3_101 | E3_102 | E3_103 | E3_104
|
|
| 94 | + | E3_105 | E3_106 | E3_107 | E3_108 | E3_109 | E3_110 | E3_111 | E3_112
|
|
| 95 | + | E3_113 | E3_114 | E3_115 | E3_116 | E3_117 | E3_118 | E3_119 | E3_120
|
|
| 96 | + | E3_121 | E3_122 | E3_123 | E3_124 | E3_125 | E3_126 | E3_127 | E3_128
|
|
| 97 | + | E3_129 | E3_130 | E3_131 | E3_132 | E3_133 | E3_134 | E3_135 | E3_136
|
|
| 98 | + | E3_137 | E3_138 | E3_139 | E3_140 | E3_141 | E3_142 | E3_143 | E3_144
|
|
| 99 | + | E3_145 | E3_146 | E3_147 | E3_148 | E3_149 | E3_150 | E3_151 | E3_152
|
|
| 100 | + | E3_153 | E3_154 | E3_155 | E3_156 | E3_157 | E3_158 | E3_159 | E3_160
|
|
| 101 | + | E3_161 | E3_162 | E3_163 | E3_164 | E3_165 | E3_166 | E3_167 | E3_168
|
|
| 102 | + | E3_169 | E3_170 | E3_171 | E3_172 | E3_173 | E3_174 | E3_175 | E3_176
|
|
| 103 | + | E3_177 | E3_178 | E3_179 | E3_180 | E3_181 | E3_182 | E3_183 | E3_184
|
|
| 104 | + | E3_185 | E3_186 | E3_187 | E3_188 | E3_189 | E3_190 | E3_191 | E3_192
|
|
| 105 | + | E3_193 | E3_194 | E3_195 | E3_196 | E3_197 | E3_198 | E3_199 | E3_200
|
|
| 106 | + | E3_201 | E3_202 | E3_203 | E3_204 | E3_205 | E3_206 | E3_207 | E3_208
|
|
| 107 | + | E3_209 | E3_210 | E3_211 | E3_212 | E3_213 | E3_214 | E3_215 | E3_216
|
|
| 108 | + | E3_217 | E3_218 | E3_219 | E3_220 | E3_221 | E3_222 | E3_223 | E3_224
|
|
| 109 | + | E3_225 | E3_226 | E3_227 | E3_228 | E3_229 | E3_230 | E3_231 | E3_232
|
|
| 110 | + | E3_233 | E3_234 | E3_235 | E3_236 | E3_237 | E3_238 | E3_239 | E3_240
|
|
| 111 | + | E3_241 | E3_242 | E3_243 | E3_244 | E3_245 | E3_246 | E3_247 | E3_248
|
|
| 112 | + | E3_249 | E3_250 | E3_251 | E3_252 | E3_253 | E3_254 | E3_255 | E3_256
|
|
| 113 | + deriving (Enum, Bounded, Show)
|
|
| 114 | + |
|
| 115 | +data U_Bool = U_Bool {-# UNPACK #-} !Bool
|
|
| 116 | + {-# UNPACK #-} !Bool
|
|
| 117 | + {-# UNPACK #-} !Bool
|
|
| 118 | + {-# UNPACK #-} !Bool
|
|
| 119 | + {-# UNPACK #-} !Bool
|
|
| 120 | + {-# UNPACK #-} !Bool
|
|
| 121 | + {-# UNPACK #-} !Bool
|
|
| 122 | + {-# UNPACK #-} !Bool
|
|
| 123 | + deriving (Show)
|
|
| 124 | + |
|
| 125 | +data U_E1 = U_E1 {-# UNPACK #-} !E1
|
|
| 126 | + {-# UNPACK #-} !E1
|
|
| 127 | + {-# UNPACK #-} !E1
|
|
| 128 | + {-# UNPACK #-} !E1
|
|
| 129 | + {-# UNPACK #-} !E1
|
|
| 130 | + {-# UNPACK #-} !E1
|
|
| 131 | + {-# UNPACK #-} !E1
|
|
| 132 | + {-# UNPACK #-} !E1
|
|
| 133 | + deriving (Show)
|
|
| 134 | + |
|
| 135 | +data U_E2 = U_E2 {-# UNPACK #-} !E2
|
|
| 136 | + {-# UNPACK #-} !E2
|
|
| 137 | + {-# UNPACK #-} !E2
|
|
| 138 | + {-# UNPACK #-} !E2
|
|
| 139 | + {-# UNPACK #-} !E2
|
|
| 140 | + {-# UNPACK #-} !E2
|
|
| 141 | + {-# UNPACK #-} !E2
|
|
| 142 | + {-# UNPACK #-} !E2
|
|
| 143 | + deriving (Show)
|
|
| 144 | + |
|
| 145 | +data U_E3 = U_E3 {-# UNPACK #-} !E3
|
|
| 146 | + {-# UNPACK #-} !E3
|
|
| 147 | + {-# UNPACK #-} !E3
|
|
| 148 | + {-# UNPACK #-} !E3
|
|
| 149 | + {-# UNPACK #-} !E3
|
|
| 150 | + {-# UNPACK #-} !E3
|
|
| 151 | + {-# UNPACK #-} !E3
|
|
| 152 | + {-# UNPACK #-} !E3
|
|
| 153 | + deriving (Show)
|
|
| 154 | + |
|
| 155 | +data U_Mixed = U_Mixed {-# UNPACK #-} !E1
|
|
| 156 | + {-# UNPACK #-} !E1
|
|
| 157 | + {-# UNPACK #-} !E2
|
|
| 158 | + {-# UNPACK #-} !E2
|
|
| 159 | + {-# UNPACK #-} !E3
|
|
| 160 | + {-# UNPACK #-} !E3
|
|
| 161 | + {-# UNPACK #-} !Bool
|
|
| 162 | + {-# UNPACK #-} !Bool
|
|
| 163 | + deriving (Show)
|
|
| 164 | + |
|
| 165 | +data U_Maybe = U_Maybe {-# UNPACK #-} !(Maybe Bool)
|
|
| 166 | + {-# UNPACK #-} !(Maybe Bool)
|
|
| 167 | + {-# UNPACK #-} !(Maybe Bool)
|
|
| 168 | + {-# UNPACK #-} !(Maybe Bool)
|
|
| 169 | + {-# UNPACK #-} !(Maybe Bool)
|
|
| 170 | + {-# UNPACK #-} !(Maybe Bool)
|
|
| 171 | + {-# UNPACK #-} !(Maybe Bool)
|
|
| 172 | + {-# UNPACK #-} !(Maybe Bool)
|
|
| 173 | + deriving (Show)
|
|
| 174 | + |
|
| 175 | + |
|
| 176 | +data MaybeW32 = NothingW32
|
|
| 177 | + | JustW32 {-# UNPACK #-} !Word32
|
|
| 178 | + deriving (Show)
|
|
| 179 | + |
|
| 180 | +data U_MaybeW32 = U_MaybeW32 {-# UNPACK #-} !MaybeW32
|
|
| 181 | + {-# UNPACK #-} !MaybeW32
|
|
| 182 | + {-# UNPACK #-} !MaybeW32
|
|
| 183 | + {-# UNPACK #-} !MaybeW32
|
|
| 184 | + {-# UNPACK #-} !MaybeW32
|
|
| 185 | + {-# UNPACK #-} !MaybeW32
|
|
| 186 | + {-# UNPACK #-} !MaybeW32
|
|
| 187 | + {-# UNPACK #-} !MaybeW32
|
|
| 188 | + deriving (Show)
|
|
| 189 | + |
|
| 190 | +u_ba :: U_Bool
|
|
| 191 | +u_ba = U_Bool minBound maxBound minBound maxBound
|
|
| 192 | + minBound maxBound minBound maxBound
|
|
| 193 | + |
|
| 194 | +u_e1a :: U_E1
|
|
| 195 | +u_e1a = U_E1 minBound maxBound minBound maxBound
|
|
| 196 | + minBound maxBound minBound maxBound
|
|
| 197 | + |
|
| 198 | +u_e1b :: U_E1
|
|
| 199 | +u_e1b = U_E1 maxBound minBound maxBound minBound
|
|
| 200 | + maxBound minBound maxBound minBound
|
|
| 201 | + |
|
| 202 | +u_e1c :: U_E1
|
|
| 203 | +u_e1c = U_E1 E1_1 E1_2 E1_3 E1_4
|
|
| 204 | + E1_5 E1_6 E1_7 E1_8
|
|
| 205 | + |
|
| 206 | +u_e1d :: U_E1
|
|
| 207 | +u_e1d = U_E1 E1_1 E1_16 E1_32 E1_64
|
|
| 208 | + E1_127 E1_128 E1_250 E1_254
|
|
| 209 | + |
|
| 210 | +u_e2a :: U_E2
|
|
| 211 | +u_e2a = U_E2 minBound maxBound minBound maxBound
|
|
| 212 | + minBound maxBound minBound maxBound
|
|
| 213 | + |
|
| 214 | +u_e3a :: U_E3
|
|
| 215 | +u_e3a = U_E3 minBound maxBound minBound maxBound
|
|
| 216 | + minBound maxBound minBound maxBound
|
|
| 217 | + |
|
| 218 | +u_mixed :: U_Mixed
|
|
| 219 | +u_mixed = U_Mixed maxBound minBound maxBound minBound
|
|
| 220 | + maxBound minBound maxBound minBound
|
|
| 221 | + |
|
| 222 | +u_maybe :: U_Maybe
|
|
| 223 | +u_maybe = U_Maybe Nothing (Just False) Nothing (Just True)
|
|
| 224 | + Nothing (Just False) Nothing (Just True)
|
|
| 225 | + |
|
| 226 | +u_maybeW32 :: U_MaybeW32
|
|
| 227 | +u_maybeW32 = U_MaybeW32 NothingW32 (JustW32 minBound)
|
|
| 228 | + NothingW32 (JustW32 maxBound)
|
|
| 229 | + NothingW32 (JustW32 minBound)
|
|
| 230 | + NothingW32 (JustW32 maxBound)
|
|
| 231 | + |
|
| 232 | +test :: Show a => String -> a -> IO ()
|
|
| 233 | +test name value = do
|
|
| 234 | + putStrLn $ "\n### " ++ name
|
|
| 235 | + value' <- evaluate value
|
|
| 236 | + print value'
|
|
| 237 | + putStrLn ("size: " ++ show (closureSize $ asBox value'))
|
|
| 238 | + |
|
| 239 | +main :: IO ()
|
|
| 240 | +main = do
|
|
| 241 | + test "u_ba" u_ba
|
|
| 242 | + test "u_e1a" u_e1a
|
|
| 243 | + test "u_e1b" u_e1b
|
|
| 244 | + test "u_e1c" u_e1c
|
|
| 245 | + test "u_e1d" u_e1d
|
|
| 246 | + test "u_e2a" u_e2a
|
|
| 247 | + test "u_e3a" u_e3a
|
|
| 248 | + test "u_mixed" u_mixed
|
|
| 249 | + test "u_maybe" u_maybe
|
|
| 250 | + test "u_maybeW32" u_maybeW32 |
| 1 | + |
|
| 2 | +### u_ba
|
|
| 3 | +U_Bool False True False True False True False True
|
|
| 4 | +size: 2
|
|
| 5 | + |
|
| 6 | +### u_e1a
|
|
| 7 | +U_E1 E1_1 E1_254 E1_1 E1_254 E1_1 E1_254 E1_1 E1_254
|
|
| 8 | +size: 2
|
|
| 9 | + |
|
| 10 | +### u_e1b
|
|
| 11 | +U_E1 E1_254 E1_1 E1_254 E1_1 E1_254 E1_1 E1_254 E1_1
|
|
| 12 | +size: 2
|
|
| 13 | + |
|
| 14 | +### u_e1c
|
|
| 15 | +U_E1 E1_1 E1_2 E1_3 E1_4 E1_5 E1_6 E1_7 E1_8
|
|
| 16 | +size: 2
|
|
| 17 | + |
|
| 18 | +### u_e1d
|
|
| 19 | +U_E1 E1_1 E1_16 E1_32 E1_64 E1_127 E1_128 E1_250 E1_254
|
|
| 20 | +size: 2
|
|
| 21 | + |
|
| 22 | +### u_e2a
|
|
| 23 | +U_E2 E2_1 E2_255 E2_1 E2_255 E2_1 E2_255 E2_1 E2_255
|
|
| 24 | +size: 2
|
|
| 25 | + |
|
| 26 | +### u_e3a
|
|
| 27 | +U_E3 E3_1 E3_256 E3_1 E3_256 E3_1 E3_256 E3_1 E3_256
|
|
| 28 | +size: 3
|
|
| 29 | + |
|
| 30 | +### u_mixed
|
|
| 31 | +U_Mixed E1_254 E1_1 E2_255 E2_1 E3_256 E3_1 True False
|
|
| 32 | +size: 3
|
|
| 33 | + |
|
| 34 | +### u_maybe
|
|
| 35 | +U_Maybe Nothing (Just False) Nothing (Just True) Nothing (Just False) Nothing (Just True)
|
|
| 36 | +size: 10
|
|
| 37 | + |
|
| 38 | +### u_maybeW32
|
|
| 39 | +U_MaybeW32 NothingW32 (JustW32 0) NothingW32 (JustW32 4294967295) NothingW32 (JustW32 0) NothingW32 (JustW32 4294967295)
|
|
| 40 | +size: 9 |
| 1 | + |
|
| 2 | +### u_ba
|
|
| 3 | +U_Bool False True False True False True False True
|
|
| 4 | +size: 3
|
|
| 5 | + |
|
| 6 | +### u_e1a
|
|
| 7 | +U_E1 E1_1 E1_254 E1_1 E1_254 E1_1 E1_254 E1_1 E1_254
|
|
| 8 | +size: 3
|
|
| 9 | + |
|
| 10 | +### u_e1b
|
|
| 11 | +U_E1 E1_254 E1_1 E1_254 E1_1 E1_254 E1_1 E1_254 E1_1
|
|
| 12 | +size: 3
|
|
| 13 | + |
|
| 14 | +### u_e1c
|
|
| 15 | +U_E1 E1_1 E1_2 E1_3 E1_4 E1_5 E1_6 E1_7 E1_8
|
|
| 16 | +size: 3
|
|
| 17 | + |
|
| 18 | +### u_e1d
|
|
| 19 | +U_E1 E1_1 E1_16 E1_32 E1_64 E1_127 E1_128 E1_250 E1_254
|
|
| 20 | +size: 3
|
|
| 21 | + |
|
| 22 | +### u_e2a
|
|
| 23 | +U_E2 E2_1 E2_255 E2_1 E2_255 E2_1 E2_255 E2_1 E2_255
|
|
| 24 | +size: 3
|
|
| 25 | + |
|
| 26 | +### u_e3a
|
|
| 27 | +U_E3 E3_1 E3_256 E3_1 E3_256 E3_1 E3_256 E3_1 E3_256
|
|
| 28 | +size: 5
|
|
| 29 | + |
|
| 30 | +### u_mixed
|
|
| 31 | +U_Mixed E1_254 E1_1 E2_255 E2_1 E3_256 E3_1 True False
|
|
| 32 | +size: 4
|
|
| 33 | + |
|
| 34 | +### u_maybe
|
|
| 35 | +U_Maybe Nothing (Just False) Nothing (Just True) Nothing (Just False) Nothing (Just True)
|
|
| 36 | +size: 11
|
|
| 37 | + |
|
| 38 | +### u_maybeW32
|
|
| 39 | +U_MaybeW32 NothingW32 (JustW32 0) NothingW32 (JustW32 4294967295) NothingW32 (JustW32 0) NothingW32 (JustW32 4294967295)
|
|
| 40 | +size: 17 |
| ... | ... | @@ -63,33 +63,33 @@ layout_tests = sequence_ |
| 63 | 63 | assert_layout "layout1"
|
| 64 | 64 | [ ubxtup [ intTy, intPrimTy ]
|
| 65 | 65 | , ubxtup [ intPrimTy, intTy ] ]
|
| 66 | - [ WordSlot, PtrLiftedSlot, WordSlot ]
|
|
| 66 | + [ Word8Slot, PtrLiftedSlot, WordSlot ]
|
|
| 67 | 67 | |
| 68 | 68 | layout2 =
|
| 69 | 69 | assert_layout "layout2"
|
| 70 | 70 | [ ubxtup [ intTy ]
|
| 71 | 71 | , intTy ]
|
| 72 | - [ WordSlot, PtrLiftedSlot ]
|
|
| 72 | + [ Word8Slot, PtrLiftedSlot ]
|
|
| 73 | 73 | |
| 74 | 74 | layout3 =
|
| 75 | 75 | assert_layout "layout3"
|
| 76 | 76 | [ ubxtup [ intTy, intPrimTy, intTy, intPrimTy ]
|
| 77 | 77 | , ubxtup [ intPrimTy, intTy, intPrimTy, intTy ] ]
|
| 78 | - [ WordSlot, PtrLiftedSlot, PtrLiftedSlot, WordSlot, WordSlot ]
|
|
| 78 | + [ Word8Slot, PtrLiftedSlot, PtrLiftedSlot, WordSlot, WordSlot ]
|
|
| 79 | 79 | |
| 80 | 80 | layout4 =
|
| 81 | 81 | assert_layout "layout4"
|
| 82 | 82 | [ ubxtup [ floatPrimTy, floatPrimTy ]
|
| 83 | 83 | , ubxtup [ intPrimTy, intPrimTy ] ]
|
| 84 | - [ WordSlot, WordSlot, WordSlot, FloatSlot, FloatSlot ]
|
|
| 84 | + [ Word8Slot, WordSlot, WordSlot, FloatSlot, FloatSlot ]
|
|
| 85 | 85 | |
| 86 | 86 | layout5 =
|
| 87 | 87 | assert_layout "layout5"
|
| 88 | 88 | [ ubxtup [ intPrimTy, intPrimTy ]
|
| 89 | 89 | , ubxtup [ floatPrimTy, floatPrimTy ] ]
|
| 90 | - [ WordSlot, WordSlot, WordSlot, FloatSlot, FloatSlot ]
|
|
| 90 | + [ Word8Slot, WordSlot, WordSlot, FloatSlot, FloatSlot ]
|
|
| 91 | 91 | |
| 92 | 92 | enum_layout =
|
| 93 | 93 | assert_layout "enum"
|
| 94 | 94 | (replicate 10 (ubxtup []))
|
| 95 | - [ WordSlot ] |
|
| 95 | + [ Word8Slot ] |