Skip to content

Release 0.24.0 - #136

Merged
Mx-Iris merged 61 commits into
mainfrom
next
Oct 26, 2026
Merged

Mx-Iris merged 61 commits into
mainfrom
next

Conversation

@Mx-Iris

@Mx-Iris Mx-Iris commented Oct 26, 2026

Copy link
Copy Markdown
Member

Merges next into main for the 0.24.0 release: 61 commits ahead of main. The user-facing summary is Changelogs/0.24.0.md, which also becomes the GitHub Release body.

What ships

  • Swift 6.4 borrow / mutate accessors and ~Copyable associated types in dump and interface.
  • interface --requirements-on-associated-types and SwiftDeclarationPrintConfiguration.protocolRequirementPlacement; a protocol requirement whose right-hand side is an optional or generic type now prints as that type.
  • The new CrossReferenceAnalysis product: callers, callees and type references of functions in loaded arm64 images.
  • dump / interface --emit-private-source-files, and emitsPrivateDeclarationSourceFiles on DumpRequest and InterfaceRequest.
  • A reader conforming to MachOReaderWrapper (MachOKitExtensions 1.3.0) is read like the reader it wraps; reading a loaded image through a wrapper no longer crashes.
  • Offline layouts of builtin leaf types read from the binary: Float16, StaticBigInt, SIMD fields, UnownedJob, UnownedSerialExecutor, distributed actors with custom executors.
  • swift-capstone 7.

Breaking

  • AccessorKind gains .borrowAccessor and .mutateAccessor.
  • Requires swift-capstone 7.0.0 and MachOKitExtensions 1.3.0.
  • The deprecated reading forms stay until 0.25.0 instead of 0.24.0: MachOKitUI and swift-decompiler have not migrated yet.

Release checklist

  • Sources/Executables/swift-section/Version.swift = 0.24.0; both agent plugin manifests = 0.24.0
  • Changelogs/0.24.0.md present
  • Proposals 0070–0075 numbered and Implemented; evolution log sections 99–106 marked 0.24.0, section 107 for the release
  • Dependency floors: swift-capstone 7.0.0, MachOKitExtensions 1.3.0 (both tagged)
  • README and AGENTS.md now state the Swift 6.3 / Xcode 26.4 requirement the manifest has had since 0.22.0
  • Tag 0.24.0 after merge to trigger the release workflow

Verification (local, remote dependencies only, Xcode 26.6)

  • Full suite (swift test --skip IntegrationTests) on a git archive copy of ecd7a521, the code this release ships, with a fresh scratch: 2574 tests in 493 suites, raw exit code 0.
  • Release builds of swift-section for x86_64 and arm64: no compiler warnings, both run; the release commit's build reports 0.24.0.
  • Rendering A/B over the archived dyld caches (26.6, 15.5) and the iOS 15.5–26.5 simulator runtimes: 24c39555 → ecd7a521 is byte-identical over 72 pairs, and 0.23.0 → 24c39555 differs only in three protocol requirement headers, all fixed by the compound right-hand side change. 7adbe83c → ecd7a521 is also identical on the in-process MachOImage leg.
  • Claude Code plugin validation (the marketplace with --strict) passes; every flag the agent skill names appears in the CLI's --help.

Mx-Iris and others added 30 commits October 14, 2026 08:26
…achOFile

MachOKitUI hands the library MachOImageSource and MachOFileSource, types
wrapping a MachOImage and a MachOFile that forward every read. Viewing a
loaded image's Swift section crashed with "Negative value is not
representable" in SymbolicDemangler: the in-process check was a cast to
MachOContext<MachOImage>, the wrapper failed it, and the opaque type
descriptor's node value was stored as an offset -- negative for a
descriptor in an image mapped below the one being read -- and converted
to UInt64. Every other place asking which kind of reader it holds cast
the same way, 38 sites in 16 files, and quietly did worse for a wrapper:
symbols indexed on raw values, member addresses counted from the shared
region start, the three ObjC indexes empty, and a file wrapper that does
not forward MachOBindRebaseResolving read unresolved chained fixups and
crashed the interface printer.

A host now declares its wrapper with MachOKitExtensions 1.3.0's
MachOReaderWrapper, and every reader-kind question goes to asMachOImage,
asMachOFile or underlyingReader, which see through it:

- MachOContext.runtimePointer(at:) and bindRebaseResolver ask the reader
  beneath the wrapper.
- SymbolicDemangler stores an opaque descriptor's absolute address when
  the context can give a pointer in this process and its offset
  otherwise -- the predicate both readers of that node value use. An
  offset that does not fit UInt64 makes the reference unresolvable
  instead of trapping, for undeclared wrappers too.
- objcImplementationClassReader and swiftSectionReader fall back to the
  underlying reader. FieldLayoutRenderable forwards its seven static
  witnesses to Base, so an empty conformance puts a wrapper in the
  printers. DependentMemberProjection no longer casts its projection
  back to the caller's reader type, which dropped a wrapper's result.

APIs constrained to a concrete reader type at compile time
(GenericSpecializer, DependencyClosure) are unchanged: a host holding a
wrapper passes its base.

ReaderKindCastScanTests rejects a cast to MachOImage, MachOFile or a
MachOContext of either anywhere in Sources outside TestSupport. The
wrapped-reader demangling, interface and symbol tests drive declared and
undeclared ForwardingMachOReader wrappers; all four suites were red
before (two SIGTRAPs, a SIGSEGV, 276 symbol issues, the 38 casts) and
pass now. The full suite passes except the arm64e strip probe, which
fails intermittently and passes alone and on the baseline. The rendering
A/B over archived caches, simulator runtimes and in-process images is
byte-identical (96 pairs). Requires MachOKitExtensions 1.3.0.
Proposal: draft-wrapped-reader-recognition.
…ted types

