Commit Graph

17229 Commits

Author SHA1 Message Date
John McCall
dadb51e708 Support in-place value metadata initialization in the runtime. 2018-07-25 03:00:36 -04:00
swift-ci
e9cb62d476 Merge pull request #17987 from brentdax/youll-get-no-argument 2018-07-24 23:39:05 -07:00
swift-ci
668a4640e3 Merge pull request #18204 from DougGregor/remove-requirement-array 2018-07-24 19:27:33 -07:00
Jordan Rose
de30596ccd Merge pull request #17665 from allevato/debug-prefix-map-wip
Implement -debug-prefix-map flag.
2018-07-24 17:34:42 -07:00
Doug Gregor
a2b2798de2 [ABI] Eliminate the now-unused protocol requirement array.
This is a holdover from the old protocol descriptor layout, which is no
longer useful.
2018-07-24 17:33:16 -07:00
swift-ci
cf501b4f71 Merge pull request #18163 from DougGregor/protocol-context-descriptor 2018-07-24 15:00:04 -07:00
Jordan Rose
a39afdc778 Merge pull request #18090 from jrose-apple/emit-interface-path
[Frontend] Add a new -emit-interface-path option
2018-07-24 12:49:27 -07:00
Tony Allevato
aade5fb1e4 Remove redundant "private" 2018-07-24 12:48:48 -07:00
Doug Gregor
191db1ea65 [Runtime] TargetProtocolDescriptor is not a TrailingGenericContextObjects.
Protocols are never generic, so don't inherit from
TrailingGenericContextObjects. Instead, directly use
swift::ABI::TrailingObjects. Since protocols are never generic, this
doesn't actually affect layout at all; it's cleanup.
2018-07-24 11:31:02 -07:00
Mike Ash
c2452cf2c2 Merge pull request #18150 from mikeash/typeref-robustness
[Reflection] Make getSubstMap and visitDependentMemberTypeRef more robust against unexpected data.
2018-07-24 10:19:40 -04:00
Doug Gregor
3039fb3d0e Eliminate now-unused (Literal)(Target)ProtocolDescriptorList.
These were used to encode the “inherited protocols” for Objective-C
Protocol structures. These are no longer a part of either Swift protocol
descriptors or the part of Objective-C Protocol structures that the
Swift runtime inspects.
2018-07-24 04:27:23 -07:00
Doug Gregor
e7998f1846 [ABI] Record unmangled names in Swift protocol descriptors.
Rather than storing a mangled name in a Swift protocol descriptor,
which encodes information that is redundant with the context of the
protocol, store an unmangled name as in nominal type descriptors. Update
the various places where this name is used to extract the demangle
tree from the context descriptors.
2018-07-24 04:25:13 -07:00
Pavel Yaskevich
2a0cbc990d Merge pull request #18167 from mdiep/SR-4270
[Diagnostics] Improve contextual member unexpected arguments diagnostic
2018-07-24 00:03:38 -07:00
Doug Gregor
a54a6d8d7f [ABI] Rework protocol descriptor metadata.
Reimplement protocol descriptors for Swift protocols as a kind of
context descriptor, dropping the Objective-C protocol compatibility
layout. The new protocol descriptors have several advantages over the
current implementation:

* They drop all of the unused fields required for layout-compatibility
  with Objective-C protocols.
* They encode the full requirement signature of the protocol. This
  maintains more information about the protocol itself, including
  (e.g.) correctly encoding superclass requirements.
* They fit within the general scheme of context descriptors, rather than
  being their own thing, which allows us to share more code with
  nominal type descriptors.
* They only use relative pointers, so they’re smaller and can be placed
  in read-only memory

 Implements rdar://problem/38815359.
