Commit Graph

1174 Commits

Author SHA1 Message Date
David Zarzycki
54ea315586 [Basic] NFC: Stop using transparent unions 2017-12-16 10:43:49 -05:00
David Zarzycki
68a846e761 [AST] NFC: Do not hard code bit size of 'Kind' field
Also, give each class hierarchy at least 8 bits for the 'Kind' field.
In practice, no class hierarchy has more than 256 nodes, so this
optimizees code generation to make isa/dyn_cast faster.
2017-12-15 14:45:38 -05:00
David Zarzycki
97541e0d1e [Basic] NFC: Standardize and simplify inline bitfields
Inline bitfields are a common design pattern in LLVM and derived
projects, but the associated boilerplate can be demotivating and
brittle. This new header makes it easier to define and use inline
bitfields in Swift.

This also reorders some fields for better code generation.
2017-12-15 14:14:59 -05:00
Slava Pestov
1f1fa3b91d AST: Remove NominalTypeDecl::hasDelayedMembers() 2017-12-12 14:01:55 -08:00
David Zarzycki
4d56dfcc31 [AST] NFC: Repack misc EnumCaseDecl bits 2017-12-10 20:38:02 -05:00
David Zarzycki
045d996127 [AST] NFC: Repack misc ClassDecl bits 2017-12-10 20:38:01 -05:00
David Zarzycki
f3a8023059 [AST] NFC: Repack misc ProtocolDecl bits 2017-12-10 20:38:01 -05:00
David Zarzycki
67f30ac3ea [AST] NFC: Repack misc GenericTypeParamDecl bits 2017-12-10 20:38:01 -05:00
David Zarzycki
82e08ed3b7 [AST] NFC: Repack misc AbstractFunctionDecl bits 2017-12-10 20:38:01 -05:00
David Zarzycki
dd617aafa5 [AST] NFC: Repack misc ImportDecl bits 2017-12-10 20:38:01 -05:00
David Zarzycki
8de981d2a9 [NFC] AST: Pack ParamDecl bits into intrusive bitfield 2017-12-05 16:41:58 -05:00
David Zarzycki
91f9f9d741 [AST] NFC: Pack FuncDecl bits into intrusive bitfield 2017-12-05 16:12:37 -05:00
David Zarzycki
9b9d1733d4 [AST] NFC: Pack Ctor bits into intrusive bitfield 2017-12-05 16:12:37 -05:00
David Zarzycki
392e33637a [AST] NFC: Make Decl bitfield be 64 bit 2017-12-05 16:12:37 -05:00
swift-ci
6285582c13 Merge pull request #13074 from gottesmm/pr-bae9d9e30d40c9211864b978ff3400b9b01034c9 2017-11-26 21:55:50 -08:00
Michael Gottesman
7be1815d3f [ast] Add support for dumping a decl to a file from the debugger.
This is often times useful when one has a wall of AST dump and one wants to
winnow the lines down in a text editor.
2017-11-26 20:16:27 -08:00
Joe Groff
39dfe07354 IRGen: Treat class layout for classes from other modules a bit more opaquely.
We would miscompile in mixed-language-version projects when a Swift class was compiled for one language version, while using Objective-C-imported types that are only available to that version, and then imported into a Swift module with a different language version that wasn't able to see all of the properties because of incompatible imported types. This manifested in a number of ways:

- We assumed we could re-derive the constant field offsets of the class's ivars from the layout, which is wrong if properties are missing, causing accesses to final properties or subclass properties to go to the wrong offsets.
- We assumed we could re-derive the instance size and alignment of a class instance in total, causing code to allocate the wrong amount of memory.
- We neglected to account for the space that stored properties take up in the field offset vector of the class object, causing us to load vtable entries for following subclass methods from the wrong offsets.

Eventually, resilience should reduce our exposure to these kinds of problems. As an incremental step in the right direction, when we look at a class from another module in IRGen, treat it as always variably-sized, so we don't try to hardcode offsets, size, or alignment of its instances. When we import a class, and we're unable to import a stored property, leave behind a new kind of MissingMemberDecl that records the number of field offset vector slots it will take up, so that we lay out subclass objects and compute vtable offsets correctly. Fixes rdar://problem/35330067.