A property, subscript or protocol requirement that declares only SE-0507
`borrow` / `mutate` accessors vanished from both the interface and the
dump: the symbol index filed only getter and setter symbols as members,
and `AccessorKind` knew get / set / read / modify. The `vb` / `vz`
symbols are now accessor symbols throughout (members, globals,
`isAccessor`), `AccessorKind` gains `.borrowAccessor` / `.mutateAccessor`,
`DefinitionBuilder` takes a `borrow` as the read accessor a declaration
prints from, and the accessor block prints `{ borrow mutate }`.

SE-0503's `associatedtype Element: ~Copyable` printed as a bare
`associatedtype Element`. The binary does not record that suppression;
`SuppressedAssociatedTypeInference` proves it from the image's own
extensions of the protocol (`where Self.Element: ~Copyable`), which only
a primary associated type can carry. The fact stays out of ABI
snapshots, since the evidence comes and goes with the extensions.

The new `AccessorKind` cases break an exhaustive switch downstream;
RuntimeViewer's `kindString` gets the two cases in the same batch. The
tests compile their own fixture with a Swift 6.4 toolchain and skip when
none is installed.

The work of 2026-10-10 was only ever staged and its worktree was later
deleted; it was recovered from an unreachable WIP commit plus three doc
edits replayed from the session transcript, then rebased onto 0.23.0
(`memberSubtree` in `DefinitionBuilder`, the async
`dumpInvertedProtocolsInheritance(resolver:)` from module selectors).

Verified with Xcode 26.6: the full suite (2450 tests) fails only the two
`MultiPayloadEnumDescriptorCacheTests` this machine has always failed;
the rendering A/B against next is byte-identical over 90 pairs; macOS
27.0's libswiftCore gains exactly two `: ~Swift.Copyable` lines.

Proposal: 0070-borrow-accessors-and-suppressed-associated-types.
New public product CrossReferenceAnalysis. A CrossReferenceAnalyzer takes a
snapshot of the current process's images - the whole dyld shared cache plus
the images loaded outside it - and reads, for any image, its functions
(LC_FUNCTION_STARTS and the symbol table) and what each one references:
calls and tail calls, Objective-C sends with the sending method's own
receiver recognized, super sends, calls through the image's own stubs or
through the stubs a macOS 27 / iOS 27 cache shares between all of its
images, and indirect calls with their table offset and pointer-
authentication constant. Functions without a symbol are scanned too; they
are half of a macOS 27.2 cache. A query for callers keeps only the
matching references, so a scan of the whole cache stays near 170 MB.

Decoding is by hand, 25 to 50 times faster than Capstone: every image of a
macOS 27.2 cache scans in about 1.6 seconds on 28 cores.

The trampoline shapes - GOT stub, stub island, cache-shared selector stub -
move into a new ARM64InstructionDecoding target, which SwiftThunkAnalysis
now uses in place of its Capstone-based recognition.

Evolution proposal cross-reference-analysis, batch one.
…g every image's table

A query for the callers of a hot selector touches thousands of images;
naming its results through function(containing:) would keep the
function table of each, which is what held 1.5 GB after a whole-cache
scan. functions(containing:) builds each image's table for the lookup and
drops it.
…side the shared cache

The cache builder rewrites the adrp / ldr of a selector reference into an
adrp / add of the selector string itself, so a classic objc_msgSend inside
the cache passes the string's address in x1 — macOS 27.2 compiles
-[NSObject debugDescription] to `adrp x8; add x1, x8; b _objc_msgSend`.
The scanner only took a selector loaded from __objc_selrefs, and reported
every such send as a plain call to objc_msgSend. It now also takes an
address built in x1, after checking that it is mapped and printable up to
its terminator.

Also adds the tests the prefilters lacked: until now they only asserted
that a prefilter keeps AppKit and drops most images, never that the images
it drops reference nothing. Three selectors and two exported functions are
now scanned in a sample of the images their prefilter drops.
…s unnamed

Half the function starts of a macOS 27.2 shared cache carry no symbol. A
function's name now comes, after the symbol table, from the export trie,
then the Objective-C method lists, then the Swift metadata:

- The export trie names 1.4 million of the cache's 8.2 million unnamed
  starts on its own: a cache image's symbol table need not hold its
  exported symbols (SiriAppIntents' holds two entries), and an iOS
  device's cache redacts the local ones while the export trie survives.
- Method lists name a class's, metaclass's and the image's own
  categories' methods (Matter's 30,863 otherwise unnamed methods).
- Swift metadata names type metadata accessors and singleton completion
  functions from their descriptor's Mn symbol, or from the descriptor
  through SymbolicDemangler, and vtable implementations from their method
  descriptor's Tq symbol. CodeFunction.Name.swiftMethod(descriptorAddress:)
  becomes .swiftMetadata(mangledName:), a full mangled name.

The names are read per image when a function is named, never during a
scan, each source only once the ones before it have no name. The analyzer
also reads the runtime libraries' export tries when it looks for
objc_msgSend and the runtime helpers.
…s branches

The scan read each function straight down, so where two paths join it
kept the values of whichever block came last. In
-[NSString stringByAppendingString:] one block puts the argument in x0,
the next puts self, and both branch to one copyWithZone: send: the scan
called its receiver self.

A forward branch now carries a snapshot of the registers to its target.
There the state is the snapshot when the instruction before was an
unconditional transfer, or what the snapshot and the fall-through agree
on otherwise. A loop header, and an instruction after a transfer no
branch targets, forget the caller-saved registers. The register file's
state is one fixed-size value (SIMD32 lanes), so a snapshot is a copy
without allocation, and the pending targets and loop headers are sorted
lists the scan steps through.

