Commit 6f2596b4 authored by Ben Gamari's avatar Ben Gamari 🐢

Revert "Merge FUN_STATIC closure with its SRT"

This reverts commit 838b6903.
parent b0f06f53
......@@ -27,8 +27,6 @@ module Cmm (
import GhcPrelude
import Id
import CostCentre
import CLabel
import BlockId
import CmmNode
......@@ -139,10 +137,7 @@ data CmmInfoTable
cit_lbl :: CLabel, -- Info table label
cit_rep :: SMRep,
cit_prof :: ProfilingInfo,
cit_srt :: Maybe CLabel, -- empty, or a closure address
cit_clo :: Maybe (Id, CostCentreStack)
-- Just (id,ccs) <=> build a static closure later
-- Nothing <=> don't build a static closure
cit_srt :: Maybe CLabel -- empty, or a closure address
}
data ProfilingInfo
......
This diff is collapsed.
......@@ -63,8 +63,7 @@ mkEmptyContInfoTable info_lbl
= CmmInfoTable { cit_lbl = info_lbl
, cit_rep = mkStackRep []
, cit_prof = NoProfilingInfo
, cit_srt = Nothing
, cit_clo = Nothing }
, cit_srt = Nothing }
cmmToRawCmm :: DynFlags -> Stream IO CmmGroup ()
-> IO (Stream IO RawCmmGroup ())
......
......@@ -470,7 +470,7 @@ info :: { CmmParse (CLabel, Maybe CmmInfoTable, [LocalReg]) }
return (mkCmmEntryLabel pkg $3,
Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel pkg $3
, cit_rep = rep
, cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing },
, cit_prof = prof, cit_srt = Nothing },
[]) }
| 'INFO_TABLE_FUN' '(' NAME ',' INT ',' INT ',' INT ',' STRING ',' STRING ',' INT ')'
......@@ -486,7 +486,7 @@ info :: { CmmParse (CLabel, Maybe CmmInfoTable, [LocalReg]) }
return (mkCmmEntryLabel pkg $3,
Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel pkg $3
, cit_rep = rep
, cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing },
, cit_prof = prof, cit_srt = Nothing },
[]) }
-- we leave most of the fields zero here. This is only used
-- to generate the BCO info table in the RTS at the moment.
......@@ -504,7 +504,7 @@ info :: { CmmParse (CLabel, Maybe CmmInfoTable, [LocalReg]) }
return (mkCmmEntryLabel pkg $3,
Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel pkg $3
, cit_rep = rep
, cit_prof = prof, cit_srt = Nothing,cit_clo = Nothing },
, cit_prof = prof, cit_srt = Nothing },
[]) }
-- If profiling is on, this string gets duplicated,
......@@ -521,7 +521,7 @@ info :: { CmmParse (CLabel, Maybe CmmInfoTable, [LocalReg]) }
return (mkCmmEntryLabel pkg $3,
Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel pkg $3
, cit_rep = rep
, cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing },
, cit_prof = prof, cit_srt = Nothing },
[]) }
| 'INFO_TABLE_RET' '(' NAME ',' INT ')'
......@@ -532,7 +532,7 @@ info :: { CmmParse (CLabel, Maybe CmmInfoTable, [LocalReg]) }
return (mkCmmRetLabel pkg $3,
Just $ CmmInfoTable { cit_lbl = mkCmmRetInfoLabel pkg $3
, cit_rep = rep
, cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing },
, cit_prof = prof, cit_srt = Nothing },
[]) }
| 'INFO_TABLE_RET' '(' NAME ',' INT ',' formals0 ')'
......@@ -547,7 +547,7 @@ info :: { CmmParse (CLabel, Maybe CmmInfoTable, [LocalReg]) }
return (mkCmmRetLabel pkg $3,
Just $ CmmInfoTable { cit_lbl = mkCmmRetInfoLabel pkg $3
, cit_rep = rep
, cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing },
, cit_prof = prof, cit_srt = Nothing },
live) }
body :: { CmmParse () }
......
......@@ -95,17 +95,19 @@ cgTopRhsClosure dflags rec id ccs _ upd_flag args body =
emitDataLits closure_label closure_rep
return ()
gen_code dflags lf_info _closure_label
= do { let name = idName id
gen_code dflags lf_info closure_label
= do { -- LAY OUT THE OBJECT
let name = idName id
; mod_name <- getModuleName
; let descr = closureDescription dflags mod_name name
closure_info = mkClosureInfo dflags True id lf_info 0 0 descr
-- We don't generate the static closure here, because we might
-- want to add references to static closures to it later. The
-- static closure is generated by CmmBuildInfoTables.updInfoSRTs,
-- See Note [SRTs], specifically the [FUN] optimisation.
caffy = idCafInfo id
info_tbl = mkCmmInfo closure_info -- XXX short-cut
closure_rep = mkStaticClosureFields dflags info_tbl ccs caffy []
-- BUILD THE OBJECT, AND GENERATE INFO TABLE (IF NECESSARY)
; emitDataLits closure_label closure_rep
; let fv_details :: [(NonVoid Id, ByteOff)]
header = if isLFThunk lf_info then ThunkHeader else StdHeader
(_, _, fv_details) = mkVirtHeapOffsets dflags header []
......@@ -365,7 +367,7 @@ mkRhsClosure dflags bndr cc _ fvs upd_flag args body
; let use_cc = cccsExpr; blame_cc = cccsExpr
; emit (mkComment $ mkFastString "calling allocDynClosure")
; let toVarArg (NonVoid a, off) = (NonVoid (StgVarArg a), off)
; let info_tbl = mkCmmInfo closure_info bndr currentCCS
; let info_tbl = mkCmmInfo closure_info
; hp_plus_n <- allocDynClosure (Just bndr) info_tbl lf_info use_cc blame_cc
(map toVarArg fv_details)
......@@ -405,7 +407,7 @@ cgRhsStdThunk bndr lf_info payload
-- BUILD THE OBJECT
; let info_tbl = mkCmmInfo closure_info bndr currentCCS
; let info_tbl = mkCmmInfo closure_info
; hp_plus_n <- allocDynClosure (Just bndr) info_tbl lf_info
use_cc blame_cc payload_w_offsets
......@@ -461,7 +463,7 @@ closureCodeBody top_lvl bndr cl_info cc _args arity body fv_details
\(_, node, _) -> thunkCode cl_info fv_details cc node arity body
where
lf_info = closureLFInfo cl_info
info_tbl = mkCmmInfo cl_info bndr cc
info_tbl = mkCmmInfo cl_info
closureCodeBody top_lvl bndr cl_info cc args arity body fv_details
= -- Note: args may be [], if all args are Void
......@@ -472,7 +474,7 @@ closureCodeBody top_lvl bndr cl_info cc args arity body fv_details
; let
lf_info = closureLFInfo cl_info
info_tbl = mkCmmInfo cl_info bndr cc
info_tbl = mkCmmInfo cl_info
-- Emit the main entry code
; emitClosureProcAndInfoTable top_lvl bndr lf_info info_tbl args $
......
......@@ -73,7 +73,6 @@ import SMRep
import Cmm
import PprCmmExpr()
import CostCentre
import BlockId
import CLabel
import Id
......@@ -746,15 +745,12 @@ data ClosureInfo
}
-- | Convert from 'ClosureInfo' to 'CmmInfoTable'.
mkCmmInfo :: ClosureInfo -> Id -> CostCentreStack -> CmmInfoTable
mkCmmInfo ClosureInfo {..} id ccs
mkCmmInfo :: ClosureInfo -> CmmInfoTable
mkCmmInfo ClosureInfo {..}
= CmmInfoTable { cit_lbl = closureInfoLabel
, cit_rep = closureSMRep
, cit_prof = closureProf
, cit_srt = Nothing
, cit_clo = if isStaticRep closureSMRep
then Just (id,ccs)
else Nothing }
, cit_srt = Nothing }
--------------------------------------
-- Building ClosureInfos
......@@ -1039,8 +1035,7 @@ mkDataConInfoTable dflags data_con is_static ptr_wds nonptr_wds
= CmmInfoTable { cit_lbl = info_lbl
, cit_rep = sm_rep
, cit_prof = prof
, cit_srt = Nothing
, cit_clo = Nothing }
, cit_srt = Nothing }
where
name = dataConName data_con
info_lbl = mkConInfoTableLabel name NoCafRefs
......@@ -1063,16 +1058,14 @@ cafBlackHoleInfoTable
= CmmInfoTable { cit_lbl = mkCAFBlackHoleInfoTableLabel
, cit_rep = blackHoleRep
, cit_prof = NoProfilingInfo
, cit_srt = Nothing
, cit_clo = Nothing }
, cit_srt = Nothing }
indStaticInfoTable :: CmmInfoTable
indStaticInfoTable
= CmmInfoTable { cit_lbl = mkIndStaticInfoLabel
, cit_rep = indStaticRep
, cit_prof = NoProfilingInfo
, cit_srt = Nothing
, cit_clo = Nothing }
, cit_srt = Nothing }
staticClosureNeedsLink :: Bool -> CmmInfoTable -> Bool
-- A static closure needs a link field to aid the GC when traversing
......
......@@ -172,6 +172,7 @@ INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con)
-------------------------------------------------------------------------- */
/* These are hard-coded. */
#define FUN_STATIC_LINK(p) (&(p)->payload[0])
#define THUNK_STATIC_LINK(p) (&(p)->payload[1])
#define IND_STATIC_LINK(p) (&(p)->payload[1])
......@@ -181,6 +182,8 @@ STATIC_LINK(const StgInfoTable *info, StgClosure *p)
switch (info->type) {
case THUNK_STATIC:
return THUNK_STATIC_LINK(p);
case FUN_STATIC:
return FUN_STATIC_LINK(p);
case IND_STATIC:
return IND_STATIC_LINK(p);
default:
......
......@@ -1912,7 +1912,7 @@ resetStaticObjectForRetainerProfiling( StgClosure *static_objects )
break;
case FUN_STATIC:
maybeInitRetainerSet(p);
p = (StgClosure*)*STATIC_LINK(p);
p = (StgClosure*)*FUN_STATIC_LINK(p);
break;
case CONSTR:
case CONSTR_1_0:
......
......@@ -212,7 +212,7 @@ thread_static( StgClosure* p )
p = *THUNK_STATIC_LINK(p);
continue;
case FUN_STATIC:
p = *STATIC_LINK(info,p);
p = *FUN_STATIC_LINK(p);
continue;
case CONSTR:
case CONSTR_NOCAF:
......
......@@ -528,8 +528,8 @@ loop:
return;
case FUN_STATIC:
if (info->srt != 0 || info->layout.payload.ptrs != 0) {
evacuate_static_object(STATIC_LINK(info,(StgClosure *)q), q);
if (info->srt != 0) {
evacuate_static_object(FUN_STATIC_LINK((StgClosure *)q), q);
}
return;
......
......@@ -690,7 +690,7 @@ checkStaticObjects ( StgClosure* static_objects )
break;
case FUN_STATIC:
p = *STATIC_LINK(info,(StgClosure *)p);
p = *FUN_STATIC_LINK((StgClosure *)p);
break;
case CONSTR:
......
......@@ -1707,11 +1707,7 @@ scavenge_static(void)
case FUN_STATIC:
scavenge_fun_srt(info);
/* fallthrough */
// a FUN_STATIC can also be an SRT, so it may have pointer
// fields. See Note [SRTs] in CmmBuildInfoTables, specifically
// the [FUN] optimisation.
break;
case CONSTR:
case CONSTR_NOCAF:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment