Commit Graph

112 Commits

Author SHA1 Message Date
David Farler
45d2355cd6 Merge pull request #2206 from bitjammer/metadata-source
Add MetadataSource classes
2016-04-15 15:14:14 -07:00
David Farler
ffdc91a038 Add MetadataSource classes
The compiler is generally free to not include pointers to metadata in
heap boxes, which are used for closure captures, if it knows you can get
to metadata through some other path. These MetadataSource classes will
describe a sequence of steps to get to metadata at runtime.

In the short term, this will be useful for describing the layout of
function/closure capture contexts, which can vary depending on what is
captured.
2016-04-15 13:52:07 -07:00
David Farler
f5583c8295 Restore const-ness of TypeRefs
We got rid of the last mutating methods on TypeRefs, so let's
make these all const again.
2016-04-15 13:13:34 -07:00
David Farler
e806fd2d1d Remove accidental CMake change to stdlib/public/Reflection 2016-04-13 15:38:03 -07:00
David Farler
cf97a12109 Tie lifetime of typerefs to the ReflectionContext
We will be handing pointers to typerefs over the SwiftRemoteMirrors C
API boundary, at which point it is unclear who will hold onto a shared
pointer. The useful lifetime of a typeref is tied to the
ReflectionContext for which they were created anyway so, when it goes
away, all of those typerefs can go away anyway.

We can't use LLVM's bump-pointer allocator here because we only build
the Support library for the host. As a compromise, stuff new typeref
pointers into a vector pool, where they will be taken down during
ReflectionContext's destructor.
2016-04-13 13:58:35 -07:00
Slava Pestov
22bf2dcdbe Reflection: Clean up Parent type handling a bit, NFC 2016-04-12 19:15:38 -07:00
Slava Pestov
d2b16597f8 Reflection: Fixes for tuple types with labels, and varargs
Just drop labels when demangling TypeRefs. This is OK for now
since labels do not affect layout.

Vararg tuple types cannot appear directly as the type of
storage, however they can appear in function input types, and
therefore must be minimally supported. Since we don't plan on
doing function call reflection just yet, this doesn't matter
for now, but again we need to not crash.

With this patch, all TypeRefs in the Swift standard library now
successfully demangle and print.
2016-04-12 19:15:37 -07:00
Slava Pestov
9738d77677 Reflection: TypeRef demangling now returns nullptr if any part of the tree is invalid
Previously, we would return TypeRefs containing nullptrs.
2016-04-12 19:15:37 -07:00
Slava Pestov
68f6a1179d Reflection: Add TypeRef kinds corresponding to {Unowned,Weak,Unmanaged}ReferenceStorageType 2016-04-12 19:15:37 -07:00
David Farler
cd13200b66 Don't install stdlib/public/Reflection into the stdlib component
This is only privately linked into the test tools for remote reflection
and eventually the C API dylib.

rdar://problem/25556475
2016-04-05 16:06:01 -07:00
David Farler
e1eca69d1a Ensure swiftReflection is always built for the host
swift-reflection-dump, a host-side tool, requires this library that
normally builds for the configured platform. So, if the host platform
isn't configured to build for some reason, swift-reflection-dump will
fail to link.
2016-04-04 15:23:07 -07:00
David Farler
5ea5bb06a3 Split swift-refleciton-test into host and target test targets
swift-reflection-test is now the test that forks a swift executable
and performs remote reflection, making it runnable on other targets,
such as the iOS simulator.

swift-reflection-dump is now a host-side tool that dumps the remote
reflection sections for any platform binary and will continue to
link in LLVM object file support.

This necessitates finally moving lib/Refleciton into stdlib/public,
since we're linking target-specific versions of the test tool and
we would eventually like to adopt some of this functionality in
the runtime anyway.
2016-03-28 16:34:44 -07:00