Skip to content

Commit 9bc5b83

Browse files
Merge pull request #3009 from swiftwasm/katei/merge-main-2021-04-20
Merge main 2021-04-20
2 parents 3373353 + fde4ec9 commit 9bc5b83

File tree

154 files changed

+3805
-1865
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+3805
-1865
lines changed

docs/SIL.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4540,7 +4540,7 @@ prev_dynamic_function_ref
45404540
// $@convention(thin) T -> U must be a thin function type
45414541
// %1 has type $T -> U
45424542

4543-
Creates a reference to a previous implemenation of a `dynamic_replacement` SIL
4543+
Creates a reference to a previous implementation of a `dynamic_replacement` SIL
45444544
function.
45454545

45464546
For the following Swift code::

include/swift/ABI/AsyncLet.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//===--- AsyncLet.h - ABI structures for async let -00-----------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// Swift ABI describing task groups.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#ifndef SWIFT_ABI_TASK_ASYNC_LET_H
18+
#define SWIFT_ABI_TASK_ASYNC_LET_H
19+
20+
#include "swift/ABI/Task.h"
21+
#include "swift/ABI/HeapObject.h"
22+
#include "swift/Runtime/Concurrency.h"
23+
#include "swift/Runtime/Config.h"
24+
#include "swift/Basic/RelativePointer.h"
25+
#include "swift/Basic/STLExtras.h"
26+
27+
namespace swift {
28+
29+
/// Represents an in-flight `async let`, i.e. the Task that is computing the
30+
/// result of the async let, along with the awaited status and other metadata.
31+
class alignas(Alignment_AsyncLet) AsyncLet {
32+
public:
33+
// These constructors do not initialize the AsyncLet instance, and the
34+
// destructor does not destroy the AsyncLet instance; you must call
35+
// swift_asyncLet_{start,end} yourself.
36+
constexpr AsyncLet()
37+
: PrivateData{} {}
38+
39+
// FIXME: not sure how many words we should reserve
40+
void *PrivateData[NumWords_AsyncLet];
41+
42+
// TODO: we could offer a "was awaited on" check here
43+
44+
/// Returns the child task that is associated with this async let.
45+
/// The tasks completion is used to fulfil the value represented by this async let.
46+
AsyncTask *getTask() const;
47+
48+
};
49+
50+
} // end namespace swift
51+
52+
#endif // SWIFT_ABI_TASK_ASYNC_LET_H

include/swift/ABI/MetadataValues.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ enum {
4949

5050
/// The number of words in a task group.
5151
NumWords_TaskGroup = 32,
52+
53+
/// The number of words in an AsyncLet (flags + task pointer)
54+
NumWords_AsyncLet = 8, // TODO: not sure how much is enough, these likely could be pretty small
5255
};
5356

5457
struct InProcess;
@@ -127,6 +130,9 @@ const size_t Alignment_DefaultActor = MaximumAlignment;
127130
/// The alignment of a TaskGroup.
128131
const size_t Alignment_TaskGroup = MaximumAlignment;
129132

133+
/// The alignment of an AsyncLet.
134+
const size_t Alignment_AsyncLet = MaximumAlignment;
135+
130136
/// Flags stored in the value-witness table.
131137
template <typename int_type>
132138
class TargetValueWitnessFlags {

include/swift/ABI/TaskGroup.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ namespace swift {
2929
/// The task group is responsible for maintaining dynamically created child tasks.
3030
class alignas(Alignment_TaskGroup) TaskGroup {
3131
public:
32-
// These constructors do not initialize the actor instance, and the
33-
// destructor does not destroy the actor instance; you must call
32+
// These constructors do not initialize the group instance, and the
33+
// destructor does not destroy the group instance; you must call
3434
// swift_taskGroup_{initialize,destroy} yourself.
3535
constexpr TaskGroup()
3636
: PrivateData{} {}
@@ -43,4 +43,4 @@ class alignas(Alignment_TaskGroup) TaskGroup {
4343

4444
} // end namespace swift
4545

46-
#endif
46+
#endif // SWIFT_ABI_TASK_GROUP_H

include/swift/AST/Builtins.def

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,19 @@ BUILTIN_MISC_OPERATION_WITH_SILGEN(GetCurrentAsyncTask, "getCurrentAsyncTask", "
782782
/// Cancel the given asynchronous task.
783783
BUILTIN_MISC_OPERATION_WITH_SILGEN(CancelAsyncTask, "cancelAsyncTask", "", Special)
784784

785+
/// startAsyncLet()<T>: (
786+
/// __owned @Sendable @escaping () async throws -> T
787+
/// ) -> Builtin.RawPointer
788+
///
789+
/// Create, initialize and start a new async-let and associated task.
790+
/// Returns an AsyncLet* that must be passed to endAsyncLet for destruction.
791+
BUILTIN_MISC_OPERATION(StartAsyncLet, "startAsyncLet", "", Special)
792+
793+
/// asyncLetEnd(): (Builtin.RawPointer) -> Void
794+
///
795+
/// Ends and destroys an async-let.
796+
BUILTIN_MISC_OPERATION_WITH_SILGEN(EndAsyncLet, "endAsyncLet", "", Special)
797+
785798
/// createAsyncTaskFuture(): (
786799
/// Int, Builtin.NativeObject?, @escaping () async throws -> T
787800
/// ) -> Builtin.NativeObject

include/swift/AST/DiagnosticsSIL.def

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -250,17 +250,25 @@ NOTE(designated_init_c_struct_fix,none,
250250

251251

252252
// Control flow diagnostics.
253-
ERROR(missing_return,none,
254-
"missing return in a %select{function|closure}1 expected to return %0",
255-
(Type, unsigned))
256-
ERROR(missing_return_last_expr,none,
257-
"missing return in a %select{function|closure}1 expected to return %0; "
258-
"did you mean to return the last expression?",
259-
(Type, unsigned))
260-
ERROR(missing_never_call,none,
261-
"%select{function|closure}1 with uninhabited return type %0 is missing "
253+
ERROR(missing_return_closure,none,
254+
"missing return in closure expected to return %0",
255+
(Type))
256+
ERROR(missing_never_call_closure,none,
257+
"closure with uninhabited return type %0 is missing "
258+
"call to another never-returning function on all paths",
259+
(Type))
260+
261+
ERROR(missing_return_decl,none,
262+
"missing return in %1 expected to return %0",
263+
(Type, DescriptiveDeclKind))
264+
ERROR(missing_never_call_decl,none,
265+
"%1 with uninhabited return type %0 is missing "
262266
"call to another never-returning function on all paths",
263-
(Type, unsigned))
267+
(Type, DescriptiveDeclKind))
268+
269+
NOTE(missing_return_last_expr_note,none,
270+
"did you mean to return the last expression?", ())
271+
264272
ERROR(guard_body_must_not_fallthrough,none,
265273
"'guard' body must not fall through, consider using a 'return' or 'throw'"
266274
" to exit the scope", ())

include/swift/AST/DiagnosticsSema.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4385,6 +4385,12 @@ ERROR(global_actor_from_nonactor_context,none,
43854385
"%0 %1 isolated to global actor %2 can not be %select{referenced|mutated|used 'inout'}4"
43864386
" from %select{this|a non-isolated}3%select{| synchronous}5 context",
43874387
(DescriptiveDeclKind, DeclName, Type, bool, unsigned, bool))
4388+
ERROR(actor_isolated_call,none,
4389+
"call to %0 function in a synchronous %1 context",
4390+
(ActorIsolation, ActorIsolation))
4391+
ERROR(actor_isolated_call_decl,none,
4392+
"call to %0 %1 %2 in a synchronous %3 context",
4393+
(ActorIsolation, DescriptiveDeclKind, DeclName, ActorIsolation))
43884394
ERROR(actor_isolated_partial_apply,none,
43894395
"actor-isolated %0 %1 can not be partially applied",
43904396
(DescriptiveDeclKind, DeclName))

include/swift/AST/Stmt.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,15 +1110,19 @@ class SwitchStmt final : public LabeledStmt,
11101110
friend TrailingObjects;
11111111

11121112
SourceLoc SwitchLoc, LBraceLoc, RBraceLoc;
1113+
/// The location of the last token in the 'switch' statement. For valid
1114+
/// 'switch' statements this is the same as \c RBraceLoc. If the '}' is
1115+
/// missing this points to the last token before the '}' was expected.
1116+
SourceLoc EndLoc;
11131117
Expr *SubjectExpr;
11141118

11151119
SwitchStmt(LabeledStmtInfo LabelInfo, SourceLoc SwitchLoc, Expr *SubjectExpr,
11161120
SourceLoc LBraceLoc, unsigned CaseCount, SourceLoc RBraceLoc,
1117-
Optional<bool> implicit = None)
1121+
SourceLoc EndLoc, Optional<bool> implicit = None)
11181122
: LabeledStmt(StmtKind::Switch, getDefaultImplicitFlag(implicit, SwitchLoc),
11191123
LabelInfo),
11201124
SwitchLoc(SwitchLoc), LBraceLoc(LBraceLoc), RBraceLoc(RBraceLoc),
1121-
SubjectExpr(SubjectExpr) {
1125+
EndLoc(EndLoc), SubjectExpr(SubjectExpr) {
11221126
Bits.SwitchStmt.CaseCount = CaseCount;
11231127
}
11241128

@@ -1129,6 +1133,7 @@ class SwitchStmt final : public LabeledStmt,
11291133
SourceLoc LBraceLoc,
11301134
ArrayRef<ASTNode> Cases,
11311135
SourceLoc RBraceLoc,
1136+
SourceLoc EndLoc,
11321137
ASTContext &C);
11331138

11341139
/// Get the source location of the 'switch' keyword.
@@ -1141,8 +1146,8 @@ class SwitchStmt final : public LabeledStmt,
11411146
SourceLoc getLoc() const { return SwitchLoc; }
11421147

11431148
SourceLoc getStartLoc() const { return getLabelLocOrKeywordLoc(SwitchLoc); }
1144-
SourceLoc getEndLoc() const { return RBraceLoc; }
1145-
1149+
SourceLoc getEndLoc() const { return EndLoc; }
1150+
11461151
/// Get the subject expression of the switch.
11471152
Expr *getSubjectExpr() const { return SubjectExpr; }
11481153
void setSubjectExpr(Expr *e) { SubjectExpr = e; }

include/swift/Basic/LangOptions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ namespace swift {
274274
bool EnableInferPublicSendable = false;
275275

276276
/// Disable the implicit import of the _Concurrency module.
277-
bool DisableImplicitConcurrencyModuleImport = false;
277+
bool DisableImplicitConcurrencyModuleImport =
278+
!SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY;
278279

279280
/// Should we check the target OSs of serialized modules to see that they're
280281
/// new enough?

include/swift/Config.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88

99
#cmakedefine HAVE_PROC_PID_RUSAGE 1
1010

11+
#cmakedefine01 SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY
12+
1113
#endif // SWIFT_CONFIG_H

0 commit comments

Comments
 (0)