2018-07-23 22:12:42 -07:00
John McCall
70e2aea266 Merge pull request #18156 from rjmccall/generalized-accessors
Implement generalized accessors using yield-once coroutines
2018-07-23 22:58:25 -04:00
Matt Diephouse
b4a2dc8add Improve contextual member unexpected arguments diagnostic 2018-07-23 20:18:40 -04:00
Doug Gregor
a777c5c6a9 [Metadata reader] Separate ObjC and Swift protocol descriptor reading.
When reading the protocol metadata from existential type metadata,
check the “isObjC” bit and handle the reading of the Objective-C
protocol name (using TargetObjCProtocolPrefix) separately from the reading the name of a Swift protocol (using TargetProtocolDescriptor).
More preparation for separating the layout of these two entities.
2018-07-23 17:08:59 -07:00
Doug Gregor
7727e5e62e [Runtime] Use a prefix Objective-C protocol layout to extract the name.
Introduce TargetObjCProtocolPrefix, which describes just enough of the
Objective-C runtime’s Protocol structure to extract the name without
having to call Objective-C’s protocol_getName().
2018-07-23 17:08:59 -07:00
Doug Gregor
89e322032a [Runtime] Minor cleanups to reduce dependency on Swift/ObjC protocol overlap.
As a small step toward splitting apart the Swift and Objective-C protocol
descriptors, eliminate most places where we rely on a shared representation.
2018-07-23 17:08:58 -07:00
John McCall
7a4aeed570 Implement generalized accessors using yield-once coroutines.
For now, the accessors have been underscored as `_read` and `_modify`.
I'll prepare an evolution proposal for this feature which should allow
us to remove the underscores or, y'know, rename them to `purple` and
`lettuce`.

`_read` accessors do not make any effort yet to avoid copying the
value being yielded.  I'll work on it in follow-up patches.

Opaque accesses to properties and subscripts defined with `_modify`
accessors will use an inefficient `materializeForSet` pattern that
materializes the value to a temporary instead of accessing it in-place.
That will be fixed by migrating to `modify` over `materializeForSet`,
which is next up after the `read` optimizations.

SIL ownership verification doesn't pass yet for the test cases here
because of a general fault in SILGen where borrows can outlive their
borrowed value due to being cleaned up on the general cleanup stack
when the borrowed value is cleaned up on the formal-access stack.
Michael, Andy, and I discussed various ways to fix this, but it seems
clear to me that it's not in any way specific to coroutine accesses.

rdar://35399664
2018-07-23 18:59:58 -04:00
Slava Pestov
787c6faa57 Merge pull request #18145 from slavapestov/compute-type
Factor out AbstractFunctionDecl's interface type computation
2018-07-23 13:39:14 -07:00
Mike Ash
e8ccfa824f [Reflection] Make getSubstMap and visitDependentMemberTypeRef more robust against unexpected data.
Remote mirrors was hitting an assertion failure due to a generic parameter not being concrete. This check catches that case early and returns a clean failure from getSubstMap, which callers can then handle appropriately.

It also hit a casting failure in visitDependentMemberTypeRef, which assumed that SubstBase was either a NominalTypeRef or a BoundGenericTypeRef. This does a dynamic cast with a graceful failure.

In general there is a tension in this code between its use in the runtime, where we usually want to treat bad data as a horrible bug and fail loudly, and its use in remote mirrors, where we need to assume that the data we're examining might be horribly broken and we just want to do the best we can. Longer term we might want to make this code configurable so that we can have an "assert and die" mode for the runtime, and a "fail gracefully" mode for remote mirrors.