In AppKit's 804,357 references, 9,699 sends now correctly name self as
their receiver and 78 no longer claim it; selectors are unaffected.
Scanning every image of the cache takes 2.0 s in release instead of
1.6-1.8 s. Forgetting the caller-saved registers after every transfer,
tried first, lost correct receivers after early exits such as
+[NSObject instanceMethodForSelector:], and was dropped.
An instruction that takes a class object's address without branching is
now a reference of its own kind, `.reference`, to
`.objectiveCClass(name:location:)`. The macOS 27.2 cache all but dropped
`__objc_classrefs`: code takes its own image's class by `adrp` / `add`,
and loads classes from its own `__got` or from the GOT pool the cache
keeps outside every image. Any other slot that happens to hold a class
pointer — a constant string's `isa`, a global caching a class — is no
static reference.

A value is a class only when the image it lies in lists it: 92,000 Swift
classes and metaclasses sit in `__data`, not `__objc_data`.
`ObjectiveCClassIndex` reads `__objc_classlist` and each class's `isa`
directly; going through `MachOImage.objc.classes64`, which looks up the
load commands again for every class, made a scan of the whole cache take
4.9 s instead of 2.0 s. A class's name is read only once a reference to
it is reported. The target carries the class object's location as well
as its name, because 18,906 of the cache's 203,621 class names are
defined by more than one image, mostly Mac Catalyst variants; table keys
stay by name.

Sends now name a class-literal receiver, also across `objc_opt_self`,
`objc_opt_class` and `swift_getInitializedObjCClass`, which return the
class they are handed — 478 of SwiftUI's 665 such receivers come through
`objc_opt_self`. A super send names the class its method loads from
`__objc_superrefs`, which covers category methods, class methods and
methods without a symbol, and falls back to the method symbol; Swift code
builds its `objc_super` from a run-time class and gets none.

`imageIndices(referencingObjectiveCClassAt:among:)` keeps the defining
image and every image importing any symbol at the class or metaclass
address: 4% of cross-image class references go through an alias such as
`__NSConcreteStackBlock` or `__xpc_type_dictionary`, not
`_OBJC_CLASS_$_<name>`.

Scanning every image of the cache takes 2.40 s instead of 2.03 s, with
3.26 million more references.
A Swift type is referenced three ways, each reported as a `.reference`:
a call to its metadata accessor (besides the call itself), the address
of the accessor or of its metadata taken with `adrp` / `add` or loaded
from a GOT slot, and a mangled name instantiated through the image's
`__swift_instantiateConcreteTypeFromMangledName…` helper or the
runtime's `swift_getTypeByMangledName…`. On macOS 27.2 the helpers are
the V2 form, which take the name's `{ offset, length }` record in `x1`;
one without a symbol is told by its shape. A name is recorded where it
lies, as `.swiftTypeName(.mangledName(location:length:))`, and not
demangled while scanning.

Tables file type references by where the type's context descriptor
lies, not by key: building a key takes demangling, and the context a
descriptor demangles to spells some types differently from their
symbols — a type in a constrained extension carries the extension's
requirements, and a private type in an extension of another module's
type loses itself (Foundation's `Mutex<…>.LockResult` came out as
`15Synchronization5MutexV`). Keys come from the descriptor's `…Mn`
symbol instead, and accessor calls now name the type their accessor's
symbol names in every case checked (SwiftUICore 15,432, SwiftUI 63,487).

`references(toSwiftType:inImageAt:)` compares descriptor locations and
the symbolic references inside names; only the standard library's and
imported types, which names may spell out, take demangling. That every
other type appears in names as a symbolic reference was checked by
demangling every name of Foundation, SwiftData, libswift_Concurrency
and SwiftUI. Types of the same key in the macOS and the Mac Catalyst
variant stay apart.

Writing the type prefilter's soundness test showed that the macOS 27.2
cache keeps no Swift symbol among its images' undefined symbols:
SharedWithYou calls `URL`'s accessor through a GOT stub the cache
builder bound, and imports nothing for it. The first batch's prefilter
by imported symbols therefore dropped every caller of a Swift function
outside its own image; it had only been tested with C functions.
Swift symbols now go by linkage — the images linking the defining
image, directly or through a re-export — in the new
`imageIndices(linkingImageAt:among:)` and
`imageIndices(callingFunctionAt:symbolNames:among:)`, and in the type
prefilter and the class prefilter of a Swift class.
`swiftFunctionPrefilterKeepsEveryCaller` fails with the prefilter by
imports.

Two slowdowns came up on the way. Building a reference in the argument
list of a non-mutating call on the scanner made Swift copy the whole
scanner, memo dictionaries included, on every call: a scan of the cache
took 95 s. And fetching type indexes from the analyzer under its lock
kept threads waiting; the scanner keeps the indexes it asked for in a
reference of its own now. A query for the callers of a selector or a
function finds no class or type references at all. Scanning every
image of the cache takes 3.0 s instead of 2.1 s with 126 million
references instead of 116 million; the callers of `init`, 1.8 s
instead of 1.6 s.
…t imports

The previous commit said the macOS 27.2 shared cache keeps no Swift
symbol among its images' undefined symbols. It keeps some: 245 of the
cache's 4,113 images do (the libswift dylibs, Foundation, CoreData,
AXCoreUtilities among them), and 44 images import `URL.path` by name.
The rest bind Swift symbols with nothing left in their symbol tables,
so a prefilter by imports found the 44 and dropped every other caller,
which is what the linkage prefilter fixes. Comments and documents now
say so.
swift-capstone 7.0 replaces the Capstone class and the AArch64Instruction
class hierarchy with Disassembler<AArch64> and drops the old API outright;
its rewrite proposal migrates this package and swift-decompiler in the same
batch. CapstoneThunkDecoder is the only file that knows Capstone, and its
decode / decodeFunction signatures stay as they were. The dependency floor
moves from 6.0.1 to 7.0.0.

