Commit Graph

1232 Commits

Author SHA1 Message Date
Doug Gregor
aa2270a043 Cope with concurrency-related function type adjustments in calls to "super".
Fixes rdar://96545062.
2022-07-07 10:05:02 -07:00
Doug Gregor
cff02f8a0f Merge pull request #59926 from DougGregor/sink-actor-hop-for-get-access
Emit actor hop as part of call to the getter.
2022-07-06 16:16:09 -07:00
Doug Gregor
bc8bd4ea60 Emit actor hop as part of call to the getter.
When emitting a call to the getter for storage, emit the actor hop (and
hop back) as part of the call itself, rather than around the whole
initialization. This address a bug involving initialization with an
optional binding in an `if let`, where the hop-back would only be
performed on the non-nil branch.

Fixes rdar://96487805 / FB10562197
2022-07-06 13:14:50 -07:00
Konrad `ktoso` Malawski
728c007fb9 [Distributed] Implement witnesses for sync or non-throw dist reqs
[Distributed] generic and inner test; without one edge case

[Distributed] fix distributed_thunk test; unsure about those extra hops, could remove later

[Distributed] Remove type pretending in getSILFunctionType; it is not needed

It seems our constant replacement in the earlier phases is enough, and
we don't need this trick at all.

[Distributed] Use thunk when calling cross-actor on DA protocols
2022-07-04 19:02:11 +09:00
Konrad `ktoso` Malawski
ef525424f6 Merge pull request #59700 from xedin/distributed-computed-properties-via-accessor-thunk
[Distributed] Implement distributed computed properties via special accessor
2022-06-30 16:04:36 +09:00
Pavel Yaskevich
59ec5ab552 [Distributed] SILGen: Remove isDistributed flags from accessor code 2022-06-29 14:49:10 -07:00
Pavel Yaskevich
5bdf94f346 [Distributed] Remove commented out code and print statements 2022-06-29 14:49:10 -07:00
Konrad `ktoso` Malawski
febfef97d4 [Distributed] Skeleton implementation of distributed computed properties 2022-06-29 14:49:04 -07:00
Michael Gottesman
6a24087f90 Merge pull request #59611 from gottesmm/moveonly-rebase
[no-implicit-copy] Update SILGen/move checker to work with new patterns from copyable_to_moveonly and friends.
2022-06-28 13:45:15 -07:00
Konrad `ktoso` Malawski
6a2778645f Revert "Merge pull request #59481 from xedin/distributed-computed-properties"
This reverts commit 8125a85a8f, reversing
changes made to 728971c5b7.
2022-06-25 08:49:00 +09:00
Michael Gottesman
3088fe1a01 [move-only] Add support in SILGen for unwrapping moveonlywrapped values before materializing for a function argument.
I discovered this as I began to write some Interpreter tests for move only. This
was triggered by SILGen attempting to pass a non-trivial type to StringBuilder
which is generic, so we needed to materialize.

I also discovered a small bug where we were not properly ignoring class_method
in the move only type eliminator. I just folded the small fix + a test for that
into this commit.
2022-06-22 15:31:57 -07:00
Michael Gottesman
0d11e8ef69 [no-implicit-copy] Update SILGen/move checker to work with new patterns from copyable_to_moveonly and friends.
This involved doing the following:

1. Update the move only checker to look for new patterns.

2. Teach emitSemanticStore to use a moveonlywrapper_to_copyable to store moveonly
   values into memory. The various checkers will validate that this code is
   correct.

3. When emitting an apply, always unwrap move only variables. In the
   future, I am going to avoid this if a parameter is explicitly marked as also
   being moveonly (e.x.: @moveOnly parameter or @noEscape argument).

4. Convert from moveOnly -> copyable on return inst automatically in SILGen.

5. Fix SILGenLValue emission so we emit an error diagnostic later rather than
   crash. This is needed to keep SILGen emitting move only addresses (that is no
   implicit copy address only lets) in a form that the move only checker then
   will error upon. Without this change, SILGen crashes instead of emitting an
   error diagnostic in the following test:
   .//test/SILOptimizer/move_only_checker_addressonly_fail.swift
