Skip to content

Merge main 2021-01-30 #2618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
472e842
Concurrency: avoid `CFRunLoopRun` on non-Darwin
compnerd Jan 24, 2021
329af74
[Concurrency] Add a debug variable pointing to the metadata for Async…
mikeash Jan 27, 2021
ba8819e
[Concurrent] Introduce concurrent function types.
DougGregor Jan 27, 2021
b77ba9a
[Concurrency] Infer @concurrent on closures from contextual type
DougGregor Jan 27, 2021
9904026
[Concurrency] Teach data race & isolation checking about @concurrent …
DougGregor Jan 28, 2021
5129d82
Add more tests for @concurrent function types
DougGregor Jan 28, 2021
6d086d4
Add support for @concurrent on function declarations
DougGregor Jan 28, 2021
60800e1
Diagnostics: improve error message at attr diagnosis failure
ktoso Jan 28, 2021
9efb44f
Adopt @concurrent in Task APIs
DougGregor Jan 28, 2021
75f4fb1
Mark async let closures as @concurrent.
DougGregor Jan 28, 2021
1d082e1
Require that concurrently-executed local functions be @concurrent.
DougGregor Jan 28, 2021
581e666
Adopt @concurrent in withCancellationHandler.
DougGregor Jan 28, 2021
844ce09
IRGen: Refer to dispatch thunk async function pointers when making calls
slavapestov Jan 27, 2021
4e96cef
Centralize logic for the actor isolation of a context
DougGregor Jan 28, 2021
0cd0a36
Try to fix the ASAN build
aschwaighofer Jan 28, 2021
798f869
[Test] Replaced runAsyncAndBlock with async @main.
nate-chandler Jan 29, 2021
0768d1e
IRGen: Fix resilient witness tables and vtables to correctly referenc…
slavapestov Jan 27, 2021
be1e8f6
Merge pull request #35642 from nate-chandler/test/20210128/1
nate-chandler Jan 29, 2021
8eae527
Tighten up actor isolation checking for closures and local functions.
DougGregor Jan 29, 2021
f4c5a26
`@concurrent` functions are actor-independent
DougGregor Jan 29, 2021
0b2a626
Revert "Comment SimplifyCFG JumpThreadingCost."
atrick Jan 29, 2021
67863c5
Revert "SimplifyCFG: fix an infinite jump-threading loop."
atrick Jan 29, 2021
61f349c
add #ifndef NDEBUG
ktoso Jan 29, 2021
27d8cef
[TBDGen] clean up spacing in test, NFC (#35643)
cyndyishida Jan 29, 2021
f1a8fff
Merge pull request #35645 from atrick/revert-jumpthreadcost
eeckstein Jan 29, 2021
ac56f03
Merge pull request #35640 from aschwaighofer/fix_asan_build
aschwaighofer Jan 29, 2021
3c90576
cmake: fix Xcode project generation to include all header files.
eeckstein Jan 29, 2021
f13167d
Merge pull request #35628 from DougGregor/concurrent-function-types
DougGregor Jan 29, 2021
3cf257f
Merge pull request #35585 from compnerd/runless
compnerd Jan 29, 2021
84a29e7
Disable CMark test for buildbot,tools=RA,stdlib=RD,test=non_executabl…
shahmishal Jan 29, 2021
948166d
Merge pull request #35651 from apple/disable-cmark-for-non_executable…
shahmishal Jan 29, 2021
1f1f703
Drop @concurrent from parameter to @asyncHandler entry point.
DougGregor Jan 29, 2021
9faf023
Merge pull request #35647 from eeckstein/fix-cmake
swift-ci Jan 29, 2021
99f8d7a
[SIL] Add @concurrent function types to SIL
DougGregor Jan 29, 2021
fd85e0e
SILLocation: remove unused flag bits.
eeckstein Jan 25, 2021
462e58d
SILLocation: a big refactoring and reducing its size from 3 to 2 words
eeckstein Jan 28, 2021
ec64f2a
SILLocation: replace CleanupLocation::get(loc) with CleanupLocation(loc)
eeckstein Jan 28, 2021
65208c0
SIL: efficiently store SILLocation in SILInstruction
eeckstein Jan 29, 2021
adae4d7
cmake: another fix for include all header files in Xcode projects.
eeckstein Jan 29, 2021
34ced2b
[capture-promotion] Update style of old pass.
gottesmm Jan 29, 2021
2ff3b3c
Merge pull request #35646 from eeckstein/shrink-sillocation
eeckstein Jan 29, 2021
8c426fc
Merge pull request #35656 from eeckstein/fix-cmake2
swift-ci Jan 29, 2021
a554ad6
[Concurrency] Diagnose mutating accesses to locals from concurrent code.
DougGregor Jan 29, 2021
5d337f7
Diagnose unsafe global variable accesses within concurrent closures/f…
DougGregor Jan 29, 2021
c97637c
Merge pull request #35655 from DougGregor/concurrent-function-types-sil
DougGregor Jan 29, 2021
5f4da4c
[Serialize] Serialize foreign async conventions.
DougGregor Jan 29, 2021
3b77ce4
Merge pull request #35658 from gottesmm/pr-a8f00546cead5e1382aab8b5ed…
swift-ci Jan 29, 2021
b7a86bb
Type check withoutActuallyEscaping on async functions
DougGregor Jan 30, 2021
6864c3a
Disable these tests on platforms other than MacOS for now
slavapestov Jan 29, 2021
edd0c47
Merge pull request #35661 from DougGregor/serialize-foreign-async-con…
swift-ci Jan 30, 2021
f368364
Merge pull request #35565 from slavapestov/resilient-async-dispatch-t…
slavapestov Jan 30, 2021
07d362d
Merge pull request #35664 from DougGregor/async-without-actually-esca…
DougGregor Jan 30, 2021
f0791b8
Merge pull request #35660 from DougGregor/mutating-concurrent-access-…
DougGregor Jan 30, 2021
662b553
Merge pull request #35620 from mikeash/debug-var-async-task-metadata
mikeash Jan 30, 2021
869b6fa
Merge pull request #35634 from apple/diagnostics-attr
ktoso Jan 30, 2021
e0151ed
Merge remote-tracking branch 'apple/main' into katei/merge-main-2021-…
kateinoigakukun Jan 30, 2021
bd1b966
Fix missing header include
kateinoigakukun Jan 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,15 @@ function(add_swift_host_library name)
endif()

if(XCODE)
get_filename_component(dir ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)

get_filename_component(base_dir ${CMAKE_CURRENT_SOURCE_DIR} NAME)
file(GLOB_RECURSE ASHL_HEADERS
${SWIFT_SOURCE_DIR}/include/swift${dir}/*.h
${SWIFT_SOURCE_DIR}/include/swift${dir}/*.def
${SWIFT_SOURCE_DIR}/include/swift/${base_dir}/*.h
${SWIFT_SOURCE_DIR}/include/swift/${base_dir}/*.def
${CMAKE_CURRENT_SOURCE_DIR}/*.h
${CMAKE_CURRENT_SOURCE_DIR}/*.def)
file(GLOB_RECURSE ASHL_TDS
${SWIFT_SOURCE_DIR}/include/swift${dir}/*.td)
${SWIFT_SOURCE_DIR}/include/swift${base_dir}/*.td)

set_source_files_properties(${ASHL_HEADERS} ${ASHL_TDS} PROPERTIES
HEADER_FILE_ONLY true)
Expand Down
6 changes: 4 additions & 2 deletions docs/ABI/Mangling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -556,13 +556,14 @@ Types
C-TYPE is mangled according to the Itanium ABI, and prefixed with the length.
Non-ASCII identifiers are preserved as-is; we do not use Punycode.

function-signature ::= params-type params-type async? throws? // results and parameters
function-signature ::= params-type params-type async? concurrent? throws? // results and parameters

params-type ::= type 'z'? 'h'? // tuple in case of multiple parameters or a single parameter with a single tuple type
// with optional inout convention, shared convention. parameters don't have labels,
// they are mangled separately as part of the entity.
params-type ::= empty-list // shortcut for no parameters

concurrent ::= 'J' // @concurrent on function types
async ::= 'Y' // 'async' annotation on function types
throws ::= 'K' // 'throws' annotation on function types

Expand Down Expand Up @@ -624,7 +625,7 @@ mangled in to disambiguate.
impl-function-type ::= type* 'I' FUNC-ATTRIBUTES '_'
impl-function-type ::= type* generic-signature 'I' FUNC-ATTRIBUTES '_'

FUNC-ATTRIBUTES ::= PATTERN-SUBS? INVOCATION-SUBS? PSEUDO-GENERIC? CALLEE-ESCAPE? DIFFERENTIABILITY-KIND? CALLEE-CONVENTION FUNC-REPRESENTATION? COROUTINE-KIND? ASYNC? (PARAM-CONVENTION PARAM-DIFFERENTIABILITY?)* RESULT-CONVENTION* ('Y' PARAM-CONVENTION)* ('z' RESULT-CONVENTION RESULT-DIFFERENTIABILITY?)?
FUNC-ATTRIBUTES ::= PATTERN-SUBS? INVOCATION-SUBS? PSEUDO-GENERIC? CALLEE-ESCAPE? DIFFERENTIABILITY-KIND? CALLEE-CONVENTION FUNC-REPRESENTATION? COROUTINE-KIND? CONCURRENT? ASYNC? (PARAM-CONVENTION PARAM-DIFFERENTIABILITY?)* RESULT-CONVENTION* ('Y' PARAM-CONVENTION)* ('z' RESULT-CONVENTION RESULT-DIFFERENTIABILITY?)?

PATTERN-SUBS ::= 's' // has pattern substitutions
INVOCATION-SUB ::= 'I' // has invocation substitutions
Expand Down Expand Up @@ -653,6 +654,7 @@ mangled in to disambiguate.
COROUTINE-KIND ::= 'A' // yield-once coroutine
COROUTINE-KIND ::= 'G' // yield-many coroutine

CONCURRENT ::= 'h' // @concurrent
ASYNC ::= 'H' // @async

PARAM-CONVENTION ::= 'i' // indirect in
Expand Down
1 change: 1 addition & 0 deletions include/swift/ABI/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,7 @@ struct TargetFunctionTypeMetadata : public TargetMetadata<Runtime> {
}
bool isAsync() const { return Flags.isAsync(); }
bool isThrowing() const { return Flags.isThrowing(); }
bool isConcurrent() const { return Flags.isConcurrent(); }
bool hasParameterFlags() const { return Flags.hasParameterFlags(); }
bool isEscaping() const { return Flags.isEscaping(); }

Expand Down
12 changes: 12 additions & 0 deletions include/swift/ABI/MetadataValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ class TargetFunctionTypeFlags {
DifferentiableMask = 0x08000000U,
LinearMask = 0x10000000U,
AsyncMask = 0x20000000U,
ConcurrentMask = 0x40000000U,
};
int_type Data;

Expand Down Expand Up @@ -831,6 +832,13 @@ class TargetFunctionTypeFlags {
(isEscaping ? EscapingMask : 0));
}

constexpr TargetFunctionTypeFlags<int_type>
withConcurrent(bool isConcurrent) const {
return TargetFunctionTypeFlags<int_type>(
(Data & ~ConcurrentMask) |
(isConcurrent ? ConcurrentMask : 0));
}

unsigned getNumParameters() const { return Data & NumParametersMask; }

FunctionMetadataConvention getConvention() const {
Expand All @@ -845,6 +853,10 @@ class TargetFunctionTypeFlags {
return bool (Data & EscapingMask);
}

bool isConcurrent() const {
return bool (Data & ConcurrentMask);
}

bool hasParameterFlags() const { return bool(Data & ParamFlagsMask); }

bool isDifferentiable() const {
Expand Down
11 changes: 11 additions & 0 deletions include/swift/AST/AnyFunctionRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ class AnyFunctionRef {
return false;
}

/// Whether this function is @concurrent.
bool isConcurrent() const {
if (!hasType())
return false;

if (auto *fnType = getType()->getAs<AnyFunctionType>())
return fnType->isConcurrent();

return false;
}

bool isObjC() const {
if (auto afd = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
return afd->isObjC();
Expand Down
7 changes: 7 additions & 0 deletions include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ TYPE_ATTR(escaping)
TYPE_ATTR(differentiable)
TYPE_ATTR(noDerivative)
TYPE_ATTR(async)
TYPE_ATTR(concurrent)

// SIL-specific attributes
TYPE_ATTR(block_storage)
Expand Down Expand Up @@ -599,6 +600,12 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(async, Async,
APIBreakingToAdd | APIBreakingToRemove,
106)

SIMPLE_DECL_ATTR(concurrent, Concurrent,
OnFunc | OnConstructor | OnAccessor | ConcurrencyOnly |
ABIStableToAdd | ABIStableToRemove |
APIBreakingToAdd | APIBreakingToRemove,
107)

#undef TYPE_ATTR
#undef DECL_ATTR_ALIAS
#undef CONTEXTUAL_DECL_ATTR_ALIAS
Expand Down
5 changes: 5 additions & 0 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5773,6 +5773,11 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
/// type of the function will be `async` as well.
bool hasAsync() const { return Bits.AbstractFunctionDecl.Async; }

/// Determine whether the given function is concurrent.
///
/// A function is concurrent if it has the @concurrent attribute.
bool isConcurrent() const;

/// Returns true if the function is a suitable 'async' context.
///
/// Functions that are an 'async' context can make calls to 'async' functions.
Expand Down
59 changes: 39 additions & 20 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -3727,26 +3727,30 @@ NOTE(silence_debug_description_in_interpolation_segment_call,none,
"use 'String(describing:)' to silence this warning", ())

NOTE(noescape_parameter,none,
"parameter %0 is implicitly non-escaping",
(Identifier))
"parameter %1 is implicitly %select{non-escaping|non-concurrent}0",
(unsigned, Identifier))
NOTE(generic_parameters_always_escaping,none,
"generic parameters are always considered '@escaping'", ())

ERROR(passing_noescape_to_escaping,none,
"passing non-escaping parameter %0 to function expecting an @escaping closure",
(Identifier))
ERROR(passing_noattrfunc_to_attrfunc,none,
"passing %select{non-escaping|non-concurrent}0 parameter %1 to function "
"expecting %select{an @escaping|a @concurrent}0 closure",
(unsigned, Identifier))
ERROR(converting_noespace_param_to_generic_type,none,
"converting non-escaping parameter %0 to generic parameter %1 may allow it to escape",
(Identifier, Type))
ERROR(assigning_noescape_to_escaping,none,
"assigning non-escaping parameter %0 to an @escaping closure",
(Identifier))
ERROR(general_noescape_to_escaping,none,
"using non-escaping parameter %0 in a context expecting an @escaping closure",
(Identifier))
ERROR(converting_noescape_to_type,none,
"converting non-escaping value to %0 may allow it to escape",
(Type))
ERROR(assigning_noattrfunc_to_attrfunc,none,
"assigning %select{non-escaping|non-concurrent}0 parameter %1 to "
"%select{an @escaping|a @concurrent}0 closure",
(unsigned, Identifier))
ERROR(general_noattrfunc_to_attr,none,
"using %select{non-escaping|non-concurrent}0 parameter %1 in a context "
"expecting %select{an @escaping|a @concurrent}0 closure",
(unsigned, Identifier))
ERROR(converting_noattrfunc_to_type,none,
"converting %select{non-escaping|non-concurrent function}0 value to %1 "
"may %select{allow it to escape|introduce data races}0",
(unsigned, Type))

ERROR(capture_across_type_decl,none,
"%0 declaration cannot close over value %1 defined in outer scope",
Expand Down Expand Up @@ -4252,14 +4256,29 @@ ERROR(global_actor_from_nonactor_context,none,
ERROR(actor_isolated_partial_apply,none,
"actor-isolated %0 %1 can not be partially applied",
(DescriptiveDeclKind, DeclName))
WARNING(concurrent_access_local,none,
"local %0 %1 is unsafe to reference in code that may execute "
"concurrently",
ERROR(concurrent_access_local,none,
"use of local %0 %1 in concurrently-executing code",
(DescriptiveDeclKind, DeclName))
ERROR(actor_isolated_concurrent_access,none,
"actor-isolated %0 %1 is unsafe to reference in code "
"that may execute concurrently",
ERROR(actor_isolated_from_concurrent_closure,none,
"actor-isolated %0 %1 cannot be referenced from a concurrent closure",
(DescriptiveDeclKind, DeclName))
ERROR(actor_isolated_from_concurrent_function,none,
"actor-isolated %0 %1 cannot be referenced from a concurrent function",
(DescriptiveDeclKind, DeclName))
ERROR(actor_isolated_from_async_let,none,
"actor-isolated %0 %1 cannot be referenced from 'async let' initializer",
(DescriptiveDeclKind, DeclName))
ERROR(actor_isolated_from_escaping_closure,none,
"actor-isolated %0 %1 cannot be referenced from an '@escaping' closure",
(DescriptiveDeclKind, DeclName))
ERROR(local_function_executed_concurrently,none,
"concurrently-executed %0 %1 must be marked as '@concurrent'",
(DescriptiveDeclKind, DeclName))
ERROR(concurrent_mutation_of_local_capture,none,
"mutation of captured %0 %1 in concurrently-executing code",
(DescriptiveDeclKind, DeclName))
NOTE(concurrent_access_here,none,
"access in concurrently-executed code here", ())
NOTE(actor_isolated_sync_func,none,
"calls to %0 %1 from outside of its actor context are "
"implicitly asynchronous",
Expand Down
Loading