[Git][ghc/ghc][wip/osa1/lfinfo] Documentation and assertions

Ömer Sinan Ağacan gitlab at gitlab.haskell.org
Wed Apr 29 09:19:40 UTC 2020



Ömer Sinan Ağacan pushed to branch wip/osa1/lfinfo at Glasgow Haskell Compiler / GHC


Commits:
c9d923b1 by Ömer Sinan Ağacan at 2020-04-29T12:19:31+03:00
Documentation and assertions

- - - - -


5 changed files:

- compiler/GHC/CoreToIface.hs
- compiler/GHC/Iface/Make.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/UpdateIdInfos.hs
- compiler/GHC/IfaceToCore.hs


Changes:

=====================================
compiler/GHC/CoreToIface.hs
=====================================
@@ -623,7 +623,10 @@ toIfaceVar v
 ---------------------
 toIfaceLFInfo :: LambdaFormInfo -> IfaceLFInfo
 toIfaceLFInfo lfi = case lfi of
-    LFReEntrant _ _ arity _ _ ->
+    LFReEntrant top_lvl one_shot arity no_fvs _arg_descr ->
+      ASSERT(isTopLevel top_lvl)
+      ASSERT(one_shot == NoOneShotInfo)
+      ASSERT(no_fvs)
       IfLFReEntrant arity
     LFThunk _ _ updatable sfi mb_fun ->
       IfLFThunk updatable (toIfaceStandardFormInfo sfi) mb_fun


=====================================
compiler/GHC/Iface/Make.hs
=====================================
@@ -99,8 +99,11 @@ mkPartialIface hsc_env mod_details
   = mkIface_ hsc_env this_mod hsc_src used_th deps rdr_env fix_env warns hpc_info self_trust
              safe_mode usages doc_hdr decl_docs arg_docs mod_details
 
--- | Fully instantiate a interface
--- Adds fingerprints and potentially code generator produced information.
+-- | Fully instantiate an interface. Adds fingerprints and potentially code
+-- generator produced information.
+--
+-- CgInfos is not available when not generating code (-fno-code), or when not
+-- generating interface pragmas (-fomit-interface-pragmas).
 mkFullIface :: HscEnv -> PartialModIface -> Maybe CgInfos -> IO ModIface
 mkFullIface hsc_env partial_iface mb_cg_infos = do
     let decls
@@ -131,7 +134,7 @@ updateDecl decls (Just CgInfos{ cgNonCafs = non_cafs, cgLFInfos = lf_infos }) =
       = IfaceId nm ty details $
           (if not_caffy then (HsNoCafRefs :) else id)
           (case mb_lf_info of
-             Nothing -> infos
+             Nothing -> infos -- LFInfos not available when building .cmm files
              Just lf_info -> HsLFInfo (toIfaceLFInfo lf_info) : infos)
 
     update_decl decl


=====================================
compiler/GHC/Iface/Syntax.hs
=====================================
@@ -391,7 +391,10 @@ data IfaceIdDetails
 -- omitted in this type.
 data IfaceLFInfo
   = IfLFReEntrant !RepArity
-  | IfLFThunk !Bool !IfaceStandardFormInfo !Bool
+  | IfLFThunk
+      !Bool -- True <=> updatable
+      !IfaceStandardFormInfo
+      !Bool -- True <=> might be a function type
   | IfLFCon !Name
   | IfLFUnknown !Bool
   | IfLFUnlifted


=====================================
compiler/GHC/Iface/UpdateIdInfos.hs
=====================================
@@ -40,7 +40,7 @@ updateModDetailsIdInfos _ cg_infos mod_details =
               } = mod_details
 
     -- type TypeEnv = NameEnv TyThing
-    ~type_env' = mapNameEnv (updateTyThingCafInfos type_env' cg_infos) type_env
+    ~type_env' = mapNameEnv (updateTyThingIdInfos type_env' cg_infos) type_env
     -- Not strict!
 
     !insts' = strictMap (updateInstIdInfos type_env' cg_infos) insts
@@ -71,12 +71,12 @@ updateInstIdInfos type_env cg_infos =
 -- TyThings
 --------------------------------------------------------------------------------
 
-updateTyThingCafInfos :: TypeEnv -> CgInfos -> TyThing -> TyThing
+updateTyThingIdInfos :: TypeEnv -> CgInfos -> TyThing -> TyThing
 
-updateTyThingCafInfos type_env cg_infos (AnId id) =
+updateTyThingIdInfos type_env cg_infos (AnId id) =
     AnId (updateIdUnfolding type_env (updateIdInfo cg_infos id))
 
-updateTyThingCafInfos _ _ other = other -- AConLike, ATyCon, ACoAxiom
+updateTyThingIdInfos _ _ other = other -- AConLike, ATyCon, ACoAxiom
 
 --------------------------------------------------------------------------------
 -- Unfoldings


=====================================
compiler/GHC/IfaceToCore.hs
=====================================
@@ -1504,6 +1504,18 @@ tcJoinInfo IfaceNotJoinPoint   = Nothing
 tcLFInfo :: IfaceLFInfo -> IfL LambdaFormInfo
 tcLFInfo lfi = case lfi of
     IfLFReEntrant rep_arity ->
+      -- LFReEntrant closures in interface files are guaranteed to
+      --
+      -- - Be top-level, as only top-level closures are exported.
+      -- - Be not one-shot, as top-level closures are never one-shot
+      -- - Have no free variables, as only non-top-level closures have free
+      --   variables
+      -- - Don't have ArgDescrs, as ArgDescr is used when generating code for
+      --   the closure
+      --
+      -- These invariants are checked when generating the iface LFInfos in
+      -- toIfaceLFInfo in CoreToIface.
+      --
       return (LFReEntrant TopLevel NoOneShotInfo rep_arity True ArgUnknown)
 
     IfLFThunk updatable sfi mb_fun ->



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9d923b1597486f87d379c7a4c8b1b8da12c84bd

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9d923b1597486f87d379c7a4c8b1b8da12c84bd
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200429/2d2bb047/attachment-0001.html>


More information about the ghc-commits mailing list