Skip to content

Commit 5be01d1

Browse files
Merge pull request #2876 from swiftwasm/katei/merge-main-2021-03-18
Merge main 2021-03-18
2 parents c59da27 + 04ba2d9 commit 5be01d1

File tree

317 files changed

+28488
-62861
lines changed

Some content is hidden

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

317 files changed

+28488
-62861
lines changed

.mailmap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Adrian-Constantin Popescu <[email protected]> <[email protected]>
22
3-
4-
3+
4+
55
Alexis Beingessner <[email protected]> <[email protected]>
66
77

CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
148148
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
149149
# can be reused when a new version of Swift comes out (assuming the user hasn't
150150
# manually set it as part of their own CMake configuration).
151-
set(SWIFT_VERSION "5.4")
151+
set(SWIFT_VERSION "5.5")
152152

153153
set(SWIFT_VENDOR "" CACHE STRING
154154
"The vendor name of the Swift compiler")
@@ -196,13 +196,6 @@ if(SWIFT_PROFDATA_FILE AND EXISTS ${SWIFT_PROFDATA_FILE})
196196
add_definitions("-fprofile-instr-use=${SWIFT_PROFDATA_FILE}")
197197
endif()
198198

199-
option(USE_SWIFT_ASYNC_LOWERING
200-
"Indicates if Swiftc should use async-specific lowering for async
201-
functions if it is supported for the target. The runtime also checks
202-
this setting before using async-specific attributes. This only applies
203-
to the async calling convention and not to the async context attribute."
204-
TRUE)
205-
206199
#
207200
# User-configurable Swift Standard Library specific options.
208201
#

docs/ABI/Mangling.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ Globals
147147
// TODO check this::
148148
global ::= mangled-name 'TA' // partial application forwarder
149149
global ::= mangled-name 'Ta' // ObjC partial application forwarder
150+
global ::= mangled-name 'Tw' index // async partial apply thunk for a non-constant function
151+
global ::= mangled-name 'TQ' index // Async await continuation partial function
152+
global ::= mangled-name 'TY' index // Async suspend continuation partial function
150153

151154
global ::= type 'w' VALUE-WITNESS-KIND // value witness
152155

@@ -209,7 +212,7 @@ types where the metadata itself has unknown layout.)
209212
global ::= global 'TD' // dynamic dispatch thunk
210213
global ::= global 'Td' // direct method reference thunk
211214
global ::= global 'TI' // implementation of a dynamic_replaceable function
212-
global :== global 'Tu' // async function pointer of a function
215+
global ::= global 'Tu' // async function pointer of a function
213216
global ::= global 'TX' // function pointer of a dynamic_replaceable function
214217
global ::= entity entity 'TV' // vtable override thunk, derived followed by base
215218
global ::= type label-list? 'D' // type mangling for the debugger with label list for function types.

include/swift/ABI/Executor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ class ExecutorRef {
114114

115115
using JobInvokeFunction =
116116
SWIFT_CC(swiftasync)
117-
void (Job *, ExecutorRef);
117+
void (Job *);
118118

119119
using TaskContinuationFunction =
120120
SWIFT_CC(swiftasync)
121-
void (AsyncTask *, ExecutorRef, SWIFT_ASYNC_CONTEXT AsyncContext *);
121+
void (SWIFT_ASYNC_CONTEXT AsyncContext *);
122122

123123
template <class AsyncSignature>
124124
class AsyncFunctionPointer;

include/swift/ABI/Task.h

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ class alignas(2 * alignof(void*)) Job : public HeapObject {
8787
/// Given that we've fully established the job context in the current
8888
/// thread, actually start running this job. To establish the context
8989
/// correctly, call swift_job_run or runJobInExecutorContext.
90-
void runInFullyEstablishedContext(ExecutorRef currentExecutor);
90+
void runInFullyEstablishedContext();
9191

9292
/// Given that we've fully established the job context in the
9393
/// current thread, and that the job is a simple (non-task) job,
9494
/// actually start running this job.
95-
void runSimpleInFullyEstablishedContext(ExecutorRef currentExecutor) {
96-
RunJob(this, currentExecutor);
95+
void runSimpleInFullyEstablishedContext() {
96+
RunJob(this);
9797
}
9898
};
9999

@@ -193,8 +193,8 @@ class AsyncTask : public Job {
193193
/// in the current thread, start running this task. To establish
194194
/// the job context correctly, call swift_job_run or
195195
/// runInExecutorContext.
196-
void runInFullyEstablishedContext(ExecutorRef currentExecutor) {
197-
ResumeTask(this, currentExecutor, ResumeContext);
196+
void runInFullyEstablishedContext() {
197+
ResumeTask(ResumeContext);
198198
}
199199

200200
/// Check whether this task has been cancelled.
@@ -390,7 +390,7 @@ class AsyncTask : public Job {
390390
}
391391

392392
/// Retrieve the error.
393-
SwiftError *&getError() { return *&error; }
393+
SwiftError *&getError() { return error; }
394394

395395
/// Compute the offset of the storage from the base of the future
396396
/// fragment.
@@ -433,7 +433,7 @@ class AsyncTask : public Job {
433433
///
434434
/// Upon completion, any waiting tasks will be scheduled on the given
435435
/// executor.
436-
void completeFuture(AsyncContext *context, ExecutorRef executor);
436+
void completeFuture(AsyncContext *context);
437437

438438
// ==== ----------------------------------------------------------------------
439439

@@ -456,11 +456,11 @@ static_assert(sizeof(AsyncTask) == 14 * sizeof(void*),
456456
static_assert(alignof(AsyncTask) == 2 * alignof(void*),
457457
"AsyncTask alignment is wrong");
458458

459-
inline void Job::runInFullyEstablishedContext(ExecutorRef currentExecutor) {
459+
inline void Job::runInFullyEstablishedContext() {
460460
if (auto task = dyn_cast<AsyncTask>(this))
461-
task->runInFullyEstablishedContext(currentExecutor);
461+
task->runInFullyEstablishedContext();
462462
else
463-
runSimpleInFullyEstablishedContext(currentExecutor);
463+
runSimpleInFullyEstablishedContext();
464464
}
465465

466466
/// An asynchronous context within a task. Generally contexts are
@@ -484,6 +484,7 @@ class alignas(MaximumAlignment) AsyncContext {
484484
ResumeParent;
485485

486486
/// The executor that the parent needs to be resumed on.
487+
/// FIXME: remove this
487488
ExecutorRef ResumeParentExecutor;
488489

489490
/// Flags describing this context.
@@ -496,10 +497,9 @@ class alignas(MaximumAlignment) AsyncContext {
496497

497498
AsyncContext(AsyncContextFlags flags,
498499
TaskContinuationFunction *resumeParent,
499-
ExecutorRef resumeParentExecutor,
500500
AsyncContext *parent)
501501
: Parent(parent), ResumeParent(resumeParent),
502-
ResumeParentExecutor(resumeParentExecutor),
502+
ResumeParentExecutor(ExecutorRef::generic()),
503503
Flags(flags) {}
504504

505505
AsyncContext(const AsyncContext &) = delete;
@@ -509,10 +509,10 @@ class alignas(MaximumAlignment) AsyncContext {
509509
///
510510
/// Generally this should be tail-called.
511511
SWIFT_CC(swiftasync)
512-
void resumeParent(AsyncTask *task, ExecutorRef executor) {
512+
void resumeParent() {
513513
// TODO: destroy context before returning?
514514
// FIXME: force tail call
515-
return ResumeParent(task, executor, Parent);
515+
return ResumeParent(Parent);
516516
}
517517
};
518518

@@ -529,11 +529,10 @@ class YieldingAsyncContext : public AsyncContext {
529529

530530
YieldingAsyncContext(AsyncContextFlags flags,
531531
TaskContinuationFunction *resumeParent,
532-
ExecutorRef resumeParentExecutor,
533532
TaskContinuationFunction *yieldToParent,
534533
ExecutorRef yieldToParentExecutor,
535534
AsyncContext *parent)
536-
: AsyncContext(flags, resumeParent, resumeParentExecutor, parent),
535+
: AsyncContext(flags, resumeParent, parent),
537536
YieldToParent(yieldToParent),
538537
YieldToParentExecutor(yieldToParentExecutor) {}
539538

@@ -550,19 +549,47 @@ class YieldingAsyncContext : public AsyncContext {
550549
/// futures.
551550
class FutureAsyncContext : public AsyncContext {
552551
public:
553-
SwiftError **errorResult = nullptr;
554-
OpaqueValue *indirectResult;
555-
556552
using AsyncContext::AsyncContext;
557553
};
558554

559-
/// An asynchronous context within a task that describes a general "Future"
560-
/// task that was started with a closure context.
561-
class FutureClosureAsyncContext : public FutureAsyncContext {
555+
/// This matches the ABI of a closure `() async throws -> ()`
556+
using AsyncVoidClosureEntryPoint =
557+
SWIFT_CC(swiftasync)
558+
void (SWIFT_ASYNC_CONTEXT AsyncContext *, SWIFT_CONTEXT HeapObject *);
559+
560+
/// This matches the ABI of a closure `<T>() async throws -> T`
561+
using AsyncGenericClosureEntryPoint =
562+
SWIFT_CC(swiftasync)
563+
void(OpaqueValue *,
564+
SWIFT_ASYNC_CONTEXT AsyncContext *, SWIFT_CONTEXT HeapObject *);
565+
566+
/// This matches the ABI of the resume function of a closure
567+
/// `() async throws -> ()`.
568+
using AsyncVoidClosureResumeEntryPoint =
569+
SWIFT_CC(swiftasync)
570+
void(SWIFT_ASYNC_CONTEXT AsyncContext *, SWIFT_CONTEXT SwiftError *);
571+
572+
class AsyncContextPrefix {
573+
public:
574+
// Async closure entry point adhering to compiler calling conv (e.g directly
575+
// passing the closure context instead of via the async context)
576+
AsyncVoidClosureEntryPoint *__ptrauth_swift_task_resume_function
577+
asyncEntryPoint;
578+
HeapObject *closureContext;
579+
SwiftError *errorResult;
580+
};
581+
582+
/// Storage that is allocated before the AsyncContext to be used by an adapter
583+
/// of Swift's async convention and the ResumeTask interface.
584+
class FutureAsyncContextPrefix {
562585
public:
586+
OpaqueValue *indirectResult;
587+
// Async closure entry point adhering to compiler calling conv (e.g directly
588+
// passing the closure context instead of via the async context)
589+
AsyncGenericClosureEntryPoint *__ptrauth_swift_task_resume_function
590+
asyncEntryPoint;
563591
HeapObject *closureContext;
564-
565-
using FutureAsyncContext::FutureAsyncContext;
592+
SwiftError *errorResult;
566593
};
567594

568595
} // end namespace swift

include/swift/ABI/TaskGroup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class alignas(Alignment_TaskGroup) TaskGroup {
3838
void *PrivateData[NumWords_TaskGroup];
3939

4040
/// Upon a future task's completion, offer it to the task group it belongs to.
41-
void offer(AsyncTask *completed, AsyncContext *context, ExecutorRef executor);
41+
void offer(AsyncTask *completed, AsyncContext *context);
4242
};
4343

4444
} // end namespace swift

include/swift/AST/ASTDemangler.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class ASTBuilder {
5959
using BuiltType = swift::Type;
6060
using BuiltTypeDecl = swift::GenericTypeDecl *; // nominal or type alias
6161
using BuiltProtocolDecl = swift::ProtocolDecl *;
62+
using BuiltSubstitution = std::pair<Type, Type>;
63+
using BuiltRequirement = swift::Requirement;
6264
explicit ASTBuilder(ASTContext &ctx) : Ctx(ctx) {}
6365

6466
ASTContext &getASTContext() { return Ctx; }
@@ -99,11 +101,14 @@ class ASTBuilder {
99101
Type output, FunctionTypeFlags flags);
100102

101103
Type createImplFunctionType(
102-
Demangle::ImplParameterConvention calleeConvention,
103-
ArrayRef<Demangle::ImplFunctionParam<Type>> params,
104-
ArrayRef<Demangle::ImplFunctionResult<Type>> results,
105-
Optional<Demangle::ImplFunctionResult<Type>> errorResult,
106-
ImplFunctionTypeFlags flags);
104+
Demangle::ImplParameterConvention calleeConvention,
105+
BuiltRequirement *witnessMethodConformanceRequirement,
106+
ArrayRef<BuiltType> GenericParameters,
107+
ArrayRef<BuiltRequirement> Requirements,
108+
ArrayRef<Demangle::ImplFunctionParam<Type>> params,
109+
ArrayRef<Demangle::ImplFunctionResult<Type>> results,
110+
Optional<Demangle::ImplFunctionResult<Type>> errorResult,
111+
ImplFunctionTypeFlags flags);
107112

108113
Type createProtocolCompositionType(ArrayRef<ProtocolDecl *> protocols,
109114
Type superclass,
@@ -128,8 +133,6 @@ class ASTBuilder {
128133

129134
Type createSILBoxType(Type base);
130135
using BuiltSILBoxField = llvm::PointerIntPair<Type, 1>;
131-
using BuiltSubstitution = std::pair<Type, Type>;
132-
using BuiltRequirement = swift::Requirement;
133136
using BuiltLayoutConstraint = swift::LayoutConstraint;
134137
Type createSILBoxTypeWithLayout(ArrayRef<BuiltSILBoxField> Fields,
135138
ArrayRef<BuiltSubstitution> Substitutions,

include/swift/AST/AnyFunctionRef.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ class AnyFunctionRef {
179179
return TheFunction.dyn_cast<AbstractClosureExpr*>();
180180
}
181181

182-
bool isDeferBody() const {
183-
if (auto *fd = dyn_cast_or_null<FuncDecl>(getAbstractFunctionDecl()))
184-
return fd->isDeferBody();
185-
return false;
186-
}
187-
188182
/// Return true if this closure is passed as an argument to a function and is
189183
/// known not to escape from that function. In this case, captures can be
190184
/// more efficient.

0 commit comments

Comments
 (0)