Commit Graph

15 Commits

Author SHA1 Message Date
David Farler
80d3e7e189 [TypeRef] Look up generic substitutions with index and depth
A little bit of trivial future-proofing looking forward to nested
generics.
2016-03-07 18:53:19 -08:00
David Farler
834b03b6cd [Reflection] Substitute generics and resolve dependent members
Once an unsubstituted typeref for a field is built, we substitute
`GenericTypeParameterTypeRef`s with concrete ones built from the generic
arguments of concrete bound generic metadata.

During that process, if we run into a `DependentMemberTypeRef` (e.g.
something of type T.Index), we substitute the base (T) using the current
list of substitutions, and then resolve what `Index` is for the base
using the associated type metadata in the 'assocty' data section.
2016-03-07 17:43:13 -08:00
David Farler
0aba14430c Move PrintTypeRef and TypeRefSubstitution into the cpp - NFC 2016-03-07 17:43:12 -08:00
David Farler
bd6d657411 Get typerefs for existential type metadata 2016-03-04 17:10:40 -08:00
practicalswift
b9dd782e4b [gardening] Fix recently introduced file header. Also: "–" → "--". 2016-03-03 23:10:43 +01:00
David Farler
0e6dd788cf FunctionTypeRef: Track arguments as an array, not a tuple 2016-03-02 21:25:04 -08:00
David Farler
0ab31065ff Flesh out remote memory reader
Adds a rough sketch of what will be a test harness, currently only supported
on OS X:
- Launch a child process: an executable written in Swift
- Receive the child process's Mach port
- Receive reflection section addresses and the address of a heap instance
  of interest
- Perform field type lookup on the instance remotely (TODO)
2016-03-02 21:25:04 -08:00
David Farler
744806a742 [Reflection] Add Foreign, ObjC, and Opaque type references
These likely don't have Swift type metadata but might be useful to
record or instantiate based on what kind of metadata is encountered for
the sake of memory tools.
2016-03-02 21:25:04 -08:00
David Farler
c5298c0b52 [Reflection] Start fleshing out the remote mirrors library
- Don't depend on LLVM Support and swiftBasic as this will bring in
  llvmSupport and other heavy dependencies, which we don't build for
  non-host architectures right now anyway.

- Add a reader template that works with the same (albeit somewhat
  clunky) interface in-process with the runtime and remotely, by having
  the memory tool supply a function that will copy data from the remote
  process.

- Add a Buffer type to abstract indirecting pointers in a remote address
  space, which is handled by the memory reader.

- Start sketching out the C remote mirrors interface.
2016-02-12 16:34:28 -08:00
David Farler
ceae63cff4 Adopt llvm::TrailingObjects for TypeRefs
Thanks @jrose-apple for making me a believer!
2016-02-07 21:40:09 -08:00
David Farler
9f76eb61c4 Add associated type name typeref
This tracks the names 'T' and 'Index' in a T.Index dependent member type.
2016-02-07 21:40:08 -08:00
David Farler
9d5947d814 Fix Linux build
- Add an explicit link to swiftBasic
- Shuffle some constness

NFC.
2016-02-04 19:59:15 -08:00
David Farler
086000a198 Start the swiftReflection library
- Nearly done: TypeRefs and the mangled name decoder.

- Add the swift-reflection-test tool.
  The field reflection pipeline is roughly:
  - Decode type references
  - Substitute generic parameters
  - Calculate sizes and offsets

  There is currently only one action in the tool, which will test the
  *Decode* part of the pipeline: `dump-reflection-section`. This reads
  the *swift3_reflect section from an object file and dumps the decoded
  type references for all of the stored properties and enum cases in the
  file.
  - TODO: Write tests with various type arrangements to exercise the
    decoder - there are likely some holes in the decoder still since the
    AST mangler is quite rich in its kinds.

  TODO: The next test mode, `dump-field-types`, will do the following:
  1. Launch a swift executable with a canned stopping point
  2. Get the address of a heap object instance of interest
  3. Dump the fully substituted typerefs of all of the stored properties
  or enum case payloads.

  That test mode will be more involved since it will attach to another
  process and need to read from its address space but will test the
  entire out-of-process reflection pipeline in a controlled environment.
  We can maybe take this test a step further, with an option or a new
  test mode, that prints the entire heap reference graph rooted at that
  object of interest, in order to test the ability to detect reference
  cycles, for example.
2016-02-04 18:10:49 -08:00
practicalswift
d5870a174f [gardening] Emacs language marker not required in *.cpp files (only *.h) 2016-02-04 13:04:51 +01:00
David Farler
ef863136f3 Sketch out TypeRef structures for the reflection library
This adds the various TypeRef classes that will hold the
type references prior to substitution. There is also some
basic TypeRef visitor and dumping support.

rdar://problem/24173679
2016-02-03 13:52:26 -08:00