Commit Graph

580 Commits

Author SHA1 Message Date
Konrad `ktoso` Malawski
6ddfb6d9c2 correct indent handling for requirement stubs 2023-11-29 14:48:11 +09:00
Konrad `ktoso` Malawski
29982fcc51 Add fixits for distributed system adhoc requirements; make easier to adopt
rdar://114185115
2023-11-29 14:48:10 +09:00
Konrad `ktoso` Malawski
1219d4b8a4 [Distributed] Remove redundant isa check in getting SR 2023-11-16 11:48:17 +09:00
Konrad `ktoso` Malawski
0f5e564bbf handle conformance requirement on extension in distributed funcs 2023-11-14 22:06:35 +09:00
Konrad `ktoso` Malawski
30653a8091 [Distributed] Don't crash in thunk generation when missing SR conformance 2023-11-14 20:57:33 +09:00
Konrad `ktoso` Malawski
aa4b0d0ae3 Merge pull request #69823 from ktoso/wip-remoteCall_argument_old_os_tests
[Distributed] Resolve test issue on old OSes in remoteCall labels
2023-11-14 11:41:11 +09:00
Konrad `ktoso` Malawski
708f23a836 [Distributed] Resolve test issue on old OSes in remoteCall labels 2023-11-14 07:21:31 +09:00
Allan Shortlidge
941ac3c097 Distributed: Enabled availability checking in Distributed tests.
Various distributed actors test cases were testing behavior that ultimately
depends on availability checking but then disabled availability checking on the
command line when building. This will break with future planned changes to
availability checking infrastructure.
2023-11-08 20:56:04 -08:00
Konrad `ktoso` Malawski
8fde809a2c Remove ad-hoc ambiguity detection code; use conflicting() 2023-11-06 12:59:30 +09:00
Konrad `ktoso` Malawski
faf287015f [Distributed] Allow overloads with different types; mangling can handle it 2023-11-02 12:36:40 +09:00
Allan Shortlidge
d0e2ca4e0c SILGen: Skip emitting distributed thunks for skipped accessors.
Generalizes https://github.com/apple/swift/pull/68917 to cover accessors in
addition to methods.

Resolves rdar://117226130
2023-10-26 16:32:51 -07:00
Konrad `ktoso` Malawski
370fa50132 Merge pull request #69093 from ktoso/wip-distributed-effective-label 2023-10-25 10:40:17 +09:00
Konrad `ktoso` Malawski
0a65445765 [Distributed] Correct handling super-class implemented ad-hoc requirements 2023-10-20 10:30:51 +09:00
Konrad `ktoso` Malawski
1d150c811c [Distributed] Fix effectiveLabel implemementation to expected semantics 2023-10-11 00:19:34 +09:00
Allan Shortlidge
a200333a2d SILGen: Skip emitting distributed thunks for skipped functions. 2023-10-02 11:04:07 -07:00
Evan Wilde
6cb608f906 Merge pull request #68757 from etcwilde/ewilde/require-swiftcompilersource 2023-09-26 08:48:37 -07:00
Alex Lorenz
6ecea1ac09 Merge pull request #68481 from hyp/eng/no-nocapture
[IRGen][interop] do not add 'nocapture' to not bitwise takable types
2023-09-26 07:52:05 -07:00
Evan Wilde
af5065dcdf Require swift_in_compiler in dist. ownership verify sil
Commit 5bc036661c introduced changes to
distributed_id_system_ownership_verify_sil.swift that don't work unless
you have SwiftCompilerSources enable. Gating test on that.
2023-09-25 20:48:23 -07:00
Alex Lorenz
4858cb6225 [IRGen][interop] do not add 'nocapture' to not bitwise takable types
The use of 'nocapture' for parameters and return values is incorrect for C++ types, as they can actually capture a pointer into its own value (e.g. std::string in libstdc++)

rdar://115062687
2023-09-25 17:43:34 -07:00
Konrad `ktoso` Malawski
04f589fea9 Disable flaky distributed_actor_executor_ast.swift while we investigate
Disable while we investigate rdar://114453974
2023-09-21 08:15:16 -05:00
eeckstein
97668d5b94 Merge pull request #68349 from eeckstein/let-property-lowering
SIL+Optimizer: a better representation for class let-fields
2023-09-19 20:27:43 +02:00
Erik Eckstein
5bc036661c SIL optimizer: add the LetPropertyLowering pass
It lowers let property accesses of classes.
Lowering consists of two tasks:

* In class initializers, insert `end_init_let_ref` instructions at places where all let-fields are initialized.
  This strictly separates the life-range of the class into a region where let fields are still written during
  initialization and a region where let fields are truly immutable.

* Add the `[immutable]` flag to all `ref_element_addr` instructions (for let-fields) which are in the "immutable"
  region. This includes the region after an inserted `end_init_let_ref` in an class initializer, but also all
  let-field accesses in other functions than the initializer and the destructor.

This pass should run after DefiniteInitialization but before RawSILInstLowering (because it relies on `mark_uninitialized` still present in the class initializer).
Note that it's not mandatory to run this pass. If it doesn't run, SIL is still correct.

Simplified example (after lowering):

  bb0(%0 : @owned C):                           // = self of the class initializer
    %1 = mark_uninitialized %0
    %2 = ref_element_addr %1, #C.l              // a let-field
    store %init_value to %2
    %3 = end_init_let_ref %1                    // inserted by lowering
    %4 = ref_element_addr [immutable] %3, #C.l  // set to immutable by lowering
    %5 = load %4
2023-09-19 15:10:30 +02:00
Kavon Farvardin
16af507d9e [Concurrency] tighten-up rules about isolated generic parameters
We were missing a check for conformance to `Actor` or `DistributedActor`
when an isolated parameter's type is a generic parameter.

Previously, if you used a generic parameter constrained to just `AnyActor`,
you'd crash the compiler in LowerHopToExecutor because it doesn't know
how to obtain the executor for such a value. Since `AnyActor` has no
`unownedExecutor` requirement, there's no way to get the executor without
emitting code to do dynamic casts down to `Actor` or `DistributedActor`.

Rather than have the compiler silently emit dynamic casting, I figured
it's best to ban it. This forces people to either do the dynamic casts
themselves, or use one of the more specific types to constrain their
parameter.

For other generic parameters, we would silently treat the function
as though it is nonisolated (i.e., as if the `isolated` wasn't written
on the parameter at all).