2022-06-21 16:47:58 -07:00
Pavel Yaskevich
4fa74c238f [AST] ApplyExpr: Rename shouldApplyDistributedThunk to usesDistributedThunk
Since the thunk is applied to expression during solution application,
the use of this flag has shifted towards stating the fact.
2022-06-17 12:35:54 -07:00
Pavel Yaskevich
cae01486c6 [CSApply] Distributed: Inject distributed thunk when necessary
Replace distributed member references with distributed thunks
when access happens outside of distributed actor context. This
significantly simplifies distributed compute properties implementation.
2022-06-17 12:35:48 -07:00
Pavel Yaskevich
567924f7f6 [Distributed] SILGen: Remove isDistributed flags from accessor code 2022-06-17 12:12:16 -07:00
Pavel Yaskevich
b963c6d20f [Distributed] Remove commented out code and print statements 2022-06-17 12:12:16 -07:00
Konrad `ktoso` Malawski
5a5b7c007c towards distributed getters 2022-06-17 12:12:16 -07:00
Konrad `ktoso` Malawski
079bbcf517 wip 2022-06-17 12:12:16 -07:00
Joe Groff
fd2a8e7745 Merge pull request #59290 from jckarter/type-expansion-wmo-private-type
SILGen: Carry WMO of type lowering context to closure captures.
2022-06-08 08:21:06 -07:00
Joe Groff
6b6a557611 SILGen: Carry WMO of type lowering context to closure captures.
TypeConverter doesn't know by itself what SILModule it's currently lowering on
behalf of, so the existing code forming the TypeExpansionContext for opaque types
incorrectly set the isWholeModule flag to always false. This created a miscompile
when a public API contained a closure that captured a value involving private types
from another file in the same module because of mismatched type expansion contexts
inside and outside the closure. Fixes rdar://93821679
2022-06-06 19:51:40 -07:00
Slava Pestov
27fd1bdc55 SILGen: Emit calls to default argument generators at the right abstraction level
Fixes rdar://problem/90717725 / https://bugs.swift.org/browse/SR-16051.
2022-06-02 00:41:32 -04:00
Ehud Adler
4267958d51 Mapping decl base name to imported name 2022-05-18 10:31:04 -04:00
Meghana Gupta
2398181b14 Fix SILGen for yields that are @guaranteed but of trivial type when opaque values are enabled 2022-05-11 21:15:21 -07:00
Meghana Gupta
f3870767b4 Fixes in SILGen for opaque value support in coroutines (#58696) 2022-05-11 01:01:09 -07:00
Kavon Farvardin
814fb42554 fix nested suspension issue with objc async calls
when two objc async functions are composed with each other,
i.e., f(g()), then the clean-ups for g() would get emitted
at an unexpected time, namely, during the suspension for
the call to f(). This means that using a clean-up to emit
the executor-hop breadcrumb was incorrect. The hop could
appear between a get_async continuation and its matching
await_continuation, which is an unsupported nested suspension.

This commit fixes that by removing the use of the breadcrumb
clean-up in favor of providing that breadcrumb directly to
the result plan, so that it may be emitted later on when the
result plan sees fit.

Fixes rdar://91502776
2022-05-02 18:20:59 -07:00
Kavon Farvardin
cb952ed37e Revert "Revert "[SR-15703] Fix missing hop in error path of foreign async throws call""
This reverts commit 05214f0d00.
2022-04-27 14:11:44 -07:00
Kavon Farvardin
6f86e2980a Revert "Revert "Simplify lifetime extension for async ObjC calls.""
This reverts commit 8441e07c0b.
2022-04-27 14:11:36 -07:00
Kavon Farvardin
8441e07c0b Revert "Simplify lifetime extension for async ObjC calls."
This reverts commit 01d470ce32.

Just to be safe, I'm reverting this part of https://github.com/apple/swift/pull/41571
as well, until it can be reimplemented in light of issues where a hop
can appear between a get_continuation and an await_continuation

resolves rdar://91502776
2022-04-25 12:12:26 -07:00
Kavon Farvardin
05214f0d00 Revert "[SR-15703] Fix missing hop in error path of foreign async throws call"
This reverts commit afd26d3974 to solve
a critical miscompile caused by a hop_to_executor appearing between
a get_continuation and await_continuation instruction in SIL.

A reimplementation of SR-15703 will be forthcoming.

Fixes rdar://91502776
2022-04-25 11:00:37 -07:00
zoecarver
336cd29333 [cxx-interop] Add support for calling members of base classes on UFOs. 2022-04-21 13:40:59 -07:00
Anthony Latsis
62a2c9e265 Merge pull request #42137 from AnthonyLatsis/objc-optional-keypath
SILGen: Handle key paths with `@objc optional` property and subscript components
2022-04-02 13:53:25 +03:00
Anthony Latsis
8462493fc9 SILGen: Avoid passing an expression to emitDynamicSubscriptExpr 2022-04-01 17:15:32 +03:00
Anthony Latsis
b68457b6aa [NFC] Gardening: Clean up a redundant computation 2022-04-01 17:15:32 +03:00
Anthony Latsis
9666ea635d SILGenApply: Avoid passing an expression to emitDynamicMemberRefExpr 2022-04-01 17:15:12 +03:00
Joe Groff
d451203b7f SILGen: Emit async let entry points at correct abstraction level.
Avoid a reabstraction thunk every time an async let entry point is emitted,
by setting the context abstraction level while we emit the implicit closure.
Adjust some surrounding logic that breaks when we do this:

- When lowering a non-throwing function type against a throwing abstraction
  pattern, include the error type in the lowered substituted type. Async
  throwing and nonthrowing functions would require another thunk to convert
  away the throwingness of the async context, which would defeat the purpose.
- Adjust the code in IRGen that pads the initial context size for `async let`
  entry points so that it works when the entry point has not yet emitted, by
  marking the async function pointer to be padded later if it isn't defined
  yet.
2022-03-30 14:51:46 -07:00
Andrew Trick
caaad424d8 [SIL-opaque] Various SILGen fixes 2022-03-22 17:04:13 -07:00
Allan Shortlidge
c1e326cbb0 SILGen: Fix SILGen for accessor functions with @_backDeploy. Previously, the @_backDeploy attribute was ignored when generating SIL for accessors on declarations with the attribute since the accessor decls themselves were not directly annotated.
Also, emit an error when `@_backDeploy` is applied to coroutine accessors since they are not supported yet.

Resolves rdar://90112441
2022-03-11 11:07:04 -08:00
Konrad `ktoso` Malawski
5ab8e0834d [Distributed] Reimplement distributed call thunks completely in AST (#41616)
* [Distributed] dist actor always has default executor (currently)

* [Distributed] extra test for missing makeEncoder

* [DistributedDecl] Add DistributedActorSystem to known SDK types

* [DistributedActor] ok progress on getting the system via witness

* [Distributed] allow hop-to `let any: any X` where X is DistActor

* [Distributed] AST: Add an accessor to determine whether type is distributed actor

- Classes have specialized method on their declarations
- Archetypes and existentials check their conformances for
  presence of `DistributedActor` protocol.

* [Distributed] AST: Account for distributed members declared in class extensions

`getConcreteReplacementForProtocolActorSystemType` should use `getSelfClassDecl`
otherwise it wouldn't be able to find actor if the member is declared in an extension.

* [Distributed] fix ad-hoc requirement checks for 'mutating'

[PreChecker] LookupDC might be null, so account for that

* [Distributed] Completed AST synthesis for dist thunk

* [Distributed][ASTDumper] print pretty distributed in right color in AST dumps

* wip on making the local/remote calls

* using the _local to mark the localCall as known local

* [Distributed] fix passing Never when not throwing

* fix lifetime of mangled string

* [Distributed] Implement recordGenericSubstitution

* [Distributed] Dont add .

* [Distributed] dont emit thunk when func broken

* [Distributed] fix tests; cleanups

* [Distributed] cleanup, move is... funcs to DistributedDecl

* [Distributed] Remove SILGen for distributed thunks, it is in Sema now!

* [Distributed]  no need to check stored props in protocols

* remote not used flag

* fix mangling test

* [Distributed] Synthesis: Don't re-use AST nodes for `decodeArgument` references

* [Distributed] Synthesis: Make sure that each thunk parameter has an internal name

* [Distributed/Synthesis] NFC: Add a comment regarding empty internal parameter names

* [Distributed] NFC: Adjust distributed thunk manglings in the accessor section test-cases

* cleanup

* [Distributed] NFC: Adjust distributed thunk manglings in the accessor thunk test-cases

* review follow ups

* xfail some linux tests for now so we can land the AST thunk

* Update distributed_actor_remote_functions.swift

Co-authored-by: Pavel Yaskevich <xedin@apache.org>
2022-03-10 23:58:23 +09:00
Allan Shortlidge
f6ab0ae7a3 Merge pull request #41612 from tshortli/back-deploy-diagnose-decls
Update @_backDeploy ABI semantics and diagnose invalid declarations
2022-03-02 12:52:47 -08:00
Allan Shortlidge
0f890b86fa Sema: Diagnose use of the @_backDeploy attribute on non-final and @objc decls. 2022-03-01 16:37:32 -08:00
Joe Groff
fb178c6c65 Merge pull request #41549 from jckarter/disable-reabstraction-opt-for-foreign-convention
SILGen: Add missing processing to reabstraction fast-path.
2022-02-28 10:32:25 -08:00
swift-ci
e16b126f09 Merge pull request #41571 from kavon/SR-15703
[SR-15703] Fix missing hop in error path of foreign async throws call
2022-02-25 21:31:18 -08:00
Kavon Farvardin
afd26d3974 [SR-15703] Fix missing hop in error path of foreign async throws call
resolves rdar://89479707
2022-02-25 18:32:43 -07:00
Kavon Farvardin
01d470ce32 Simplify lifetime extension for async ObjC calls.
Since the clean-up is not unwind only, we can rely on the
clean-ups to be emitted on both result and throw paths.

This does slightly change when the hop_to_executor is emitted,
in those paths, but that shouldn't matter.

refactors solution for rdar://78982371
2022-02-25 18:32:13 -07:00
Joe Groff
7c9f13a72a SILGen: Add missing processing to reabstraction fast-path.
Calling into foreign-convention functions requires bridging, and the code
that bypassed reabstraction conversions failed to take this into account.
Fixes rdar://89319249.
2022-02-25 12:42:25 -08:00
Allan Shortlidge
5339dae08e SILGen: Emit a fallback variant of a back deployable function and call it when the original function is not available at run time. 2022-02-23 18:07:18 -08:00
Allan Shortlidge
97e8e31b5c SILGen: Emit a thunk that wraps the call to a back deployed function. The thunk calls the original function if it is available at runtime and otherwise falls back to calling a copy that is emitted into the client (not yet implemented). 2022-02-17 11:28:12 -08:00
John McCall
b3b6701a50 Implement @_unsafeInheritExecutor.
SE-0338 changed the execution of non-actor async functions
so that they always hop to the generic executor, but some
functions need a way to suppress this so that they inherit
the caller's executor.

The right way to implement this is to have the caller pass
down the target executor in some reliable way and then
switch to it in all the appropriate places in the caller.
We might reasonably be able to build this on top of isolated
parameters, using some sort of default argument, or we might
need a wholly novel mechanism.

But those things are all ABI-breaking absent some sort of
guarantee about switching that we probably don't want to make,
and unfortunately we have functions in the library which we
need to export that need to inherit executors.  So in the
short term, we need some unsafe way of getting back to the
previous behavior.
2022-02-14 20:46:03 -05:00
Konrad `ktoso` Malawski
a5c2236535 [SGF][Distributed] emitStringLiteral and use it in distributed 2022-01-27 21:19:14 +09:00
Konrad `ktoso` Malawski
4bf2a92bda [Distributed] Remove @_dynamic replacements; impl remoteCall ad-hoc reqs
Squashed commit of the following:

commit e5a05ffe44
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 27 17:45:31 2022 +0900

    cleanup

commit 1f751cea5a
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 27 14:50:33 2022 +0900

    cleanups

commit c632f3215d
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 27 14:01:09 2022 +0900

    add test for generic from actor decl

commit 09b8bd50a7
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 27 14:00:58 2022 +0900

    cleanups

commit 31f4d0cffd
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 27 11:40:51 2022 +0900

    fix test

commit ad4db2fb6c
Merge: 97227edcca 07e2dfda56
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 26 23:31:41 2022 +0900

    Merge branch 'main' into wip-zzz

commit 97227edcca
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 26 21:01:25 2022 +0900

    remove @_dynamic methods!

    fix tests

commit 1c79344dbb
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 19 12:51:09 2022 +0900

    cleanup

    wip

    stuck

    fixed the stack cleanups

    cleanups pretty good now

    weird load

    rki

    works

    remove hack

    add take + throw + return

    fix test

    more tests fixed

    more tests fixed

    more tests fixed

commit 3ed494c175
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Tue Jan 18 21:09:28 2022 +0900

    stack issues in SIL verification

commit 5cf43a7f86
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Tue Jan 18 09:19:51 2022 +0900

    about to call the remoteCall

    goot to return, but missing subs

commit df8e47122a
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 13 14:09:49 2022 +0900

    [Distributed] Refactor Invocation to Decoder/Encoder

    getting there

    done-recording

    working on the string init

    stuck trying to get String initializer SILFunction

    created the remote call target

commit fc7bd62f32
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 23:01:14 2022 +0900

    [Distributed] Pass arguments from Invocation to HBuffer

commit cafc2cc058
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 22:08:47 2022 +0900

    works

commit a7d01837ff
Author: Pavel Yaskevich <pyaskevich@apple.com>
Date:   Tue Jan 11 15:48:58 2022 -0800

    [Distributed] Adjust interface of `swift_distributed_execute_target`

    Since this is a special function, `calleeContext` doesn't point to
    a direct parent but instead both parent context (uninitialized)
    and resume function are passed as last arguments which means that
    `callContext` has to act as an intermediate context in call to accessor.

commit c1f830be27
Author: Pavel Yaskevich <pyaskevich@apple.com>
Date:   Tue Jan 11 17:00:08 2022 -0800

    [Distributed] Drop optionality from result buffer in `_executeDistributedTarget`

    `RawPointer?` is lowered into a two arguments since it's a struct,
    to make it easy let's just allocate an empty pointer for `Void` result.

commit c83c2c37b6
Author: Pavel Yaskevich <pyaskevich@apple.com>
Date:   Tue Jan 11 17:02:45 2022 -0800

    [Distributed] NFC: Update _remoteCall test-case to check multiple different result types

commit 29e7cf50e4
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 21:32:37 2022 +0900

    wip

commit 9128ecc6f8
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 20:46:20 2022 +0900

    wip

commit a6b2a62a67
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 20:38:22 2022 +0900

    wip

commit 8b188f0d43
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 16:55:10 2022 +0900

    wip

commit 3796bec2b9
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 16:55:02 2022 +0900

    wip

commit 0ffc68b5ef
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Tue Jan 11 21:44:58 2022 +0900

    [Distributed] Implementing ad-hoc protocol requirements

commit 78862575e4
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 6 18:03:54 2022 +0900

    cleanup

commit 5f4ab89e25
Merge: 24a628e7c0 fdda6f2ee4
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 6 15:51:39 2022 +0900

    Merge branch 'main' into wip-impl-execute-swift

commit 24a628e7c0
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 6 15:33:21 2022 +0900

    wip

commit 69e7fed09d
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Dec 22 06:36:45 2021 +0900

    [Distributed] comment out distributed_actor_remoteCall for now

commit 376733a9f6
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Tue Dec 21 16:00:06 2021 +0900

    reimplement distributed get type info impls

commit 74ab47886a
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Dec 15 21:37:08 2021 +0900

    [Distributed] Implement func metadata and executeDistributedTarget

    dont expose new entrypoints

    able to get all the way to calling _execute
2022-01-27 17:51:43 +09:00