Skip to content
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

Merge main 2021-04-15 #2986

Merged
merged 99 commits into from Apr 15, 2021
Merged

Merge main 2021-04-15 #2986

merged 99 commits into from Apr 15, 2021

Conversation

kateinoigakukun
Copy link
Member

No description provided.

slavapestov and others added 30 commits April 8, 2021 21:26
…ch with a 'reasync' function

This fixes a performance regression with the reasync '&&', '||' and '??'
operators.

Also arguably it makes sense anyway since 'reasync' functions can in
fact be called from synchronous functions, so the solution should not
be considered worse.

We don't actually want to be able to overload a synchronous function
with a 'reasync' function anyway; the whole point of 'reasync' is to
avoid the need for such overloading.

Fixes rdar://problem/76254445.
One last usage of getOldType() remains here, but it's actually
meaningful since we want to handle InOutType there, so it will
take more work to eliminate.
…ilability-checking`.

This isn't an officially supported configuration, but is useful for testing and runtime development,
and we shouldn't crash.
The actual fix is to perform qualified lookup on a TypeExpr in `collectPossibleCalleesForApply`.

This changes the behaviour of some test cases in `complete_multiple_trailingclosure.swift`, which now provide argument labels. To make the choices suggested less verbose, I refined the parameter matching to only match trailing closures to parameters of function types.

In `INIT_FALLBACK_1` we technically shouldn't be suggesting `arg3` based on the matched argument types (the closure returns `Int` and the constructor with `arg3` requires the closure to return `String`), but AFAICT we aren't doing type-checking at this stage, so there's no way to rule it out.
…ken in case stmt

The last token in a case stmt can be a string literal token, which can *contain* its interpolation segments. If one of these interpolation segments is the reference point, we'd return false from `isReferencePointInRange` because the string literal token's start location is before the interpolation token. To fix this, adjust the range we are checking to range until the end of the string interpolation token.

Fixes rdar://76330416 [SR-14455]
Due to apple#36552, parsing the code completion token as a type inside a generic parameter list no longer fails. Instead, it consumes the code completion token as a type identifier. However, since `parseExprIdentifer` does not return a `ParserStatus`, the information whether a code completion token was consumed gets lost, causing `setCodeCompletionDelayedDeclState` to not be called and thus no code completion results show up.

To resolve this, make `parseExprIdentifier` return its `ParserStatus` through a `ParserResult`.

Fixes rdar://76335452 [SR-14432]
Otherwise, the runtime needs to be able to adjust the instance size when nonfragile ObjC bases
and/or resilient Swift bases are accounted for. rdar://54089488
Through various means, it is possible for a synchronous actor-isolated
function to escape to another concurrency domain and be called from
outside the actor. The problem existed previously, but has become far
easier to trigger now that `@escaping` closures and local functions
can be actor-isolated.

Introduce runtime detection of such data races, where a synchronous
actor-isolated function ends up being called from the wrong executor.
Do this by emitting an executor check in actor-isolated synchronous
functions, where we query the executor in thread-local storage and
ensure that it is what we expect. If it isn't, the runtime complains.
The runtime's complaints can be controlled with the environment
variable `SWIFT_UNEXPECTED_EXECUTOR_LOG_LEVEL`:

  0 - disable checking
  1 - warn when a data race is detected
  2 - error and abort when a data race is detected

At an implementation level, this introduces a new concurrency runtime
entry point `_checkExpectedExecutor` that checks the given executor
(on which the function should always have been called) against the
executor on which is called (which is in thread-local storage). There
is a special carve-out here for `@MainActor` code, where we check
against the OS's notion of "main thread" as well, so that `@MainActor`
code can be called via (e.g.) the Dispatch library's
`DispatchQueue.main.async`.

The new SIL instruction `extract_executor` performs the lowering of an
actor down to its executor, which is implicit in the `hop_to_executor`
instruction. Extend the LowerHopToExecutor pass to perform said
lowering.
… fix for placeholders

If left-hand side of a conversion that requires l-value is a placeholder type,
let's fix that by propagating placeholder to the order side (to allow it to
infer a placeholder if needed) without recording a fix since placeholder can
be converted to `inout` and/or l-value and already indicates existence of a
problem at some other spot in the expression.

Resolves: rdar://76250381
An actor's deinit can be invoked from any thread, and does not
(cannot!) synchronize to the actor. However, because "self" is
by definition unique and cannot escape, don't perform data race
checking in it or any local functions/closures within the initializer.

This is an imperfect approximation, because one could introduce a data
race by invoking a concurrent algorithm on "self" that does not
escape the closure but subverts @sendable checking and concurrently
accesses actor state. However, for the moment we accept this false
negative because the false positives from performing this checking are
much more prevalent.
Since 865e80f we are keeping track of internal closure labels in the closure’s type. With this change, wer are also serializing them to the swiftmodules.

Furthermore, this change adjusts the printing behaviour to print the parameter labels in the swiftinterfaces.

Resolves rdar://63633158
…ons."

... with a fix for a non-assert build crash: I used the wrong ilist type for SlabList. This does not explain the crash, though. What I think happened here is that llvm miscompiled and put the llvm_unreachable from the Slab's deleteNode function unconditionally into the SILModule destructor.
Now by using simple_ilist, there is no need for a deleteNode at all.
[Test] Disable tests that require new libswiftCore features for back deploy.
…-compat-hook

Compatibility50: Use __dso_handle for cheaper main executable check.
…ss-layout-fixed

IRGen: ObjC rodata can only go in __objc_const if layout is fixed.
…k_arm64_macos

This test currently fails on macos arm64
…cking-assertion-failure

SILGen: Don't crash when compiling `if #available` with `-disable-availability-checking`.
Reinstate "SIL: add a StackList data structure with zero cost operations."
…n-switch-case

