%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: CLabel.lhs,v 1.22 1998/12/18 17:40:34 simonpj Exp $
+% $Id: CLabel.lhs,v 1.34 2000/05/15 15:03:36 simonmar Exp $
%
\section[CLabel]{@CLabel@: Information to make C Labels}
mkStaticConEntryLabel,
mkRednCountsLabel,
mkConInfoTableLabel,
- mkStaticClosureLabel,
mkStaticInfoTableLabel,
mkApEntryLabel,
mkApInfoTableLabel,
mkAsmTempLabel,
+ mkModuleInitLabel,
+
mkErrorStdEntryLabel,
- mkUpdEntryLabel,
+ mkUpdInfoLabel,
+ mkTopTickyCtrLabel,
mkBlackHoleInfoTableLabel,
+ mkCAFBlackHoleInfoTableLabel,
+ mkSECAFBlackHoleInfoTableLabel,
mkRtsPrimOpLabel,
+ moduleRegdLabel,
+
mkSelectorInfoLabel,
mkSelectorEntryLabel,
mkCC_Label, mkCCS_Label,
- needsCDecl, isReadOnly, isAsmTemp, externallyVisibleCLabel,
+ needsCDecl, isAsmTemp, externallyVisibleCLabel,
- CLabelType(..), labelType,
+ CLabelType(..), labelType, labelDynamic,
pprCLabel
#if ! OMIT_NATIVE_CODEGEN
import {-# SOURCE #-} MachMisc ( underscorePrefix, fmtAsmLbl )
#endif
+import CmdLineOpts ( opt_Static, opt_DoTickyProfiling )
import CStrings ( pp_cSEP )
import DataCon ( ConTag, DataCon )
-import Name ( Name, isExternallyVisibleName )
+import Module ( ModuleName )
+import Name ( Name, getName, isDllName, isExternallyVisibleName )
import TyCon ( TyCon )
import Unique ( pprUnique, Unique )
import PrimOp ( PrimOp, pprPrimOp )
| AsmTempLabel Unique
+ | ModuleInitLabel ModuleName
+
| RtsLabel RtsLabelInfo
| CC_Label CostCentre
data DataConLabelInfo
= ConEntry -- the only kind of entry pt for constructors
| ConInfoTbl -- corresponding info table
-
- | StaticClosure -- Static constructor closure
- -- e.g., nullary constructor
| StaticConEntry -- static constructor entry point
| StaticInfoTbl -- corresponding info table
deriving (Eq, Ord)
data RtsLabelInfo
= RtsShouldNeverHappenCode
- | RtsBlackHoleInfoTbl
+ | RtsBlackHoleInfoTbl FAST_STRING -- black hole with info table name
- | RtsUpdEntry
+ | RtsUpdInfo
| RtsSelectorInfoTbl Bool{-updatable-} Int{-offset-} -- Selector thunks
| RtsSelectorEntry Bool{-updatable-} Int{-offset-}
| RtsPrimOp PrimOp
+ | RtsTopTickyCtr
+
+ | RtsModuleRegd
+
deriving (Eq, Ord)
-- Label Type: for generating C declarations.
= InfoTblType
| ClosureType
| VecTblType
+ | ClosureTblType
| CodeType
| DataType
\end{code}
mkRednCountsLabel id = IdLabel id RednCounts
-mkStaticClosureLabel con = DataConLabel con StaticClosure
mkStaticInfoTableLabel con = DataConLabel con StaticInfoTbl
mkConInfoTableLabel con = DataConLabel con ConInfoTbl
mkConEntryLabel con = DataConLabel con ConEntry
mkAsmTempLabel = AsmTempLabel
+mkModuleInitLabel = ModuleInitLabel
+
-- Some fixed runtime system labels
mkErrorStdEntryLabel = RtsLabel RtsShouldNeverHappenCode
-mkUpdEntryLabel = RtsLabel RtsUpdEntry
-mkBlackHoleInfoTableLabel = RtsLabel RtsBlackHoleInfoTbl
+mkUpdInfoLabel = RtsLabel RtsUpdInfo
+mkTopTickyCtrLabel = RtsLabel RtsTopTickyCtr
+mkBlackHoleInfoTableLabel = RtsLabel (RtsBlackHoleInfoTbl SLIT("BLACKHOLE_info"))
+mkCAFBlackHoleInfoTableLabel = RtsLabel (RtsBlackHoleInfoTbl SLIT("CAF_BLACKHOLE_info"))
+mkSECAFBlackHoleInfoTableLabel = if opt_DoTickyProfiling then
+ RtsLabel (RtsBlackHoleInfoTbl SLIT("SE_CAF_BLACKHOLE_info"))
+ else -- RTS won't have info table unless -ticky is on
+ panic "mkSECAFBlackHoleInfoTableLabel requires -ticky"
mkRtsPrimOpLabel primop = RtsLabel (RtsPrimOp primop)
+moduleRegdLabel = RtsLabel RtsModuleRegd
+
mkSelectorInfoLabel upd off = RtsLabel (RtsSelectorInfoTbl upd off)
mkSelectorEntryLabel upd off = RtsLabel (RtsSelectorEntry upd off)
\begin{code}
needsCDecl :: CLabel -> Bool -- False <=> it's pre-declared; don't bother
-isReadOnly :: CLabel -> Bool -- lives in C "text space"
isAsmTemp :: CLabel -> Bool -- is a local temporary for native code generation
externallyVisibleCLabel :: CLabel -> Bool -- not C "static"
\end{code}
needsCDecl (CaseLabel _ CaseReturnPt) = True
needsCDecl (DataConLabel _ _) = True
needsCDecl (CaseLabel _ _) = False
+needsCDecl (TyConLabel _) = True
needsCDecl (AsmTempLabel _) = False
-needsCDecl (TyConLabel _) = False
+needsCDecl (ModuleInitLabel _) = False
needsCDecl (RtsLabel _) = False
needsCDecl (CC_Label _) = False
needsCDecl (CCS_Label _) = False
\end{code}
-Whether the labelled thing can be put in C "text space":
-
-\begin{code}
-isReadOnly (IdLabel _ InfoTbl) = True -- info-tables: yes
-isReadOnly (IdLabel _ other) = False -- others: pessimistically, no
-
-isReadOnly (DataConLabel _ _) = True -- and so on, for other
-isReadOnly (TyConLabel _) = True
-isReadOnly (CaseLabel _ _) = True
-isReadOnly (AsmTempLabel _) = True
-isReadOnly (RtsLabel _) = True
-isReadOnly (CC_Label _) = True
-isReadOnly (CCS_Label _) = True
-\end{code}
-
Whether the label is an assembler temporary:
\begin{code}
externallyVisibleCLabel (TyConLabel tc) = True
externallyVisibleCLabel (CaseLabel _ _) = False
externallyVisibleCLabel (AsmTempLabel _) = False
+externallyVisibleCLabel (ModuleInitLabel _)= True
+externallyVisibleCLabel (RtsLabel RtsModuleRegd) = False --hack
externallyVisibleCLabel (RtsLabel _) = True
externallyVisibleCLabel (IdLabel id _) = isExternallyVisibleName id
externallyVisibleCLabel (CC_Label _) = False -- not strictly true
\begin{code}
labelType :: CLabel -> CLabelType
-labelType (RtsLabel RtsBlackHoleInfoTbl) = InfoTblType
+labelType (RtsLabel (RtsBlackHoleInfoTbl _)) = InfoTblType
labelType (RtsLabel (RtsSelectorInfoTbl _ _)) = InfoTblType
labelType (RtsLabel (RtsApInfoTbl _ _)) = InfoTblType
+labelType (RtsLabel RtsUpdInfo) = InfoTblType
labelType (CaseLabel _ CaseReturnInfo) = InfoTblType
labelType (CaseLabel _ CaseReturnPt) = CodeType
labelType (CaseLabel _ CaseVecTbl) = VecTblType
+labelType (TyConLabel _) = ClosureTblType
labelType (IdLabel _ info) =
case info of
case info of
ConInfoTbl -> InfoTblType
StaticInfoTbl -> InfoTblType
- StaticClosure -> ClosureType
_ -> CodeType
labelType _ = DataType
\end{code}
+When referring to data in code, we need to know whether
+that data resides in a DLL or not. [Win32 only.]
+@labelDynamic@ returns @True@ if the label is located
+in a DLL, be it a data reference or not.
+
+\begin{code}
+labelDynamic :: CLabel -> Bool
+labelDynamic lbl =
+ case lbl of
+ RtsLabel _ -> not opt_Static -- i.e., is the RTS in a DLL or not?
+ IdLabel n k -> isDllName n
+ DataConLabel n k -> isDllName n
+ TyConLabel tc -> isDllName (getName tc)
+ _ -> False
+\end{code}
+
+
OLD?: These GRAN functions are needed for spitting out GRAN_FETCH() at the
right places. It is used to detect when the abstractC statement of an
CCodeBlock actually contains the code for a slow entry point. -- HWL
dflt Default case alternative
btm Large bitmap vector
closure Static closure
- static_closure Static closure (???)
con_entry Dynamic Constructor entry code
con_info Dynamic Constructor info table
static_entry Static Constructor entry code
static_info Static Constructor info table
sel_info Selector info table
sel_entry Selector entry code
+ cc Cost centre
+ ccs Cost centre stack
\begin{code}
-- specialised for PprAsm: saves lots of arg passing in NCG
pprCLbl (RtsLabel RtsShouldNeverHappenCode) = ptext SLIT("stg_error_entry")
-pprCLbl (RtsLabel RtsUpdEntry) = ptext SLIT("Upd_frame_entry")
+pprCLbl (RtsLabel RtsUpdInfo) = ptext SLIT("upd_frame_info")
+
+pprCLbl (RtsLabel RtsTopTickyCtr) = ptext SLIT("top_ct")
-pprCLbl (RtsLabel RtsBlackHoleInfoTbl) = ptext SLIT("BLACKHOLE_info")
+pprCLbl (RtsLabel (RtsBlackHoleInfoTbl info)) = ptext info
pprCLbl (RtsLabel (RtsSelectorInfoTbl upd_reqd offset))
= hcat [ptext SLIT("__sel_"), text (show offset),
pprCLbl (RtsLabel (RtsPrimOp primop))
= pprPrimOp primop <> ptext SLIT("_fast")
+pprCLbl (RtsLabel RtsModuleRegd)
+ = ptext SLIT("module_registered")
+
pprCLbl (TyConLabel tc)
= hcat [ppr tc, pp_cSEP, ptext SLIT("closure_tbl")]
pprCLbl (CC_Label cc) = ppr cc
pprCLbl (CCS_Label ccs) = ppr ccs
+pprCLbl (ModuleInitLabel mod) = ptext SLIT("__init_") <> ptext mod
+
ppIdFlavor :: IdLabelInfo -> SDoc
ppIdFlavor x = pp_cSEP <>
ppConFlavor x = pp_cSEP <>
(case x of
- StaticClosure -> ptext SLIT("static_closure")
ConEntry -> ptext SLIT("con_entry")
ConInfoTbl -> ptext SLIT("con_info")
StaticConEntry -> ptext SLIT("static_entry")