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

Merge main 2021-01-30 #2618

merged 57 commits into from
Jan 30, 2021

Conversation

kateinoigakukun
Copy link
Member

No description provided.

compnerd and others added 30 commits January 25, 2021 09:26
The CoreFoundation implementation on non-Darwin platforms included in
Foundation is not meant to be used as a general purpose CoreFoundation
implementation.  Since non-Darwin targets do not default to providing a
CoreFoundation implementation, we should generally assume that the
symbol is not present.  This changes the non-Darwin paths to always use
`dispatch_main` rather than `CFRunLoopRun`.
…Task.

Debugging tools can use _swift_concurrency_debug_asyncTaskMetadata to identify memory blocks as async task allocations by looking at their isa/metadata pointer.

rdar://72906895
Introduce `@concurrent` attribute on function types, including:
* Parsing as a type attribute
* (De-/re-/)mangling for concurrent function types
* Implicit conversion from @Concurrent to non-@Concurrent
- (De-)serialization for concurrent function types
- AST printing and dumping support
…functions.

@Concurrent functions are, of course, concurrent. Treat them that way.
    Used to just crash:

    > Assertion failed: (loc.isValid() && "Diagnosing attribute with invalid
    location"), function diagnoseAndRemoveAttr

    but now includes at least information what attribute caused the crash:

    > Attribute '@actorIndependent ' has invalid location, failed to
    diagnose!
    Assertion failed: (false && "Diagnosing attribute with invalid
    location"), function diagnoseAndRemoveAttr
This ensures that they enable concurrency-related checks.
We want to use the 'just built' compiler for the runtime tests because
of the recently added `swiftasync` parameter support.

But ASAN won't link if we use the 'just built' compiler because libgtest
and LLVMSupport are compiled by the host compiler.

Disable the runtime test when running under ASAN.

rdar://73664504
The last outstanding usage is in

    Concurrency/Runtime/checked_continuation.swift
…e async methods

Resilient witness tables and resilient class vtables are built from
descriptors. Make sure we reference the AsyncFunctionPointer of a
method implementation, and not the implementation itself, if the
method is async.

Part of rdar://problem/73625623.
[Test] Replaced temporary function with async main.
Make sure that we check the isolation of the context in which a reference
to `self` is made, rather than the context in which `self` is declared,
when checking whether we are within actor-isolated code. This ensures
that we report errors as actor-isolation errors rather than falling
back to the "may execute concurrently with" checking.
Concurrent functions need to be actor-independent because they wouldn't
ever be safe to run concurrently while isolated on an actor. This
allows us to elimate the "may execute concurrently with" check related
to actor isolation, which is a cleaner overall story.
This reverts commit fe928d5.

This causes an ASAN failure. Reverting until it can be debugged.
This was broken by commit cf1f240.
This commit reverts the 2 lines which broke the inclusion of header files in the generated Xcode project.
Concurrency: avoid `CFRunLoopRun` on non-Darwin
DougGregor and others added 26 commits January 29, 2021 09:53
The async handler code doesn't really run concurrently with where it is
launched, despite the implementation currently using `runDetached`
internally. Drop the @Concurrent and bitcase it back on when needed.
Add @Concurrent to SIL function types, mirroring what's available on
AST function types. @Concurrent function types will have by-value
capture semantics.
PointsToStartBit: was never set.
IsInTopLevel: was never checked (except for SIL printing)
My goal was to reduce the size of SILLocation. It now contains only of a storage union, which is basically a pointer and a bitfield containing the Kind, StorageKind and flags. By far, most locations are only single pointers to an AST node. For the few cases where more data needs to be stored, this data is allocated separately: with the SILModule's bump pointer allocator.

While working on this, I couldn't resist to do a major refactoring to simplify the code:

* removed unused stuff
* The term "DebugLoc" was used for 3 completely different things:
    - for `struct SILLocation::DebugLoc` -> renamed it to `FilePosition`
    - for `hasDebugLoc()`/`getDebugSourceLoc()` -> renamed it to `hasASTNodeForDebugging()`/`getSourceLocForDebugging()`
    - for `class SILDebugLocation` -> kept it as it is (though, `SILScopedLocation` would be a better name, IMO)
* made SILLocation more "functional", i.e. replaced some setters with corresponding constructors
* replaced the hand-written bitfield `KindData` with C bitfields
* updated and improved comments
No need to have a static get function - the constructor can be used directly.
NFC
Store the 1-byte kindAndFlags of SILLocation in the instruction's SILNode bitfield and only store SILLocation::storage in SILInstruction directly.
This reduces the space for the location from 2 to 1 word in SILInstruction.
Header files from within the lib directory were missing.
Also: use get_filename_component instead of regex matching.
No one has touched this pass in years and I am going to do a little work in it
to help with concurrency. So I am formatting the pass before I make further
changes.

All I did was I renamed CamelCase -> camelCase and git-clang-format the diff. I
used clangd to incrementally perform the renaming using some integration into my
editor.
SIL: shrink SILLocation and some refactoring
Replace the existing warning about any access to a local variable from
concurrently-executing code with a more tailored error:
concurrently-executing code may read a mutable varable, but cannot
modify it. This is safe so long as we either always do by-value
captures in concurrent closures or we ensure that no mutation of that
variable can occur after the point of capture.

We'll follow up with one of those. For now... be careful out there.

Since we're promoting this to an error, narrow it down to concurrent
closures and local functions, dropping the assumption that escaping
closures "may execute concurrently."
…unctions.

Concurrent closures and functions are, of course... concurrent. Treat
them as such for the warnings about unsafe accesses to global variables.
…n-types-sil

[SIL] Add `@concurrent` function types to SIL
…ispatch-thunks

Support async calling convention for resilient class and protocol method dispatch thunks
…metadata

[Concurrency] Add a debug variable pointing to the metadata for AsyncTask.
Diagnostics: improve error message at attr diagnosis failure
Copy link

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MaxDesiatov MaxDesiatov merged commit a02c617 into swiftwasm Jan 30, 2021
@kateinoigakukun kateinoigakukun deleted the katei/merge-main-2021-01-30 branch April 21, 2021 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.