rdar://problem/40136609
2018-07-23 14:32:39 -04:00
Doug Gregor
72e0ee960b Merge pull request #18129 from DougGregor/protocol-descriptor-ref
[ABI] Distinguish @objc from Swift protocol descriptor references
2018-07-23 09:25:33 -07:00
Slava Pestov
f6b96da3e2 Move TypeChecker::configureInterfaceType() to {AbstractFunction,Subscript}Decl::computeType()
It doesn't actually depend on the type checker, and using
it on synthesized declarations will eliminate a lot of
boilerplate.
2018-07-23 02:09:43 -07:00
Doug Gregor
c7a02a26a1 [ABI] Distinguish Swift/ObjC protocols in TargetGenericRequirement.
In a generic requirement, distinguish between Swift and
Objective-C protocols using a spare bit within the relative
(indirectable) reference to the protocol.
2018-07-22 22:48:57 -07:00
Doug Gregor
03c3baab6e [Runtime] TargetProtocolDescriptorRef cleanups.
Eliminate an unnecessary nullptr constructor and make the Metadata
unit test compile when Objective-C interoperability is disabled.
2018-07-22 21:05:45 -07:00
Slava Pestov
90cd772228 AST: Remove getParameterLists() and friends from AbstractFunctionDecl subclasses
Now, an AbstractFunctionDecl always stores a single parameter list.

Furthermore, ConstructorDecl and DestructorDecl always store a
ParamDecl for 'self'.

FuncDecl only has a 'self' if it is a member of a nominal type or
extension, so we tail-allocate the storage for it.
2018-07-22 20:56:56 -07:00
Slava Pestov
df9f7f979a Parse: Remove uses of getParameterLists() from default argument parsing 2018-07-22 20:56:56 -07:00
Brent Royal-Gordon
6cfcd4c256 [AST] Don’t allow application of most bare exprs
Most ApplyExpr subclasses will now require a ParenExpr, TupleExpr, or TupleShuffleExpr around their argument lists. The exceptions are BinaryExpr, which requires a TupleExpr, and SelfApplyExpr and its subclasses, which allow anything (and only ever have one argument).

This change doesn’t fix any of the places where we actually generate these.
2018-07-22 19:29:50 -07:00
Doug Gregor
bec722df57 [Runtime/IRGen] Switch swift_getExistentialTypeMetadata() to ProtocolDescriptorRef.
Switch one entry point in the runtime (swift_getExistentialTypeMetadata)
to use ProtocolDescriptorRef rather than a protocol descriptor. Update
IRGen to produce ProtocolDescriptorRef instances for its calls, setting
the discriminator bit appropriately.

Within the runtime, verify that all instances of ProtocolDescriptorRef have
the right layout, i.e., the discriminator bit is set for @objc protocols
but not Swift protocols.
2018-07-21 07:48:34 -07:00
Slava Pestov
5ce44bf93e Serialization: Bump module format 2018-07-21 07:30:30 -07:00
Slava Pestov
bfc4121971 AST: Rework AbstractFunctionDecl construction away from multiple parameter lists
There are two general constructor forms here:

- One took the number of parameter lists, to be filled in later.
  Now, this takes a boolean indicating if there is an implicit
  'self'.

- The other one took the actual parameter lists and filled them
  in right away. This now takes a separate 'self' ParamDecl and
  ParameterList.

Instead of storing the number of parameter lists, an
AbstractFunctionDecl now only needs to store if there is a 'self'
or not.

I've updated most places that construct AbstractFunctionDecls to
properly use these new forms. In the ClangImporter, there is
more code that remains to be untangled, so we continue to build
multiple ParameterLists and unpack them into a ParamDecl and
ParameterList at the last minute.
2018-07-21 07:30:30 -07:00
Doug Gregor
3464929638 [ABI] Rework existential type metadata to use ProtocolDescriptorRef.
Use ProtocolDescriptorRefs within the runtime representation of
existential type metadata (TargetExistentialTypeMetadata) instead of
bare protocol descriptor pointers. Start rolling out the use of
ProtocolDescriptorRef in a few places in the runtime that touch this
code. Note that we’re not yet establishing any strong invariants on
the TargetProtocolDescriptorRef instances.