[CodeComplete] Fix issue with completion in string literal as last token in case stmt
…sure-name

[Serialization] Serialize internal closure labels
LucianoPAlmeida and others added 25 commits April 14, 2021 09:09
[Sema] Adding a space in closure parameter destructuring fix in cases closure body is empty
Add missing `REQUIRES: concurrency`
…ync_task_yield

[windows][test] Unsupport async_task_yield in OS=windows-msvc
…y-tests-linux

[Test] Disable failing concurrency tests on Linux.
[Test] Disabled Interpreter/SDK/cf_without_foundation.swift on watchos.
…y some code.

We have for a long time talked about creating a scope like data structure for
use in the SILOptimizer. The discussion was whether or not to reuse the
infrastructure in SILGen that does this already. There were concerns about doing
so since the code in the SILOptimizer and SILGen can work differently.

With that in mind, I added a small AssertingScope class and built on top of that
a composition SIL level class called SILOptScope that one can use to add various
cleanups. One is able to both destructively pop at end of scope and pop along
early exits.

At an implementation level, I kept it simple and:

1. Represented a scope as a stack of Optional<Cleanup> which are just a wrapper
   around a std::function. The Optional is so that we can invalidate a cleanup.
2. Based all of these scopes around the idea that the user of the scope must
   invalidate the scope by hand. If not, the scope object will assert at the end
   of its RAII scope.
3. Rather than creating a whole class hierarchy, I just used std::function
   closures to keep things simple.
…nicalizeInstruction into OwnershipOptUtils.

This API is useful when writing compiler code that needs to handle ossa/non-ossa
as well as load_borrow/load while in OSSA. I am going to use this in
SILMem2Reg.
[Tests] NFC: Disable concurrency data race detection test on all plat…
Add location to the `sema_no_import_target` diagnostic
Per @xedin, it's fine to leave this test disabled here.
While ModuleDecl::lookupConformance() did the right thing here, we have
another entry point, TypeChecker::containsProtocol(), that also needs
to special-case Error.

Fixes https://bugs.swift.org/browse/SR-13734 / rdar://problem/70338670.
…entification-logic

[ConstraintSystem] NFC: Factor operator overload identification and partitioning.
…ype_checker_perf/fast/rdar26564101.swift
…5c892eb164aec334530

[ownership] Refactor out the composition type LoadOperation from CanonicalizeInstruction into OwnershipOptUtils.
…atype

Sema: Handle Error self-conformance in TypeChecker::containsProtocol()
…77bc7eef73664feef8a

[sil-mem2reg] Add a simple scope data structure and use it to simplify some code.
[ASTPrinter] Don't transform type if current type can't have members
@kateinoigakukun kateinoigakukun marked this pull request as ready for review April 15, 2021 10:24
@kateinoigakukun kateinoigakukun merged commit ec58843 into swiftwasm Apr 15, 2021
@kateinoigakukun kateinoigakukun deleted the katei/merge-main-2021-04-15 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.

None yet