Skip to content

Commit

Permalink
Docs fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Nov 2, 2024
1 parent b6393e0 commit ba34a49
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No

for M in restored
M = M::Module
if parentmodule(M) === M && PkgId(M) == pkg
if is_root_module(M) && PkgId(M) == pkg
register && register_root_module(M)
if timing_imports
elapsed_time = time_ns() - t_before
Expand Down
2 changes: 1 addition & 1 deletion base/runtime_internals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Base
"""
parentmodule(m::Module) = (@_total_meta; ccall(:jl_module_parent, Ref{Module}, (Any,), m))

is_root_module(m::Module) = parentmodule(m) === m || (isdefined(Main, :Base) && m === Main.Base)
is_root_module(m::Module) = parentmodule(m) === m || m === Compiler || (isdefined(Main, :Base) && m === Main.Base)

"""
moduleroot(m::Module) -> Module
Expand Down
12 changes: 6 additions & 6 deletions doc/src/devdocs/EscapeAnalysis.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `EscapeAnalysis`

`Core.Compiler.EscapeAnalysis` is a compiler utility module that aims to analyze
`Compiler.EscapeAnalysis` is a compiler utility module that aims to analyze
escape information of [Julia's SSA-form IR](@ref Julia-SSA-form-IR) a.k.a. `IRCode`.

This escape analysis aims to:
Expand Down Expand Up @@ -59,7 +59,7 @@ The symbols on the side of each call argument and SSA statements represent the f
- `` (green or cyan): this value never escapes (`has_no_escape(result.state[x])` holds), colored blue if it has arg escape also (`has_arg_escape(result.state[x])` holds)
- `` (blue or yellow): this value can escape to the caller via return (`has_return_escape(result.state[x])` holds), colored yellow if it has unhandled thrown escape also (`has_thrown_escape(result.state[x])` holds)
- `X` (red): this value can escape to somewhere the escape analysis can't reason about like escapes to a global memory (`has_all_escape(result.state[x])` holds)
- `*` (bold): this value's escape state is between the `ReturnEscape` and `AllEscape` in the partial order of [`EscapeInfo`](@ref Core.Compiler.EscapeAnalysis.EscapeInfo), colored yellow if it has unhandled thrown escape also (`has_thrown_escape(result.state[x])` holds)
- `*` (bold): this value's escape state is between the `ReturnEscape` and `AllEscape` in the partial order of [`EscapeInfo`](@ref Base.Compiler.EscapeAnalysis.EscapeInfo), colored yellow if it has unhandled thrown escape also (`has_thrown_escape(result.state[x])` holds)
- ``: this value has additional object field / array element information in its `AliasInfo` property

Escape information of each call argument and SSA value can be inspected programmatically as like:
Expand All @@ -74,7 +74,7 @@ result.state[Core.SSAValue(3)] # get EscapeInfo of `r3`
### Lattice Design

`EscapeAnalysis` is implemented as a [data-flow analysis](https://en.wikipedia.org/wiki/Data-flow_analysis)
that works on a lattice of [`x::EscapeInfo`](@ref Core.Compiler.EscapeAnalysis.EscapeInfo),
that works on a lattice of [`x::EscapeInfo`](@ref Base.Compiler.EscapeAnalysis.EscapeInfo),
which is composed of the following properties:
- `x.Analyzed::Bool`: not formally part of the lattice, only indicates `x` has not been analyzed or not
- `x.ReturnEscape::BitSet`: records SSA statements where `x` can escape to the caller via return
Expand Down Expand Up @@ -366,9 +366,9 @@ More interestingly, it is also valid to use `IPO EA` escape information for type
e.g., inference accuracy can be improved by forming `Const`/`PartialStruct`/`MustAlias` of mutable object.

```@docs
Core.Compiler.EscapeAnalysis.analyze_escapes
Core.Compiler.EscapeAnalysis.EscapeState
Core.Compiler.EscapeAnalysis.EscapeInfo
Base.Compiler.EscapeAnalysis.analyze_escapes
Base.Compiler.EscapeAnalysis.EscapeState
Base.Compiler.EscapeAnalysis.EscapeInfo
```

--------------------------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion stdlib/Compiler/src/Compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ else
# Needs to match UUID defined in Project.toml
ccall(:jl_set_module_uuid, Cvoid, (Any, NTuple{2, UInt64}), Compiler,
(0x807dbc54_b67e_4c79, 0x8afb_eafe4df6f2e1))
ccall(:jl_set_module_parent, Cvoid, (Any, Any), Compiler, Compiler)

# The interactive reflection utilities (`code_`, etc.) look for this symbol
# in Main and if present use that Compiler instead of the builtin one. By
Expand Down
3 changes: 3 additions & 0 deletions stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module REPLCompletions
export completions, shell_completions, bslash_completions, completion_text

using Core: Const
# We want to insulate the REPLCompletion module from any changes the user may
# make to the compiler, since it runs by default and the system becomes unusable
# if it breaks.
const CC = Base.Compiler
using Base.Meta
using Base: propertynames, something, IdSet
Expand Down

0 comments on commit ba34a49

Please sign in to comment.