X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FcodeGen%2FCgConTbls.lhs;h=e3197fadc419d8ccacd23c7d3a9a062f376e9061;hb=2540a99f8e67237f7fa9cd49143ae2cd9d7f84d6;hp=6b75ee50d9adffe131bf13f1b5bf7eddac55be6c;hpb=506fa77d392191e46c12b2c19387ff5b0888f6a2;p=ghc-hetmet.git diff --git a/ghc/compiler/codeGen/CgConTbls.lhs b/ghc/compiler/codeGen/CgConTbls.lhs index 6b75ee5..e3197fa 100644 --- a/ghc/compiler/codeGen/CgConTbls.lhs +++ b/ghc/compiler/codeGen/CgConTbls.lhs @@ -11,22 +11,19 @@ module CgConTbls ( genStaticConBits ) where import AbsCSyn import CgMonad -import StgSyn ( SRT(..) ) import AbsCUtils ( mkAbstractCs, mkAbsCStmts ) import CgTailCall ( performReturn, mkStaticAlgReturnCode ) -import CLabel ( mkConEntryLabel, mkStaticClosureLabel ) +import CLabel ( mkConEntryLabel ) import ClosureInfo ( layOutStaticClosure, layOutDynCon, mkConLFInfo, ClosureInfo ) import CostCentre ( dontCareCCS ) -import FiniteMap ( fmToList, FiniteMap ) -import DataCon ( DataCon, dataConName, dataConRawArgTys ) -import Const ( Con(..) ) -import Name ( getOccString ) +import DataCon ( DataCon, dataConName, dataConRepArgTys, isNullaryDataCon ) +import Name ( getOccName ) +import OccName ( occNameUserString ) import PrimRep ( getPrimRepSize, PrimRep(..) ) import TyCon ( tyConDataCons, isEnumerationTyCon, TyCon ) -import Type ( typePrimRep, Type ) -import Outputable +import Type ( typePrimRep ) \end{code} For every constructor we generate the following info tables: @@ -58,12 +55,9 @@ Static occurrences of the constructor macro: @STATIC_INFO_TABLE@. \end{description} -For zero-arity constructors, \tr{con}, we also generate a static closure: -\begin{description} -\item[@_closure@:] -A single static copy of the (zero-arity) constructor itself. -\end{description} +For zero-arity constructors, \tr{con}, we NO LONGER generate a static closure; +it's place is taken by the top level defn of the constructor. For charlike and intlike closures there is a fixed array of static closures predeclared. @@ -115,8 +109,7 @@ genConInfo comp_info tycon data_con = mkAbstractCs [ CSplitMarker, closure_code, - static_code, - closure_maybe] + static_code] -- Order of things is to reduce forward references where (closure_info, body_code) = mkConCodeAndInfo data_con @@ -131,8 +124,7 @@ genConInfo comp_info tycon data_con profCtrC SLIT("TICK_ENT_CON") [CReg node] `thenC` body_code)) - entry_addr = CLbl entry_label CodePtrRep - con_descr = getOccString data_con + con_descr = occNameUserString (getOccName data_con) -- Don't need any dynamic closure code for zero-arity constructors closure_code = if zero_arity_con then @@ -142,28 +134,13 @@ genConInfo comp_info tycon data_con static_code = CClosureInfoAndCode static_ci body Nothing con_descr - cost_centre = mkCCostCentreStack dontCareCCS -- not worried about static data costs - - -- For zero-arity data constructors, or, more accurately, - -- those which only have VoidRep args (or none): - -- We make the closure too (not just info tbl), so that we can share - -- one copy throughout. - closure_maybe = if not zero_arity_con then - AbsCNop - else - CStaticClosure closure_label -- Label for closure - static_ci -- Info table - cost_centre - [{-No args! A slight lie for constrs - with VoidRep args-}] - - zero_size arg_ty = getPrimRepSize (typePrimRep arg_ty) == 0 - - zero_arity_con = all zero_size arg_tys + zero_arity_con = isNullaryDataCon data_con + -- We used to check that all the arg-sizes were zero, but we don't + -- really have any constructors with only zero-size args, and it's + -- just one more thing to go wrong. - arg_tys = dataConRawArgTys data_con + arg_tys = dataConRepArgTys data_con entry_label = mkConEntryLabel con_name - closure_label = mkStaticClosureLabel con_name con_name = dataConName data_con \end{code} @@ -173,7 +150,7 @@ mkConCodeAndInfo :: DataCon -- Data constructor mkConCodeAndInfo con = let - arg_tys = dataConRawArgTys con + arg_tys = dataConRepArgTys con (closure_info, arg_things) = layOutDynCon con typePrimRep arg_tys