- Each instruction is converted to a ThunkInstruction inside
  forEachInstruction, so nothing of Capstone's outlives the call.
- Aliases are read from alias (.aliasMov, .aliasCmp) instead of pairing the
  identifier with the mnemonic string.
- Write-back is writesBackBaseRegister instead of isPostIndex or a "]!" in
  the operands text; isPostIndex is no longer optional.

The public API is unchanged, but a package that also depends on
swift-capstone 6 directly no longer resolves alongside this one.

Before the release, against the local swift-capstone branch through swift
package edit: the 82 thunk analysis tests, the 52 tests of the five suites
that reach the decoder, and the full swift test --skip IntegrationTests run
pass. After it, in a fresh build directory with swift-capstone resolved from
the remote at 7.0.0 and capstone at 6.0.101, the full run passes again: 2450
tests in 470 suites. Raw exit codes 0 throughout.

Proposal: 0071-swift-capstone-7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rites

The scanner forgets the registers an instruction it does not model
writes, and missed several kinds of write: a pre- or post-indexed load
or store moves its base (a vector register's as much as a general one's,
and the old code returned early for vector registers); an atomic without
ordering (`ldadd`, `swp`) encodes like a store yet returns the old value;
`ldxp` writes a second register and `casp` writes `Rs` and `Rs+1`;
`umov` / `smov`, floating point to fixed point, the SVE and SME
instructions that yield a general register, `sysl`, and `svc`, whose
result is in `x0` and `x1`. A stale base would make a later load read
the slot the base no longer points at.

The decision is now a pure function, `registersWritten(by:)`, returning
a mask by the A64 load/store groups; the XPAC comment says what the code
does (it is forgotten, which is only conservative).

`RegisterFileTests` checks 48 assembler-encoded instructions, cross-checked
against Capstone's register-access lists, and that a plain load or store
forgets only what it loads. 34 cases failed before this change.
`ThunkRegisterTracker` kept the base of a pre- or post-indexed `ldp` /
`stp`, and `ThunkTypeEvaluator` forgot it only when the base was the
stack pointer. Thunks write back only through `sp`, so neither showed;
found while sweeping for the register-write gap fixed in the cross-
reference scanner.

`ThunkRegisterTrackerTests.aWriteBackPairForgetsItsBase` and
`ThunkTypeEvaluatorTests.aWriteBackPairMovesItsBase` (both halves) failed
before this change.
… dyld loaded them

`imagePaths` held each image's install name (`MachOImage.path`). An
app's main executable and its bundles have none, so their path was the
empty string, and its frameworks have an `@rpath/...` one: a host that
knows these images by their file path (RuntimeViewer does) could not
find them, and the results it got back named no file.

An image outside the cache now goes by the path `dladdr` reads off its
header; a cache image keeps its install name. A table from install name
to every image with it resolves load commands, so two copies of one
framework both count, and `imageIndex(forPath:)` falls back to it. A
bundle linked with `-bundle_loader` binds to the main executable through
no load command, so every bundle counts as linking every executable.

`StandaloneImageTests` gains three tests (the fixture framework goes by
its loaded path, the test bundle goes by its `dladdr` path, the bundle
links the executable); all three failed before this change.
…ort a function under

A callers prefilter compared a C function's own names with other images'
imports. An image that re-exports it under a name of its own makes its
callers import that name instead: libsystem_c exports libsystem_platform's
`__platform_strlen` as `_strlen`, CoreGraphics exports 1,112 of SkyLight's
`_SL...` functions as `_CG...` (AppKit imports 273 of them by those
names), UIFoundation exports CoreText's `CTEmojiImageAsset` class as
`NSEmojiImageAsset`. The macOS 27.2 cache holds 1,438 such re-exports in
12 images, and the prefilter dropped every caller that used them.

`RenamedReexportIndex` walks every image's export trie once, on first
use, keeping only the renamed re-exports (a name is spelled out only when
one matches). `reexportedNames(ofSymbolsNamed:inImageAt:)` follows a name
renamed again and a re-export through an umbrella that re-exports the
image whole; the function and class prefilters look for those names too.

`RenamedReexportTests`: the prefilters keep AppKit for `__platform_strlen`
and `_SLSMainConnectionID` (which AppKit does call) and CharacterPicker
for `CTEmojiImageAsset`; all three failed before this change.
…query alone

`swiftTypeKeys(in:)` and `SwiftTypeIndex.key(ofDescriptorAt:)` demangled
with `demangleAsNode`, which interns every tree in the shared `NodeCache`,
and a mangled name went through `SymbolicDemangler.demangleType(for:in:)`
with the in-process context, which memoizes it for the process. Neither
is ever evicted, and nothing bounds the names a type query meets, so a
long-lived engine process grew with every query. AGENTS.md forbids
`demangleAsNode` on unbounded inputs.

Both now use the transient forms (`demangleAsNodeTransient`,
`demangleTypeUncached`); the per-image `demangleContext` memo, which an
image's eviction drops, stays.

`TypeNameRetentionTests` queries names no other code spells (random
identifiers, and a type only this test declares) and checks they left no
leaf in `NodeCache` and nothing in the process memo, through a new
package-level probe `SymbolicDemangler.processScopedMemoHoldsType(for:)`
alongside the existing `cacheExists(for:)`. All three failed before this
change, each on its retention check alone.
…before it ships

- `CodeReferenceTable.keys` returns `some Collection<Key>` instead of
  `Dictionary<Key, [Int32]>.Keys`, which exposed the storage.
