ghc-9.15: The GHC API
Safe HaskellNone
LanguageGHC2024

GHC.Types.Tickish

Synopsis

Documentation

data GenTickish (pass :: TickishPass) Source #

Constructors

ProfNote

An {-# SCC #-} profiling annotation, either automatically added by the desugarer as a result of -auto-all, or added by the user.

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

Instances details
Outputable (XTickishId pass) => Outputable (GenTickish pass) Source # 
Instance details

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.

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.

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) Bool` instead of `tick (f Bool)`.

PlaceNonLam

As PlaceRuntime, but we float the tick through all lambdas. This makes sense where there is little difference between annotating the lambda and annotating the lambda's code.

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.

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 ModBreaks created during desugaring (after inserting the breakpoint ticks in the expressions). See Note [Breakpoint identifiers]

Constructors

BreakpointId 

Fields

Instances

Instances details
NFData BreakpointId Source # 
Instance details

Defined in GHC.Types.Tickish

Methods

rnf :: BreakpointId -> () Source #

Binary BreakpointId Source # 
Instance details

Defined in GHC.Types.Tickish

Outputable BreakpointId Source # 
Instance details

Defined in GHC.Types.Tickish

Eq BreakpointId Source # 
Instance details

Defined in GHC.Types.Tickish

Ord BreakpointId Source # 
Instance details

Defined in GHC.Types.Tickish

Data BreakpointId Source # 
Instance details

Defined in GHC.Types.Tickish

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BreakpointId -> c BreakpointId Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BreakpointId Source #

toConstr :: BreakpointId -> Constr Source #

dataTypeOf :: BreakpointId -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BreakpointId) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BreakpointId) Source #

gmapT :: (forall b. Data b => b -> b) -> BreakpointId -> BreakpointId Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BreakpointId -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BreakpointId -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> BreakpointId -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> BreakpointId -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> BreakpointId -> m BreakpointId Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BreakpointId -> m BreakpointId Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BreakpointId -> m BreakpointId Source #

type BreakTickIndex = Int Source #

Breakpoint tick index newtype BreakTickIndex = BreakTickIndex Int deriving (Eq, Ord, Data, Ix, NFData, Outputable)