Commit Graph

137 Commits

Author SHA1 Message Date
Joe Groff
ae4d40ac85 SILGen: Fix key paths that reference internal private(set) decls from other files.
The setter needs to be given hidden linkage so that other files can still form key paths to it.
2018-07-25 10:49:29 -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
b0f59dc7af SIL: Remove uses of AbstractFunctionDecl::getParameterLists() 2018-07-19 21:28:39 -07:00
Slava Pestov
301d9f0cf3 AST: Give destructors a second parameter list
Constructors and methods had two parameter lists, one for self and one
for the formal parameters. Destructors only had one parameter list,
which introduced an annoying corner case.
2018-07-19 12:28:13 -07:00
Huon Wilson
98bc2d278a [SIL] Default arg generators shouldn't be connected to their class.
These are never public (at least, in Swift > 4), and so shouldn't be connected
to their superclass.

Fixes rdar://problem/41563759.
2018-06-28 15:57:53 +10:00
Huon Wilson
ed64fadb28 [SIL]/[SILOpt] Thunks and specializations shouldn't be connected to their parent class.
The "subclass scope" is meant to represent a connection to a vtable (and how
public something needs to be), for things that end up in class
vtables. Specializations and thunks are mostly internal implementation details
and do not end up there, so subclass scope is not applicable to them. This stops
the thunks and specializations being incorrectly public.

(Note, there are some thunks that _are_ public facing: if a function has its
signature optimized, the original entry point becomes a thunk, and this entry
point is what ends up in vtables etc., so needs to remain around, which means
keeping the same hacks for `private` members of an `open` class.)

Fixes rdar://problem/40738913.
2018-06-26 16:25:42 +10:00
John McCall
9022b5152f Rename accessor kinds from IsGetter -> IsGet, etc.
Introduce some metaprogramming of accessors and generally prepare
for storing less-structured accessor lists.

NFC except for a change to the serialization format.
2018-06-14 17:08:55 -04:00
Slava Pestov
05ea885465 AST: More renaming of 'versioned' things 2018-04-05 16:09:44 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Slava Pestov
e85b20f019 SIL: Stored property initializers in non-resilient modules might need public linkage
Because of a ill-advised core team decision, Swift now
allows @_inlineable root initializers on types that
are not @_fixed_layout (aa85e4512f).

Since stored property initializers of types that are not
@_fixed_layout are permitted to reference non-public symbols,
they cannot be serialized and must instead have public
linkage. This negates most of the benefit of inlining the
constructor in the first place, but oh well.

This does not affect resilient builds.

