Commit Graph

10 Commits

Author SHA1 Message Date
Joe Groff
f0e5e1911d IRGen: Access concrete type metadata by mangled name.
When we generate code that asks for complete metadata for a fully concrete specific type that
doesn't have trivial metadata access, like `(Int, String)` or `[String: [Any]]`,
generate a cache variable that points to a mangled name, and use a common accessor function
that turns that cache variable into a pointer to the instantiated metadata. This saves a bunch
of code size, and should have minimal runtime impact, since the demangling of any string only
has to happen once.

This mostly just works, though it exposed a couple of issues:

- Mangling a type ref including objc protocols didn't cause the objc protocol record to get
  instantiated. Fixed as part of this patch.
- The runtime type demangler doesn't correctly handle retroactive conformances. If there are
  multiple retroactive conformances in a process at runtime, then even though the mangled string
  refers to a specific conformance, the runtime still just picks one without listening to the
  mangler. This is left to fix later, rdar://problem/53828345.

There is some more follow-up work that we can do to further improve the gains:

- We could improve the runtime-provided entry points, adding versions that don't require size
  to be cached, and which can handle arbitrary metadata requests. This would allow for mangled
  names to also be used for incomplete metadata accesses and improve code size of some generic
  type accessors. However, we'd only be able to take advantage of the new entry points in
  OSes that ship a new runtime.
- We could choose to always symbolic reference all type references, which would generally reduce
  the size of mangled strings, as well as make runtime demangling more efficient, since it wouldn't
  need to hit the runtime caches. This would however require that we be able to handle symbolic
  references across files in the MetadataReader in order to avoid regressing remote mirror
  functionality.
2019-08-02 14:28:53 -07:00
Saleem Abdulrasool
afd0b69a8c test: get most of the multifile tests working on Windows
We cannot link against the DSO (dll) on Windows and instead link against
the import library.  Let the driver understand this and use the standard
linking technique.  Adjust the name of the emitted files accordingly and
use the `%target-library-name` macro more freely.

Two tests remain:
- multifile.protocol-conformance-member
    The getter is synthesized by not exported so `llvm-nm` is unable to
    see it
- multifile.nested_types
    Windows uses the singleton strategy, so the emitted full type
    metadata does not have the reference to the value witness table for
    Void
2018-12-25 11:26:53 -08:00
Saleem Abdulrasool
d77801abaf test: define and use %target-rpath
Create a new capturing substitution for adding a rpath to a target
library.  This is needed as Windows doesn't really support the concept
of a rpath.  This also makes it possible to remove the parameter from
the command line on windows.
2018-12-12 19:51:08 -08:00
Saleem Abdulrasool
8968fcad5f test: create and use target-library-name 2018-12-12 08:37:59 -08:00
Saleem Abdulrasool
b212229db1 test: add and use prefix substitutions for libraries
The naming convention is different on Windows than on Unix-like
environments.  In order to follow the convention we need to substitute
the prefix and the suffix.  Take the opportunity to rename the
`target-dylib-extension` to the CMake-like variable
`target-shared-library-suffix` and introduce
`target-shared-library-prefix`.  This helps linking the test suite
binaries on Windows.
2018-12-11 15:56:06 -08:00
Slava Pestov
432644ad20 These tests require the ability to execute code 2018-08-29 14:47:50 -07:00
Arnold Schwaighofer
cddf20baee Codesign test/multifile 2018-08-10 06:58:40 -07:00
Arnold Schwaighofer
eaef4f2016 Fix the test case to work on the simulator 2018-05-16 10:16:59 -07:00
Arnold Schwaighofer
6bb13b7cfa Add codesign 2018-05-15 08:40:45 -07:00
Arnold Schwaighofer
e78c840647 Witness table pointers shall now be part of the metadata cache key
rdar://24958043
2018-05-14 13:53:54 -07:00