Commit Graph

42 Commits

Author SHA1 Message Date
Max Moiseev
cf4bafe9e3 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-03 13:22:03 -08:00
Slava Pestov
6bf9ab19ff Add preliminary library evolution test for resiliently adding a new protocol requirement
This test ensures that the runtime correctly instantiates resilient conformances,
and that IRGen emits the correct metadata, allowing a conformance that was
compiled before a new requirement was added to present a default implementation
of this requirement.

For now, this runs with --no-backward-deployment, so we only test before/before,
before/after and after/after cases.

Getting after/before working is also an expected capability here, but requires
IRGen witness table emission to know which requirements were satisfied by
defaults, so that they can be dropped if they appear at the end of a witness
table. In turn, this requires serializing SILDefaultWitnessTables. This will
be added in a subsequent patch.

In addition to fixing the above case, I need to write additional tests and
possibly fix bugs related to more elaborate cases involving generics, as well as
default witnesses for properties and subscripts.
2016-03-03 07:37:00 -08:00
Max Moiseev
a49dab6bf8 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-29 12:08:52 -08:00
Daniel Duan
2bc78b8c09 [stdlib] update for 'inout' adjustment (SE-0031) 2016-02-26 12:02:29 -08:00
Max Moiseev
40b1a0b7e0 [stdlib] all sorts of require renamed back to precondition 2016-02-19 18:21:29 -08:00
Dmitri Gribenko
0f36bec31f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-18 16:41:35 -08:00
Dmitri Gribenko
65d840c0ae stdlib: lowercase cases in Optional and ImplicitlyUnwrappedOptional 2016-02-18 00:40:33 -08:00
Dmitri Gribenko
dd75aed67a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-17 14:40:05 -08:00
Luke Larson
f53db0ebd3 [rth] Add resilience test helper utility 2016-02-16 18:52:34 -08:00
Max Moiseev
3a3984877a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-15 15:43:34 -08:00
Dmitri Gribenko
7e9b8fe325 Fix Evolution tests in the mode when StdlibUnittest is built with -sil-serialize-all 2016-02-13 18:37:27 -08:00
Slava Pestov
c823974f85 Fix add_conformance evolution tests to pass with optimized builds
Even dynamically casting a generic parameter to a protocol type is only
guaranteed to succeed for conformances available at build time.

Since we can't express conditional availability of conformances yet,
this part of the test is useless, so redo it.
2016-02-13 18:21:58 -08:00
Max Moiseev
55fde4c923 making tests pass 2016-02-10 16:08:40 -08:00
Michael Gottesman
de7ecf16a0 Disable this evolution test on ASAN builders for now to get all of the bots green. 2016-02-07 09:08:03 -08:00
Michael Gottesman
34904f9edb Disable evolution test that is failing in ASAN in the clang importer so I can land the stable merge. rdar://24540778. 2016-02-06 18:25:25 -08:00
Slava Pestov
44951f0bd3 These two Evolution tests are failing with optimizations enabled
I'll investigate shortly.
2016-02-05 12:50:05 -08:00
Dmitri Gribenko
0646b00498 Mark Evolution tests as executable 2016-02-04 17:17:41 -08:00
Slava Pestov
d887d823ef Re-apply "Protocol conformances can now reference resilient value types"
This comes with a fix for a null pointer dereference in _typeByName()
that would pop with foreign classes that do not have a
NominalTypeDescriptor.

Also, I decided to back out part of the change for now, where the
NominalTypeDescriptor references an accessor function instead of a
pattern, since this broke LLDB, which reaches into the pattern to
get the generic cache.

Soon we will split off the generic cache from the pattern, and at
that time we can change the NominalTypeDescriptor to point at the
cache. But for now, let's avoid needless churn in LLDB by keeping
that part of the setup unchanged.
2016-01-29 00:49:00 -08:00
Slava Pestov
4fd1387b3a Revert "Protocol conformances can now reference resilient value types"
This apparently broke Foundation and LLDB tests. I need to investigate further.

This reverts commit 65dd0e7b93.
2016-01-28 01:03:39 -08:00
Slava Pestov
65dd0e7b93 Protocol conformances can now reference resilient value types
Change conformance records to reference NominalTypeDescriptors instead of
metadata patterns for resilient or generic types.

For a resilient type, we don't know if the metadata is constant or not,
so we can't directly reference either constant metadata or the metadata
template.

Also, whereas previously NominalTypeDescriptors would point to the
metadata pattern, they now point to the metadata accessor function.
This allows the recently-added logic for instantiating concrete types
by name to continue working.

In turn, swift_initClassMetadata_UniversalStrategy() would reach into
the NominalTypeDescriptor to get the pattern out, so that its bump
allocator could be used to allocate ivar tables. Since the pattern is
no longer available this way, we have to pass it in as a parameter.

In the future, we will split off the read-write metadata cache entry
from the pattern; then swift_initClassMetadata_UniversalStrategy() can
just take a pointer to that, since it doesn't actually need anything
else from the pattern.

Since Clang doesn't guarantee alignment for function pointers, I had
to kill the cute trick that packed the NominalTypeKind into the low
bits of the relative pointer to the pattern; instead the kind is now
stored out of line. We could fix this by packing it with some other
field, or keep it this way in case we add new flags later.

Now that generic metadata is instantiated by calling accessor functions,
this change removes the last remaining place that metadata patterns were
referenced from outside the module they were defined in. Now, the layout
of the metadata pattern and the behavior of swift_getGenericMetadata()
is purely an implementation detail of generic metadata accessors.