- `swiftTypeDescriptorLocations(withKey:inImageAt:)` promised "one
  location, or none"; that holds when the type's `...Mn` symbol settles
  it, while the fallback returns every descriptor with the key, in no
  particular order. The documentation now says so.
- `approximateByteCount` says it leaves out the strings' heap storage,
  which the references to one name from one scan share.
… claim to

- `callSitesMatchCapstone` only checked that the scan found every call
  Capstone found, while its comment said "and nothing more". It now
  checks both ways (a `br`, which Capstone cannot tell from a jump-table
  jump, is allowed), and that it compared more than one branch out.
- `superSendsNameTheClassOfTheirMethod` could not tell a class read from
  `__objc_superrefs` from the method symbol's, which the scanner falls
  back on. `superSendsInBlocksNameTheClassOfTheirMethod` checks super
  sends in blocks, whose symbols are no method names; with the slot
  reading removed it fails while the older test still passes.
- The comments of the type-name query test and `FallbackNamingTests` say
  what they actually pin: the standard library types compare with the
  same demangling the query falls back on, and the images were picked for
  what macOS 27.2 strips.
… it changed

- Roadmaps/2026-10-17-cross-reference-analysis-review-findings.md: every
  finding with its four answers, reproduction, fix and test, and the
  measurements behind the open decision on loop headers (A5).
- ReviewAdjudications A62-A67: per-analyzer caches without `SharedCache`,
  images unloaded during an analyzer's life, the cache's direct stubs
  (deferred: not reproducible on macOS 27.2), `bc.cond` and the shared
  selector stub check, the pending-target insertion cost (measured), and
  tests that pin macOS 27.2 code.
- AGENTS.md and the module reference: the scan uses class lists and type
  descriptors, takes two to three seconds over the whole cache, reports
  class and type references; images outside the cache go by their loaded
  path; what the analyzer keeps for its lifetime; renamed re-exports;
  which instructions write which registers; the known limitation at loop
  headers.
- The proposal: a review section, decision-log rows, and notes where the
  plan was revised; its two sets of AppKit probe numbers are told apart.
…g as a known limitation

At a loop header, and at a jump-table target nothing branches to, the
scanner forgets x0-x18 but keeps x19-x28 from the block before it. The
review (A5) measured the alternatives: rescanning functions with loops
until the back-edge state stops changing differs from the current
behaviour in 0.04% of the references in six large images and 0.02% in a
257-image sample, at 42% and 61% more scan time; forgetting every
register at a loop header loses about 39,000 correct facts. Kept as is
and recorded as ReviewAdjudications A68, with what would reopen it.
…rences in its own image alone

`imageIndices(referencingSwiftType:among:)` kept every image that can
bind to the image defining the type, whatever the type: a Type
References query on AppKit's internal `NSSmartNamingSuggestion` scanned
every image linking AppKit, most of the cache, minutes in a Debug build
with every core busy.

Another image reaches a type through a symbol of it - its descriptor
(`...Mn`), its metadata accessor (`...Ma`), its metadata (`...N`) - or by
spelling its name, which another module cannot do for an internal type.
So when the defining image exports none of the three, only that image is
kept; the class prefilter's own linkage step is left out the same way
(`includingSwiftLinkage`). The export trie is read into a set per image on
first need (`exportedSymbolNames(ofImageAt:)`). Public types export all
three (checked for `URL`, `SwiftUI.Text`, `JSONEncoder`), and the tests
that no referencing image is dropped for them still pass.

`typesNoImageExportsAreLookedForInTheirOwnImage` failed before; it also
scans every sixty-fourth image linking AppKit to confirm none references
the type. Swift functions need no such change: a cache image's functions
that are not exported have no symbol name in process, so their callers
were never widened by linkage.
…le a host can keep per image

RuntimeViewer now reads the cross references of every indexed image ahead
of the queries and keeps them, so its queries answer without scanning. A
CodeReferenceTable costs about 80 bytes a reference - AppKit's 67 MiB on
macOS 27.2 - too much to keep for each open image.

`referenceIndex(ofImageAt:)` scans the image once and files what a query
for callers or for a type's references reads: calls and tail calls,
sends, imported names, class and Swift type references. Each name is
stored once and the referencing function and instruction as 32-bit
offsets into `__text`; indirect calls and branches into no image are left
out. AppKit's index takes 21 MiB, Foundation's 9 (34 as a table),
SwiftUICore's 9 (35), libswiftCore's 1 (7).

`index.references(to:)` and `references(toSwiftType:in:)` answer exactly
what `references(to:inImageAt:)` and `references(toSwiftType:inImageAt:)`
scan for, in the same order. Building an index keeps the image's function
table, which naming the answers needs; `keepFunctionTable(ofImageAt:)`
lets a replacement analyzer keep it again. A progress closure reports
every 2,048 functions and can stop the scan.

CodeReferenceIndexTests: every key of Foundation's table against the
index, a multi-key AppKit query and three Swift types (URL, JSONEncoder,
Array) against the scans, the size, the function table, progress and
stopping. Docs: the module reference, AGENTS.md and a decision-log row.
…ery reads

A host that keeps an image's CodeReferenceIndex still saw its first query
about the image wait: the query read the names it shows results by, and
a query across many images read the prefilters' tables. In a debug build
the names took AppKit 0.29 s, building every Swift type's key to look one
up took it 0.69 s, the renamed re-exports 3.4 s on all 28 cores.

What can go unread now does:
- A type looked up by key has the keys built of the types its descriptor
  names alike only, about 1 ms. A type imported from C under another
  Swift name keeps that C name, which its key spells, in the import info
  after its name; both are compared.
