Class CoverageProbeIds

java.lang.Object
org.ek9lang.compiler.phase7.generation.CoverageProbeIds

final class CoverageProbeIds extends Object
THE identities of coverage and profiling instrumentation (IR tidy W3.9, INFRA-10): a module, a function and a probe each get a deterministic FNV-1a 64-bit hash of their source context, so ids are unique across every source file without any coordination during parallel compilation, and two parameterisations of one generic produce the SAME ids for the same source lines (which is what lets CoverageProbePlacer.absorb(CoverageProbePlacer) de-duplicate by id).

Never hash a coverage or profiling id anywhere else in the compiler: the runtime, the report and the IR all key on these values. The hash is the runtime's org.ek9.lang.CoverageRuntime.fnv1a64 (which registers a module's metadata under moduleId(String)); it is repeated here rather than called because calling it would initialise the whole coverage runtime inside every compile. CoverageProbePlacerTest pins the two as equal. Hold an instance.

  • Constructor Details

    • CoverageProbeIds

      CoverageProbeIds()
  • Method Details

    • moduleId

      long moduleId(String moduleName)
      The id of a module: the hash of its name.
    • functionId

      long functionId(String moduleName, String sourceFile, String functionName, int startLine)
      The id of a function: module name, source file, function name and start line.
    • probeId

      long probeId(String moduleName, String sourceFile, int line, CoverageProbeType type, String functionName)
      The id of a probe: module name, source file, line, probe type and the enclosing function's name (empty when there is none).