This patch allows two previously-XFAIL'd tests to pass.
2016-01-28 00:33:10 -08:00
Slava Pestov
59a2e2aff8 Library evolution tests: add test for changing body of a transparent function
I'm going to add some more tests related to @_transparent shortly,
and it is important to verify that bodies of @_transparent functions
are serialized (at least in single-frontend mode, for now).

I realize this test is probably too specific, since in the future
we may sometimes choose not to inline @_transparent functions into
their callers, even if a serialized body is available; but this
will suffice for now.
2016-01-22 16:44:33 -08:00
Slava Pestov
14c9329920 Library evolution tests: preliminary tests for resiliently-sized classes
Note that subclassing of resilient classes doesn't work yet, and
there are no tests for it.
2016-01-22 16:04:38 -08:00
Slava Pestov
c5592e63ff Library evolution tests: split up struct_add_remove_properties into multiple tests 2016-01-22 16:04:29 -08:00
Slava Pestov
b6b5f8bfa9 Add preliminary enum evolution tests
These are passing now that resilient enum case numbering has been
implemented.
2016-01-21 12:10:58 -08:00
Slava Pestov
0159627322 As promised, split up struct_add_remove_conformances library evolution test
We now test four setups, with the four {before, after}^2 runs of each:

a) Client adds conformance -vs- library adds public conformance -- fixed-layout struct
b) Client adds conformance -vs- library removes internal conformance -- fixed-layout struct
c) Client adds conformance -vs- library adds public conformance -- resilient struct
d) Client adds conformance -vs- library removes internal conformance -- resilient struct

The first two pass, but a) requires a hack to ensure we don't
directly reference conformance table, otherwise the 'after_before'
version doesn't link. I think the right idea here is to weakly
reference conformance tables where the deployment target is
lower than the availability of the conformance.

The second two are XFAIL'd until protocol conformance tables can
reference resilient types from other modules. This requires emitting
indirect metadata symbols, since the client doesn't know if the
resilient type's metadata is direct or a template, and the
conformance table cannot use the metadata accessor either.

These tests will also become important if we decide to revisit
synthesized accessors, and make them lazy again for structs.
2016-01-20 19:08:13 -08:00
Slava Pestov
1d77d810fd Re-apply "Sema: Always synthesize accessors for structs, unless they were imported from Clang"
This reverts commit 24a70e17ea.
2016-01-20 15:04:10 -08:00
Mark Lacey
24a70e17ea Revert "Sema: Always synthesize accessors for structs, unless they were imported from Clang"
This reverts commit 2b6ab633fc because it
at least breaks:
    Swift :: stdlib/SequenceType.swift.gyb
and possibly also results in some or all of these failures:
    Swift :: compiler_crashers/27944-swift-astvisitor.swift
    Swift :: compiler_crashers/28200-swift-typebase-getdesugaredtype.swift
    Swift :: stdlib/CollectionType.swift.gyb
    Swift :: stdlib/MicroStdlib.swift
2016-01-20 08:32:39 -08:00
Slava Pestov
2b6ab633fc Sema: Always synthesize accessors for structs, unless they were imported from Clang
This fixes the issue that "SILGen: Correctly emit accessors synthesized to
witness protocol requirements" was meant to solve, but in a simpler way.

A better fix would be to first address the issue where @_transparent
function bodies are not serialized in some cases, and then only emit
synthesized accessors as needed, in the original version of this patch.
To fix the duplicate symbol issues, we would emit the synthesized
accessors with shared linkage, which would always work once serialized
bodies were available.

For resilient structs of course, we'll always need to emit accessors
anyway.
2016-01-20 02:11:53 -08:00
Slava Pestov
5d1da8b957 Fix for struct_add_remove_conformances accessing witness table directly
The test removes a public conformance, which is technically not resilient.
I will split up the test into two tests soon:

- client library adds conformance, library adds public conformance
- client library adds conformance, library removes *private* conformance
2016-01-20 01:50:17 -08:00
Slava Pestov
0d96017b0d Add some more detail to library evolution test readme 2016-01-18 23:27:50 -08:00
Slava Pestov
afe2893835 SIL: Mark alloc_global as having side effects
Otherwise it just gets optimized away.

Fixes <rdar://problem/24222892>.
2016-01-17 19:40:03 -08:00
Erik Eckstein
e369c95cce tests: temporarily disable the test_global_change_size test in optimized mode.
Reason: rdar://problem/24222892
2016-01-17 10:37:18 -08:00
Erik Eckstein
f213f444eb tests: 32-bit platforms don't like dead beef 2016-01-17 09:49:15 -08:00
Slava Pestov
4e8af2735c Forgot to re-enable some tests in test_global_stored_to_computed 2016-01-16 02:31:52 -08:00
Slava Pestov
1b2288fa96 Add library evolution test for changing a static struct property from stored to computed 2016-01-16 02:28:39 -08:00
Slava Pestov
7e96a93372 Add library evolution tests for resiliently-sized and resiliently-accessed globals 2016-01-16 02:23:28 -08:00
David Farler
7b27c71770 Add Readme for resilience execution tests 2016-01-15 22:22:26 -08:00
David Farler
7229ce29df Convert resilient superclass dispatch tests to StdlibUnittest
Also run the full product of before/after combinations.
2016-01-15 22:22:26 -08:00
David Farler
a5c01b4b13 Test fix: make resilient super tests platform agnostic 2016-01-15 21:24:01 -08:00
David Farler
762c1f62d1 Add before/after execution tests for resilient super method dispatch 2016-01-15 19:31:01 -08:00
practicalswift
19fdd8fd0d [gardening] Fix recently introduced typo. 2016-01-13 13:49:11 +01:00
Slava Pestov
e711d5e427 Preliminary evolution tests
Checking these in to get some discussion over FileCheck style and
test file structure going before I write too many more tests.
2016-01-13 01:32:27 -08:00