- Whether an image exports a type's symbols is looked up in its export
  trie instead of reading the whole trie into a kept set (6 MiB for
  SwiftUICore).

What cannot, the host reads ahead:
- prepareNames(inImageAt:) reads the three fallback name sources, the
  class names and the type symbols, and keeps the function table.
- preparePrefilters() reads the linkage and the renamed re-exports on the
  calling thread alone: in parallel it is barely faster (3.4 s against
  3.9), and background work should not take every core. A query asking
  meanwhile waits for it instead of reading the tries again.
- approximateByteCount(ofImageDataAt:) estimates what the analyzer keeps
  for an image, within about a tenth of malloc's figure; AppKit's is
  14 MiB beside its 21 MiB index.
- releaseImageData(exceptForImagesAt:) drops the other images' data and
  keeps what was read ahead, which replacing the analyzer would discard.

The equivalence tests compare the new lookups with the old ones for every
type of Foundation and AppKit; the first version of the name filter left
115 imported types unfound there.
The library half of RuntimeViewer's cross references lands in next on the
day RuntimeViewer's engine and interface land in its own next as 0056; its
CLI and MCP front ends are still to come and need nothing more from here.

- The proposal is numbered 0072 and Implemented. The "not done" items of
  each batch are gathered in a new follow-up section, with RuntimeViewer's
  measurement of how much is still unnamed: 37.8% of macOS 26.7's function
  starts have no symbol, and protocol and value witnesses - 11-18% and
  4-13% of the functions in fully named Swift images - are what witness
  tables could still name.
- The evolution log's two sections are numbered 101 and 102, after next's
  100; the second, opened as in progress, now records the review's fixes
  and the preparation API a host reads ahead with.
- Every link to the proposal, and to RuntimeViewer's, follows the numbers.
  The module note stays the implementation note; no usage guide, since
  RuntimeViewer is the only user and the contract is in that note.
# Conflicts:
#	Documentations/Evolutions/README.md
#	Documentations/Internal/ProjectEvolutionLog.md
#	Documentations/README.md
Merging next brought swift-capstone 7.0, which drops the Capstone class
outright. The three tests that hold the hand decoder against Capstone -
the AppKit call-site comparison, the written-register check and the
encoders' agreement - move to Disassembler<AArch64> as its migration guide
maps them: decode(_:address:) for disassemble(code:address:), identifier
for instruction, registersWritten and implicitRegistersWritten for the
access lists. Details are always on in version 7, so the option goes.
…he leaf fallback with the binary

libswiftCore's __swift5_builtin section records every Builtin.* leaf type
(the compiler collects them only while compiling the standard library),
but BuiltinTypeLayoutIndex keyed those records by their raw mangling
(`Bi1_`) while the resolver looks a builtin up by its demangled name
(`Builtin.Int1`), so none was ever used and every leaf came from the
hard-coded fallback. Key them by the builtin name.

Align the fallback with the binary and IRGen: Builtin.Int1 has 254 extra
inhabitants, not 0; Builtin.RawUnsafeContinuation saturates like a managed
reference (an aligned, never-null task pointer) instead of reserving only
null; add Builtin.FPIEEE16, Builtin.Job, Builtin.Executor and
Builtin.NonDefaultDistributedActorStorage, which _Concurrency and
distributed actors declare fields of but no image records.

StandardLibraryLeafLayoutTests pins libswiftCore's leaf records, the
fallback against those records and against live value-witness tables, and
every KnownLayoutTable entry against what libswiftCore's own metadata
computes. The suite joins the CI filter.
…ts verification

The proposal marks its four landing steps done and the implementation
ready to merge. ProjectEvolutionLog gains a section (numbered when it
lands): the placement rule and where it departs from the compiler's, the
composite right-hand side fix and its one real hit in SwiftUICore
(`Self.PropertyValue == Self.NonOptionalPropertyValue?` had lost its
`?`), and how it was verified -- mutation checks, byte-for-byte
interfaces of five host images against the CLI before the change, and a
full suite whose only reds are this machine's known ones plus two test
bundles that crash on the base commit too.
…s it

The review of the protocol-requirement-placement branch found that the
doc comment on ProtocolRequirementPlacement.associatedTypes promised more
than the partition does: "any other requirement mentioning Self.Item goes
into its where clause". A conformance, superclass or layout requirement
goes by its subject alone, as the proposal says and as the compiler's own
printer places it, so a superclass requirement on a refined protocol's
Element stays on the protocol even when its superclass names one of the
protocol's own associated types. The evolution log's first key decision
said the same broader thing.

- The doc comment and the log now state the rule per requirement kind.
- The fixture gains SubjectOnlyRequirements (a Sequence refinement where
  Element: GenericBase<First>), and the placement table expects that
  requirement in the protocol's header, where Swift 6.3.3's
  -emit-module-interface prints it too. The parameterized tests over the
  fixture's protocols - the bare default, the recompiled requirement
  signatures, the diff header - cover it as well.
A /code-review high pass over PR #135 raised eight findings. One was real
and is fixed in the previous commit: the configuration's doc comment
stated the placement rule more broadly than the partition applies it.
The other seven are adjudicated A69-A75:

- A69: the two new suites in CI's filter had been run only with Swift 6.4.
  Run with CI's Xcode 26.6 and freshly resolved remote dependencies, all
  45 tests of the four suites the branch touches pass, before and after
  the fix (debug only).
- A70: the SwiftDumpConformance placeholder is unreachable; the compiler
  never emits a same-conformance requirement.
- A71, A72: one more associated-type name read per protocol and a memo-hit
  second demangle on the opt-in path, both negligible.
- A73: the fixture compile helper is the 42nd copy of its kind, a refactor
  of its own; 25 of the 41 copies on next still lack a pinned language
  mode.