While here, replace TargetExistentialTypeMetadata’s hand-rolled pointer 
arithmetic with swift::ABI::TrailingObjects and centralize knowledge of
its layout better.
2018-07-20 20:54:49 -07:00
Doug Gregor
9af914eafa [ABI] Remove the “final” assertion from the ABI’s TrailingObjects.
In our ABI, we’re using some C++ ABI tricks to simplify the 
implementation of the runtime. One of them, in FullMetadata, requires
that we inherit from classes that we would also like to make use
TrailingObjects. Remove the “final” assertion from TrailingObjects
so we can do so.

We promise to be careful.
2018-07-20 20:54:49 -07:00
Doug Gregor
e5921ab029 [ABI] Introduce TargetProtocolDescriptorRef.
TargetProtocolDescriptorRef provides a reference to either a Swift or
an Objective-C protocol, using a spare bit to indicate which kind of
protocol it is. At present, the protocol descriptor also has this
information (so this is redundant), but that will change shortly.

There are no clients of TargetProtocolDescriptorRef yet.
2018-07-20 20:54:49 -07:00
John McCall
3257145cf1 Merge pull request #18111 from rjmccall/generalized-accessor-recording
Generalize the recording of parsed accessors
2018-07-20 20:20:13 -04:00
Jordan Rose
79928ad5f2 Make sure we handle a supplementary output list with no outputs in it (#18117) 2018-07-20 17:19:45 -07:00
Jordan Rose
b9ae66d768 [Frontend] Add a new -emit-interface-path option
...but don't hook it up to anything yet.

This is the very very start of the module stability / textual
interfaces feature described at

  https://forums.swift.org/t/plan-for-module-stability/14551/

For now I've just made it a frontend option (not a driver option),
which is good enough for testing.
2018-07-20 16:40:51 -07:00
John McCall
06edd256c2 Generalize the recording of parsed accessors.
As part of this, lift the now-unnecessary restriction against
combining a non-mutable addressor with a setter.  I've also
tweaked some of the diagnostics.

This is in preparation for generalized accessors.
2018-07-20 17:54:57 -04:00
Davide Italiano
dc85c0a469 Merge pull request #17426 from sparkasaurusRex/codeview-linetables
[IRGen] Fix debug locations to work well with CodeView
2018-07-20 09:54:31 -07:00
swift-ci
5980c4c916 Merge pull request #18093 from CodaFi/typo-through-the-tulips 2018-07-19 18:27:33 -07:00
swift-ci
4158517ab5 Merge pull request #17771 from dcci/remotemirrorself 2018-07-19 17:44:22 -07:00
Huon Wilson
103170bcbb Merge pull request #17688 from huonw/merging-tbd
Allow TBD files to be generated in non-wmo mode
2018-07-20 09:44:50 +10:00
Robert Widmann
9ebb47430b [NFC] Correct a typo 2018-07-19 16:31:56 -07:00
Robert Widmann
79b38ba6f3 Merge pull request #18083 from CodaFi/system-of-a-down
Add -track-system-dependencies Flag
2018-07-19 16:29:50 -07:00
Davide Italiano
e9d8e0a8ba [ELF] Remove a wrong comment and clarify another one.
<rdar://problem/41901725>
2018-07-19 15:23:58 -07:00
Davide Italiano
a907398872 [RemoteMirrors] Add support for reading ELF.
<rdar://problem/41901725>
2018-07-19 15:21:42 -07:00
Huon Wilson
2e3e6558b7 [Driver] Pass -emit-tbd through to -frontend -merge-modules, to get TBD files without -wmo.
Fixes rdar://problem/33735706
2018-07-20 08:12:22 +10:00
Huon Wilson
9dab667544 [Driver] Make the TBD file behave more like a normal auxiliary output. 2018-07-20 08:12:22 +10:00
eeckstein
d61b923e81 Merge pull request #18077 from eeckstein/closure-specializer
ClosureSpecializer: extend the benefit-analysis so that specialization is also done in case a closure is passed through multiple call-levels.
2018-07-19 15:10:16 -07:00