Rodrigo Mesquita pushed to branch wip/romes/25636 at Glasgow Haskell Compiler / GHC
Commits:
-
5aaacfeb
by Rodrigo Mesquita at 2025-12-18T18:42:33+00:00
13 changed files:
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Types/Prim.hs
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/ByteCode/Linker.hs
- compiler/GHC/Linker/Loader.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/StgToJS/Prim.hs
- libraries/ghci/GHCi/CreateBCO.hs
- libraries/ghci/GHCi/ResolvedBCO.hs
- rts/PrimOps.cmm
- rts/RtsSymbols.c
- rts/include/stg/MiscClosures.h
- utils/genprimopcode/Main.hs
Changes:
| ... | ... | @@ -2099,6 +2099,9 @@ exceptionContextTyConKey = mkPreludeTyConUnique 420 |
| 2099 | 2099 | |
| 2100 | 2100 | unsafeUnpackJSStringUtf8ShShKey = mkPreludeMiscIdUnique 805
|
| 2101 | 2101 | |
| 2102 | +staticConObjPrimTyConKey :: Unique
|
|
| 2103 | +staticConObjPrimTyConKey = mkPreludeTyConUnique 501
|
|
| 2104 | + |
|
| 2102 | 2105 | {-
|
| 2103 | 2106 | ************************************************************************
|
| 2104 | 2107 | * *
|
| ... | ... | @@ -82,6 +82,7 @@ module GHC.Builtin.Types.Prim( |
| 82 | 82 | stableNamePrimTyCon, mkStableNamePrimTy,
|
| 83 | 83 | compactPrimTyCon, compactPrimTy,
|
| 84 | 84 | bcoPrimTyCon, bcoPrimTy,
|
| 85 | + staticConObjPrimTyCon, staticConObjPrimTy,
|
|
| 85 | 86 | weakPrimTyCon, mkWeakPrimTy,
|
| 86 | 87 | threadIdPrimTyCon, threadIdPrimTy,
|
| 87 | 88 | stackSnapshotPrimTyCon, stackSnapshotPrimTy,
|
| ... | ... | @@ -309,7 +310,7 @@ charPrimTyConName, intPrimTyConName, int8PrimTyConName, int16PrimTyConName, int3 |
| 309 | 310 | mutableArrayPrimTyConName, mutableByteArrayPrimTyConName,
|
| 310 | 311 | smallMutableArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName,
|
| 311 | 312 | tVarPrimTyConName, stablePtrPrimTyConName,
|
| 312 | - stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName,
|
|
| 313 | + stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName, staticConObjPrimTyConName,
|
|
| 313 | 314 | weakPrimTyConName, threadIdPrimTyConName,
|
| 314 | 315 | eqPrimTyConName, eqReprPrimTyConName, eqPhantPrimTyConName,
|
| 315 | 316 | stackSnapshotPrimTyConName, promptTagPrimTyConName :: Name
|
| ... | ... | @@ -347,6 +348,7 @@ stableNamePrimTyConName = mkPrimTc (fsLit "StableName#") stableNamePrimTyC |
| 347 | 348 | compactPrimTyConName = mkPrimTc (fsLit "Compact#") compactPrimTyConKey compactPrimTyCon
|
| 348 | 349 | stackSnapshotPrimTyConName = mkPrimTc (fsLit "StackSnapshot#") stackSnapshotPrimTyConKey stackSnapshotPrimTyCon
|
| 349 | 350 | bcoPrimTyConName = mkPrimTc (fsLit "BCO") bcoPrimTyConKey bcoPrimTyCon
|
| 351 | +staticConObjPrimTyConName = mkPrimTc (fsLit "StaticConObj#") staticConObjPrimTyConKey staticConObjPrimTyCon
|
|
| 350 | 352 | weakPrimTyConName = mkPrimTc (fsLit "Weak#") weakPrimTyConKey weakPrimTyCon
|
| 351 | 353 | threadIdPrimTyConName = mkPrimTc (fsLit "ThreadId#") threadIdPrimTyConKey threadIdPrimTyCon
|
| 352 | 354 | promptTagPrimTyConName = mkPrimTc (fsLit "PromptTag#") promptTagPrimTyConKey promptTagPrimTyCon
|
| ... | ... | @@ -1399,6 +1401,12 @@ bcoPrimTy = mkTyConTy bcoPrimTyCon |
| 1399 | 1401 | bcoPrimTyCon :: TyCon
|
| 1400 | 1402 | bcoPrimTyCon = pcPrimTyCon0 bcoPrimTyConName liftedRepTy
|
| 1401 | 1403 | |
| 1404 | +-- A static constructor object is never a thunk, unlike BCOs
|
|
| 1405 | +staticConObjPrimTy :: Type
|
|
| 1406 | +staticConObjPrimTy = mkTyConTy staticConObjPrimTyCon
|
|
| 1407 | +staticConObjPrimTyCon :: TyCon
|
|
| 1408 | +staticConObjPrimTyCon = pcPrimTyCon0 staticConObjPrimTyConName unliftedRepTy
|
|
| 1409 | + |
|
| 1402 | 1410 | {-
|
| 1403 | 1411 | ************************************************************************
|
| 1404 | 1412 | * *
|
| ... | ... | @@ -3909,6 +3909,9 @@ section "Bytecode operations" |
| 3909 | 3909 | primtype BCO
|
| 3910 | 3910 | { Primitive bytecode type. }
|
| 3911 | 3911 | |
| 3912 | +primtype StaticConObj#
|
|
| 3913 | + { Primitive static constructor allocated on the heap type. }
|
|
| 3914 | + |
|
| 3912 | 3915 | primop AddrToAnyOp "addrToAny#" GenPrimOp
|
| 3913 | 3916 | Addr# -> (# a_levpoly #)
|
| 3914 | 3917 | { Convert an 'Addr#' to a followable Any type. }
|
| ... | ... | @@ -3947,6 +3950,17 @@ primop NewBCOOp "newBCO#" GenPrimOp |
| 3947 | 3950 | effect = ReadWriteEffect
|
| 3948 | 3951 | out_of_line = True
|
| 3949 | 3952 | |
| 3953 | +primop NewStaticConOp "newStaticCon#" GenPrimOp
|
|
| 3954 | + Array# a -> Int# -> State# s -> (# State# s, StaticConObj# #)
|
|
| 3955 | + { @'newStaticCon#' data size@ creates a new static constructor object. The
|
|
| 3956 | + resulting object points to the given data laid out contiguously on a heap allocated location.
|
|
| 3957 | + The first element of the @data@ array must be a pointer to the info table representing the
|
|
| 3958 | + constructor, which will be followed by the rest of the data. The given
|
|
| 3959 | + @size@ describes how many words should be allocated for the data. }
|
|
| 3960 | + with
|
|
| 3961 | + effect = ReadWriteEffect
|
|
| 3962 | + out_of_line = True
|
|
| 3963 | + |
|
| 3950 | 3964 | primop UnpackClosureOp "unpackClosure#" GenPrimOp
|
| 3951 | 3965 | a -> (# Addr#, ByteArray#, Array# b #)
|
| 3952 | 3966 | { @'unpackClosure#' closure@ copies the closure and pointers in the
|
| ... | ... | @@ -50,16 +50,17 @@ import Data.Array.Unboxed |
| 50 | 50 | import Foreign.Ptr
|
| 51 | 51 | import GHC.Exts
|
| 52 | 52 | |
| 53 | -{-
|
|
| 53 | +{- |
|
|
| 54 | 54 | Linking interpretables into something we can run
|
| 55 | 55 | -}
|
| 56 | - |
|
| 57 | 56 | linkBCO
|
| 58 | 57 | :: Interp
|
| 59 | 58 | -> PkgsLoaded
|
| 60 | 59 | -> LinkerEnv
|
| 61 | 60 | -> LinkedBreaks
|
| 62 | - -> NameEnv Int
|
|
| 61 | + -> NameEnv (Int, Bool)
|
|
| 62 | + -- ^ A mapping from names to int references to other BCOs or Static Constructors in this group.
|
|
| 63 | + -- The boolean identifies whether the referenced object is a BCO (when @True@) or a Static Constructor (when @False@)
|
|
| 63 | 64 | -> UnlinkedBCO
|
| 64 | 65 | -> IO ResolvedBCO
|
| 65 | 66 | linkBCO interp pkgs_loaded le lb bco_ix
|
| ... | ... | @@ -80,7 +81,7 @@ linkBCO interp pkgs_loaded le lb bco_ix |
| 80 | 81 | (UnlinkedStaticCon conName conArgs) = do
|
| 81 | 82 | all_data <- mapM (either doBCOPtr doBCONPtr) (Right (BCONPtrItbl conName):elemsFlatBag conArgs)
|
| 82 | 83 | return ResolvedStaticCon
|
| 83 | - { resolvedStaticConIsLE = isLittleEndian
|
|
| 84 | + { resolvedBCOIsLE = isLittleEndian
|
|
| 84 | 85 | , resolvedStaticConData = addListToSS emptySS all_data
|
| 85 | 86 | }
|
| 86 | 87 | where
|
| ... | ... | @@ -170,13 +171,16 @@ resolvePtr |
| 170 | 171 | -> PkgsLoaded
|
| 171 | 172 | -> LinkerEnv
|
| 172 | 173 | -> LinkedBreaks
|
| 173 | - -> NameEnv Int
|
|
| 174 | + -> NameEnv (Int, Bool)
|
|
| 174 | 175 | -> BCOPtr
|
| 175 | 176 | -> IO ResolvedBCOPtr
|
| 176 | 177 | resolvePtr interp pkgs_loaded le lb bco_ix ptr = case ptr of
|
| 177 | 178 | BCOPtrName nm
|
| 178 | - | Just ix <- lookupNameEnv bco_ix nm
|
|
| 179 | - -> return (ResolvedBCORef ix) -- ref to another BCO in this group
|
|
| 179 | + | Just (ix, b) <- lookupNameEnv bco_ix nm
|
|
| 180 | + -> if b then
|
|
| 181 | + return (ResolvedBCORef ix) -- ref to another BCO in this group
|
|
| 182 | + else
|
|
| 183 | + return (ResolvedStaticConRef ix) -- ref to another StaticCon in this group
|
|
| 180 | 184 | |
| 181 | 185 | | Just (_, rhv) <- lookupNameEnv (closure_env le) nm
|
| 182 | 186 | -> return (ResolvedBCOPtr (unsafeForeignRefToRemoteRef rhv))
|
| ... | ... | @@ -1025,11 +1025,13 @@ linkSomeBCOs interp pkgs_loaded le lb mods = foldr fun do_link mods [] |
| 1025 | 1025 | do_link [] = return []
|
| 1026 | 1026 | do_link mods = do
|
| 1027 | 1027 | let flat = [ bco | bcos <- mods, bco <- bcos ]
|
| 1028 | - names = map unlinkedBCOName flat
|
|
| 1029 | - bco_ix = mkNameEnv (zip names [0..])
|
|
| 1028 | + names = map (\case UnlinkedBCO{unlinkedBCOName} -> (unlinkedBCOName, True)
|
|
| 1029 | + UnlinkedStaticCon{unlinkedStaticConName} -> (unlinkedStaticConName, False)
|
|
| 1030 | + ) flat
|
|
| 1031 | + bco_ix = mkNameEnv (zipWith (\(n,isBCO) ix -> (n,(ix, isBCO))) names [0..])
|
|
| 1030 | 1032 | resolved <- sequence [ linkBCO interp pkgs_loaded le lb bco_ix bco | bco <- flat ]
|
| 1031 | 1033 | hvrefs <- createBCOs interp resolved
|
| 1032 | - return (zip names hvrefs)
|
|
| 1034 | + return (zipWith (\(n,_) hvr -> (n, hvr)) names hvrefs)
|
|
| 1033 | 1035 | |
| 1034 | 1036 | -- | Useful to apply to the result of 'linkSomeBCOs'
|
| 1035 | 1037 | makeForeignNamedHValueRefs
|
| ... | ... | @@ -1772,6 +1772,7 @@ emitPrimOp cfg primop = |
| 1772 | 1772 | DataToTagLargeOp -> alwaysExternal
|
| 1773 | 1773 | MkApUpd0_Op -> alwaysExternal
|
| 1774 | 1774 | NewBCOOp -> alwaysExternal
|
| 1775 | + NewStaticConOp -> alwaysExternal
|
|
| 1775 | 1776 | UnpackClosureOp -> alwaysExternal
|
| 1776 | 1777 | ListThreadsOp -> alwaysExternal
|
| 1777 | 1778 | ClosureSizeOp -> alwaysExternal
|
| ... | ... | @@ -1165,6 +1165,7 @@ genPrim prof bound ty op = case op of |
| 1165 | 1165 | AnyToAddrOp -> unhandledPrimop op
|
| 1166 | 1166 | MkApUpd0_Op -> unhandledPrimop op
|
| 1167 | 1167 | NewBCOOp -> unhandledPrimop op
|
| 1168 | + NewStaticConOp -> unhandledPrimop op
|
|
| 1168 | 1169 | UnpackClosureOp -> unhandledPrimop op
|
| 1169 | 1170 | ClosureSizeOp -> unhandledPrimop op
|
| 1170 | 1171 | GetApStackValOp -> unhandledPrimop op
|
| ... | ... | @@ -6,6 +6,8 @@ |
| 6 | 6 | {-# LANGUAGE UnboxedTuples #-}
|
| 7 | 7 | {-# LANGUAGE RecordWildCards #-}
|
| 8 | 8 | {-# LANGUAGE CPP #-}
|
| 9 | +{-# LANGUAGE LambdaCase #-}
|
|
| 10 | +{-# LANGUAGE KindSignatures #-}
|
|
| 9 | 11 | |
| 10 | 12 | --
|
| 11 | 13 | -- (c) The University of Glasgow 2002-2006
|
| ... | ... | @@ -30,6 +32,7 @@ import GHC.Exts hiding ( BCO, mkApUpd0#, newBCO# ) |
| 30 | 32 | import GHC.Internal.Base ( BCO, mkApUpd0#, newBCO# )
|
| 31 | 33 | import GHC.IO
|
| 32 | 34 | import Control.Exception ( ErrorCall(..) )
|
| 35 | +import Data.Kind
|
|
| 33 | 36 | |
| 34 | 37 | createBCOs :: [ResolvedBCO] -> IO [HValueRef]
|
| 35 | 38 | createBCOs bcos = do
|
| ... | ... | @@ -40,36 +43,39 @@ createBCOs bcos = do |
| 40 | 43 | mapM mkRemoteRef hvals
|
| 41 | 44 | |
| 42 | 45 | createBCO :: Array Int HValue -> ResolvedBCO -> IO HValue
|
| 43 | -createBCO _ ResolvedBCO{..} | resolvedBCOIsLE /= isLittleEndian
|
|
| 46 | +createBCO _ obj | resolvedBCOIsLE obj /= isLittleEndian
|
|
| 44 | 47 | = throwIO (ErrorCall $
|
| 45 | 48 | unlines [ "The endianness of the ResolvedBCO does not match"
|
| 46 | 49 | , "the systems endianness. Using ghc and iserv in a"
|
| 47 | 50 | , "mixed endianness setup is not supported!"
|
| 48 | 51 | ])
|
| 49 | 52 | createBCO arr bco
|
| 50 | - = do linked_bco <- linkBCO' arr bco
|
|
| 51 | - -- Note [Updatable CAF BCOs]
|
|
| 52 | - -- ~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
| 53 | - -- Why do we need mkApUpd0 here? Otherwise top-level
|
|
| 54 | - -- interpreted CAFs don't get updated after evaluation. A
|
|
| 55 | - -- top-level BCO will evaluate itself and return its value
|
|
| 56 | - -- when entered, but it won't update itself. Wrapping the BCO
|
|
| 57 | - -- in an AP_UPD thunk will take care of the update for us.
|
|
| 58 | - --
|
|
| 59 | - -- Furthermore:
|
|
| 60 | - -- (a) An AP thunk *must* point directly to a BCO
|
|
| 61 | - -- (b) A zero-arity BCO *must* be wrapped in an AP thunk
|
|
| 62 | - -- (c) An AP is always fully saturated, so we *can't* wrap
|
|
| 63 | - -- non-zero arity BCOs in an AP thunk.
|
|
| 64 | - --
|
|
| 65 | - -- See #17424.
|
|
| 66 | - if (resolvedBCOArity bco > 0)
|
|
| 67 | - then return (HValue (unsafeCoerce linked_bco))
|
|
| 68 | - else case mkApUpd0# linked_bco of { (# final_bco #) ->
|
|
| 69 | - return (HValue final_bco) }
|
|
| 70 | - |
|
| 71 | - |
|
| 72 | -linkBCO' :: Array Int HValue -> ResolvedBCO -> IO BCO
|
|
| 53 | + = do linked_thing <- linkBCO' arr bco
|
|
| 54 | + case linked_thing of
|
|
| 55 | + LeftL linked_bco -> do
|
|
| 56 | + -- Note [Updatable CAF BCOs]
|
|
| 57 | + -- ~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
| 58 | + -- Why do we need mkApUpd0 here? Otherwise top-level
|
|
| 59 | + -- interpreted CAFs don't get updated after evaluation. A
|
|
| 60 | + -- top-level BCO will evaluate itself and return its value
|
|
| 61 | + -- when entered, but it won't update itself. Wrapping the BCO
|
|
| 62 | + -- in an AP_UPD thunk will take care of the update for us.
|
|
| 63 | + --
|
|
| 64 | + -- Furthermore:
|
|
| 65 | + -- (a) An AP thunk *must* point directly to a BCO
|
|
| 66 | + -- (b) A zero-arity BCO *must* be wrapped in an AP thunk
|
|
| 67 | + -- (c) An AP is always fully saturated, so we *can't* wrap
|
|
| 68 | + -- non-zero arity BCOs in an AP thunk.
|
|
| 69 | + --
|
|
| 70 | + -- See #17424.
|
|
| 71 | + if (resolvedBCOArity bco > 0)
|
|
| 72 | + then return (HValue (unsafeCoerce linked_bco))
|
|
| 73 | + else case mkApUpd0# linked_bco of { (# final_bco #) ->
|
|
| 74 | + return (HValue final_bco) }
|
|
| 75 | + RightU linked_static_con -> do
|
|
| 76 | + return (HValue (unsafeCoerce linked_static_con))
|
|
| 77 | + |
|
| 78 | +linkBCO' :: Array Int HValue -> ResolvedBCO -> IO (EitherLU BCO StaticConObj#)
|
|
| 73 | 79 | linkBCO' arr ResolvedBCO{..} = do
|
| 74 | 80 | let
|
| 75 | 81 | ptrs = ssElts resolvedBCOPtrs
|
| ... | ... | @@ -83,21 +89,59 @@ linkBCO' arr ResolvedBCO{..} = do |
| 83 | 89 | bitmap_barr = barr (getBCOByteArray resolvedBCOBitmap)
|
| 84 | 90 | literals_barr = barr (getBCOByteArray resolvedBCOLits)
|
| 85 | 91 | |
| 86 | - PtrsArr marr <- mkPtrsArray arr n_ptrs ptrs
|
|
| 92 | + PtrsArr marr <- mkPtrsArray arr n_ptrs (zip ptrs [0..])
|
|
| 87 | 93 | IO $ \s ->
|
| 88 | 94 | case unsafeFreezeArray# marr s of { (# s, arr #) ->
|
| 89 | 95 | case newBCO insns_barr literals_barr arr arity# bitmap_barr of { IO io ->
|
| 90 | 96 | io s
|
| 91 | 97 | }}
|
| 98 | +linkBCO' arr ResolvedStaticCon{..} = do
|
|
| 99 | + |
|
| 100 | + let data_size@(I# data_size#)
|
|
| 101 | + = sizeSS resolvedStaticConData
|
|
| 102 | + data_els = ssElts resolvedStaticConData
|
|
| 103 | + |
|
| 104 | + -- First, write pointers at the ptrs locations
|
|
| 105 | + PtrsArr marr <- mkPtrsArray arr data_size $
|
|
| 106 | + mapMaybe (\case
|
|
| 107 | + (Left _,_) -> Nothing
|
|
| 108 | + (Right p,_) -> Just p
|
|
| 109 | + ) (zip data_els [0..])
|
|
| 110 | + -- Second, write literals at the remaining location
|
|
| 111 | + writeLiterals marr $
|
|
| 112 | + mapMaybe (\case
|
|
| 113 | + (Left l,_) -> Just l
|
|
| 114 | + (Right _,_) -> Nothing
|
|
| 115 | + ) (zip data_els [0..])
|
|
| 92 | 116 | |
| 117 | + IO $ \s ->
|
|
| 118 | + case unsafeFreezeArray# marr' s of { (# s, arr #) ->
|
|
| 119 | + newStaticCon# arr data_size# s
|
|
| 120 | + }
|
|
| 121 | + where
|
|
| 122 | + writeLiterals :: MutableArray# RealWorld Word -> [(Word, Int)] -> IO ()
|
|
| 123 | + writeLiterals arr = mapM_ (uncurry (writeLiteral arr))
|
|
| 124 | + |
|
| 125 | + writeLiteral :: MutableArray# RealWorld Word -> Word -> Int -> IO ()
|
|
| 126 | + writeLiteral arr w i = IO $ \s ->
|
|
| 127 | + case writeArray# arr i w s of s' -> (# s', () #)
|
|
| 128 | + |
|
| 129 | +-- | Either for lifted @a@ and unlifted @b@
|
|
| 130 | +data EitherLU (a :: Type) (b :: UnliftedType) = LeftL a | RightU b
|
|
| 93 | 131 | |
| 94 | 132 | -- we recursively link any sub-BCOs while making the ptrs array
|
| 95 | -mkPtrsArray :: Array Int HValue -> Word -> [ResolvedBCOPtr] -> IO PtrsArr
|
|
| 133 | +mkPtrsArray :: Array Int HValue -> Word -> [(ResolvedBCOPtr, Int{-index of array at which to write ResolvedBCOPtr-})] -> IO PtrsArr
|
|
| 96 | 134 | mkPtrsArray arr n_ptrs ptrs = do
|
| 97 | 135 | marr <- newPtrsArray (fromIntegral n_ptrs)
|
| 98 | 136 | let
|
| 99 | 137 | fill (ResolvedBCORef n) i =
|
| 100 | 138 | writePtrsArrayHValue i (arr ! n) marr -- must be lazy!
|
| 139 | + fill (ResolvedStaticConRef n) i = do
|
|
| 140 | + -- this MUST be /strict/!
|
|
| 141 | + -- the static con reference must be an evaluated pointer to the data con
|
|
| 142 | + -- info table, but (arr ! n) would construct a thunk instead if unforced.
|
|
| 143 | + let !hv = arr ! n
|
|
| 144 | + writePtrsArrayHValue i hv marr
|
|
| 101 | 145 | fill (ResolvedBCOPtr r) i = do
|
| 102 | 146 | hv <- localRef r
|
| 103 | 147 | writePtrsArrayHValue i hv marr
|
| ... | ... | @@ -109,7 +153,7 @@ mkPtrsArray arr n_ptrs ptrs = do |
| 109 | 153 | fill (ResolvedBCOPtrBreakArray r) i = do
|
| 110 | 154 | BA mba <- localRef r
|
| 111 | 155 | writePtrsArrayMBA i mba marr
|
| 112 | - zipWithM_ fill ptrs [0..]
|
|
| 156 | + mapM_ fill ptrs
|
|
| 113 | 157 | return marr
|
| 114 | 158 | |
| 115 | 159 | data PtrsArr = PtrsArr (MutableArray# RealWorld HValue)
|
| ... | ... | @@ -165,3 +209,5 @@ emptyArr = unsafeDupablePerformIO $ IO $ \s -> |
| 165 | 209 | case unsafeFreezeByteArray# arr s of { (# s, farr #) ->
|
| 166 | 210 | (# s, EmptyArr farr #)
|
| 167 | 211 | }}
|
| 212 | + |
|
| 213 | + |
| ... | ... | @@ -50,7 +50,7 @@ data ResolvedBCO |
| 50 | 50 | -- | A resolved static constructor
|
| 51 | 51 | -- See Note [Static constructors in Bytecode]
|
| 52 | 52 | | ResolvedStaticCon {
|
| 53 | - resolvedStaticConIsLE :: Bool,
|
|
| 53 | + resolvedBCOIsLE :: Bool,
|
|
| 54 | 54 | resolvedStaticConData :: SizedSeq (Either ResolvedBCOPtr Word)
|
| 55 | 55 | -- ^ All the data to be laid contiguously for this static datacon.
|
| 56 | 56 | -- The first entry is the info table pointer for the datacon it represents.
|
| ... | ... | @@ -97,7 +97,7 @@ instance Binary ResolvedBCO where |
| 97 | 97 | put resolvedBCOPtrs
|
| 98 | 98 | put ResolvedStaticCon{..} = do
|
| 99 | 99 | putWord8 1
|
| 100 | - put resolvedStaticConIsLE
|
|
| 100 | + put resolvedBCOIsLE
|
|
| 101 | 101 | put resolvedStaticConData
|
| 102 | 102 | get = do
|
| 103 | 103 | t <- getWord8
|
| ... | ... | @@ -123,6 +123,8 @@ data ResolvedBCOPtr |
| 123 | 123 | -- ^ a nested BCO
|
| 124 | 124 | | ResolvedBCOPtrBreakArray {-# UNPACK #-} !(RemoteRef BreakArray)
|
| 125 | 125 | -- ^ Resolves to the MutableArray# inside the BreakArray
|
| 126 | + | ResolvedStaticConRef {-# UNPACK #-} !Int
|
|
| 127 | + -- ^ reference to the Nth static constructor in the current set
|
|
| 126 | 128 | deriving (Generic, Show)
|
| 127 | 129 | |
| 128 | 130 | instance Binary ResolvedBCOPtr
|
| ... | ... | @@ -2181,6 +2181,21 @@ for: |
| 2181 | 2181 | return (bco);
|
| 2182 | 2182 | }
|
| 2183 | 2183 | |
| 2184 | +stg_newStaticConzh ( P_ data, W_ size )
|
|
| 2185 | +{
|
|
| 2186 | + W_ staticConObj, itbl, bytes;
|
|
| 2187 | + |
|
| 2188 | + bytes = WDS(size);
|
|
| 2189 | + |
|
| 2190 | + ALLOC_PRIM (bytes);
|
|
| 2191 | + |
|
| 2192 | + staticConObj = Hp - bytes;
|
|
| 2193 | + // No memory barrier necessary as this is a new allocation.
|
|
| 2194 | + SET_HDR(staticConObj, stg_BCO_info, CCS_MAIN);
|
|
| 2195 | + |
|
| 2196 | + TODOOOOOOO
|
|
| 2197 | +}
|
|
| 2198 | + |
|
| 2184 | 2199 | stg_mkApUpd0zh ( P_ bco )
|
| 2185 | 2200 | {
|
| 2186 | 2201 | W_ ap;
|
| ... | ... | @@ -634,6 +634,7 @@ extern char **environ; |
| 634 | 634 | SymI_HasDataProto(stg_casSmallArrayzh) \
|
| 635 | 635 | SymI_HasDataProto(stg_copyArray_barrier) \
|
| 636 | 636 | SymI_HasDataProto(stg_newBCOzh) \
|
| 637 | + SymI_HasDataProto(stg_newStaticConzh) \
|
|
| 637 | 638 | SymI_HasDataProto(stg_newByteArrayzh) \
|
| 638 | 639 | SymI_HasDataProto(stg_casIntArrayzh) \
|
| 639 | 640 | SymI_HasDataProto(stg_casInt8Arrayzh) \
|
| ... | ... | @@ -583,6 +583,7 @@ RTS_FUN_DECL(stg_deRefWeakzh); |
| 583 | 583 | RTS_FUN_DECL(stg_runRWzh);
|
| 584 | 584 | |
| 585 | 585 | RTS_FUN_DECL(stg_newBCOzh);
|
| 586 | +RTS_FUN_DECL(stg_newStaticConzh);
|
|
| 586 | 587 | RTS_FUN_DECL(stg_mkApUpd0zh);
|
| 587 | 588 | |
| 588 | 589 | RTS_FUN_DECL(stg_retryzh);
|
| ... | ... | @@ -944,6 +944,7 @@ ppType (TyApp (TyCon "RealWorld") []) = "realWorldTy" |
| 944 | 944 | ppType (TyApp (TyCon "ThreadId#") []) = "threadIdPrimTy"
|
| 945 | 945 | ppType (TyApp (TyCon "ForeignObj#") []) = "foreignObjPrimTy"
|
| 946 | 946 | ppType (TyApp (TyCon "BCO") []) = "bcoPrimTy"
|
| 947 | +ppType (TyApp (TyCon "StaticConObj#") []) = "staticConObjPrimTy"
|
|
| 947 | 948 | ppType (TyApp (TyCon "Compact#") []) = "compactPrimTy"
|
| 948 | 949 | ppType (TyApp (TyCon "StackSnapshot#") []) = "stackSnapshotPrimTy"
|
| 949 | 950 | ppType (TyApp (TyCon "()") []) = "unitTy" -- unitTy is GHC.Builtin.Types's name for ()
|