- A74, A75: the parallel inheritance-clause loops and the diff header's
  fixed placement are deliberate.

Roadmaps/2026-10-21-pr135-review-findings.md keeps each finding's four
answers and the verification: a mutation of the partition that reads a
superclass's right-hand side turns exactly the new case red, and Swift
6.3.3's -emit-module-interface places that requirement as the test
expects.
The option to print protocol requirements on their associated types, and
the fix for composite right-hand sides, land in next after the review.

- The proposal is numbered 0073, after next's 0072, and Implemented; its
  decision log records the review and the landing, and its fixture list
  the subject-only case the review added.
- The evolution log's section is numbered 104, after next's 103. Its
  verification now includes the review and the runs with CI's Xcode 26.6
  that the offline build had left out.
- Every link to the proposal follows the number, and the documentation
  index gains its row. No usage guide: the CLI's --help and the agent
  plugin's skill describe the flag, and the proposal and the partition's
  doc comment are the implementation note. No new glossary terms.
A package function is no candidate for the compiler's default
cross-module optimization - outside library evolution only public
linkage is - so the three `align(to: 4)` calls in MachOSwiftSection's
generic-context and protocol readers stayed unspecialized generic calls
into Utilities even in release builds: about 200 instructions and 14
witness-table calls each, for what inlines to two instructions.

