Commit Graph

78 Commits

Author SHA1 Message Date
David Farler
9fac5409e8 Don't bail reading a metadata instance if swift_isaMask isn't available
This symbol is conditionally emitted based on whether there is an isa
mask for the platform. For 32-bit embedded platforms, this symbol
isn't present.
2016-05-03 21:04:31 -07:00
David Farler
5f5ce39a1d SwiftRemoteMirror: Wire up existential projection API
Implement the ReflectionContext's implementation of:
swift_reflection_projectExistential.

First, we get the type info of the existential typeref - it should be a
record type info. If it's a class existential, it has trivial layout:
the first word is a pointer to the class instance. Otherwise, if the
value fits in the 3-word buffer of the existential container, it
trivially is also at the start of the container. Otherwise, the value is
off in a heap box somewhere, but the first word of the container is a
pointer to that box.
2016-05-03 21:04:31 -07:00
David Farler
bfc94f4290 SwiftRemoteMirror: Add API to convert mangled type name to a typeref
This is useful on its own as well as for testing, so you can generate
typerefs to canned types such as Any, Swift.Int, etc.
2016-05-03 21:04:31 -07:00
Slava Pestov
86dae6850c Reflection: Add SILBoxTypeRef, which can come up in capture descriptors 2016-05-02 19:26:12 -07:00
Slava Pestov
1d5b9b09ac Reflection: Add instance-specific layout entry point, and do some refactoring
Closure context layout will depend on the instance itself as well
as the isa pointer, because instead of instantiating metadata for
closures that capture generic parameters, we store the substitutions
inside the context itself.

For classes, this entry point just reads the isa pointer, applies
the isa mask and proceeds down the metadata path.

For now, the only the latter is hooked up.
2016-04-29 15:39:49 -07:00
Slava Pestov
975401ba3d Reflection: Fix broken Linux build
For some reason, initializer lists are not supported by std::tuple
in our Linux CI. Just call std::make_tuple() instead.
2016-04-29 00:25:14 -06:00
Slava Pestov
e81fca926a Reflection: Use correct starting offset and alignment in class instance layout
Also, add caching for class instance layout.
2016-04-28 22:56:15 -07:00
Slava Pestov
ce1c30b1bc Reflection: Support reading the remote process's isaMask
Also, use the instance layout entry point in swift-reflection-test,
so that we can dump the layout of a class instance and not the
lowering of the reference value.
2016-04-28 22:56:15 -07:00
Slava Pestov
7a9a4dca83 Reflection: Preliminary C API entry points for class instance layout
Tested by manually running swift-reflection-test, no automated
tests yet, but coming soon.
2016-04-27 23:15:08 -07:00
John McCall
83dc7cffe8 RemoteAST: implement member-offset calculations for tuples. 2016-04-27 19:00:30 -07:00
John McCall
92cf4a6d39 Teach MetadataReader how to handle ObjCClassWrapper metadata. 2016-04-26 13:04:02 -07:00
John McCall
627e2325d3 Read tuple labels in MetadataReader and preserve them in RemoteAST.
The metadata system doesn't actually unique based on labels
correctly, so the test case has to play some games.  That's
something that will be easier to fix when there are fewer
clients poking at the internals of the metadata runtime.
2016-04-25 22:33:41 -07:00
Slava Pestov
c0c02a3148 Reflection: ProtocolTypeRefs now store a mangled name
This is better for field metadata lookups. Clients that want the
module name and decl name can demangle, just like they do with
NominalTypeRefs.
2016-04-25 20:08:49 -07:00
John McCall
812557ca24 Reorganization within RemoteAST. Basic error propagation.
Initial stabs towards reading foreign class metadata, although
these do not yet successfully resolve the declaration.
2016-04-25 16:57:19 -07:00
John McCall
964bd44066 Remove unnecessary shared ownership of loaded metadata/dominator buffers. 2016-04-25 14:45:14 -07:00
Enrico Granata
5d315ae30b Add a getKindForRemoteTypeMetadata() API to the RemoteAST - LLDB plans to use this API to decide whether certain kinds of existential containers need a two-level type resolution (e.g. if an existential box points to a class, the true type that we want to resolve is the type that the class's ISA refers to, not the static type that the box refers to) 2016-04-25 11:50:03 -07:00
David Farler
3a3cafc6bd MetadataReader infrastructure for reading capture descriptors
This starts wiring up capture descriptors to the metadata reader
so we can discern the layout of closures at runtime.

rdar://problem/24989531
2016-04-24 23:47:41 -07:00
practicalswift
9a078b54ef [gardening] Fix recently introduced typo: "a executable" → "an executable"
[gardening] Fix recently introduced typo: "a offset" → "an offset"
[gardening] Fix recently introduced typo: "accessiblity" → "accessibility"
[gardening] Fix recently introduced typo: "cant" → "can't"
[gardening] Fix recently introduced typo: "inteference" → "interference"
[gardening] Fix recently introduced typo: "unsatified" → "unsatisfied"
[gardening] Remove accidental space.
2016-04-24 22:11:59 +02:00
John McCall
f450d09e00 Unindent cases to match LLVM style. 2016-04-23 13:31:46 -07:00
John McCall
014bfa10f7 Handle MetadataKind::Class in readMetadata. This can only
come up as the exact value of the metadata kind for classes
where ObjC interop is disabled.
2016-04-21 23:23:47 -07:00
John McCall
66208c31e5 More organization and redunancy elimination in MetadataReader. 2016-04-21 22:08:28 -07:00
John McCall
590706a8c6 Pass around address/buffer pairs in the MetadataReader instead of
just the address.  Use this to avoid repeatedly reading metadata so
often (even if it's cached, this is better).  Fix some bugs involving
nominal type parents.
2016-04-21 21:47:14 -07:00
John McCall
b42f2c014a Remove spurious call to readMetadata. 2016-04-21 16:25:19 -07:00
John McCall
e758ba3569 Stub out a RemoteAST library for translating remote metadata
pointers into a local AST.

This is intended primarily for the use of LLDB and does not have
a stable ABI.
2016-04-19 16:36:57 -07:00
John McCall
0278616eb9 Allow MetadataReader to use a more precise type for tracking nominal
types than just a std::string.
2016-04-19 11:34:24 -07:00
Slava Pestov
d184122e83 Reflection: Move field and associated type metadata parsing from ReflectionContext to TypeRefBuilder, NFC
ReflectionContext is now solely concerned with converting runtime
metadata in a remote address space into a TypeRef.

TypeRefBuilder now knows how to parse reflection metadata, and
in particular look up associated type witnesses. This decouples
the TypeRef substitution code from the ReflectionContext. Now
substitution only needs a TypeRefBuilder, which means the code
is no longer templated, and can be moved from TypeRef.h to
TypeRef.cpp.

This also allows the upcoming TypeRef lowering code to live in
a source file instead of headers.
2016-04-16 02:19:04 -07:00
Slava Pestov
a24e95f86c Reflection: Extract new decodeMangledType() for when we have a TypeRefBuilder but not ReflectionContext, NFC
In particular, this will allow the field and associated type metadata
parsing to be moved out of ReflectionContext and into TypeRefBuilder,
which is required for TypeRef lowering.
2016-04-16 02:18:31 -07:00
John McCall
5eef441240 Extract the core implementation of ReflectionContext and
template it over the builder type.

Also preserves more information about function types until
the builder, at least.
2016-04-14 21:21:44 -07:00