A side effect of this is that the RemoteAST library is no longer able to provide fixed field offsets for class ivars. This doesn't appear to impact the lldb test suite, and they will ultimately need to use more abstract access patterns to get ivar offsets from resilient classes (if they aren't already), so I just removed the RemoteAST test cases that tested for class field offsets for now.
2017-11-17 14:38:08 -08:00
Nathan Hawes
fcc27f04ee Merge pull request #12981 from nathawes/rdar34859742-protocol-rename-failure-in-generic-requirement-of-subscript
[ASTWalker|Refactoring] Walk generic params and requirements in source order for subscript decls
2017-11-16 18:20:39 -08:00
Nathan Hawes
7403e779ad [ASTWalker|Refactoring] Walk generic params and requirements in source order for subscript decls
Also handle requirements in non-trailing where clauses (for -swift-version 3)
Resolves rdar://problem/34859742
2017-11-16 16:02:12 -08:00
Graydon Hoare
97ac580384 Merge pull request #12782 from graydon/fix-35198678-a-little-better
Fix 35198678 a little better
2017-11-15 00:21:47 -08:00
Slava Pestov
ed0ef94d91 Sema: Use a flag to short-circuit the requestClassLayout() check 2017-11-12 19:47:33 -08:00
Alex Hoppen
746bfc6d59 [Refactoring] Add refactoring action to move type members to extension (#12795)
This implements SR-6297.
2017-11-09 11:08:34 -08:00
Graydon Hoare
798f1e19b0 [AST] Address review comments. 2017-11-06 15:50:50 -08:00
Graydon Hoare
6d46fb144f [AST] Move copyFormalAccess to ValueDecl. 2017-11-06 14:31:21 -08:00
Graydon Hoare
7e363ff97a [AST] Add implicit dtors outside typechecking, rdar://35198678 2017-11-04 02:59:52 -07:00
Graydon Hoare
924948419a [NamedLazyMemberLoading] Serialize ProtocolDeclBits.ExistentialTypeSupported. 2017-11-02 15:55:22 -07:00
Doug Gregor
cd3c63cbfd [AST] Stop including GenericSignature.h in other headers.
Except GenericEnvironment.h, because you can't meaningfully use a
GenericEnvironment without its signature. Lots less depends on
GenericSignature.h now. NFC
2017-10-12 14:23:46 -07:00
Slava Pestov
124251cf2c Merge pull request #9619 from allevato/synthesize-equatable-hashable
Synthesize Equatable/Hashable for complex enums, structs
2017-10-10 18:22:40 -07:00
Doug Gregor
a92d8d5760 [Cleanup] Reduce dependencies on swift/AST/LazyResolver.h. 2017-10-10 10:01:39 -07:00
Tony Allevato
ddaa390a62 Merge branch 'master' into synthesize-equatable-hashable 2017-10-10 01:39:48 -07:00
swift-ci
7aa9839b68 Merge pull request #12351 from adrian-prantl/18296829 2017-10-09 17:07:09 -07:00
Tony Allevato
715ba632dd Merge branch 'master' into synthesize-equatable-hashable 2017-10-09 15:57:36 -07:00
Adrian Prantl
44aa4822e0 Debug Info: Represent private discriminators in DWARF.
... using an inline namespace as the parent of the outermost
declaration(s) that have private or fileprivate accessability. Once
LLDB supports this we can retire the existing hack of storing it as a
fake command line argument.

rdar://problem/18296829
2017-10-09 15:32:06 -07:00
Mishal Shah
08a404c014 Merge pull request #12346 from adrian-prantl/18296829
Revert
2017-10-09 13:44:27 -07:00
Doug Gregor
d3de4f2321 Merge pull request #12321 from DougGregor/assoc-type-overrides
Track "overrides" of associated types
2017-10-09 12:59:21 -07:00
Adrian Prantl
dd3ac0e043 Revert "Debug Info: Represent private discriminators in DWARF."
This reverts commit 0aea1c0528 while investigating bot breakage.
2017-10-09 12:55:37 -07:00
adrian-prantl
53ca3b78e2 Merge pull request #12280 from adrian-prantl/18296829
Debug Info: Represent private discriminators in DWARF.
2017-10-09 09:13:15 -07:00
Doug Gregor
ea1396c364 [GSB] Only build potential archetypes for associated type "anchors".
Use the "override" information in associated type declarations to provide
AST-level access to the associated type "anchor", i.e., the canonical
associated type that will be used in generic signatures, mangling,
etc.

In the Generic Signature Builder, only build potential archetypes for
associated types that are anchors, which reduces the number of
potential archetypes we build when type-checking the standard library
by 14% and type-checking time for the standard library by 16%.

There's a minor regression here in some generic signatures that were
accidentally getting (correct) same-type constraints. There were
existing bugs in this area already (Huon found some of them), while
will be addressed as a follow-up.

Fies SR-5726, where we were failing to type-check due to missed
associated type constraints.
2017-10-07 21:52:40 -07:00
Doug Gregor
15386fa0bf [AST] Track overriding relationship among associated types.
When an associated type declaration “overrides” (restates) an associated
type from a protocol it inherits, note that it overrides that declaration.
SourceKit now reports overrides of associated types.
2017-10-07 21:52:40 -07:00
Adrian Prantl
0aea1c0528 Debug Info: Represent private discriminators in DWARF.
... using an inline namespace as the parent of the outermost
declaration(s) that have private or fileprivate accessability. Once
LLDB supports this we can retire the existing hack of storing it as a
fake command line argument.

rdar://problem/18296829
2017-10-06 15:17:25 -07:00
Graydon Hoare
51d759e0f1 [AST] Add dedicated lazier-path to getting protocol associated types. 2017-10-06 01:55:47 -04:00
Jordan Rose
31f97cf93c Use AnyObject instead of Builtin.UnknownObject
...for addressors and for dynamic self.
2017-10-02 09:05:35 -07:00
Doug Gregor
9fa2a8bdca Don’t create a new generic signature builder for non-generic members.
When type-checking a function or subscript that itself does not have generic
parameters (but is within a generic context), we were creating a generic
signature builder which will always produce the same generic signature as
the enclosing context. Stop creating that generic signature builder.

Instead, teach the CompleteGenericTypeResolver to use the generic signature
+ the canonical generic signature builder for that signature to resolve
types, which also eliminates some extraneous re-type-checking.

Improves type-checking performance of the standard library by 36%.
2017-09-24 22:23:00 -07:00
Joe Shajrawi
00f44ce24a Revert "Create fewer generic signature builders" 2017-09-22 21:57:53 -07:00
Doug Gregor
eccdedaf97 Merge pull request #12062 from DougGregor/make-fewer-gsbs
Create fewer generic signature builders
2017-09-22 18:38:27 -07:00
Doug Gregor
98a255994d Don’t create a new generic signature builder for non-generic members.
When type-checking a function or subscript that itself does not have generic
parameters (but is within a generic context), we were creating a generic
signature builder which will always produce the same generic signature as
the enclosing context. Stop creating that generic signature builder.

Instead, teach the CompleteGenericTypeResolver to use the generic signature
+ the canonical generic signature builder for that signature to resolve
types, which also eliminates some extraneous re-type-checking.

Improves type-checking performance of the standard library by 36%.
2017-09-22 11:32:25 -07:00
Tony Allevato
f2c434a038 Merge branch 'master' into synthesize-equatable-hashable 2017-09-21 22:54:36 -07:00
swift-ci
abe34f804b Merge pull request #11902 from itaiferber/factor-out-isdefaultinitializable 2017-09-20 11:32:39 -07:00
Itai Ferber
cda3bf19aa Factor isDefaultInitializable logic for reuse
Factors isDefaultInitializable logic from
TypeChecker::addImplicitConstructors (and others) so it can be reused
for Codable synthesis.
2017-09-20 09:45:25 -07:00
Slava Pestov
400693b811 AST: Store the default argument resilience expansion in the AbstractFunctionDecl
Previously we stored this inside each default argument
initializer context. This was overkill, because it is
the same for all default arguments in a single function,
and also insufficient, because initializer contexts are
not serialized and thus not available in SILGen when
the function is in a different module.

Instead store it directly inside the function and
serialize it.

NFC for now, since SILGen isn't using this yet.
2017-09-15 16:20:45 -07:00