Class FunctionProbes

java.lang.Object
org.ek9lang.compiler.phase7.generator.FunctionProbes

public final class FunctionProbes extends Object
THE coverage and profiling probes of one function, method or operator - every IR generator that instruments a callable registers it and places its probes through this; never a private copy of the choreography.

Sibling to CoverageDisplayName and ConstructMetrics, which it calls: the registration is always the five-argument enterFunction (identity, display name, source file, start line and the phase-5 metrics), and the probes are always the same three - the coverage FUNCTION_ENTRY, the PROFILING_ENTRY after it, and the PROFILING_EXIT before the return. Before this there were five copies (an explicit body, the aggregate and service wraps of synthesised members, the text wrap and an application's _prepare); the application's registered with no metrics, its _decommission was not registered at all, and the copies disagreed on which members they skipped.

Two shapes use it. A body generated with its probes in place (OperationDfnGenerator, an application) calls enter(CoverageProbePlacer, ISymbol, DebugInfo) before generating the body - so the body's own statement and branch probes belong to this function - places FunctionProbes.Registered.entryProbes() first and FunctionProbes.Registered.profilingExit() before its return. A body generated elsewhere and instrumented afterwards (a synthesised member, a text method) calls enter(CoverageProbePlacer, ISymbol, DebugInfo) and then wrap(List, FunctionProbes.Registered, IRInstr). Either way the caller ends the function with exitFunction(endLine); the end line is the caller's to know. Which synthesised members get probes at all is IsInstrumentedMember. Hold an instance.

  • Constructor Details

    • FunctionProbes

      public FunctionProbes()
  • Method Details

    • enter

      public FunctionProbes.Registered enter(CoverageProbePlacer placer, ISymbol operation, DebugInfo debugInfo)
      THE registration of a callable with the probe placer, and its three probes. Everything about the function - its identity, its display name, its metrics - is read from the symbol here, and nowhere else.
      Parameters:
      placer - the module's probe placer
      operation - the callable being instrumented
      debugInfo - where it starts (null gives no file and line 0)
      Returns:
      its probes; the caller must end the function with placer.exitFunction(endLine)
    • wrap

      public List<IRInstr> wrap(List<IRInstr> body, FunctionProbes.Registered probes, IRInstr beforeReturn)
      A body generated without probes, instrumented afterwards: the entry probes first, then the body, with beforeReturn (if any) and then the profiling exit before every top-level RETURN.
      Parameters:
      body - the body's instructions
      probes - the function's registered probes
      beforeReturn - a further probe of this function to place before each return, or null
      Returns:
      the instrumented instructions