Skip to content

Commit 718b988

Browse files
authored
documentation followup for "invert linetable representation (#52415)" (#53781)
- fix up added documents: eb05b4f - ~~set up a specific type to capture the 3-set data of `codelocs`: 6afde4b~~ (moved to a separate PR)
1 parent 0ac60b7 commit 718b988

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

doc/src/devdocs/ast.md

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -696,14 +696,10 @@ A (usually temporary) container for holding lowered source code.
696696
Statement-level 32 bits flags for each expression in the function.
697697
See the definition of `jl_code_info_t` in julia.h for more details.
698698

699-
* `linetable`
700-
701-
An array of source location objects
702-
703-
* `codelocs`
699+
* `debuginfo`
704700

705-
An array of integer indices into the `linetable`, giving the location associated
706-
with each statement.
701+
An object to retrieve source information for each statements, see
702+
[How to interpret line numbers in a `CodeInfo` object](@ref).
707703

708704
Optional Fields:
709705

@@ -769,7 +765,7 @@ Boolean properties:
769765
See the documentation of `Base.@assume_effects` for more details.
770766

771767

772-
How to interpret line numbers in a `CodeInfo` object:
768+
#### How to interpret line numbers in a `CodeInfo` object
773769

774770
There are 2 common forms for this data: one used internally that compresses the data somewhat and one used in the compiler.
775771
They contain the same basic info, but the compiler version is all mutable while the version used internally is not.
@@ -780,7 +776,7 @@ Many consumers may be able to call `Base.IRShow.buildLineInfoNode`,
780776

781777
The definitions of each of these are:
782778

783-
```
779+
```julia
784780
struct Core.DebugInfo
785781
@noinline
786782
def::Union{Method,MethodInstance,Symbol}
@@ -801,11 +797,11 @@ end
801797
```
802798

803799

804-
* `def` : where this DebugInfo was defined (the Method, MethodInstance, or file scope, for example)
800+
* `def` : where this `DebugInfo` was defined (the `Method`, `MethodInstance`, or `Symbol` of file scope, for example)
805801

806802
* `linetable`
807803

808-
Another debuginfo that this was derived from, which contains the actual line numbers,
804+
Another `DebugInfo` that this was derived from, which contains the actual line numbers,
809805
such that this DebugInfo contains only the indexes into it. This avoids making copies,
810806
as well as makes it possible to track how each individual statement transformed from
811807
source to optimized, not just the separate line numbers. If `def` is not a Symbol, then
@@ -820,27 +816,26 @@ end
820816
* `firstline` (when uncompressed to DebugInfoStream)
821817

822818
The line number associated with the `begin` statement (or other keyword such as
823-
`function` or `quote`) that delinated where this code definition "starts".
819+
`function` or `quote`) that delineates where this code definition "starts".
824820

825-
* `codelocs` (when uncompressed to DebugInfoStream)
821+
* `codelocs` (when uncompressed to `DebugInfoStream`)
826822

827823
A vector of indices, with 3 values for each statement in the IR plus one for the
828824
starting point of the block, that describe the stacktrace from that point:
829825
1. the integer index into the `linetable.codelocs` field, giving the
830826
original location associated with each statement (including its syntactic edges),
831827
or zero indicating no change to the line number from the previously
832-
executed statement (which is not necessarily syntactic or lexical prior).
833-
or
834-
the line number itself if the `linetable` field is `nothing`
835-
2. the integer index into edges, giving the DebugInfo inlined there (or zero if there
836-
are no edges).
837-
3. (if entry 2 is non-zero) the integer index into edges[].codelocs, to interpret
838-
recursively for each function in the inlining stack, or zero indicating to use
839-
`edges[].firstline` as the line number.
840-
841-
Special codes include:
842-
- (zero, zero, *) : no change to the line number or edges from the previous statement
828+
executed statement (which is not necessarily syntactic or lexical prior),
829+
or the line number itself if the `linetable` field is `nothing`.
830+
2. the integer index into `edges`, giving the `DebugInfo` inlined there,
831+
or zero if there are no edges.
832+
3. (if entry 2 is non-zero) the integer index into `edges[].codelocs`,
833+
to interpret recursively for each function in the inlining stack,
834+
or zero indicating to use `edges[].firstline` as the line number.
835+
836+
Special codes include:
837+
- `(zero, zero, *) `: no change to the line number or edges from the previous statement
843838
(you may choose to interpret this either syntactically or lexically). The inlining
844839
depth also might have changed, though most callers should ignore that.
845-
- (zero, non-zero, *) : no line number, just edges (usually because of macro-expansion into
846-
top-level code)
840+
- `(zero, non-zero, *)` : no line number, just edges (usually because of
841+
macro-expansion into top-level code).

0 commit comments

Comments
 (0)