Fixes <rdar://problem/38439363>.
2018-03-14 18:28:14 -07:00
Jordan Rose
0c92fdda33 [SIL] Remove unused ResilienceExpansion from SILDeclRef (#14451)
We ended up not using this, so let's not leave it in as cruft.
No functionality change.
2018-02-07 09:41:25 -08:00
Slava Pestov
9b0f6fca53 IRGen: Emit class dispatch thunks in IRGen instead of SILGen
This allows us to re-use the same code for emitting protocol dispatch
thunks.
2018-01-15 22:38:16 -08:00
Slava Pestov
4e002c9192 SIL: Use PublicNonABI linkage for stored property initializers of @_fixed_layout types
Fixes <rdar://problem/36429556>.
2018-01-14 22:59:41 -08:00
Slava Pestov
bfe24472ea SIL: Use PublicNonABI linkage for default argument generators in Swift 4 mode
Fixes <rdar://problem/33767513>, <https://bugs.swift.org/browse/SR-5647>.
2018-01-14 22:59:41 -08:00
Slava Pestov
48897ded11 SIL: Remove never-emitted SILDeclRef::Kind::GlobalGetter 2018-01-14 21:39:53 -08:00
Slava Pestov
7bc0c960b0 SIL: Stored property initializers inside @_fixed_layout types are serialized
Now that we enforce the restriction that they can only reference public
symbols, we can allow the optimizer to fully inline them away in client
code.

This is the second part of <rdar://problem/36454839>.
2018-01-12 17:08:01 -08:00
John McCall
52bb547a7e Merge pull request #13866 from rjmccall/accessor-decl
Split AccessorDecl out from FuncDecl.  NFC.
2018-01-12 17:02:35 -05:00
John McCall
7f0f8830cd Split AccessorDecl out from FuncDecl. NFC.
This has three principal advantages:

- It gives some additional type-safety when working
  with known accessors.

- It makes it significantly easier to test whether a declaration
  is an accessor and encourages the use of a common idiom.

- It saves a small amount of memory in both FuncDecl and its
  serialized form.
2018-01-12 14:20:27 -05:00
Slava Pestov
9ff97367df AST: Rename hasFixedLayout() to isResilient() and flip polarity
In IRGen we call this isResilient() already in IRGen, and it's
more consistent to call it the same thing everywhere.
2018-01-11 21:57:42 -08:00
Slava Pestov
98a734386e SIL: Don't give global variable addressors public linkage
We don't use them from outside the module, because we want to
resiliently change a stored property to computed and vice versa.

Fixes <rdar://problem/32937029>.
2018-01-10 19:12:06 -08:00
Slava Pestov
faeab704c6 SIL: Clean up SILDeclRef::getLinkage() 2018-01-10 19:12:05 -08:00
Slava Pestov
4737b28001 SIL: Clean up getMethodDispatch() 2018-01-04 21:53:34 -08:00
Slava Pestov
4f9e53dfa9 SIL: Clean up requiresForeignEntryPoint() 2018-01-04 21:53:34 -08:00
Slava Pestov
e6d498437e SIL: Remove unused hasLoweredLocalCaptures() method 2018-01-04 21:53:33 -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
Michael Gottesman
a8b1917512 [all-+0] Add a new convention for setters: DefaultSetterConventions.
In a situation where normal arguments are +0, we want setters to still take
normal parameters at +1 since in most cases setters will be taking a parameter
that is being forwarded into to be store into a field.

Since this doesn't actually change the current ParameterConvention for setter
normal arguments, this is NFC.

rdar://34222540
2017-11-19 12:35:18 -08:00
Greg Parker
1e894cd80b [runtime] Clean up symbols in error machinery. (#12853)
* [runtime] Clean up symbols in error machinery.

* [runtime] Clean up symbols in Foundation overlay.

* [runtime] Clean up symbols in collections and hashing.

* [runtime] Remove symbol controls from the Linux definition of swift_allocError.

* [tests] Add more stub functions for tests that link directly to the runtime.
2017-11-15 22:20:11 -08:00
Slava Pestov
78ad6c4577 AST: New mangling for method dispatch thunks 2017-11-11 16:31:53 -08:00
Slava Pestov
ce2a434587 SILGen: Fix bug with vtable entries for allocating initializers
Some changes I was working on uncovered a latent bug where we would
emit a class_method instruction to call an allocating initializer
that did not have a vtable entry.

Previously this wasn't caught because the only example of this in
our test suite was in test/SILGen/objc_bridging_any.swift, which
did not test with IRGen; if it did, an IRGen crash would have been
observed.

Factor out some code duplication to prevent this from happening
again, and add a SILGen test that we emit a vtable entry in this
case, and that the test case passes IRGen also.
2017-11-11 02:01:50 -08:00
Slava Pestov
ced25fb0d7 SILGen: Remove more references to the 'uncurry level' concept 2017-11-06 18:48:20 -08:00
Slava Pestov
d73650122b SIL: Serialize default argument generators in Swift 4 mode 2017-09-15 16:20:48 -07:00
Alex Hoppen
b261e099f9 [Mangling] Make appendAccessorEntity take an AbstractStorageDecl 2017-09-10 19:42:22 +02:00
Jordan Rose
449cd98997 Excise "Accessibility" from the compiler (3/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

Rename AccessibilityAttr to AccessControlAttr and
SetterAccessibilityAttr to SetterAccessAttr, then track down the last
few uses of "accessibility" that don't have to do with
NSAccessibility. (I left the SourceKit XPC API alone because that's
supposed to be more stable.)
2017-08-28 13:27:59 -07:00
Jordan Rose
1c651973c3 Excise "Accessibility" from the compiler (2/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the 'Accessibility' enum to be named 'AccessLevel'.
2017-08-28 11:34:44 -07:00
Joe Groff
c374763632 SILGen: Fix override handling when a dynamic init is also required.
A missed case from #11107. Fixes SR-5542 | rdar://problem/33490780.
2017-07-25 10:24:19 -07:00
Slava Pestov
e03e77d5a1 SILGen: Fix linkage for stored property initializers of private properties
Always give stored property initializers the linkage of the type
that contains them, even if the property is less visible than the
type.

This fixes the case where a type defines a private property, and an
extension in a different file from the same module defines a
constructor.

Fixes <rdar://problem/32743703>.
2017-06-28 02:13:35 -04:00
Robert Widmann
3b202c18d8 Use 'hasAssociatedValues'
Use 'hasAssociatedValues' instead of computing and discarding the
interface type of an enum element decl.  This change has specifically not
been made in conditions that use the presence or absence of the
interface type, only conditions that depend on the presence or absence
of associated values in the enum element decl.
2017-05-22 09:54:47 -07:00
Huon Wilson
606a3cc679 Merge pull request #9313 from huonw/symbol-list-7
TBD: ivar init/destroy, materializeForSet callbacks
2017-05-11 20:13:22 +10:00
Huon Wilson
890d348562 [SIL] ivar initializers & destroyers are never public. 2017-05-09 21:16:36 +10:00
Huon Wilson
3bf8dee578 [SIL] Factor out repeated X or XExternal linkage logic. NFC. 2017-05-09 21:15:01 +10:00
Slava Pestov
775462bf52 SILGen: Don't model closure captures as an 'uncurry level' 2017-05-09 00:56:36 -07:00
Slava Pestov
edb1e97a35 SIL: Remove uncurryLevel from SILDeclRef
All we need to store is whether the SILDeclRef directly
references the declaration, or if it references a curry
thunk, and we already have an isCurried bit for that.
2017-05-09 00:56:35 -07:00
practicalswift
492f5cd35a [gardening] Remove redundant repetition of type names (DRY): RepeatedTypeName foo = dyn_cast<RepeatedTypeName>(bar)
Replace `NameOfType foo = dyn_cast<NameOfType>(bar)` with DRY version `auto foo = dyn_cast<NameOfType>(bar)`.

The DRY auto version is by far the dominant form already used in the repo, so this PR merely brings the exceptional cases (redundant repetition form) in line with the dominant form (auto form).

See the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es11-use-auto-to-avoid-redundant-repetition-of-type-names) for a general discussion on why to use `auto` to avoid redundant repetition of type names.
2017-05-05 09:45:53 +02:00
Huon Wilson
64ba6f0379 [SIL] Overriding final decls can behave like non-overriding ones. 2017-04-14 10:13:12 -07:00
Huon Wilson
c41319b24b [SIL] Only open classes can be subclassed externally. 2017-04-14 10:13:11 -07:00
Huon Wilson
b59f95418c [SIL] Extract ClassVisibility from SILFunction to SubclassScope in SILLinkage. 2017-04-13 14:17:29 -07:00
practicalswift
3a652a3939 [gardening] Remove unused variables 2017-04-02 16:02:44 +02:00
Slava Pestov
94ce4c2ac3 SIL: Only give closures shared linkage if they're going to be serialized
Otherwise, we don't want them to be linkonce_odr at the LLVM level
to avoid unnecessary link-time overhead.
2017-03-31 20:26:27 -07:00
Slava Pestov
91b980b94d SILGen: Dynamic, curry, foreign thunks should be serializable
This fixes a crash when referencing partially-applied methods
from @_inlineable functions.

Also, curry thunks for private methods do not need shared
linkage; private is sufficient.
2017-03-29 21:35:25 -07:00
Slava Pestov
8fe8b89b0f SIL: Terminology change: [fragile] => [serialized]
Also, add a third [serializable] state for functions whose bodies we
*can* serialize, but only do so if they're referenced from another
serialized function.

This will be used for bodies synthesized for imported definitions,
such as init(rawValue:), etc, and various thunks, but for now this
change is NFC.
2017-03-29 16:47:28 -07:00