Rodrigo Mesquita pushed to branch wip/spj-reinstallable-base2 at Glasgow Haskell Compiler / GHC Commits: b413547b by Rodrigo Mesquita at 2026-04-30T11:23:22+01:00 runIOMain, runRW - - - - - 2d7a3edb by Rodrigo Mesquita at 2026-04-30T11:26:03+01:00 bindMName, considerAccessibleName - - - - - 5ed1b76b by Rodrigo Mesquita at 2026-04-30T11:30:19+01:00 fix: show things necessary for deriving show - - - - - 3426681d by Rodrigo Mesquita at 2026-04-30T13:33:04+01:00 WIP: unpackCString, unpackCStringUtf8 - - - - - a299f51e by Rodrigo Mesquita at 2026-04-30T13:33:09+01:00 Revert "WIP: unpackCString, unpackCStringUtf8" a bit unclear how to continue This reverts commit 3426681d949dc81ca17971fd4b3af777d47f6ced. - - - - - b2be111b by Rodrigo Mesquita at 2026-04-30T13:35:30+01:00 otherwiseIdName, assertName, dollarName - - - - - 31f947b9 by Rodrigo Mesquita at 2026-04-30T13:39:57+01:00 traceName - - - - - dbda1e30 by Rodrigo Mesquita at 2026-04-30T13:48:54+01:00 assertError - - - - - 3b9dd300 by Rodrigo Mesquita at 2026-04-30T13:53:11+01:00 trGhcPrimModule - - - - - e3056af0 by Rodrigo Mesquita at 2026-04-30T14:05:47+01:00 StablePtr tc - - - - - 10 changed files: - compiler/GHC/Builtin/KnownKeys.hs - compiler/GHC/Builtin/KnownOccs.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/Foreign/Wasm.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Module.hs - libraries/base/src/GHC/Essentials.hs - libraries/ghc-internal/src/GHC/Internal/Event/KQueue.hsc Changes: ===================================== compiler/GHC/Builtin/KnownKeys.hs ===================================== @@ -240,6 +240,9 @@ knownKeyTable -- Static pointers , (mkVarOcc "makeStatic", makeStaticKey) + -- Stable pointers + , (mkTcOcc "StablePtr", stablePtrTyConKey) + -- WithDict , (mkTcOcc "WithDict", withDictClassKey) @@ -338,37 +341,24 @@ basicKnownKeyNames -- classes in "Class.standardClassKeys" (quite a few) -- The IO type ioTyConName, ioDataConName, - runMainIOName, - runRWName, -- KindReps for common cases - trGhcPrimModuleName, starKindRepName, starArrStarKindRepName, starArrStarArrStarKindRepName, constraintKindRepName, - -- Monad stuff - bindMName, - - -- GHC Extensions - considerAccessibleName, - -- Strings and lists unpackCStringName, unpackCStringUtf8Name, -- FFI primitive types that are not wired-in. - stablePtrTyConName, ptrTyConName, funPtrTyConName, constPtrConName, + ptrTyConName, funPtrTyConName, constPtrConName, int8TyConName, int16TyConName, int32TyConName, int64TyConName, word8TyConName, word16TyConName, word32TyConName, word64TyConName, jsvalTyConName, -- Others - otherwiseIdName, - assertName, - assertErrorName, traceName, printName, - dollarName, -- Type-level naturals knownNatClassName, knownSymbolClassName, knownCharClassName, @@ -436,10 +426,6 @@ and it's convenient to write them all down in one place. wildCardName :: Name wildCardName = mkSystemVarName wildCardKey (fsLit "wild") -runMainIOName, runRWName :: Name -runMainIOName = varQual gHC_INTERNAL_TOP_HANDLER (fsLit "runMainIO") runMainKey -runRWName = varQual gHC_MAGIC (fsLit "runRW#") runRWKey - specTyConName :: Name specTyConName = tcQual gHC_TYPES (fsLit "SPEC") specTyConKey @@ -448,10 +434,6 @@ unpackCStringName, unpackCStringUtf8Name :: Name unpackCStringName = varQual gHC_CSTRING (fsLit "unpackCString#") unpackCStringIdKey unpackCStringUtf8Name = varQual gHC_CSTRING (fsLit "unpackCStringUtf8#") unpackCStringUtf8IdKey --- Class Monad -bindMName :: Name -bindMName = varQual gHC_INTERNAL_BASE (fsLit ">>=") bindMClassOpKey - -- Class MonadFail failMName :: Name failMName = varQual gHC_INTERNAL_MONAD_FAIL (fsLit "fail") failMClassOpKey @@ -469,19 +451,6 @@ pureAClassOpKey = mkPreludeMiscIdUnique 752 thenAClassOpKey = mkPreludeMiscIdUnique 753 alternativeClassKey = mkPreludeMiscIdUnique 754 - --- Functions for GHC extensions -considerAccessibleName :: Name -considerAccessibleName = varQual gHC_MAGIC (fsLit "considerAccessible") considerAccessibleIdKey - --- Random GHC.Internal.Base functions -otherwiseIdName, - assertName, - dollarName :: Name -dollarName = varQual gHC_INTERNAL_BASE (fsLit "$") dollarIdKey -otherwiseIdName = varQual gHC_INTERNAL_BASE (fsLit "otherwise") otherwiseIdKey -assertName = varQual gHC_INTERNAL_BASE (fsLit "assert") assertIdKey - bnbVarQual, bnnVarQual, bniVarQual :: String -> Unique -> Name bnbVarQual str key = varQual gHC_INTERNAL_NUM_BIGNAT (fsLit str) key bnnVarQual str key = varQual gHC_INTERNAL_NUM_NATURAL (fsLit str) key @@ -495,11 +464,10 @@ bniVarQual str key = varQual gHC_INTERNAL_NUM_INTEGER (fsLit str) key -- Class Typeable, and functions for constructing `Typeable` dictionaries -trGhcPrimModuleName, starKindRepName, starArrStarKindRepName, +starKindRepName, starArrStarKindRepName, starArrStarArrStarKindRepName, constraintKindRepName :: Name -- This is the Typeable 'Module' for GHC.Prim (which has no code, so we place in GHC.Types) -- See Note [Grand plan for Typeable] in GHC.Tc.Instance.Typeable. -trGhcPrimModuleName = varQual gHC_TYPES (fsLit "tr$ModuleGHCPrim") trGhcPrimModuleKey starKindRepName = varQual gHC_TYPES (fsLit "krep$*") starKindRepKey starArrStarKindRepName = varQual gHC_TYPES (fsLit "krep$*Arr*") starArrStarKindRepKey starArrStarArrStarKindRepName = varQual gHC_TYPES (fsLit "krep$*->*->*") starArrStarArrStarKindRepKey @@ -536,14 +504,6 @@ typeErrorShowTypeDataConName = unsafeCoercePrimName:: Name unsafeCoercePrimName = varQual gHC_INTERNAL_UNSAFE_COERCE (fsLit "unsafeCoerce#") unsafeCoercePrimIdKey --- Error module -assertErrorName :: Name -assertErrorName = varQual gHC_INTERNAL_IO_Exception (fsLit "assertError") assertErrorIdKey - --- GHC.Internal.Debug.Trace -traceName :: Name -traceName = varQual gHC_INTERNAL_DEBUG_TRACE (fsLit "trace") traceKey - genericClassKeys :: [KnownKey] genericClassKeys = [genClassKey, gen1ClassKey] @@ -580,10 +540,6 @@ ptrTyConName, funPtrTyConName :: Name ptrTyConName = tcQual gHC_INTERNAL_PTR (fsLit "Ptr") ptrTyConKey funPtrTyConName = tcQual gHC_INTERNAL_PTR (fsLit "FunPtr") funPtrTyConKey --- Foreign objects and weak pointers -stablePtrTyConName :: Name -stablePtrTyConName = tcQual gHC_INTERNAL_STABLE (fsLit "StablePtr") stablePtrTyConKey - -- Annotation type checking toAnnotationWrapperName :: Name toAnnotationWrapperName = varQual gHC_INTERNAL_DESUGAR (fsLit "toAnnotationWrapper") toAnnotationWrapperIdKey @@ -1145,12 +1101,10 @@ srcLocDataConKey :: KnownKey srcLocDataConKey = mkPreludeDataConUnique 37 trTyConDataConKey, trModuleDataConKey, - trNameSDataConKey, - trGhcPrimModuleKey :: KnownKey + trNameSDataConKey :: KnownKey trTyConDataConKey = mkPreludeDataConUnique 41 trModuleDataConKey = mkPreludeDataConUnique 43 trNameSDataConKey = mkPreludeDataConUnique 45 -trGhcPrimModuleKey = mkPreludeDataConUnique 47 typeErrorTextDataConKey, typeErrorAppendDataConKey, @@ -1337,10 +1291,9 @@ rootMainKey, runMainKey :: KnownKey rootMainKey = mkPreludeMiscIdUnique 101 runMainKey = mkPreludeMiscIdUnique 102 -thenIOIdKey, lazyIdKey, assertErrorIdKey, oneShotKey, runRWKey :: KnownKey +thenIOIdKey, lazyIdKey, oneShotKey, runRWKey :: KnownKey thenIOIdKey = mkPreludeMiscIdUnique 103 lazyIdKey = mkPreludeMiscIdUnique 104 -assertErrorIdKey = mkPreludeMiscIdUnique 105 oneShotKey = mkPreludeMiscIdUnique 106 runRWKey = mkPreludeMiscIdUnique 107 ===================================== compiler/GHC/Builtin/KnownOccs.hs ===================================== @@ -309,6 +309,15 @@ metaDataDataConOcc = mkDataOcc "MetaData" metaConsDataConOcc = mkDataOcc "MetaCons" metaSelDataConOcc = mkDataOcc "MetaSel" +runMainIOOcc :: KnownOcc +runMainIOOcc = mkVarOcc "runMainIO" + +traceIdOcc :: KnownOcc +traceIdOcc = mkVarOcc "trace" + +assertErrorIdOcc :: KnownOcc +assertErrorIdOcc = mkVarOcc "assertError" + {- ********************************************************************* * * Known-occ RdrNames ===================================== compiler/GHC/HsToCore/Foreign/C.hs ===================================== @@ -178,7 +178,7 @@ dsCFExportDynamic id co0 cconv = do -- depending on Unique. See #13807 and Note [Unique Determinism]. cback <- newSysLocalDs scaled_arg_ty newStablePtrId <- dsLookupKnownOccId newStablePtrIdOcc - stable_ptr_tycon <- dsLookupTyCon stablePtrTyConName + stable_ptr_tycon <- dsLookupKnownKeyTyCon stablePtrTyConKey let stable_ptr_ty = mkTyConApp stable_ptr_tycon [arg_ty] export_ty = mkVisFunTyMany stable_ptr_ty arg_ty ===================================== compiler/GHC/HsToCore/Foreign/JavaScript.hs ===================================== @@ -278,7 +278,7 @@ dsJsFExportDynamic id co0 cconv = do -- depending on Unique. See #13807 and Note [Unique Determinism]. cback <- newSysLocalDs scaled_arg_ty newStablePtrId <- dsLookupKnownOccId newStablePtrIdOcc - stable_ptr_tycon <- dsLookupTyCon stablePtrTyConName + stable_ptr_tycon <- dsLookupKnownKeyTyCon stablePtrTyConKey let stable_ptr_ty = mkTyConApp stable_ptr_tycon [arg_ty] export_ty = mkVisFunTyMany stable_ptr_ty arg_ty ===================================== compiler/GHC/HsToCore/Foreign/Wasm.hs ===================================== @@ -135,7 +135,7 @@ dsWasmJSDynamicExport :: CCallStaticTargetUnit -> DsM ([Binding], CHeader, CStub, [Id]) dsWasmJSDynamicExport sync fn_id co unitId = do - sp_tycon <- dsLookupTyCon stablePtrTyConName + sp_tycon <- dsLookupKnownKeyTyCon stablePtrTyConKey let ty = coercionLKind co (tv_bndrs, fun_ty) = tcSplitForAllTyVarBinders ty ([Scaled ManyTy arg_ty], io_jsval_ty) = tcSplitFunTys fun_ty ===================================== compiler/GHC/HsToCore/Monad.hs ===================================== @@ -87,6 +87,7 @@ import GHC.Iface.Load import GHC.Tc.Utils.Monad +import GHC.Builtin.KnownOccs (traceIdOcc) import GHC.Builtin.KnownKeys import GHC.Data.FastString @@ -730,7 +731,7 @@ pprRuntimeTrace :: String -- ^ header -> CoreExpr -- ^ expression -> DsM CoreExpr pprRuntimeTrace str doc expr = do - traceId <- dsLookupGlobalId traceName + traceId <- dsLookupKnownOccId traceIdOcc unpackCStringId <- dsLookupGlobalId unpackCStringName dflags <- getDynFlags let message :: CoreExpr ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -63,6 +63,7 @@ import GHC.Types.Name.Reader import GHC.Types.SrcLoc import GHC.Types.Error +import GHC.Builtin.KnownOccs import GHC.Builtin.KnownKeys import GHC.Driver.DynFlags @@ -657,7 +658,8 @@ tcInferId lname@(L loc (WithUserRdr rdr id_name)) do { dflags <- getDynFlags ; if gopt Opt_IgnoreAsserts dflags then tc_infer_id lname - else tc_infer_id (L loc $ WithUserRdr rdr assertErrorName) } + else do { assertErrorName <- idName <$> tcLookupKnownOccId assertErrorIdOcc + ; tc_infer_id (L loc $ WithUserRdr rdr assertErrorName) } } | otherwise = tc_infer_id lname ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -1948,7 +1948,7 @@ generateMainBinding tcg_env main_name = do -- See Note [Root-main Id] -- Construct the binding -- :Main.main :: IO res_ty = runMainIO res_ty main - ; run_main_id <- tcLookupId runMainIOName + ; run_main_id <- tcLookupKnownOccId runMainIOOcc ; let { root_main_name = mkExternalName rootMainKey rOOT_MAIN (mkVarOccFS (fsLit "main")) (getSrcSpan main_name) ===================================== libraries/base/src/GHC/Essentials.hs ===================================== @@ -90,6 +90,7 @@ module GHC.Essentials -- Error , error + , assertError -- Numbers , Num, Integral, Real, Floating, Fractional, RealFloat, RealFrac @@ -129,11 +130,14 @@ module GHC.Essentials , IsStatic( fromStaticPtr ), makeStatic -- Stable pointers - , newStablePtr + , StablePtr, newStablePtr -- Dynamic , toDyn + -- Run Top Handler (Note [Dealing with main]) + , runMainIO + -- Names that have BuiltinRules , CS.unpackFoldrCString#, CS.unpackFoldrCStringUtf8#, CS.unpackAppendCString# , CS.unpackAppendCStringUtf8#, CS.cstringLength# @@ -236,6 +240,7 @@ import GHC.Internal.TypeError( Unsatisfiable, unsatisfiable ) import GHC.Internal.System.IO( print ) import qualified GHC.Internal.IsList as IL import GHC.Internal.Err( error ) +import GHC.Internal.IO.Exception( assertError ) import GHC.Internal.Int( Int8(I8#), Int16(I16#), Int32(I32#), Int64(I64#) ) import GHC.Internal.Word( Word8(W8#), Word16(W16#), Word32(W32#), Word64(W64#) ) @@ -244,7 +249,7 @@ import GHC.Internal.Unsafe.Coerce( UnsafeEquality(..), unsafeEqualityProof ) import GHC.Internal.StaticPtr( IsStatic(..) ) import GHC.Internal.StaticPtr.Internal( makeStatic ) -import GHC.Internal.Stable( newStablePtr ) +import GHC.Internal.Stable( StablePtr, newStablePtr ) import GHC.Internal.Data.Typeable( gcast1, gcast2 ) import GHC.Internal.Data.Typeable.Internal as TR import GHC.Internal.Generics hiding( Fixity(..), prec ) @@ -257,3 +262,4 @@ import GHC.Internal.TH.Syntax as TH import GHC.Internal.TH.Lib import GHC.Internal.TH.Lift import GHC.Internal.TH.Monad +import GHC.Internal.TopHandler ===================================== libraries/ghc-internal/src/GHC/Internal/Event/KQueue.hsc ===================================== @@ -43,7 +43,7 @@ import GHC.Internal.Foreign.Storable (Storable(..)) import GHC.Internal.Enum (toEnum) import GHC.Internal.Num (Num(..)) import GHC.Internal.Real (quotRem, fromIntegral) -import GHC.Internal.Show (Show(show)) +import GHC.Internal.Show import GHC.Internal.Event.Internal (Timeout(..)) import GHC.Internal.System.Posix.Internals (c_close,c_getpid) import GHC.Internal.System.Posix.Types (Fd(..), CPid) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2d331e279ee02688cc5ab138ea748af... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2d331e279ee02688cc5ab138ea748af... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Rodrigo Mesquita (@alt-romes)