Commit Graph

39 Commits

Author SHA1 Message Date
Joe Groff
a795b4fc0c SIL: Move responsibility for external keypath equals/hash to the caller.
A public subscript might have generic indexes that aren't unconditionally Hashable, or might use indexes that are retroactively made Hashable, so the property descriptor on the implementer's side can't always resiliently provide this information to the final instantiated KeyPath.
2018-03-14 14:05:49 -07:00
Joe Groff
4c2dde56a0 IRGen: Lower external key path components.
The key path pattern needs to include a reference to the external descriptor, along with hooks for lowering its type arguments and indices, if any. The runtime will need to instantiate and interpolate the external component when the key path object is instantiated.

While we're here, let's also reserve some more component header bytes for future expansion, since this is an ABI we're going to be living with for a while.
2018-02-23 19:03:15 -08:00
Joe Groff
d4e03f2ba3 SIL: Add an 'external' KeyPathPatternComponent kind.
This will allow key paths to resiliently reference public properties from other binaries by referencing a descriptor vended by the originating binary. NFC yet, this just provides printing/parsing/verification of the new component.
2018-02-14 10:48:24 -08:00
Arnold Schwaighofer
2678788438 IRGen: Set artifical functions for key path code
Otherwise, debug info asserts get triggered because of a missing debug
loc.

rdar://36797675
2018-01-23 20:44:51 -08:00
Slava Pestov
3dae007465 IRGen: Remove FieldAccess::NonConstantIndirect 2018-01-10 21:32:54 -08:00
Doug Gregor
12a774abec [Runtime] Fill in the superclass of foreign class metadata.
When emitting foreign class metadata (e.g., for an imported CF type), fill
in the superclass when we have one. The superclass will itself be a foreign
metadata candidate, so also register an initialization function that uniques
the superclass metadata once we've picked the canonical foreign class
metadata.
2018-01-04 10:15:32 -08:00
Slava Pestov
c16c2c35bf SIL: Move getOverriddenVTableEntry() from TypeLowering to SILDeclRef
There's no reason for this to be an instance method on the TypeLowering
object, because it (no longer?) uses any type lowering operations.
2017-12-18 23:28:33 -08:00
Slava Pestov
ffd036e8f4 IRGen: Add some FIXMEs 2017-12-05 16:31:46 -08:00
Joe Shajrawi
d8289aa3ec Code size: destroy_addr outline 2017-11-17 16:10:27 -08:00
Joe Shajrawi
62d823c56d Code size: Do not use a global state for isOutlined 2017-11-15 15:28:27 -08:00
Arnold Schwaighofer
f10f8d55dc IRGen: Nuke isSILOnly usage
It queried for [transparent] [serialized] definitions and only had an effect
when the module was compiled with -Onone because we remove [serialized]
as part of the optimizer pipeline.

It was causing bad effects when the module we imported from was compiled
with -Onone:

 The definition would be marked internal in said module.

and the importing module is compile with -O:

 The definition would be marked as available_externally.

because neither would guaranteed the presence of a definition of the
imported symbol available to the importer.

