|
1 | 1 | # Relocation model |
2 | 2 | # |
3 | 3 | # A relocation is a site => target pair. Targets are Julia object identities |
4 | | -# (`JuliaValueRef`, like codegen's identity-keyed `global_targets`) or named libjulia |
5 | | -# globals (`CGlobalRef`, like JuliaVariables). Every site names a word at a byte offset in a |
6 | | -# global. Dedicated sites use offset zero in a word-sized declaration (like |
7 | | -# `jl_sysimg_gvars`); other sites are inside defined globals (like |
8 | | -# `gctags_list`/`relocs_list`). Declarations can be baked, patched, or imported; sites in |
9 | | -# definitions can only be baked or patched. |
| 4 | +# (`JuliaValueRef`, like codegen's identity-keyed `global_targets`) or named |
| 5 | +# libjulia globals (`CGlobalRef`, like JuliaVariables). Every site names a word |
| 6 | +# at a byte offset in a global. Dedicated sites use offset zero in a word-sized |
| 7 | +# declaration (like `jl_sysimg_gvars`); other sites are inside defined globals |
| 8 | +# (like `gctags_list`/`relocs_list`). Declarations can be baked, patched, or |
| 9 | +# imported; sites in definitions can only be baked or patched. |
10 | 10 | # |
11 | 11 | # produce ──▶ merge (on link) ──▶ prune (after DCE) ──▶ lower (at emit_asm) |
12 | 12 | # |
13 | | -# Lowering strategy Loader contract Julia analog |
14 | | -# `bake_relocations!` none; current-session words baked JIT address folding |
15 | | -# `emit_patchable_relocations!` patch named globals after load sysimage gvars |
| 13 | +# Lowering strategy Loader contract Julia analog |
| 14 | +# ----------------- --------------- ------------ |
| 15 | +# `bake_relocations!` none; current-session words baked JIT address folding |
| 16 | +# `emit_patchable_relocations!` patch named globals after load sysimage gvars |
16 | 17 | # |
17 | 18 | # The producers are `collect_julia_value_relocations!` during IR generation and |
18 | | -# `collect_cglobal_relocations!` immediately before backend lowering. Names are globally |
19 | | -# unique and assigned once, so linking can merge IR and metadata without renaming. |
| 19 | +# `collect_cglobal_relocations!` immediately before backend lowering. Names are |
| 20 | +# globally unique and assigned once, so linking can merge IR and metadata |
| 21 | +# without renaming. |
20 | 22 | # |
21 | | -# Generated code is portable only when `supports_relocatable_ir()` and the backend preserves |
22 | | -# these relocations for its loader. The default lowering bakes current-session values. |
| 23 | +# Generated code is portable only when `supports_relocatable_ir()` and the |
| 24 | +# backend preserves these relocations for its loader. The default lowering bakes |
| 25 | +# current-session values. |
23 | 26 |
|
24 | | -## Targets |
| 27 | + |
| 28 | +## targets |
25 | 29 |
|
26 | 30 | """ |
27 | 31 | JuliaValueRef(value) |
@@ -79,7 +83,8 @@ function resolve_relocation_target(target::CGlobalRef) |
79 | 83 | return unsafe_load(address) |
80 | 84 | end |
81 | 85 |
|
82 | | -## The table |
| 86 | + |
| 87 | +## the table |
83 | 88 |
|
84 | 89 | """ |
85 | 90 | RelocationSite(name, offset) |
@@ -172,7 +177,8 @@ function foreach_relocation(f, mod::LLVM.Module, relocs::Relocations) |
172 | 177 | return |
173 | 178 | end |
174 | 179 |
|
175 | | -## Producers |
| 180 | + |
| 181 | +## producers |
176 | 182 |
|
177 | 183 | function collect_julia_value_relocations!(mod::LLVM.Module, |
178 | 184 | gv_to_value::Dict{String, Ptr{Cvoid}}) |
@@ -364,7 +370,8 @@ function has_unresolved_cglobal_loads(mod::LLVM.Module, relocs::Relocations) |
364 | 370 | return false |
365 | 371 | end |
366 | 372 |
|
367 | | -## Bookkeeping |
| 373 | + |
| 374 | +## bookkeeping |
368 | 375 |
|
369 | 376 | function link_relocatable!(dest_mod::LLVM.Module, dest_relocs::Relocations, |
370 | 377 | src_mod::LLVM.Module, src_relocs::Relocations; |
@@ -422,7 +429,8 @@ function prune_dead_relocations!(mod::LLVM.Module, relocs::Relocations) |
422 | 429 | return |
423 | 430 | end |
424 | 431 |
|
425 | | -## Lowering |
| 432 | + |
| 433 | +## lowering |
426 | 434 |
|
427 | 435 | """ |
428 | 436 | lower_relocations!(job, mod, relocs) |
@@ -487,7 +495,8 @@ function emit_patchable_relocations!(mod::LLVM.Module, relocs::Relocations) |
487 | 495 | return |
488 | 496 | end |
489 | 497 |
|
490 | | -## Introspection |
| 498 | + |
| 499 | +## introspection |
491 | 500 |
|
492 | 501 | function referenced_object(value, relocs::Relocations) |
493 | 502 | # This is best-effort: optimized shapes fall back to the unknown-binding error path. |
|
0 commit comments