Add DyldCache.locateValue for cache hierarchy lookup - #297
Open
p-x9 wants to merge 1 commit into
Open
Conversation
Introduce `@_spi(Support)` helpers that resolve a value across the receiver, its `mainCache`, and the main cache's subcaches in order, deduplicating by header UUID. Provides both a KeyPath overload for non-throwing optional properties and a `rethrows` closure overload for throwing or computed lookups (e.g. `symbolCache`). Returns a `LocatedValue<Value>` that pairs the resolved value with the cache it came from, since offsets contained in the value must be interpreted against that cache.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DyldCache.locateValue(_:)(@_spi(Support) public) that resolves a value by walking the receiver →mainCache→ main cache's subcaches in order, deduplicating by header UUID.KeyPath<DyldCache, Value?>form for plain optional properties and arethrowsclosure form for throwing / computed lookups (e.g.symbolCache).LocatedValue<Value>struct pairing the resolved value with the cache that produced it — needed because offsets inside the value must be interpreted against that cache.Notes
@inline(__always)is applied to the thin KeyPath overload and the private_resolvehelper so the resolver closure specializes; the closure-form body itself is left as-is since cost is dominated bysubcache(for:)I/O.@_spi(Support)for now to keep flexibility before committing to a fully public API. Symmetric variants onDyldCacheLoaded/FullDyldCacheare intentionally deferred.LocatedValuewhen looking up repeatedly.Test plan
swift buildDyldCachePrintTestsagainst a local dyld cache (optional, follow-up)