David Eichmann pushed to branch wip/davide/windows-dlls at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/Cmm/Info/Build.hs
    ... ... @@ -1295,15 +1295,17 @@ updInfoSRTs profile srt_env funSRTEnv caffy (CmmProc top_info top_l live g)
    1295 1295
           | l == g_entry g, Just (inf, _) <- maybeStaticClosure = inf
    
    1296 1296
           | otherwise  = info_tbl { cit_srt = mapLookup l srt_env }
    
    1297 1297
     
    
    1298
    -    -- Generate static closures [FUN].  Note that this also generates
    
    1299
    -    -- static closures for thunks (CAFs), because it's easier to treat
    
    1300
    -    -- them uniformly in the code generator.
    
    1298
    +    -- Generate static closures [FUN].  CAF thunks are excluded: they are
    
    1299
    +    -- treated as dynamic closures and have their closure data emitted in
    
    1300
    +    -- GHC.StgToCmm.Bind.cgTopRhsClosure; the cit_clo guard below is
    
    1301
    +    -- sufficient to rule them out since dynamic thunks have cit_clo=Nothing.
    
    1301 1302
         maybeStaticClosure :: Maybe (CmmInfoTable, CmmDeclSRTs)
    
    1302 1303
         maybeStaticClosure
    
    1303 1304
           | Just info_tbl@CmmInfoTable{..} <-
    
    1304 1305
                mapLookup (g_entry g) (info_tbls top_info)
    
    1305 1306
           , Just (id, ccs) <- cit_clo
    
    1306
    -      , isStaticRep cit_rep =
    
    1307
    +      , isStaticRep cit_rep
    
    1308
    +      , not (isThunkRep cit_rep) =
    
    1307 1309
             let
    
    1308 1310
               (newInfo, srtEntries) = case mapLookup (g_entry g) funSRTEnv of
    
    1309 1311
                 Nothing ->
    

  • compiler/GHC/StgToCmm/Bind.hs
    ... ... @@ -129,17 +129,24 @@ cgTopRhsClosure platform rec id ccs upd_flag args body =
    129 129
              emitDecl $ CmmData (Section Data closure_label) $
    
    130 130
                  CmmStatics closure_label info ccs [] [lit]
    
    131 131
     
    
    132
    -  gen_code lf_info _closure_label
    
    132
    +  gen_code lf_info closure_label
    
    133 133
        = do { profile <- getProfile
    
    134 134
             ; let name = idName id
    
    135 135
             ; mod_name <- getModuleName
    
    136 136
             ; let descr         = closureDescription mod_name name
    
    137
    -              closure_info  = mkClosureInfo profile True id lf_info 0 0 descr
    
    138
    -
    
    139
    -        -- We don't generate the static closure here, because we might
    
    140
    -        -- want to add references to static closures to it later.  The
    
    141
    -        -- static closure is generated by GHC.Cmm.Info.Build.updInfoSRTs,
    
    142
    -        -- See Note [SRTs], specifically the [FUN] optimisation.
    
    137
    +              -- CAFs (top-level updatable thunks with no arguments) are treated
    
    138
    +              -- as dynamic closures: they use heap-style thunk update semantics
    
    139
    +              -- and do not call newCAF/link_caf.
    
    140
    +              is_caf        = isLFThunk lf_info && lfUpdatable lf_info
    
    141
    +              closure_info  = mkClosureInfo profile (not is_caf) id lf_info 0 0 descr
    
    142
    +
    
    143
    +        -- We don't generate the static closure here for non-CAF top-level
    
    144
    +        -- closures, because we might want to add references to static closures
    
    145
    +        -- to it later.  The static closure is generated by
    
    146
    +        -- GHC.Cmm.Info.Build.updInfoSRTs, See Note [SRTs], specifically the
    
    147
    +        -- [FUN] optimisation.
    
    148
    +        -- For CAFs we generate the closure data immediately: they are dynamic
    
    149
    +        -- (heap-style thunks) so maybeStaticClosure will not pick them up.
    
    143 150
     
    
    144 151
             ; let fv_details :: [(NonVoid Id, ByteOff)]
    
    145 152
                   header = if isLFThunk lf_info then ThunkHeader else StdHeader
    
    ... ... @@ -148,6 +155,10 @@ cgTopRhsClosure platform rec id ccs upd_flag args body =
    148 155
             ; forkClosureBody (closureCodeBody True id closure_info ccs
    
    149 156
                                     args body fv_details)
    
    150 157
     
    
    158
    +        ; when is_caf $
    
    159
    +            emitDecl $ CmmData (Section Data closure_label) $
    
    160
    +                CmmStatics closure_label (mkCmmInfo closure_info id ccs) ccs [] []
    
    161
    +
    
    151 162
             ; return () }
    
    152 163
     
    
    153 164
       unLit (CmmLit l) = l