Commit Graph

2588 Commits

Author SHA1 Message Date
Holly Borla
234b5dc660 [SE-0393] Require the repeat keyword for generic requirement expansions. 2023-04-12 22:04:01 -07:00
Michael Gottesman
19f1dedf1f [move-only] When emitting an initializer for an empty struct, store an instance to make sure it is initialized.
I ran into this while fixing the parent commit when attempting to add the
interpreter test in this commit into the aforementioned parent commit.

rdar://107974302
2023-04-12 20:56:31 -07:00
Slava Pestov
db058a4f9c Merge pull request #64753 from slavapestov/variadic-conformances
Fixes for conformances of variadic generic types
2023-04-06 08:18:22 -04:00
Slava Pestov
268fff7884 Add executable test for conformances of variadic generic types 2023-04-05 23:42:17 -04:00
Slava Pestov
c6746a5b20 Merge pull request #64949 from slavapestov/fix-variadic-generics-test-old-OS
test/Interpreter/import_parameter_pack_library.swift passes with the optimizer, but needs a new OS
2023-04-05 20:18:27 -04:00
Slava Pestov
86ec73f432 test/Interpreter/import_parameter_pack_library.swift passes with the optimizer, but needs a new OS 2023-04-05 16:44:47 -04:00
Rintaro Ishizaki
655e30b1c7 [Tests] Disable 2 tests in use_os_stdlib
rdar://107658865
rdar://107670464
2023-04-05 12:12:36 -07:00
John McCall
9c9671b349 Merge pull request #64887 from rjmccall/vanishing-tuple-silgen
SILGen and SIL type lowering support for vanishing tuples
2023-04-04 12:41:29 -04:00
John McCall
70497970f4 Tests for the vanishing tuples work in this PR.
Fixes rdar://107459964 and rdar://107478603.
2023-04-03 23:17:57 -04:00
Joe Groff
736242d394 Merge pull request #64850 from jckarter/move-only-escape-di
MoveOnlyAddressChecker: Confine analysis to current formal access.
2023-04-03 09:27:56 -07:00
Slava Pestov
3d9a79e4b1 Merge pull request #64777 from slavapestov/sil-optimizer-variadic-generics
SIL optimizer fixes for variadic generics
2023-04-03 11:30:03 -04:00
Slava Pestov
39d82deabd Enable SIL optimizer for some executable variadic generics tests
variadic_generic_tuples is still WIP.
2023-04-02 23:02:37 -04:00
Joe Groff
8e21bfcc47 MoveOnlyAddressChecker: Confine analysis to current formal access.
Code can only locally interact with a mutable memory location within a
formal access, and is only responsible for maintaining its invariants
during that access, so the move-only address checker does not need to,
and should not, observe operations that occur outside of the access
marked with the `mark_must_check` instruction. And for immutable
memory locations, although there are no explicit formal accesses, that's
because every access must be read-only, so although individual
accesses are not delimited, they are all compatible as far as
move-only checking is concerned. So we can back out the changes to SILGen
to re-project a memory location from its origin on every access, a
change which breaks invariants assumed by other SIL passes.
2023-04-02 16:33:57 -07:00
Michael Gottesman
43d8ab24f4 [move-only] Add a new type of mark_must_check initable_but_not_consumable.
This is used to teach the checker that the thing being checked is supposed to be
uninitialized at the mark_must_check point so that we don't put a destroy_addr
there.

The way this is implemented is that we always initially add
assignable_but_not_consumable but in DI once we discover that the assign we are
guarding is an init, we convert the assignable to its initable variant.

rdar://106525988
2023-03-31 17:32:58 -07:00
Slava Pestov
be058dfec0 Mark opaque_result_type_runtime_call.swift as an executable_test 2023-03-30 09:25:04 -04:00
Rintaro Ishizaki
0c1c922c9c [Tests] Add 'REQUIRES: executable_test' to a Interpreter test
rdar://107388467
2023-03-29 15:11:47 -07:00
Rintaro Ishizaki
4de3d033dd [Tests] Disable a test case
Disable test/Interpreter/objc_protocols.swift while investigating

