| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
GHC.Types.Tickish
Contents
Synopsis
- data GenTickish (pass :: TickishPass)
- = ProfNote {
- profNoteCC :: CostCentre
- profNoteCount :: !Bool
- profNoteScope :: !Bool
- | HpcTick {
- tickModule :: Module
- tickId :: !Int
- | Breakpoint {
- breakpointExt :: XBreakpoint pass
- breakpointId :: !BreakpointId
- breakpointFVs :: [XTickishId pass]
- | SourceNote { }
- = ProfNote {
- type CoreTickish = GenTickish 'TickishPassCore
- type StgTickish = GenTickish 'TickishPassStg
- type CmmTickish = GenTickish 'TickishPassCmm
- type family XTickishId (pass :: TickishPass)
- tickishCounts :: GenTickish pass -> Bool
- tickishHasNoScope :: GenTickish pass -> Bool
- tickishHasSoftScope :: GenTickish pass -> Bool
- tickishFloatable :: GenTickish pass -> Bool
- tickishCanSplit :: GenTickish pass -> Bool
- mkNoCount :: GenTickish pass -> GenTickish pass
- mkNoScope :: GenTickish pass -> GenTickish pass
- tickishIsCode :: GenTickish pass -> Bool
- isProfTick :: GenTickish pass -> Bool
- data TickishPlacement
- tickishPlace :: GenTickish pass -> TickishPlacement
- tickishContains :: Eq (GenTickish pass) => GenTickish pass -> GenTickish pass -> Bool
- data BreakpointId = BreakpointId {}
- type BreakTickIndex = Int
Documentation
data GenTickish (pass :: TickishPass) Source #
Constructors
| ProfNote | An |
Fields
| |
| HpcTick | A "tick" used by HPC to track the execution of each subexpression in the original source code. |
Fields
| |
| Breakpoint | A breakpoint for the GHCi debugger. This behaves like an HPC tick, but has a list of free variables which will be available for inspection in GHCi when the program stops at the breakpoint. NB. we must take account of these Ids when (a) counting free variables, and (b) substituting (don't substitute for them) |
Fields
| |
| SourceNote | A source note. Source notes are pure annotations: Their presence should neither influence compilation nor execution. The semantics are given by causality: The presence of a source note means that a local change in the referenced source code span will possibly provoke the generated code to change. On the flip-side, the functionality of annotated code *must* be invariant against changes to all source code *except* the spans referenced in the source notes (see "Causality of optimized Haskell" paper for details). Therefore extending the scope of any given source note is always valid. Note that it is still undesirable though, as this reduces their usefulness for debugging and profiling. Therefore we will generally try only to make use of this property where it is necessary to enable optimizations. |
Fields
| |
Instances
| Outputable (XTickishId pass) => Outputable (GenTickish pass) Source # | |
Defined in GHC.Core.Ppr Methods ppr :: GenTickish pass -> SDoc Source # | |
type CoreTickish = GenTickish 'TickishPassCore Source #
type StgTickish = GenTickish 'TickishPassStg Source #
type CmmTickish = GenTickish 'TickishPassCmm Source #
Tickish in Cmm context (annotations only)
type family XTickishId (pass :: TickishPass) Source #
tickishCounts :: GenTickish pass -> Bool Source #
A "counting tick" (for which tickishCounts is True) is one that
counts evaluations in some way. We cannot discard a counting tick,
and the compiler should preserve the number of counting ticks (as
far as possible).
See Note [Counting ticks]
tickishHasNoScope :: GenTickish pass -> Bool Source #
Is this a non-scoping tick, for which we don't care about precisely the extent of code that the tick encompasses?
See Note [Scoped ticks]
tickishHasSoftScope :: GenTickish pass -> Bool Source #
A "tick with soft scoping" (for which tickishHasSoftScope is True) is
one that either does not scope at all (for which tickishHasNoScope is True),
or that has a "soft" scope: we allow new code to be floated into to the scope,
as long as all code that was covered remains covered.
See Note [Scoped ticks]
tickishFloatable :: GenTickish pass -> Bool Source #
Returns True for ticks that can be floated upwards easily even
where it might change execution counts, such as:
Just (tick... foo) ==> tick... (Just foo)
This is a combination of tickishHasSoftScope and tickishCounts.
Note that in principle splittable ticks can become floatable using mkNoTick,
even though there's currently no tickish for which that is the case.
tickishCanSplit :: GenTickish pass -> Bool Source #
Returns True for a tick that is both counting and scoping and
can be split into its (tick, scope) parts using mkNoScope and
mkNoTick respectively.
mkNoCount :: GenTickish pass -> GenTickish pass Source #
mkNoScope :: GenTickish pass -> GenTickish pass Source #
tickishIsCode :: GenTickish pass -> Bool Source #
Return True if this source annotation compiles to some backend
code. Without this flag, the tickish is seen as a simple annotation
that does not have any associated evaluation code.
What this means that we are allowed to disregard the tick if doing so means that we can skip generating any code in the first place. A typical example is top-level bindings:
foo = tick... y -> ... ==> foo = y -> tick... ...
Here there is just no operational difference between the first and the second version. Therefore code generation should simply translate the code as if it found the latter.
isProfTick :: GenTickish pass -> Bool Source #
data TickishPlacement Source #
Governs the kind of expression that the tick gets placed on when
annotating for example using mkTick. If we find that we want to
put a tickish on an expression ruled out here, we try to float it
inwards until we find a suitable expression.
Constructors
| PlaceRuntime | Place ticks exactly on run-time expressions. We can still
move the tick through pure compile-time constructs such as
other ticks, casts or type lambdas. This is the most
restrictive placement rule for ticks, as all tickishs have in
common that they want to track runtime processes. The only
legal placement rule for counting ticks.
NB: We generally try to move these as close to the relevant
runtime expression as possible. This means they get pushed through
tyoe arguments. E.g. we create `(tick f) |
| PlaceNonLam | As |
| PlaceCostCentre | In addition to floating through lambdas, cost-centre style tickishs can also be moved from constructors, non-function variables and literals. For example: let x = scc... C (scc... y) (scc... 3) in ... Neither the constructor application, the variable or the literal are likely to have any cost worth mentioning. And even if y names a thunk, the call would not care about the evaluation context. Therefore removing all annotations in the above example is safe. |
Instances
| Outputable TickishPlacement Source # | |
Defined in GHC.Types.Tickish Methods ppr :: TickishPlacement -> SDoc Source # | |
| Eq TickishPlacement Source # | |
Defined in GHC.Types.Tickish Methods (==) :: TickishPlacement -> TickishPlacement -> Bool Source # (/=) :: TickishPlacement -> TickishPlacement -> Bool Source # | |
| Show TickishPlacement Source # | |
Defined in GHC.Types.Tickish | |
tickishPlace :: GenTickish pass -> TickishPlacement Source #
Placement behaviour we want for the ticks
tickishContains :: Eq (GenTickish pass) => GenTickish pass -> GenTickish pass -> Bool Source #
Returns whether one tick "contains" the other one, therefore making the second tick redundant.
Breakpoint tick identifiers
data BreakpointId Source #
Breakpoint identifier.
Indexes into the structures in the created during desugaring
(after inserting the breakpoint ticks in the expressions).
See Note [Breakpoint identifiers]ModBreaks
Constructors
| BreakpointId | |
Fields
| |
Instances
type BreakTickIndex = Int Source #
Breakpoint tick index newtype BreakTickIndex = BreakTickIndex Int deriving (Eq, Ord, Data, Ix, NFData, Outputable)