`@inline(always)` (SE-0496, Swift 6.3, the package's tools version)
implies `@inlinable` on a package function and inlines in debug builds
too. The attributes were commented out in 8dcd273 by a repository-wide
sweep of every `@inlinable`, not because of a crash in these helpers.
With them back the full suite (2532 tests) passes in debug; in release
only the five SpecializedRuntimeTypeNameTests fail, whose private
fixture types a release build strips from the test binary.
AppleDB has no macOS 11.0 or 12.0 image, only 11.0.1 and 12.0.1, so
those are the directories the volume holds, and the evolution suite's
version axis copied the directory names into its labels: a declaration
first seen in 12.0.1 printed as `@available(macOS, introduced: 12.0.1)`.
ArchivedDyldCacheTests now labels those two caches 11.0 and 12.0, the
versions an SDK's `@available` attributes name; `cacheVersions` still
lists the directories, and DyldSharedCachePath and the other suites are
untouched. Proposal 0061's decision log and section 80 of the evolution
log record the follow-up.
Evolution and diff tell a declaration that is absent from a version apart from one that version cannot show. SwiftUI in the macOS 13.0-14.8 dyld shared caches carries no local Swift symbols, so every non-exported member reads as removed in 13.0 and added again in 15.0. Snapshots record whether an image keeps its local Swift symbols and whether each member is exported; a gap bounded by the same observed state on both sides is inferred and marked, and one bounded by different states becomes a range event.
The source-file recovery behind RuntimeViewer's Private tag has lived in SwiftPrivateDiscriminators since the private-declarations proposal, but nothing in this package uses it: dump prints a private declaration's discriminator and never the file it was derived from, and interface prints neither, so two same-named private types from different files print identical headers. A new opt-in flag, --emit-private-source-files on both subcommands, adds a comment above every declaration whose name brings a discriminator its enclosing declaration does not carry, naming the source file the discriminator was derived from, or saying it could not be recovered. The whole image is searched once before printing; the candidates and the search itself are unchanged.
… a seam

Dump and interface sit below SwiftPrivateDiscriminators, so they ask for a private discriminator's source file through PrivateDeclarationSourceFileProviding, which PrivateDiscriminatorSourceFileIndex adopts. PrivateDeclarationSourceFileComments words the lines both outputs print: one per discriminator a name reads that the declaration it is printed inside does not, naming the last declaration read with it, the hashed module when the declaration prints under another, a synthesized file, or that nothing recovered it - with the discriminator, which the interface prints nowhere else. DeclarationRenderConfiguration carries the provider for the dump.

The index's recoverSourceFiles(ofEveryDeclarationIn:) searches once for every discriminator an indexed image declares something with - the names it reads anyway, and its member and global symbols - so that asking for each declaration afterwards is a lookup: asked one at a time, every discriminator nothing recovers would run through all the candidates on its own.

The result type is a new one rather than PrivateDiscriminatorSourceFiles.SourceFile moved down behind a typealias: RuntimeViewerCore builds with MemberImportVisibility, under which reading the moved type's members could take an import it does not have.
…it-private-source-files

With DumpRequest.emitsPrivateDeclarationSourceFiles (CLI dump --emit-private-source-files, off by default), every type, protocol, conformance and associated-type header whose name reads a private discriminator is printed under a comment naming the source file the discriminator was derived from, or saying it could not be recovered - and so is every member line of a struct, enum or class, vtable methods included, and every default implementation of a protocol, that reads one its enclosing declaration does not. Members of a private type repeat nothing: they are declared in its file.

dump has no indexer of its own, so the request builds one for the candidates, the same ones interface reads, and searches every discriminator the image declares once before the first declaration prints. The indexer lives until the dump is done: its last release evicts the caches its prepare built, the symbol index every member line is read from among them. With the option off nothing is indexed and the output is byte-identical.
… --emit-private-source-files

With InterfaceRequest.emitsPrivateDeclarationSourceFiles (CLI interface --emit-private-source-files, off by default), the interface prints the same comments as the dump: above every type, protocol and extension header, every member and every global whose name reads a private discriminator the declaration it is printed inside does not. The interface prints no discriminator anywhere, so two same-named private types from different files - which printed identical headers - now read apart, and an unrecovered file is named by its discriminator.

The printer takes the provider through setPrivateDeclarationSourceFileProvider(_:), the way it takes type-name resolvers, and leaves its Equatable configuration alone; the request installs the index after prepare(), every discriminator of the image already searched. A nested type or protocol is measured against the parent it prints inside rather than its name's own context: a local type's context is the function declaring it, which prints nowhere above it.
…ainst its parent at any level

A nested type or protocol left out its parent's discriminators only when printed below the top level, so printed on its own it gained a line it did not have inside its parent's print. RuntimeViewer takes nested definitions out of their parent's print (marksNestedDefinitions) and relies on each reading exactly as its own print, so the comparison is now always against the definition's parent. NestedDefinitionRegionContractTests gains a variant with the source-file comments on, over both readers.
… private members

An Objective-C class reads no private discriminator, so a private Swift member of its @implementation body names its own source file under --emit-private-source-files, the way a public Swift type's private member does.
README, the agent plugin's CLI skill and the module references of SwiftPrivateDiscriminators, SwiftSectionKit and SwiftInterface describe the new flag: what the comment says, which declarations carry one, why dump indexes the image when it is on and keeps the indexer until the dump is done, and what it costs. On macOS 27.2 with a release build, SwiftUI's dump goes from 12 s to 58 s and its interface from 20 s to 61 s, nearly all of it the search for the 167 discriminators nothing recovers; Foundation's interface barely moves.

The proposal and a dated ledger section record the decisions taken during implementation and the verification: the full suite (2565 tests) passes, and with the flag off the rendering A/B over the archived 26.6 and 15.5 caches and the iOS 15.5, 18.5 and 26.5 simulator runtimes is byte-identical on all 54 pairs. The two new suites join the CI filter.
Numbers the evolution log's section 105 and updates both indexes; the previous commit carried only the rename.
…he cache maps SwiftUICore below it

WrappedReaderDemanglingTests required at least one of SwiftUI's witnesses to reach an opaque type in an image mapped below SwiftUI. That holds on macOS 27, whose dyld shared cache places SwiftUICore below SwiftUI, but macOS 15 and 26 place it above (26.6: SwiftUICore at 0x22d953000, SwiftUI at 0x1b594e000), so the declared-wrapper test failed on every macOS 26 host. CI does not run the suite, which is why nothing caught it.

The declared-wrapper comparison now runs everywhere and requires at least one opaque type reference, the node an unrecognized wrapper recorded as an offset instead of an address. The reference below SwiftUI becomes the precondition of the undeclared-wrapper test, which runs only where the loaded cache's image list maps SwiftUICore below SwiftUI. Both tests pass on macOS 27.2, the second one not skipped.
# Conflicts:
#	Documentations/Evolutions/README.md
#	Documentations/README.md
ReaderKindCastScanTests reads only the package's sources and WrappedReaderInterfaceTests only the SymbolTestsCore fixture, so both meet the CI filter's rule of depending on nothing a development machine has and a runner lacks. The other two wrapped-reader suites stay local: WrappedReaderSymbolTests reads the system dyld cache and WrappedReaderDemanglingTests loads SwiftUI into the process.
Renames the draft, marks it Implemented and points every link at the new path; numbers the evolution log's section 106. The proposal and the section record what changed on the way in: the pre-merge check that found WrappedReaderDemanglingTests tied to macOS 27's cache layout and split it, the two suites added to the CI filter, the release of MachOKitExtensions 1.3.0, and the landing verification on the final tree (next@7adbe83c merged in): the full suite passes, 2574 tests with exit code 0, and the rendering A/B against next@7adbe83c is byte-identical on all 96 pairs across the archived 15.5 and 26.6 caches, five iOS simulator runtimes and in-process images. The fix ships with the release after 0.23.0, which it missed while waiting for MachOKitExtensions. The per-pointer cost of the widened bindRebaseResolver on in-process images is recorded as a follow-up to measure.
0.23.0 moved their removal to 0.24.0, with the downstream repositories migrated first. MachOKitUI (main db0d03d, from: "0.19.0", so it resolves 0.24.0 on its own) and swift-decompiler (main 0e186ec, tracking next) still call them, and removing them now would break both on their next resolution. The forwarders stay for one more release: AGENTS.md, the glossary, the implementation note and the index say 0.25.0, and 0057 records the decision.
…ad since 0.22.0

26c9012 raised swift-tools-version to 6.3 on 2026-09-29, so 0.22.0 and 0.23.0 already need a Swift 6.3 toolchain (Xcode 26.4, the release workflow's), while the README and AGENTS.md still said Swift 6.2 / Xcode 26.0. The README also promised the MetadataReader alias for one release only; it is still there four releases later, so it no longer names an end.
Bumps BundledVersion and both agent plugin manifests to 0.24.0, adds Changelogs/0.24.0.md in the one-sentence-per-entry style, points the README's package snippet at 0.24.0 and lists the CrossReferenceAnalysis and SwiftPrivateDiscriminators products, which the README's tables never named. The agent skill dates interface --requirements-on-associated-types and --emit-private-source-files to 0.24.0.

The evolution log marks sections 99-106 as 0.24.0 and gains section 107 for the release. Verification on Xcode 26.6 with remote dependencies only (MachOKit 0.54.101, MachOKitExtensions 1.3.0, MachOObjCSection 0.8.200, swift-demangling 0.7.2, swift-semantic-string 0.5.0, swift-capstone 7.0.0): on ecd7a52, the code this release ships, the full suite passed with 2574 tests in 493 suites, release builds for x86_64 and arm64 have no compiler warnings and both run, and the rendering A/B against 24c3955 is byte-identical over 72 pairs; against 0.23.0 the only differences are the three protocol requirements section 104 fixed. Claude Code plugin validation passes.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 14:56
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-26T14:56:13.758504Z 4746219 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@Mx-Iris
Mx-Iris merged commit 5290a90 into main Oct 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants