mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Use current public Dispatch API to schedule global work.
We expect to iterate on this quite a bit, both publicly and internally, but this is a fine starting-point. I've renamed runAsync to runAsyncAndBlock to underline very clearly what it does and why it's not long for this world. I've also had to give it a radically different implementation in an effort to make it continue to work given an actor implementation that is no longer just running all work synchronously. The major remaining bit of actor-scheduling work is to make swift_task_enqueue actually do something sensible based on the executor it's been given; currently it's expecting a flag that IRGen simply doesn't know to set.
This commit is contained in:
@@ -435,10 +435,18 @@ option(SWIFT_BUILD_ONLY_SYNTAXPARSERLIB "Only build the Swift Syntax Parser libr
|
||||
option(SWIFT_BUILD_SOURCEKIT "Build SourceKit" TRUE)
|
||||
option(SWIFT_ENABLE_SOURCEKIT_TESTS "Enable running SourceKit tests" ${SWIFT_BUILD_SOURCEKIT})
|
||||
|
||||
if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT)
|
||||
# Use dispatch as the system scheduler by default.
|
||||
# For convenience, we set this to false when concurrency is disabled.
|
||||
# TODO: don't do this when building a single-threaded runtime
|
||||
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
|
||||
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY)
|
||||
set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE)
|
||||
endif()
|
||||
|
||||
if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT OR SWIFT_CONCURRENCY_USES_DISPATCH)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
if(NOT EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
|
||||
message(SEND_ERROR "SyntaxParserLib and SourceKit require libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
|
||||
message(SEND_ERROR "SyntaxParserLib, SourceKit, and concurrency require libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@@ -941,7 +949,7 @@ if (LLVM_ENABLE_DOXYGEN)
|
||||
message(STATUS "Doxygen: enabled")
|
||||
endif()
|
||||
|
||||
if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT)
|
||||
if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT OR SWIFT_CONCURRENCY_USES_DISPATCH)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL Clang AND
|
||||
CMAKE_C_COMPILER_VERSION VERSION_GREATER 3.8
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#define SWIFT_ABI_EXECUTOR_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "swift/ABI/HeapObject.h"
|
||||
|
||||
namespace swift {
|
||||
class AsyncContext;
|
||||
@@ -65,6 +66,10 @@ public:
|
||||
return reinterpret_cast<DefaultActor*>(Value & ~PointerMask);
|
||||
}
|
||||
|
||||
uintptr_t getRawValue() const {
|
||||
return Value;
|
||||
}
|
||||
|
||||
/// Do we have to do any work to start running as the requested
|
||||
/// executor?
|
||||
bool mustSwitchToRun(ExecutorRef newExecutor) const {
|
||||
@@ -87,10 +92,53 @@ using TaskContinuationFunction =
|
||||
SWIFT_CC(swiftasync)
|
||||
void (AsyncTask *, ExecutorRef, AsyncContext *);
|
||||
|
||||
template <class Fn>
|
||||
template <class AsyncSignature>
|
||||
class AsyncFunctionPointer;
|
||||
template <class AsyncSignature>
|
||||
struct AsyncFunctionTypeImpl;
|
||||
template <class Result, class... Params>
|
||||
struct AsyncFunctionTypeImpl<Result(Params...)> {
|
||||
|
||||
/// The abstract signature for an asynchronous function.
|
||||
template <class Sig, bool HasErrorResult>
|
||||
struct AsyncSignature;
|
||||
|
||||
template <class DirectResultTy, class... ArgTys, bool HasErrorResult>
|
||||
struct AsyncSignature<DirectResultTy(ArgTys...), HasErrorResult> {
|
||||
bool hasDirectResult = !std::is_same<DirectResultTy, void>::value;
|
||||
using DirectResultType = DirectResultTy;
|
||||
|
||||
bool hasErrorResult = HasErrorResult;
|
||||
|
||||
using FunctionPointer = AsyncFunctionPointer<AsyncSignature>;
|
||||
using FunctionType = typename AsyncFunctionTypeImpl<AsyncSignature>::type;
|
||||
};
|
||||
|
||||
/// A signature for a thin async function that takes no arguments
|
||||
/// and returns no results.
|
||||
using ThinNullaryAsyncSignature =
|
||||
AsyncSignature<void(), false>;
|
||||
|
||||
/// A signature for a thick async function that takes no formal
|
||||
/// arguments and returns no results.
|
||||
using ThickNullaryAsyncSignature =
|
||||
AsyncSignature<void(HeapObject*), false>;
|
||||
|
||||
/// A class which can be used to statically query whether a type
|
||||
/// is a specialization of AsyncSignature.
|
||||
template <class T>
|
||||
struct IsAsyncSignature {
|
||||
static const bool value = false;
|
||||
};
|
||||
template <class DirectResultTy, class... ArgTys, bool HasErrorResult>
|
||||
struct IsAsyncSignature<AsyncSignature<DirectResultTy(ArgTys...),
|
||||
HasErrorResult>> {
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template <class Signature>
|
||||
struct AsyncFunctionTypeImpl {
|
||||
static_assert(IsAsyncSignature<Signature>::value,
|
||||
"template argument is not an AsyncSignature");
|
||||
|
||||
// TODO: expand and include the arguments in the parameters.
|
||||
using type = TaskContinuationFunction;
|
||||
};
|
||||
@@ -102,11 +150,11 @@ using AsyncFunctionType = typename AsyncFunctionTypeImpl<Fn>::type;
|
||||
///
|
||||
/// Eventually, this will always be signed with the data key
|
||||
/// using a type-specific discriminator.
|
||||
template <class FnType>
|
||||
template <class AsyncSignature>
|
||||
class AsyncFunctionPointer {
|
||||
public:
|
||||
/// The function to run.
|
||||
RelativeDirectPointer<AsyncFunctionType<FnType>,
|
||||
RelativeDirectPointer<AsyncFunctionType<AsyncSignature>,
|
||||
/*nullable*/ false,
|
||||
int32_t> Function;
|
||||
|
||||
|
||||
@@ -723,6 +723,12 @@ BUILTIN_MISC_OPERATION(TypePtrAuthDiscriminator, "typePtrAuthDiscriminator", "n"
|
||||
// int_instrprof_increment has type (Builtin.RawPointer, Builtin.Int64, Builtin.Int32, Builtin.Int32) -> ().
|
||||
BUILTIN_MISC_OPERATION(IntInstrprofIncrement, "int_instrprof_increment", "", Special)
|
||||
|
||||
/// Initialize the default-actor instance in a default actor object.
|
||||
BUILTIN_MISC_OPERATION(InitializeDefaultActor, "initializeDefaultActor", "", Special)
|
||||
|
||||
/// Destroy the default-actor instance in a default actor object.
|
||||
BUILTIN_MISC_OPERATION(DestroyDefaultActor, "destroyDefaultActor", "", Special)
|
||||
|
||||
// BUILTIN_MISC_OPERATION_WITH_SILGEN - Miscellaneous operations that are
|
||||
// specially emitted during SIL generation.
|
||||
//
|
||||
|
||||
@@ -42,16 +42,21 @@ struct AsyncTaskAndContext {
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
|
||||
AsyncTaskAndContext swift_task_create(JobFlags flags,
|
||||
AsyncTask *parent,
|
||||
const AsyncFunctionPointer<void()> *function);
|
||||
const ThinNullaryAsyncSignature::FunctionPointer *function);
|
||||
|
||||
/// Create a task object with no future which will run the given
|
||||
/// function.
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
|
||||
AsyncTaskAndContext swift_task_create_f(JobFlags flags,
|
||||
AsyncTask *parent,
|
||||
AsyncFunctionType<void()> *function,
|
||||
ThinNullaryAsyncSignature::FunctionType *function,
|
||||
size_t initialContextSize);
|
||||
|
||||
/// Caution: not all future-initializing functions actually throw, so
|
||||
/// this signature may be incorrect.
|
||||
using FutureAsyncSignature =
|
||||
AsyncSignature<void(void*), /*throws*/ true>;
|
||||
|
||||
/// Create a task object with a future which will run the given
|
||||
/// function.
|
||||
///
|
||||
@@ -68,14 +73,15 @@ AsyncTaskAndContext swift_task_create_f(JobFlags flags,
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
|
||||
AsyncTaskAndContext swift_task_create_future(
|
||||
JobFlags flags, AsyncTask *parent, const Metadata *futureResultType,
|
||||
const AsyncFunctionPointer<void()> *function);
|
||||
const FutureAsyncSignature::FunctionPointer *function);
|
||||
|
||||
/// Create a task object with a future which will run the given
|
||||
/// function.
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
|
||||
AsyncTaskAndContext swift_task_create_future_f(
|
||||
JobFlags flags, AsyncTask *parent, const Metadata *futureResultType,
|
||||
AsyncFunctionType<void()> *function, size_t initialContextSize);
|
||||
FutureAsyncSignature::FunctionType *function,
|
||||
size_t initialContextSize);
|
||||
|
||||
/// Allocate memory in a task.
|
||||
///
|
||||
@@ -127,6 +133,9 @@ struct TaskFutureWaitResult {
|
||||
OpaqueValue *storage;
|
||||
};
|
||||
|
||||
using TaskFutureWaitSignature =
|
||||
AsyncSignature<TaskFutureWaitResult(AsyncTask *), /*throws*/ false>;
|
||||
|
||||
/// Wait for a future task to complete.
|
||||
///
|
||||
/// This can be called from any thread. Its Swift signature is
|
||||
@@ -135,8 +144,8 @@ struct TaskFutureWaitResult {
|
||||
/// func swift_task_future_wait(on task: Builtin.NativeObject) async
|
||||
/// -> TaskFutureWaitResult
|
||||
/// \endcode
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
|
||||
AsyncFunctionType<TaskFutureWaitResult(AsyncTask *task)>
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swiftasync)
|
||||
TaskFutureWaitSignature::FunctionType
|
||||
swift_task_future_wait;
|
||||
|
||||
/// Add a status record to a task. The record should not be
|
||||
@@ -204,9 +213,18 @@ SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
|
||||
NearestTaskDeadline
|
||||
swift_task_getNearestDeadline(AsyncTask *task);
|
||||
|
||||
// TODO: Remove this hack.
|
||||
/// Run the given async function and block the current thread until
|
||||
/// it returns. This is a hack added for testing purposes; eventually
|
||||
/// top-level code will be an async context, and the need for this in
|
||||
/// tests should go away. We *definitely* do not want this to be part
|
||||
/// of the standard feature set.
|
||||
///
|
||||
/// The argument is a `() async -> ()` function, whose ABI is currently
|
||||
/// quite complex. Eventually this should use a different convention;
|
||||
/// that's rdar://72105841.
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
|
||||
void swift_task_run(AsyncTask *taskToRun);
|
||||
void swift_task_runAndBlockThread(const void *function,
|
||||
HeapObject *functionContext);
|
||||
|
||||
/// Switch the current task to a new executor if we aren't already
|
||||
/// running on a compatible executor.
|
||||
|
||||
@@ -1439,6 +1439,13 @@ static ValueDecl *getConvertTaskToJob(ASTContext &ctx, Identifier id) {
|
||||
_job);
|
||||
}
|
||||
|
||||
static ValueDecl *getDefaultActorInitDestroy(ASTContext &ctx,
|
||||
Identifier id) {
|
||||
return getBuiltinFunction(ctx, id, _thin,
|
||||
_parameters(_nativeObject),
|
||||
_void);
|
||||
}
|
||||
|
||||
static ValueDecl *getAutoDiffCreateLinearMapContext(ASTContext &ctx,
|
||||
Identifier id) {
|
||||
return getBuiltinFunction(
|
||||
@@ -2651,6 +2658,10 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
|
||||
case BuiltinValueKind::TriggerFallbackDiagnostic:
|
||||
return getTriggerFallbackDiagnosticOperation(Context, Id);
|
||||
|
||||
case BuiltinValueKind::InitializeDefaultActor:
|
||||
case BuiltinValueKind::DestroyDefaultActor:
|
||||
return getDefaultActorInitDestroy(Context, Id);
|
||||
|
||||
case BuiltinValueKind::WithUnsafeContinuation:
|
||||
return getWithUnsafeContinuation(Context, Id, /*throws=*/false);
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
///
|
||||
///===----------------------------------------------------------------------===///
|
||||
///
|
||||
/// The standard actor implementation for Swift actors.
|
||||
/// The default actor implementation for Swift actors, plus related
|
||||
/// routines such as generic executor enqueuing and switching.
|
||||
///
|
||||
///===----------------------------------------------------------------------===///
|
||||
|
||||
@@ -1357,21 +1358,9 @@ void swift::swift_task_enqueue(Job *job, ExecutorRef executor) {
|
||||
if (executor.isDefaultActor())
|
||||
return asImpl(executor.getDefaultActor())->enqueue(job);
|
||||
|
||||
// Just assume it's actually a default actor that we haven't tagged
|
||||
// properly.
|
||||
// FIXME: call the general method.
|
||||
job->run(executor);
|
||||
return asImpl(reinterpret_cast<DefaultActor*>(executor.getRawValue()))
|
||||
->enqueue(job);
|
||||
}
|
||||
|
||||
SWIFT_CC(swift)
|
||||
void (*swift::swift_task_enqueueGlobal_hook)(Job *job) = nullptr;
|
||||
|
||||
void swift::swift_task_enqueueGlobal(Job *job) {
|
||||
assert(job && "no job provided");
|
||||
|
||||
// If the hook is defined, use it.
|
||||
if (swift_task_enqueueGlobal_hook)
|
||||
return swift_task_enqueueGlobal_hook(job);
|
||||
|
||||
// FIXME: implement this properly
|
||||
job->run(ExecutorRef::generic());
|
||||
}
|
||||
|
||||
|
||||
196
stdlib/public/Concurrency/AsyncCall.h
Normal file
196
stdlib/public/Concurrency/AsyncCall.h
Normal file
@@ -0,0 +1,196 @@
|
||||
//===--- AsyncCall.h - Conveniences for doing async calls ----------*- C++ -*-//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Convenience functions for implementing Swift asynchronous functions
|
||||
// in C++ code.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SWIFT_CONCURRENCY_ASYNCCALL_H
|
||||
#define SWIFT_CONCURRENCY_ASYNCCALL_H
|
||||
|
||||
#include "swift/Runtime/Concurrency.h"
|
||||
#include "swift/ABI/Task.h"
|
||||
#include <tuple>
|
||||
|
||||
namespace swift {
|
||||
namespace {
|
||||
|
||||
/// Template-metaprogrammed basic layout for the given sequence of types.
|
||||
template <size_t StartingOffset, class... FieldTys>
|
||||
struct BasicLayout;
|
||||
template <size_t StartingOffset>
|
||||
struct BasicLayout<StartingOffset> {
|
||||
static constexpr size_t size = StartingOffset;
|
||||
};
|
||||
template <size_t StartingOffset, class HeadTy, class... TailTys>
|
||||
struct BasicLayout<StartingOffset, HeadTy, TailTys...> {
|
||||
// Round up to a multiple of the alignment.
|
||||
static constexpr size_t fieldOffset =
|
||||
(StartingOffset + alignof(HeadTy) - 1) & ~(alignof(HeadTy) - 1);
|
||||
static constexpr size_t fieldEnd = fieldOffset + sizeof(HeadTy);
|
||||
using TailLayout = BasicLayout<fieldEnd, TailTys...>;
|
||||
static constexpr size_t size = TailLayout::size;
|
||||
};
|
||||
|
||||
template <class Layout, size_t Index>
|
||||
struct BasicLayoutOffset {
|
||||
static constexpr size_t value =
|
||||
BasicLayoutOffset<typename Layout::TailLayout, Index - 1>::value;
|
||||
};
|
||||
template <class Layout>
|
||||
struct BasicLayoutOffset<Layout, 0> {
|
||||
static constexpr size_t value = Layout::fieldOffset;
|
||||
};
|
||||
|
||||
/// Template-metaprogrammed layout for an async frame with the given
|
||||
/// signature. Works as long as you don't have a mix of indirect and
|
||||
/// direct results; indirect results should be coded as initial
|
||||
/// indirect arguments in the function signature.
|
||||
///
|
||||
/// Note that there's always a slot for an error result.
|
||||
template <class Signature>
|
||||
struct AsyncFrameLayout;
|
||||
|
||||
template <class... ArgTys, bool HasErrorResult>
|
||||
struct AsyncFrameLayout<AsyncSignature<void(ArgTys...), HasErrorResult>> {
|
||||
using BasicLayout = BasicLayout<0, SwiftError*, ArgTys...>;
|
||||
static constexpr size_t firstArgIndex = 1;
|
||||
};
|
||||
template <class ResultTy, class... ArgTys, bool HasErrorResult>
|
||||
struct AsyncFrameLayout<AsyncSignature<ResultTy(ArgTys...), HasErrorResult>> {
|
||||
using BasicLayout = BasicLayout<0, SwiftError*, ResultTy, ArgTys...>;
|
||||
static constexpr size_t firstArgIndex = 2;
|
||||
};
|
||||
|
||||
/// A helper class which, when used as a base class under common
|
||||
/// C++ ABIs, adds no extra size to a struct when the template
|
||||
/// argument is 0.
|
||||
template <size_t Size>
|
||||
class AsyncFrameStorageHelper: public AsyncContext {
|
||||
// This needs to be aligned at least this much or else Itanium
|
||||
// will try to put it in the tail-padding of the AsyncContext.
|
||||
alignas(void*)
|
||||
char buffer[Size];
|
||||
public:
|
||||
using AsyncContext::AsyncContext;
|
||||
char *data() { return buffer; }
|
||||
};
|
||||
template <>
|
||||
class AsyncFrameStorageHelper<0>: public AsyncContext {
|
||||
public:
|
||||
using AsyncContext::AsyncContext;
|
||||
char *data() { return reinterpret_cast<char*>(this); }
|
||||
};
|
||||
|
||||
template <class CalleeSignature,
|
||||
class FrameLayout = AsyncFrameLayout<CalleeSignature>>
|
||||
struct AsyncFrameStorage;
|
||||
template <class ResultTy, class... ArgTys,
|
||||
bool HasErrorResult, class FrameLayout>
|
||||
struct AsyncFrameStorage<AsyncSignature<ResultTy(ArgTys...),
|
||||
HasErrorResult>,
|
||||
FrameLayout>
|
||||
: AsyncFrameStorageHelper<FrameLayout::BasicLayout::size> {
|
||||
|
||||
AsyncFrameStorage(AsyncContextFlags flags,
|
||||
TaskContinuationFunction *resumeFunction,
|
||||
ExecutorRef resumeToExecutor,
|
||||
AsyncContext *resumeToContext,
|
||||
ArgTys... args)
|
||||
: AsyncFrameStorageHelper<FrameLayout::BasicLayout::size>(
|
||||
flags, resumeFunction, resumeToExecutor, resumeToContext) {
|
||||
initializeHelper<FrameLayout::firstArgIndex>(this->data(), args...);
|
||||
}
|
||||
|
||||
private:
|
||||
template <size_t NextArgIndex>
|
||||
void initializeHelper(char *buffer) {}
|
||||
|
||||
template <size_t NextArgIndex, class NextArgTy, class... TailArgTys>
|
||||
void initializeHelper(char *buffer, NextArgTy nextArg,
|
||||
TailArgTys... tailArgs) {
|
||||
auto offset = BasicLayoutOffset<typename FrameLayout::BasicLayout,
|
||||
NextArgIndex>::value;
|
||||
new (buffer + offset) NextArgTy(nextArg);
|
||||
initializeHelper<NextArgIndex+1>(buffer, tailArgs...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// The context header for calling a function that takes the
|
||||
/// given arguments.
|
||||
template <class CallerContextType, class CalleeSignature>
|
||||
struct AsyncCalleeContext : AsyncFrameStorage<CalleeSignature> {
|
||||
using CallerContext = CallerContextType;
|
||||
|
||||
template <class... Args>
|
||||
AsyncCalleeContext(TaskContinuationFunction *resumeFunction,
|
||||
ExecutorRef resumeToExecutor,
|
||||
CallerContext *resumeToContext,
|
||||
Args... args)
|
||||
: AsyncFrameStorage<CalleeSignature>(AsyncContextKind::Ordinary,
|
||||
resumeFunction, resumeToExecutor,
|
||||
resumeToContext, args...) {}
|
||||
|
||||
CallerContext *getParent() const {
|
||||
return static_cast<CallerContext*>(this->Parent);
|
||||
}
|
||||
};
|
||||
|
||||
/// Push a context to call a function.
|
||||
template <class CalleeSignature, class CallerContext, class... Args>
|
||||
static AsyncCalleeContext<CallerContext, CalleeSignature> *
|
||||
pushAsyncContext(AsyncTask *task, ExecutorRef executor,
|
||||
CallerContext *callerContext, size_t calleeContextSize,
|
||||
TaskContinuationFunction *resumeFunction,
|
||||
Args... args) {
|
||||
using CalleeContext =
|
||||
AsyncCalleeContext<CallerContext, CalleeSignature>;
|
||||
assert(calleeContextSize >= sizeof(CalleeContext));
|
||||
|
||||
void *rawCalleeContext = swift_task_alloc(task, calleeContextSize);
|
||||
return new (rawCalleeContext) CalleeContext(resumeFunction, executor,
|
||||
callerContext, args...);
|
||||
}
|
||||
|
||||
/// Make an asynchronous call.
|
||||
template <class CalleeSignature, class CallerContext, class... Args>
|
||||
SWIFT_CC(swiftasync)
|
||||
static void callAsync(AsyncTask *task,
|
||||
ExecutorRef executor,
|
||||
CallerContext *callerContext,
|
||||
TaskContinuationFunction *resumeFunction,
|
||||
const typename CalleeSignature::FunctionPointer *function,
|
||||
Args... args) {
|
||||
auto calleeContextSize = function->ExpectedContextSize;
|
||||
auto calleeContext = pushAsyncContext(task, executor, callerContext,
|
||||
calleeContextSize, resumeFunction,
|
||||
args...);
|
||||
return function->Function(task, executor, calleeContext);
|
||||
}
|
||||
|
||||
/// Given that that we've just entered the caller's continuation function
|
||||
/// upon return from a function previously called with callAsync, pop the
|
||||
/// callee's context and return the caller's context.
|
||||
template <class CalleeContext>
|
||||
static typename CalleeContext::CallerContext *
|
||||
popAsyncContext(AsyncTask *task, CalleeContext *calleeContext) {
|
||||
auto callerContext = calleeContext->getParent();
|
||||
swift_task_dealloc(task, calleeContext);
|
||||
return callerContext;
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
} // end namespace swift
|
||||
|
||||
#endif
|
||||
@@ -16,9 +16,21 @@ set(swift_concurrency_objc_sources
|
||||
set(LLVM_OPTIONAL_SOURCES
|
||||
${swift_concurrency_objc_sources})
|
||||
|
||||
set(swift_concurrency_link_libraries
|
||||
swiftCore)
|
||||
|
||||
if(SWIFT_CONCURRENCY_USES_DISPATCH)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
list(APPEND swift_concurrency_link_libraries
|
||||
dispatch)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
|
||||
Actor.cpp
|
||||
Actor.swift
|
||||
GlobalExecutor.cpp
|
||||
PartialAsyncTask.swift
|
||||
Task.cpp
|
||||
Task.swift
|
||||
@@ -41,7 +53,7 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
|
||||
SWIFT_MODULE_DEPENDS_HAIKU Glibc
|
||||
SWIFT_MODULE_DEPENDS_WINDOWS CRT
|
||||
|
||||
LINK_LIBRARIES swiftCore
|
||||
LINK_LIBRARIES ${swift_concurrency_link_libraries}
|
||||
|
||||
C_COMPILE_FLAGS
|
||||
-Dswift_Concurrency_EXPORTS
|
||||
|
||||
116
stdlib/public/Concurrency/GlobalExecutor.cpp
Normal file
116
stdlib/public/Concurrency/GlobalExecutor.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
///===--- GlobalExecutor.cpp - Global concurrent executor ------------------===///
|
||||
///
|
||||
/// This source file is part of the Swift.org open source project
|
||||
///
|
||||
/// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
|
||||
/// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
///
|
||||
/// See https:///swift.org/LICENSE.txt for license information
|
||||
/// See https:///swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
///
|
||||
///===----------------------------------------------------------------------===///
|
||||
///
|
||||
/// Routines related to the global concurrent execution service.
|
||||
///
|
||||
/// The execution side of Swift's concurrency model centers around
|
||||
/// scheduling work onto various execution services ("executors").
|
||||
/// Executors vary in several different dimensions:
|
||||
///
|
||||
/// First, executors may be exclusive or concurrent. An exclusive
|
||||
/// executor can only execute one job at once; a concurrent executor
|
||||
/// can execute many. Exclusive executors are usually used to achieve
|
||||
/// some higher-level requirement, like exclusive access to some
|
||||
/// resource or memory. Concurrent executors are usually used to
|
||||
/// manage a pool of threads and prevent the number of allocated
|
||||
/// threads from growing without limit.
|
||||
///
|
||||
/// Second, executors may own dedicated threads, or they may schedule
|
||||
/// work onto some some underlying executor. Dedicated threads can
|
||||
/// improve the responsiveness of a subsystem *locally*, but they impose
|
||||
/// substantial costs which can drive down performance *globally*
|
||||
/// if not used carefully. When an executor relies on running work
|
||||
/// on its own dedicated threads, jobs that need to run briefly on
|
||||
/// that executor may need to suspend and restart. Dedicating threads
|
||||
/// to an executor is a decision that should be made carefully
|
||||
/// and holistically.
|
||||
///
|
||||
/// If most executors should not have dedicated threads, they must
|
||||
/// be backed by some underlying executor, typically a concurrent
|
||||
/// executor. The purpose of most concurrent executors is to
|
||||
/// manage threads and prevent excessive growth in the number
|
||||
/// of threads. Having multiple independent concurrent executors
|
||||
/// with their own dedicated threads would undermine that.
|
||||
/// Therefore, it is sensible to have a single, global executor
|
||||
/// that will ultimately schedule most of the work in the system.
|
||||
/// With that as a baseline, special needs can be recognized and
|
||||
/// carved out from the global executor with its cooperation.
|
||||
///
|
||||
/// This file defines Swift's interface to that global executor.
|
||||
///
|
||||
/// The default implementation is backed by libdispatch, but there
|
||||
/// may be good reasons to provide alternatives (e.g. when building
|
||||
/// a single-threaded runtime).
|
||||
///
|
||||
///===----------------------------------------------------------------------===///
|
||||
|
||||
#include "swift/Runtime/Concurrency.h"
|
||||
|
||||
#include <dispatch/dispatch.h>
|
||||
|
||||
using namespace swift;
|
||||
|
||||
SWIFT_CC(swift)
|
||||
void (*swift::swift_task_enqueueGlobal_hook)(Job *job) = nullptr;
|
||||
|
||||
static void __swift_run_job(void *_job) {
|
||||
Job *job = (Job*) _job;
|
||||
job->run(ExecutorRef::generic());
|
||||
}
|
||||
|
||||
void swift::swift_task_enqueueGlobal(Job *job) {
|
||||
assert(job && "no job provided");
|
||||
|
||||
// If the hook is defined, use it.
|
||||
if (swift_task_enqueueGlobal_hook)
|
||||
return swift_task_enqueueGlobal_hook(job);
|
||||
|
||||
// We really want four things from the global execution service:
|
||||
// - Enqueuing work should have minimal runtime and memory overhead.
|
||||
// - Adding work should never result in an "explosion" where many
|
||||
// more threads are created than the available cores.
|
||||
// - Jobs should run on threads with an appropriate priority.
|
||||
// - Thread priorities should temporarily elevatable to avoid
|
||||
// priority inversions.
|
||||
//
|
||||
// Of these, the first two are the most important. Many programs
|
||||
// do not rely on high-usage priority scheduling, and many priority
|
||||
// inversions can be avoided at a higher level (albeit with some
|
||||
// performance cost, e.g. by creating higher-priority tasks to run
|
||||
// critical sections that contend with high-priority work). In
|
||||
// contrast, if the async feature adds too much overhead, or if
|
||||
// heavy use of it leads to thread explosions and memory exhaustion,
|
||||
// programmers will have no choice but to stop using it. So if
|
||||
// goals are in conflict, it's best to focus on core properties over
|
||||
// priority-inversion avoidance.
|
||||
|
||||
// We currently use Dispatch for our thread pool on all platforms.
|
||||
// Dispatch currently backs its serial queues with a global
|
||||
// concurrent queue that is prone to thread explosions when a flood
|
||||
// of jobs are added to it. That problem does not apply equally
|
||||
// to the global concurrent queues returned by dispatch_get_global_queue,
|
||||
// which are not strictly CPU-limited but are at least much more
|
||||
// cautious about adding new threads. We cannot safely elevate
|
||||
// the priorities of work added to this queue using Dispatch's public
|
||||
// API, but as discussed above, that is less important than avoiding
|
||||
// performance problems.
|
||||
dispatch_function_t dispatchFunction = &__swift_run_job;
|
||||
void *dispatchContext = job;
|
||||
|
||||
JobPriority priority = job->getPriority();
|
||||
|
||||
// TODO: cache this to avoid the extra call
|
||||
auto queue = dispatch_get_global_queue((dispatch_qos_class_t) priority,
|
||||
/*flags*/ 0);
|
||||
|
||||
dispatch_async_f(queue, dispatchContext, dispatchFunction);
|
||||
}
|
||||
@@ -17,8 +17,10 @@
|
||||
#include "swift/Runtime/Concurrency.h"
|
||||
#include "swift/ABI/Task.h"
|
||||
#include "swift/ABI/Metadata.h"
|
||||
#include "swift/Runtime/Mutex.h"
|
||||
#include "swift/Runtime/HeapObject.h"
|
||||
#include "TaskPrivate.h"
|
||||
#include "AsyncCall.h"
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// TODO: We shouldn't need this
|
||||
@@ -224,14 +226,14 @@ static void completeTask(AsyncTask *task, ExecutorRef executor,
|
||||
|
||||
AsyncTaskAndContext
|
||||
swift::swift_task_create(JobFlags flags, AsyncTask *parent,
|
||||
const AsyncFunctionPointer<void()> *function) {
|
||||
const ThinNullaryAsyncSignature::FunctionPointer *function) {
|
||||
return swift_task_create_f(flags, parent, function->Function.get(),
|
||||
function->ExpectedContextSize);
|
||||
}
|
||||
|
||||
AsyncTaskAndContext
|
||||
swift::swift_task_create_f(JobFlags flags, AsyncTask *parent,
|
||||
AsyncFunctionType<void()> *function,
|
||||
ThinNullaryAsyncSignature::FunctionType *function,
|
||||
size_t initialContextSize) {
|
||||
return swift_task_create_future_f(
|
||||
flags, parent, nullptr, function, initialContextSize);
|
||||
@@ -239,7 +241,7 @@ swift::swift_task_create_f(JobFlags flags, AsyncTask *parent,
|
||||
|
||||
AsyncTaskAndContext swift::swift_task_create_future(
|
||||
JobFlags flags, AsyncTask *parent, const Metadata *futureResultType,
|
||||
const AsyncFunctionPointer<void()> *function) {
|
||||
const FutureAsyncSignature::FunctionPointer *function) {
|
||||
return swift_task_create_future_f(
|
||||
flags, parent, futureResultType, function->Function.get(),
|
||||
function->ExpectedContextSize);
|
||||
@@ -247,7 +249,7 @@ AsyncTaskAndContext swift::swift_task_create_future(
|
||||
|
||||
AsyncTaskAndContext swift::swift_task_create_future_f(
|
||||
JobFlags flags, AsyncTask *parent, const Metadata *futureResultType,
|
||||
AsyncFunctionType<void()> *function, size_t initialContextSize) {
|
||||
FutureAsyncSignature::FunctionType *function, size_t initialContextSize) {
|
||||
assert((futureResultType != nullptr) == flags.task_isFuture());
|
||||
assert(!flags.task_isFuture() ||
|
||||
initialContextSize >= sizeof(FutureAsyncContext));
|
||||
@@ -354,9 +356,104 @@ void swift::swift_task_future_wait(
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
/// The header of a function context (closure captures) of
|
||||
/// a thick async function with a non-null context.
|
||||
struct ThickAsyncFunctionContext: HeapObject {
|
||||
uint32_t ExpectedContextSize;
|
||||
};
|
||||
|
||||
struct RunAndBlockSemaphore {
|
||||
ConditionVariable Queue;
|
||||
ConditionVariable::Mutex Lock;
|
||||
bool Finished = false;
|
||||
};
|
||||
|
||||
using RunAndBlockSignature =
|
||||
AsyncSignature<void(HeapObject*), /*throws*/ false>;
|
||||
struct RunAndBlockContext: AsyncContext {
|
||||
const void *Function;
|
||||
HeapObject *FunctionContext;
|
||||
RunAndBlockSemaphore *Semaphore;
|
||||
};
|
||||
using RunAndBlockCalleeContext =
|
||||
AsyncCalleeContext<RunAndBlockContext, RunAndBlockSignature>;
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
/// Second half of the runAndBlock async function.
|
||||
SWIFT_CC(swiftasync)
|
||||
static void runAndBlock_finish(AsyncTask *task, ExecutorRef executor,
|
||||
AsyncContext *_context) {
|
||||
auto calleeContext = static_cast<RunAndBlockCalleeContext*>(_context);
|
||||
auto context = popAsyncContext(task, calleeContext);
|
||||
|
||||
auto semaphore = context->Semaphore;
|
||||
semaphore->Lock.withLockThenNotifyAll(semaphore->Queue, [&]{
|
||||
semaphore->Finished = true;
|
||||
});
|
||||
|
||||
return context->ResumeParent(task, executor, context);
|
||||
}
|
||||
|
||||
/// First half of the runAndBlock async function.
|
||||
SWIFT_CC(swiftasync)
|
||||
static void runAndBlock_start(AsyncTask *task, ExecutorRef executor,
|
||||
AsyncContext *_context) {
|
||||
auto callerContext = static_cast<RunAndBlockContext*>(_context);
|
||||
|
||||
size_t calleeContextSize;
|
||||
RunAndBlockSignature::FunctionType *function;
|
||||
|
||||
// If the function context is non-null, then the function pointer is
|
||||
// an ordinary function pointer.
|
||||
auto functionContext = callerContext->FunctionContext;
|
||||
if (functionContext) {
|
||||
function = reinterpret_cast<RunAndBlockSignature::FunctionType*>(
|
||||
const_cast<void*>(callerContext->Function));
|
||||
calleeContextSize =
|
||||
static_cast<ThickAsyncFunctionContext*>(functionContext)
|
||||
->ExpectedContextSize;
|
||||
|
||||
// Otherwise, the function pointer is an async function pointer.
|
||||
} else {
|
||||
auto fnPtr = reinterpret_cast<const RunAndBlockSignature::FunctionPointer*>(
|
||||
callerContext->Function);
|
||||
function = fnPtr->Function;
|
||||
calleeContextSize = fnPtr->ExpectedContextSize;
|
||||
}
|
||||
|
||||
auto calleeContext =
|
||||
pushAsyncContext<RunAndBlockSignature>(task, executor, callerContext,
|
||||
calleeContextSize,
|
||||
&runAndBlock_finish,
|
||||
functionContext);
|
||||
return function(task, executor, calleeContext);
|
||||
}
|
||||
|
||||
// TODO: Remove this hack.
|
||||
void swift::swift_task_run(AsyncTask *taskToRun) {
|
||||
taskToRun->run(ExecutorRef::generic());
|
||||
void swift::swift_task_runAndBlockThread(const void *function,
|
||||
HeapObject *functionContext) {
|
||||
RunAndBlockSemaphore semaphore;
|
||||
|
||||
// Set up a task that runs the runAndBlock async function above.
|
||||
auto pair = swift_task_create_f(JobFlags(JobKind::Task,
|
||||
JobPriority::Default),
|
||||
/*parent*/ nullptr,
|
||||
&runAndBlock_start,
|
||||
sizeof(RunAndBlockContext));
|
||||
auto context = static_cast<RunAndBlockContext*>(pair.InitialContext);
|
||||
context->Function = function;
|
||||
context->FunctionContext = functionContext;
|
||||
context->Semaphore = &semaphore;
|
||||
|
||||
// Enqueue the task.
|
||||
swift_task_enqueueGlobal(pair.Task);
|
||||
|
||||
// Wait for the task to finish.
|
||||
semaphore.Lock.withLockOrWait(semaphore.Queue, [&] {
|
||||
return semaphore.Finished;
|
||||
});
|
||||
}
|
||||
|
||||
size_t swift::swift_task_getJobFlags(AsyncTask *task) {
|
||||
|
||||
@@ -137,11 +137,6 @@ extension Task {
|
||||
public func cancel() {
|
||||
Builtin.cancelAsyncTask(task)
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This is a temporary hack")
|
||||
public func run() {
|
||||
runTask(task)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,6 +257,9 @@ extension Task {
|
||||
// Create the asynchronous task future.
|
||||
let (task, _) = Builtin.createAsyncTaskFuture(flags.bits, nil, operation)
|
||||
|
||||
// Enqueue the resulting job.
|
||||
_enqueueJobGlobal(Builtin.convertTaskToJob(task))
|
||||
|
||||
return Handle<T>(task: task)
|
||||
}
|
||||
|
||||
@@ -308,6 +306,9 @@ extension Task {
|
||||
// Create the asynchronous task future.
|
||||
let (task, _) = Builtin.createAsyncTaskFuture(flags.bits, nil, operation)
|
||||
|
||||
// Enqueue the resulting job.
|
||||
_enqueueJobGlobal(Builtin.convertTaskToJob(task))
|
||||
|
||||
return Handle<T>(task: task)
|
||||
}
|
||||
|
||||
@@ -372,16 +373,15 @@ extension Task {
|
||||
}
|
||||
}
|
||||
|
||||
@_silgen_name("swift_task_run")
|
||||
public func runTask(_ task: __owned Builtin.NativeObject)
|
||||
|
||||
@_silgen_name("swift_task_getJobFlags")
|
||||
func getJobFlags(_ task: Builtin.NativeObject) -> Task.JobFlags
|
||||
|
||||
public func runAsync(_ asyncFun: @escaping () async -> ()) {
|
||||
let childTask = Builtin.createAsyncTask(0, nil, asyncFun)
|
||||
runTask(childTask.0)
|
||||
}
|
||||
@_silgen_name("swift_task_enqueueGlobal")
|
||||
@usableFromInline
|
||||
func _enqueueJobGlobal(_ task: Builtin.Job)
|
||||
|
||||
@_silgen_name("swift_task_runAndBlockThread")
|
||||
public func runAsyncAndBlock(_ asyncFun: @escaping () async -> ())
|
||||
|
||||
@_silgen_name("swift_task_future_wait")
|
||||
func _taskFutureWait(
|
||||
|
||||
@@ -1,43 +1,14 @@
|
||||
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch) | %FileCheck %s --dump-input always
|
||||
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency) | %FileCheck %s --dump-input always
|
||||
// REQUIRES: executable_test
|
||||
// REQUIRES: concurrency
|
||||
// REQUIRES: libdispatch
|
||||
|
||||
import Dispatch
|
||||
|
||||
#if canImport(Darwin)
|
||||
import Darwin
|
||||
#elseif canImport(Glibc)
|
||||
import Glibc
|
||||
#endif
|
||||
|
||||
// ==== ------------------------------------------------------------------------
|
||||
// MARK: "Infrastructure" for the tests
|
||||
|
||||
extension DispatchQueue {
|
||||
func async<R>(operation: @escaping () async -> R) -> Task.Handle<R> {
|
||||
let handle = Task.runDetached(operation: operation)
|
||||
|
||||
// Run the task
|
||||
_ = { self.async { handle.run() } }() // force invoking the non-async version
|
||||
|
||||
return handle
|
||||
}
|
||||
}
|
||||
|
||||
// ==== ------------------------------------------------------------------------
|
||||
// MARK: Tests
|
||||
|
||||
func test_getPriority() {
|
||||
_ = DispatchQueue.main.async { () async in
|
||||
runAsyncAndBlock {
|
||||
let p = await Task.currentPriority()
|
||||
// CHECK: priority: default
|
||||
print("priority: \(p)")
|
||||
assert(p == Task.Priority.default)
|
||||
exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
test_getPriority()
|
||||
|
||||
dispatchMain()
|
||||
|
||||
@@ -12,17 +12,6 @@ import Darwin
|
||||
import Glibc
|
||||
#endif
|
||||
|
||||
extension DispatchQueue {
|
||||
func async<R>(execute: @escaping () async throws -> R) -> Task.Handle<R> {
|
||||
let handle = Task.runDetached(operation: execute)
|
||||
|
||||
// Run the task
|
||||
_ = { self.async { handle.run() } }()
|
||||
|
||||
return handle
|
||||
}
|
||||
}
|
||||
|
||||
enum HomeworkError: Error, Equatable {
|
||||
case dogAteIt(String)
|
||||
}
|
||||
@@ -36,16 +25,9 @@ func testSimple(
|
||||
) {
|
||||
print("Testing name: \(name), dog: \(dogName), shouldThrow: \(shouldThrow) doSuspend: \(doSuspend)")
|
||||
|
||||
let queue = DispatchQueue(label: "concurrent", attributes: .concurrent)
|
||||
let group = DispatchGroup()
|
||||
var completed = false
|
||||
|
||||
group.enter()
|
||||
let taskHandle = queue.async { () async throws -> String in
|
||||
defer {
|
||||
group.leave()
|
||||
}
|
||||
|
||||
let taskHandle = Task.runDetached { () async throws -> String in
|
||||
let greeting = await formGreeting(name: name)
|
||||
|
||||
// If the intent is to test suspending, wait a bit so the second task
|
||||
@@ -64,12 +46,7 @@ func testSimple(
|
||||
return greeting + "!"
|
||||
}
|
||||
|
||||
group.enter()
|
||||
_ = queue.async { () async in
|
||||
defer {
|
||||
group.leave()
|
||||
}
|
||||
|
||||
runAsyncAndBlock {
|
||||
// If the intent is not to test suspending, wait a bit so the first task
|
||||
// can complete.
|
||||
if !doSuspend {
|
||||
@@ -92,7 +69,6 @@ func testSimple(
|
||||
}
|
||||
}
|
||||
|
||||
group.wait()
|
||||
assert(completed)
|
||||
print("Finished test")
|
||||
}
|
||||
|
||||
@@ -12,33 +12,6 @@ import Darwin
|
||||
import Glibc
|
||||
#endif
|
||||
|
||||
extension DispatchQueue {
|
||||
func async<R>(execute: @escaping () async throws -> R) -> Task.Handle<R> {
|
||||
let handle = Task.runDetached(operation: execute)
|
||||
|
||||
// Run the task
|
||||
_ = { self.async { handle.run() } }()
|
||||
|
||||
return handle
|
||||
}
|
||||
|
||||
func async<R>(in group: DispatchGroup,
|
||||
execute: @escaping () async throws -> R) -> Task.Handle<R> {
|
||||
let handle = Task.runDetached(operation: execute)
|
||||
|
||||
// Run the task
|
||||
group.enter()
|
||||
_ = {
|
||||
self.async {
|
||||
handle.run()
|
||||
group.leave()
|
||||
}
|
||||
}()
|
||||
|
||||
return handle
|
||||
}
|
||||
}
|
||||
|
||||
func fib(_ n: Int) -> Int {
|
||||
var first = 0
|
||||
var second = 1
|
||||
@@ -50,17 +23,17 @@ func fib(_ n: Int) -> Int {
|
||||
return first
|
||||
}
|
||||
|
||||
func asyncFib(_ n: Int, group: DispatchGroup, queue: DispatchQueue) async -> Int {
|
||||
func asyncFib(_ n: Int) async -> Int {
|
||||
if n == 0 || n == 1 {
|
||||
return n
|
||||
}
|
||||
|
||||
let first = queue.async(in: group) {
|
||||
await asyncFib(n - 2, group: group, queue: queue)
|
||||
let first = Task.runDetached {
|
||||
await asyncFib(n - 2)
|
||||
}
|
||||
|
||||
let second = queue.async(in: group) {
|
||||
await asyncFib(n - 1, group: group, queue: queue)
|
||||
let second = Task.runDetached {
|
||||
await asyncFib(n - 1)
|
||||
}
|
||||
|
||||
// Sleep a random amount of time waiting on the result producing a result.
|
||||
@@ -75,14 +48,10 @@ func asyncFib(_ n: Int, group: DispatchGroup, queue: DispatchQueue) async -> Int
|
||||
}
|
||||
|
||||
func runFibonacci(_ n: Int) {
|
||||
let queue = DispatchQueue(label: "concurrent", attributes: .concurrent)
|
||||
let group = DispatchGroup()
|
||||
|
||||
var result = 0
|
||||
_ = queue.async(in: group) {
|
||||
result = await asyncFib(n, group: group, queue: queue)
|
||||
runAsyncAndBlock {
|
||||
result = await asyncFib(n)
|
||||
}
|
||||
group.wait()
|
||||
|
||||
print()
|
||||
print("Async fib = \(result), sequential fib = \(fib(n))")
|
||||
|
||||
@@ -1,28 +1,17 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-clang %S/Inputs/objc_async.m -c -o %t/objc_async_objc.o
|
||||
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency %import-libdispatch -import-objc-header %S/Inputs/objc_async.h %s %t/objc_async_objc.o -o %t/objc_async
|
||||
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -import-objc-header %S/Inputs/objc_async.h %s %t/objc_async_objc.o -o %t/objc_async
|
||||
// RUN: %target-run %t/objc_async | %FileCheck %s
|
||||
|
||||
// REQUIRES: executable_test
|
||||
// REQUIRES: concurrency
|
||||
// REQUIRES: libdispatch
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
import _Concurrency
|
||||
|
||||
let task = Task.runDetached {
|
||||
runAsyncAndBlock {
|
||||
let butt = Butt()
|
||||
let result = await butt.butt(1738)
|
||||
print("finishing \(result)")
|
||||
// FIXME: with a proper task runtime, we should exit naturally once all tasks
|
||||
// complete
|
||||
exit(0)
|
||||
}
|
||||
|
||||
// FIXME: use the real task runtime facilities
|
||||
task.run()
|
||||
|
||||
dispatchMain()
|
||||
|
||||
// CHECK: starting 1738
|
||||
// CHECK-NEXT: finishing 679
|
||||
|
||||
@@ -87,7 +87,7 @@ sil_vtable S {
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%s_type = metatype $@thick S.Type
|
||||
@@ -109,7 +109,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -87,7 +87,7 @@ sil_vtable S {
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%s_type = metatype $@thick S.Type
|
||||
@@ -107,7 +107,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -70,7 +70,7 @@ bb0:
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 7384783
|
||||
@@ -85,7 +85,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -29,7 +29,7 @@ bb0(%out : $*T, %in : $*T):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%int_literal = integer_literal $Builtin.Int64, 42
|
||||
@@ -57,7 +57,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -28,7 +28,7 @@ bb0(%instance : $*T):
|
||||
return %result : $()
|
||||
}
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%int_literal = integer_literal $Builtin.Int64, 922337203685477580
|
||||
@@ -48,7 +48,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -30,7 +30,7 @@ bb0(%0 : $*T, %1 : $*T):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%int1_literal = integer_literal $Builtin.Int64, 42
|
||||
@@ -65,7 +65,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -30,7 +30,7 @@ entry(%int1: $Int64, %int2: $Int64):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%int_literal1 = integer_literal $Builtin.Int64, 42
|
||||
@@ -50,7 +50,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -29,7 +29,7 @@ entry(%int: $Int64):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%int_literal = integer_literal $Builtin.Int64, 42
|
||||
@@ -47,7 +47,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -62,7 +62,7 @@ bb0(%self_addr : $*I):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%i_type = metatype $@thin I.Type
|
||||
@@ -86,7 +86,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -52,7 +52,7 @@ bb0(%self_addr : $*I):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%i_type = metatype $@thin I.Type
|
||||
@@ -77,7 +77,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -23,7 +23,7 @@ import ResilientClass
|
||||
sil public_external [exact_self_class] @$s14ResilientClass5ClazzCACycfC : $@convention(method) (@thick Clazz.Type) -> @owned Clazz
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
// CHECK-LL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @test_case(%swift.task* {{%[0-9]+}}, %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}}) {{#[0-9]*}} {
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
@@ -44,7 +44,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -26,4 +26,4 @@ func test_case() async {
|
||||
await call(impl) // CHECK: Impl()
|
||||
}
|
||||
|
||||
_Concurrency.runAsync(test_case)
|
||||
_Concurrency.runAsyncAndBlock(test_case)
|
||||
|
||||
@@ -41,7 +41,7 @@ entry(%pack : $Pack):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
// CHECK-LL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @test_case(%swift.task* {{%[0-9]+}}, %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}}) {{#[0-9]*}} {
|
||||
sil @test_case : $@async @convention(thin) () -> () {
|
||||
@@ -69,7 +69,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -49,7 +49,7 @@ bb0(%self : $S, %int : $Int64):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%s_type = metatype $@thin S.Type
|
||||
@@ -70,7 +70,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -116,7 +116,7 @@ bb0:
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 42
|
||||
@@ -131,7 +131,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -139,7 +139,7 @@ bb0:
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 42
|
||||
@@ -154,7 +154,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -126,7 +126,7 @@ bb0:
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 42
|
||||
@@ -141,7 +141,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -140,7 +140,7 @@ bb0:
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 42
|
||||
@@ -155,7 +155,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -126,7 +126,7 @@ bb0:
|
||||
throw %error : $Error
|
||||
}
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 42
|
||||
@@ -141,7 +141,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -74,7 +74,7 @@ bb0:
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%call = function_ref @call : $@async @convention(thin) () -> ()
|
||||
@@ -89,7 +89,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -31,7 +31,7 @@ sil @voidToInt64AndInt64 : $@async @convention(thin) () -> (Int64, Int64) {
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%voidToInt64AndInt64 = function_ref @voidToInt64AndInt64 : $@async @convention(thin) () -> (Int64, Int64)
|
||||
@@ -52,7 +52,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -28,7 +28,7 @@ sil @voidToInt64 : $@async @convention(thin) () -> (Int64) {
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%voidToInt64 = function_ref @voidToInt64 : $@async @convention(thin) () -> Int64
|
||||
@@ -46,7 +46,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -125,7 +125,7 @@ sil hidden @printBig : $@async @convention(thin) () -> () {
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%printBig = function_ref @printBig : $@async @convention(thin) () -> ()
|
||||
@@ -140,7 +140,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -63,7 +63,7 @@ bb0(%out_addr : $*U, %self_addr : $*T, %in_addr : $*U):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%I_type = metatype $@thin I.Type
|
||||
@@ -99,7 +99,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -61,7 +61,7 @@ bb0(%t : $*T):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%i_type = metatype $@thin I.Type
|
||||
@@ -86,7 +86,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -26,7 +26,7 @@ entry(%int : $Int64):
|
||||
return %result : $()
|
||||
}
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%int64ToVoid = function_ref @int64ToVoid : $@async @convention(thin) (Int64) -> ()
|
||||
@@ -50,7 +50,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -77,7 +77,7 @@ entry(%instance : $S):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%s_type = metatype $@thick S.Type
|
||||
@@ -100,7 +100,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -64,7 +64,7 @@ bb0(%0 : $*S):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%observableImpl = alloc_ref $ObservableImpl
|
||||
@@ -91,7 +91,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -40,7 +40,7 @@ entry(%a : $*T):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%in_literal = integer_literal $Builtin.Int64, 876
|
||||
@@ -75,7 +75,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -71,7 +71,7 @@ bb0(%one : $Int64, %two : $Int64):
|
||||
return %sum : $Int64
|
||||
}
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%createAndInvokeClosure = function_ref @createAndInvokeClosure : $@async @convention(thin) () -> ()
|
||||
@@ -86,7 +86,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -62,7 +62,7 @@ bb0(%one : $Int64, %two : $Int64):
|
||||
return %sum : $Int64
|
||||
}
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%createAndInvokeClosure = function_ref @createAndInvokeClosure : $@async @convention(thin) () -> ()
|
||||
@@ -77,7 +77,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -38,7 +38,7 @@ entry(%out_t : $*T, %x : $Int32, %in_t : $*T):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%callee = function_ref @callee : $@async @convention(thin) <T> (Int32, @in_guaranteed T) -> @out T
|
||||
@@ -70,7 +70,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -84,7 +84,7 @@ bb0(%x : $S):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%s_type = metatype $@thick C.Type
|
||||
@@ -112,7 +112,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -66,7 +66,7 @@ bb0(%0 : $*A2<A3>):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%a3 = alloc_ref $A3
|
||||
@@ -106,7 +106,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -52,7 +52,7 @@ bb0(%0 : $*τ_0_1):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%bind_polymorphic_param_from_context = function_ref @bind_polymorphic_param_from_context : $@async @convention(thin) <τ_0_1>(@in τ_0_1) -> @owned @async @callee_owned () -> ()
|
||||
@@ -74,7 +74,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -55,7 +55,7 @@ bb0(%0 : $*τ_0_1):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%bind_polymorphic_param_from_forwarder_parameter = function_ref @bind_polymorphic_param_from_forwarder_parameter : $@async @convention(thin) <τ_0_1>(@in τ_0_1) -> @callee_owned @async (@owned WeakBox<BaseProducer<τ_0_1>>) -> ()
|
||||
@@ -79,7 +79,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -85,7 +85,7 @@ entry(%S_type: $@thin S.Type, %C_instance: $C):
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%c_type = metatype $@thick C.Type
|
||||
@@ -108,7 +108,7 @@ bb0(%argc : $Int32, %argv : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%out_literal = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -45,7 +45,7 @@ final actor class MyActor {
|
||||
// CHECK: switch back
|
||||
// CHECK: 66
|
||||
|
||||
runAsync {
|
||||
runAsyncAndBlock {
|
||||
let a = MyActor(p: 27)
|
||||
print("run")
|
||||
await print(a.testit())
|
||||
|
||||
@@ -39,7 +39,7 @@ entry:
|
||||
}
|
||||
|
||||
// Defined in _Concurrency
|
||||
sil public_external @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
sil public_external @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
sil @test_case : $@convention(thin) @async () -> () {
|
||||
%test_apply_of_thin_to_thick = function_ref @test_apply_of_thin_to_thick : $@async @convention(thin) () -> ()
|
||||
@@ -54,7 +54,7 @@ bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>
|
||||
|
||||
%2 = function_ref @test_case : $@convention(thin) @async () -> ()
|
||||
%3 = thin_to_thick_function %2 : $@convention(thin) @async () -> () to $@async @callee_guaranteed () -> ()
|
||||
%4 = function_ref @$s12_Concurrency8runAsyncyyyyYcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%4 = function_ref @swift_task_runAndBlockThread : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
%5 = apply %4(%3) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> ()) -> ()
|
||||
|
||||
%6 = integer_literal $Builtin.Int32, 0
|
||||
|
||||
@@ -23,7 +23,7 @@ func sayWithClosure(_ action: () async -> ()) async {
|
||||
print("hallo welt")
|
||||
}
|
||||
|
||||
runAsync {
|
||||
runAsyncAndBlock {
|
||||
// CHECK: hello
|
||||
await sayHello()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user