resolves rdar://109059544
2023-09-18 20:27:46 -07:00
swift-ci
b1abe1b7ab Merge pull request #68451 from ktoso/wip-radar-91857262
[Distributed] Add test coverage for extension where Self: DistributedActor
2023-09-12 04:20:20 -07:00
Becca Royal-Gordon
8770c7f826 Rework ASTDumper (#68438)
This PR refactors the ASTDumper to make it more structured, less mistake-prone, and more amenable to future changes. For example:

```cpp
  // Before:
  void visitUnresolvedDotExpr(UnresolvedDotExpr *E) {
    printCommon(E, "unresolved_dot_expr")
      << " field '" << E->getName() << "'";
    PrintWithColorRAII(OS, ExprModifierColor)
      << " function_ref=" << getFunctionRefKindStr(E->getFunctionRefKind());
    if (E->getBase()) {
      OS << '\n';
      printRec(E->getBase());
    }
    PrintWithColorRAII(OS, ParenthesisColor) << ')';
  }

  // After:
  void visitUnresolvedDotExpr(UnresolvedDotExpr *E, StringRef label) {
    printCommon(E, "unresolved_dot_expr", label);

    printFieldQuoted(E->getName(), "field");
    printField(E->getFunctionRefKind(), "function_ref", ExprModifierColor);

    if (E->getBase()) {
      printRec(E->getBase());
    }

    printFoot();
  }
```

* Values are printed through calls to base class methods, rather than direct access to the underlying `raw_ostream`.
    * These methods tend to reduce the chances of bugs like missing/extra spaces or newlines, too much/too little indentation, etc.
    * More values are quoted, and unprintable/non-ASCII characters in quoted values are escaped before printing.
* Infrastructure to label child nodes now exists.
    * Some weird breaks from the normal "style", like `PatternBindingDecl`'s original and processed initializers, have been brought into line.
* Some types that previously used ad-hoc dumping functions, like conformances and substitution maps, are now structured similarly to the dumper classes.
* I've fixed the odd dumping bug along the way. For example, distributed actors were only marked `actor`, not `distributed actor`.

This PR doesn't change the overall style of AST dumps; they're still pseudo-S-expressions. But the logic that implements this style is now isolated into a relatively small base class, making it feasible to introduce e.g. JSON dumping in the future.
2023-09-11 23:56:38 -07:00
Konrad `ktoso` Malawski
954c38bbfd Add test coverage for extension where Self: DistributedActor
Additional test coverage for rdar://91857262
2023-09-12 13:55:40 +09:00
Konrad `ktoso` Malawski
b5219c31ed Make sure we don't crash on missing ActorSystem typealias
Refs rdar://90886302
2023-09-12 11:11:37 +09:00
Slava Pestov
9ebb5f2e03 AST: Rename VarDecl::getType() to VarDecl::getTypeInContext()
This is a futile attempt to discourage future use of getType() by
giving it a "scary" name.

We want people to use getInterfaceType() like with the other decl kinds.
2023-08-04 14:19:25 -04:00
Konrad `ktoso` Malawski
8c8fdf90c4 [Distributed] Try redirecting AST dump to file for test 2023-07-12 18:01:50 +09:00
Konrad `ktoso` Malawski
5fd22b09af Merge pull request #67043 from ktoso/wip-poc-validate-distributed-param 2023-07-04 12:04:16 +09:00
Konrad `ktoso` Malawski
037df0130f [Distributed] PoC using a property wrapper on distributed func param for validation 2023-06-30 11:28:27 +09:00
Arnold Schwaighofer
fc766a39d3 Fix some more tests 2023-06-29 16:16:56 -07:00
Doug Gregor
740cd7bd61 [Distributed] Implement distributed actor semantics in call checking
The move to perform all call checking that can cross concurrency
domains into one place dropped the specific logic for distributed
actor calls. Introduce that logic, cleaning it up to consistently use
the "known to be local" semantics needed for distributed actors.
2023-06-26 13:39:56 -07:00
Arnold Schwaighofer
39da8be6f4 Fix test/Distributed directory 2023-06-20 13:14:59 -07:00
Konrad `ktoso` Malawski
b420190059 Merge pull request #66695 from ktoso/wip-distributed-harden-empty-impls
[Distributed] Harden typechecker against completely empty DAS types
2023-06-16 22:24:43 +09:00
Konrad `ktoso` Malawski
fc7ecc8f67 [Distributed] Harden typechecker against completely empty DAS types 2023-06-16 11:54:51 +09:00
Arnold Schwaighofer
316e982bbf Fix linux tests 2023-06-14 10:49:50 -07:00
Arnold Schwaighofer
c1a93e0bde Move tests over to use the %use_no_opaque_pointers option 2023-06-14 10:49:48 -07:00
Michael Gottesman
59c8cff917 [borrowing] Add support for borrowing/consuming copyable types to be a noimplicitcopy type.
rdar://108383660
2023-06-06 18:12:29 -04:00
Tristan Labelle
98bace060f Fix case mismatch in test error message expectation 2023-05-25 13:54:45 -04:00
Konrad `ktoso` Malawski
6e14025b95 [Distributed] Explicitly ban __owned and other specifiers we dont support 2023-05-25 10:59:01 +02:00
Konrad `ktoso` Malawski
237f552e8f add missing %empty-directory in test 2023-05-22 14:13:07 +02:00
swift-ci
222946b1e1 Merge pull request #65952 from ktoso/wip-destroy-dist-args-reverse-order
[Distributed] Ensure to swift_release during destroying decoded distributed call arguments
2023-05-19 17:28:20 -07:00
Konrad `ktoso` Malawski
cd3e243ff8 [Distributed] Ensure decoded classes get refcounted down to 0 from decoding 2023-05-19 23:29:49 +02:00
Konrad `ktoso` Malawski
00243c6d8b [Distributed] Report error rather than crash no ad-hoc requirements are implemented 2023-05-19 16:06:53 +02:00
Konrad `ktoso` Malawski
24a5458cbe [Distributed][Test] Avoid overlapping dump-ast which cause flaky test 2023-05-18 12:01:10 +02:00
Pavel Yaskevich
89ba257037 [Tests] Distributed/NFC: Add a test-case for rdar://109207043 2023-05-15 17:31:22 -07:00
Yuta Saito
5f94468416 [Test] Disable part of distributed tests on singlethreaded global executor 2023-04-29 10:58:04 +00:00
Konrad `ktoso` Malawski
ecb9df18bf Always dump input of distributed_actor_executor_ast.swift
This test likes to fail once in a blue moon and we don't have enough information to debug when those happen.

Dump the entire input in case the failure happens again.
2023-04-13 20:26:43 +09:00
Konrad `ktoso` Malawski
80b93863a9 [Concurrency] Rename Job to ExecutorJob, ease transition with typealias (#65006) 2023-04-11 14:52:10 +09:00