rdar://35100697
2017-11-13 14:33:39 -08:00
Greg Parker
9a38e609af [IRGen][runtime] Reduce object header to 8 bytes on 32-bit platforms. (#12790)
SR-4353, rdar://29765800
2017-11-08 02:50:11 -08:00
Doug Gregor
936a701b15 [AST] Stop uniquing canonical GSBs based on the module.
Now that the GenericSignatureBuilder is no longer sensitive to the input
module, stop uniquing the canonical GSBs based on that module. The main
win here is when deserializing a generic environment: we would end up 
creating a canonical GSB in the module we deserialized and another
canonical GSB in the module in which it is used.
2017-10-10 09:41:23 -07:00
Roman Levenstein
9e07d5e0b0 Remove LinkEntity::isFragile which is always false now.
And remove all the code that is dead because of it.
2017-10-05 15:51:17 -07:00
Joe Groff
158ec12616 IRGen: Forward return value from equals/hash helpers when thunking generic helpers. 2017-09-18 11:59:43 -07:00
Joe Groff
6ccc96cf67 Code updates from review on #11953
- Remove dead `if !genericEnv` checks
- Do conformance checks for subscript indexes `InExpression`
- Use `GenericEnvironment::mapTypeOutOfContext` static method instead of null checking everywhere
2017-09-15 15:43:59 -07:00
Joe Groff
b7566dacdb IRGen: Lowering for key paths with indices. 2017-09-15 10:24:28 -07:00
Erik Eckstein
90501578b0 IRGen: fix statically initialized globals which contain an empty type.
This caused a compiler assert or a miscompile

rdar://problem/34123143
2017-08-29 09:53:18 -07:00
John McCall
4e48bc0ff7 Cache type-metadata layouts instead of using scanners everywhere. NFC.
Also counts as incremental work towards metadata resilience.
2017-08-03 04:13:53 -04:00
John McCall
a0f20f673d Switch all of the indirect-call code in IRGen to FunctionPointer.
To make this stick, I've disallowed direct use of that overload of
CreateCall.  I've left the Constant overloads available, but eventually
we might want to consider fixing those, too, just to get all of this
code out of the business of manually remembering to pass around
attributes and calling conventions.

The test changes reflect the fact that we weren't really setting
attributes consistently at all, in this case on value witnesses.
2017-07-28 23:26:35 -04:00
Joe Groff
8793212293 Merge pull request #10741 from jckarter/key-path-generic-computed
Handle generic computed properties in key paths.
2017-07-07 13:50:27 -07:00
Joe Groff
101788dbd4 IRGen: Support for computed properties with dependent generic context.
Use the KeyPath implementation's new support for instantiating and dealing with captures to lower the generic context required to dispatch computed accessors with dependent generics.
2017-07-06 20:07:41 -07:00
Robert Widmann
957d633185 Rename getInOutOrLValueObjectType to getWithoutSpecifierType
Prepares the AST for a future in which more than just inout and
@lvalue need to be stripped off of ephemeral types.
2017-07-06 09:35:04 -07:00
Joe Groff
3c82e981f9 KeyPaths: Add support for optional chaining/forcing components.
rdar://problem/31768715
2017-06-26 09:40:31 -07:00
Joe Groff
752beac4f1 KeyPaths: Pointer-align pointer fields within key path patterns.
To get the full benefit of dyld3 on Darwin platforms, pointer relocations need to be pointer-aligned, which unfortunately requires growing some key path data structures a little bit. This does tidy up some code that had to hack around our lack of unaligned load/store operations on UnsafeRawPointer, at least. While we're here, we can also simplify the identification strategy for reabstracted stored properties; we only need the property index to identify, not the absolute offset. rdar://problem/32318829
2017-06-20 14:42:05 -07:00
Joe Groff
fe88bd5f3f KeyPaths: Correctly instantiate offsets for final stored properties in NSObject subclasses.
We need to use the ivar offset variables in this case, since the Swift field offset vector doesn't pick up the adjusted offsets from the ObjC runtime. Fixes SR-5036 | rdar://problem/32488871.
2017-06-16 14:42:32 -07:00
Joe Groff
9830f394c1 SILGen/IRGen/KeyPaths: Components for ObjC properties need to be identified by selector.
A property imported from Objective-C, or marked in Swift with the `dynamic` keyword, doesn't have a vtable slot, so can't be identified that way. Use the ObjC selector as the unique identifier to ascribe equality to such components. Fixes rdar://problem/31768669. (While we're here, throw some more execution tests and a changelog note in.)
2017-05-11 14:28:19 -07:00
practicalswift
fff77b01c7 [gardening] Remove unused variables 2017-05-05 17:03:02 +02:00
Joe Groff
525001f7a7 Support key paths on 32-bit platforms.
I had optimistically written the code here optimistically hoping #7837 would land in time for me to merge, but that didn't happen, so adjust some things to match the current 12-byte object header size on 32-bit, and introduce some ABI constants for the expected 32- and 64-bit object header sizes we can assert against so that we have some robustness when it eventually changes again. Implements rdar://problem/31768303.
2017-05-02 18:19:07 -07:00
Joe Groff
d5cdf658da KeyPaths: Generate _kvcKeyPathString for ObjC-compatible keypaths. 2017-04-21 16:56:17 -07:00
Joe Groff
a6cd471c2b IRGen/stdlib: Instantiate non-generic computed key path components. 2017-04-18 21:51:12 -07:00
Joe Groff
4522cd09aa SILGen: Tweak key path computed property lowering to produce a consistent runtime-callable ABI. 2017-04-18 11:44:39 -07:00
Joe Groff
0bb83bb185 KeyPaths: Support out-of-place instantiation of generic key paths. 2017-04-17 22:36:26 -07:00
Joe Groff
aaddafa55b IRGen: Support for generic key path patterns. 2017-04-17 17:50:57 -07:00
Joe Groff
25eaa09463 wip irgen generic/computed key paths 2017-04-17 11:34:31 -07:00
Joe Groff
9ade487689 SIL: Allow computed components in KeyPathInst.
A computed component needs:

- A stable identifier for equality checking. This can be either a static function reference for concrete property implementations, or a reference into a vtable or witness table for a dynamically dispatched property. This should correspond to a public ABI interface for public things.
- Getter and setter (TODO: and materializeForSet) references. These might be thunks to reach the necessary abstraction level for the keypath implementation, so they can't be used as stable identifiers directly.
2017-04-13 14:18:28 -07:00
Joe Groff
d6ced9d9e4 SIL: Rework KeyPathInst to accommodate computed components.
- Separate out a uniquable KeyPathPattern that describes the context-free shape of the key path, with generic parameters and (eventually) subscript index slots factored out.
- Add component kinds for gettable and settable properties.
2017-04-12 20:09:17 -07:00
Joe Groff
d42f2049f7 KeyPaths: Implement in-place instantiation of invariant key paths.
For key paths without generic or subscript parameterization, we can turn the compiler-generated key path pattern into a global object in-place.
2017-04-05 08:46:45 -07:00
Joe Groff
f929c29bdf IRGen: Lower keypath instructions to patterns for the runtime to instantiate. 2017-04-04 11:31:15 -07:00