rdar://107343134
2023-03-29 13:53:19 -07:00
Slava Pestov
5c9c05934e Merge pull request #64679 from slavapestov/varidic-generic-captures
IRGen support for closures that capture metadata and witness table packs
2023-03-29 07:46:11 -04:00
Slava Pestov
8a6bb30c4c IRGen: Heap-allocate metadata and witness table packs captured by escaping closures 2023-03-28 21:44:53 -04:00
Slava Pestov
5e1ff23930 Add some tests for variadic generic captures 2023-03-28 21:44:53 -04:00
Slava Pestov
a57ecb36ed IRGen: Clean up duplication in withOpaqueTypeGenericArgs() 2023-03-28 19:21:45 -04:00
Michael Gottesman
aa75e6d99f [move-only] Temporarily ban deinits on non-copyable enums.
The reason why we are doing this is that:

1. For non-copyable types, switches are always at +1 for now.
2. non-copyable enums with deinits cannot be switched upon since that would
invalidate the deinit.

So deinits on non-copyable enums are just not useful at this point since you
cannot open the enum.

Once we make it so that you can bind a non-copyable enum at +0, we will
remove this check.

I added an experimental feature MoveOnlyEnumDeinits so tests that validate the
codegen/etc will still work.

rdar://101651138
2023-03-28 16:07:15 -07:00
Holly Borla
58abfb8f08 [Parameter Packs] Add an execution test for building and importing a library using
parameter packs.
2023-03-27 20:11:57 -07:00
Slava Pestov
5f0d7320df Runtime: Fix MetadataCacheKey::installInto() for variadic generics 2023-03-22 16:53:25 -04:00
Slava Pestov
c50e8bb5de Runtime: Check same-type pack requirements in checkGenericPackRequirement() 2023-03-17 22:19:18 -04:00
Slava Pestov
a21b0d9749 Runtime: Check layout pack requirements in checkGenericPackRequirement() 2023-03-17 22:19:18 -04:00
Slava Pestov
d17baed985 Runtime: Check superclass pack requirements in checkGenericPackRequirement() 2023-03-17 22:19:17 -04:00
Dario Rexin
2f8c1a402c [IRGen] Make pointers to accessor functions in layout strings relative (#64155)
* [IRGen] Make pointers to accessor functions in layout strings relative

rdar://106319336

Pointers embedded in static layout strings should always be relative, so layout strings can reside in read-only memory.

* Properly handle reference storage ownership

* Pass layout tag and metadata / type layout ppointers separately

* Layout string instantiation fully working

* Fix cases where hasLayoutString flag was not set when it should have

* Update include/swift/ABI/Metadata.h
2023-03-17 09:02:51 -07:00
Michael Gottesman
3de646e7c4 [move-only] Change global_addr assignable_but_not_consumable accesses such that they are initialized at end of lifetime.
I also added an interpreter test that validates that ref_element_addr works as
expected (I fixed that in an earlier commit, but did not add an interpreter
test).

rdar://106724277
2023-03-16 12:28:59 -07:00
Kavon Farvardin
a8a44ebb17 Merge pull request #64106 from kavon/enable-moveonly-by-default
Enable moveonly / noncopyable types by default
2023-03-15 09:59:29 -07:00
Kavon Farvardin
2c7d9a5047 update tests given move-only types are enabled
the main things still left behind the experimental flag(s) are
- move-only classes (guarded by MoveOnlyClasses feature)
- noimplicitcopy
- the _borrow operator
2023-03-14 18:35:13 -07:00
Michael Gottesman
b3bbaec709 Merge pull request #64366 from gottesmm/pr-63fcd3307c126048533239ab77552bb5acdc728c
[move-only] Treat mark_must_check assignable_but_not_consumable as ending initialized
2023-03-14 17:12:11 -07:00
Michael Gottesman
8f9772dcf1 [move-only] Make sure to treat (mark_must_check (begin_access (project_box (@capture box arg)))) like an inout term user requiring situation.
We already did this for the situation without the begin_access. In truth, using
the terminator is a bit too wide, but it works for these sorts of arguments that
use assignable_but_not_consumable so for expediency (and since we are just
walking blocks), I just decided to do something quick.

rdar://106208343
2023-03-14 14:03:20 -07:00
Joe Groff
730c5cf632 Merge pull request #64295 from jckarter/noncopyable-hide-field-types
Don't let reflection handle noncopyable types yet.
2023-03-13 17:01:25 -07:00
Joe Groff
4d6d7657fa Don't let reflection handle noncopyable types yet.
We don't have any language or runtime support for noncopyable types as generic
or dynamic types yet, and existing reflection code almost certainly assumes it
can copy the values it's working with, and will trap or corrupt state if it does
so with noncopyable types. But a class can have noncopyable fields while the
type itself is copyable, and existing code assumes that it can use `Mirror` or
other reflection mechanisms to safely traverse the contents of an arbitrary
class.

Allow this sort of code to continue working, while still preparing for forward
compatibility with future runtimes that do support noncopyable generics, by
emitting the type references for fields using a function that probes the
address of a new symbol in the Swift runtime. The symbol will either be missing
or defined with an absolute address of zero in current or previous runtime
versions, but can be changed to a non-null address in the future.
2023-03-13 11:50:24 -07:00
Holly Borla
8862b1bfb5 Merge pull request #64272 from hborla/emit-materialize-pack-expr
[SILGen] Emit `MaterializePackExpr`s.
2023-03-11 13:30:52 -08:00
Slava Pestov
de73859d0f Add execution tests for dynamic layout of variadic generic types 2023-03-10 12:15:55 -05:00
Holly Borla
dce70f373f [SILGen] Emit MaterializePackExprs.
The subexpression of a MaterializePackExpr (which is always a tuple value
currently) is emitted while preparing to emit a pack expansion expr, and its
elements are projected from within the dynamic pack loop. This means that a
materialized pack is only evaluated once, rather than being evaluated on
every iteration over the pack elements.
2023-03-09 21:44:03 -08:00
Slava Pestov
d776f71b4f Runtime: Teach checkGenericRequirements() to check same-shape and conformance pack requirements 2023-03-09 09:42:00 -05:00
Slava Pestov
76103ce4c0 Disable variadic_generic_types.swift in backward-deployment tests
Fixes rdar://106294162.
2023-03-06 13:37:01 -05:00
Dario Rexin
5fe716577b [IRGen] Add layout strings for generic and resilient types (#64023)
* [IRGen] Add layout strings for generic and resilient types

rdar://105837048

* Add some corner cases

* Add flag to enable generic instantiation and some fixes

* Fix resilient types

* Fix metadata accessor function pointers in combined layout strings
2023-03-05 15:26:45 -08:00
Slava Pestov
5e52ad5e0b Add executable test for variadic generic type metadata 2023-03-04 10:42:42 -05:00
Slava Pestov
8c984ee7e5 Rename test/Interpreter/variadic_generic_types.swift to variadic_generic_tuples.swift and add more tests 2023-03-04 00:12:12 -05:00
Sophia Poirier
a9e5075a94 Merge pull request #64039 from sophiapoirier/pack-type-syntax-each
[Variadic Generics] type parameter pack syntax change: T... -> each T
2023-03-02 19:17:19 -08:00
Doug Gregor
cfc333af50 Merge pull request #64040 from DougGregor/objc-impl-initial-value-stored-properties
Support initial values for stored properties of `@_objcImplementation`.
2023-03-02 15:42:01 -08:00
swift-ci
cad2c7baeb Merge pull request #63305 from mikeash/print-keypath-dependent-generic-type
[Runtime] Fix subscript key path printing when arguments can't be resolved.
2023-03-02 15:19:08 -08:00
Sophia Poirier
70cffb06f3 [Variadic Generics] type parameter pack syntax change: T... -> each T 2023-03-02 14:42:28 -08:00
Doug Gregor
9a91a448e3 Support initial values for stored properties of @_objcImplementation.
Fixes rdar://106108285.
2023-03-02 12:22:11 -08:00
Mike Ash
91dcf8d298 [Runtime] Fix subscript key path printing when arguments can't be resolved.
If there's a mismatch between the arguments we match and the arguments we actually have, we can end up indexing off the end of the argumentTypeNames vector. This can happen when an argument has a dependent generic type. Add a bounds check and print <unknown> when we're out of bounds to avoid crashing.

For correctness, we should match generic dependent types and add them to the arguments array, but we'll fix the crashes first.

rdar://104438524
2023-03-02 13:46:44 -05:00
Joe Groff
bfd6d96ca8 Merge pull request #64019 from jckarter/se-0366-consume-final-spelling
Implement `consume x` operator with the accepted SE-0366 syntax.
2023-03-02 07:23:17 -08:00