-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closure metadata #2274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closure metadata #2274
Conversation
@swift-ci Please test |
|
Yeah, looks like this function has witness method convention and the fulfillment isn't from a class pointer, metadata or l-value metadata. I'll fix it up in the morning. Maybe we'll want to add metadata sources for self and self's witness table for completeness. |
Create a builder divorced from the ReflectionContext so that MetadataSources can be created in other contexts, such as emitting private heap metadata during IRGen, where we'll have to record the layout of captures and how to get metadata for generic arguments in order to construct typerefs of the captures, etc. Add Parent, Metadata capture, and Impossible metadata sources.
Now we can discern the types of values in heap boxes at runtime! Closure reference captures are a common way of creating reference cycles, so this provides some basic infrastructure for detecting those someday. A closure capture descriptor has the following: - The number of captures. - The number of sources of metadata reachable from the closure. This is important for substituting generics at runtime since we can't know precisely what will get captured until we observe a closure. - The number of types in the NecessaryBindings structure. This is a holding tank in a closure for sources of metadata that can't be gotten from the captured values themselves. - The metadata source map, a list of pairs, for each source of metadata for every generic argument needed to perform substitution at runtime. Key: The typeref for the generic parameter visible from the closure in the Swift source. Value: The metadata source, which describes how to crawl the heap from the closure to get to the metadata for that generic argument. - A list of typerefs for the captured values themselves. Follow-up: IRGen tests for various capture scenarios, which will include MetadataSource encoding tests. rdar://problem/24989531
These can show up in partial applications of functions with the witness_method calling convention.
For convenience when reading looking at heap closure metadata. Also move the capture typerefs above the metadata sources, since they're more likely to be accessed than generic metadata sources.
MCJIT doesn't like offset relocations into the data sections, so the capture descriptors and their typerefs/metadata source encoded strings will need to be emitted as globals and not go into the reflection data sections.
d545824
to
e4d71eb
Compare
@swift-ci Please test |
@egranata is that Linux failure real? |
Just rebuilt LLDB locally and the REPL commands that the test runs are working fine, so I think it's noise.
|
Ah, that Linux test has been failing for a while on that bot. I filed https://bugs.swift.org/browse/SR-1301 to track that. |
Adds metadata emission for heap closures.
rdar://problem/24989531