forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 30
[pull] swiftwasm from main #4220
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This patch removes as much checked math as I was able to find from the unsafe buffer pointers types. In particular, I removed two kinds of checked math: 1. Checked math that was provably unable to trap due to prior operations done in the same function, or in a function that must have been called before the current one. For example, in index(_:offsetBy:limitedBy:), when we do the final index addition we have already validated that it must be in-bounds. Therefore, it cannot overflow. 2. Checked math that can only fail if the user is misusing the indices. As previously discussed with Karoy and Andrew, the unsafe raw buffer types are not obligated to crash if you misuse their indices, they are free to invoke undefined behaviour. In these cases, I added defensive overflow checks in debug mode. The result of this change should be reductions in code size in almost all usage sites of the raw buffer types.
If a requirement calls for a parameter's function type to be @sendable, Swift will now permit a witness that does *not* make that parameter @sendable. This is fine because @sendable does not affect the calling convention and the witness may not need to exploit the opportunity to send the closure anywhere. In other words, this code is now valid: ``` protocol P { func fn(_: @sendable () -> Void) } struct S: P { func fn(_: () -> Void) } ``` There's an edge case where this still isn't allowed when an associated type is @sendable.
If a method has an `async` variant, the non-`async` variant will now mark its completion handler parameter `@Sendable`. This shouldn't be a breaking change in Swift 5 code since these declarations are automatically `@_predatesConcurrency`. Also adds: • Support for `@_nonSendable` on parameters, which can be used to override this implicit `@Sendable` • Support for `@Sendable` on block typedefs; it's generally going to be a good idea to mark completion block typedefs `@Sendable`. Fixes rdar://85569247.
In 0325e29, the implementation of deinit barrier predicate was copied out of ShrinkBorrowScope into MemAccessUtils. Delete the source of that copy from ShrinkBorrowScope and just call the now common utility.
Control 'async' variant of imported ObjC methods. For non-'async' variant: 1) if 'swift_private' is specified, hide. For 'async' variant: 1) if 'swift_async(swift_private)' is specified, hide. 2) if 'swift_async(not_swift_private)' is specified, show. 3) if 'swift_async_name()' is specified, show. 4) if 'swift_private' is specified, hide. rdar://80602940
Replace the existing `-enable-experimental-clang-importer-diagnostics` flag with an opt-out version entitled `-disable-experimentalc-clang-importer-diagnostics`. Enable the beviour previously hidden behind the old flag by default.
…d cache. Extend the support for precomputed protocol conformances in the shared cache. When available, we'll query dyld for conformances in optimized images loaded outside the shared cache. This is a relatively small addition; where we previously checked the shared cache, we now check both. The order is conditionalized on `scanSectionsBackwards` to preserve that behavior. We also rename some identifiers to fit this more expansive use of preoptimized conformances. rdar://87425446
The problem is in `OptimizeHopToExecutor::collectActors`, which is causing `removeRedundantHopToExecutors` to drop the `hop_to_executor`. The issue is triggered by the order in which the Actors map is populated, and the reuse of a SILValue representing an executor. Suppose we have a function like this: ``` bb0: %7 = builtin "getCurrentExecutor"() : $Optional<Builtin.Executor> // ... cond_br %12, bb2, bb1 bb1: // ... hop_to_executor %7 : $Optional<Builtin.Executor> bb2: // ... hop_to_executor %7 : $Optional<Builtin.Executor> // ... hop_to_executor %28 : $MainActor ``` Since `collectActors` goes through each function's instructions top-down, and assigns to each unique SILValue an ID equal to the size of the Actors map prior to inserting the SILValue in the map, and we end up with the wrong actor IDs. This commit changes the ID numbering scheme to correct the issue.
As part of SE-327, global-actor isolation applied to the instance-stored properties of a value type do not require any isolation, since there is no way to create a race on access to that storage. https://github.com/apple/swift-evolution/blob/main/proposals/0327-actor-initializers.md#removing-redundant-isolation This change turns global-actor annotations on such properties into an error in Swift 6+, and a warning in Swift 5 and earlier. In addition, inference for global-actor isolation no longer applies global-actor isolation to such properties. Since this latter change only results in warnings in existing Swift 5 code, about a now superflous 'await', this change will happen in Swift 5+. Fixes rdar://87568381
LowerHopToActor expected either an optional executor or an actor, and would crash when given a non-optional executor. This patch adds the wrapping to produce an optional executor from a non-optional executor in the pass to avoid crashing.
Adding test to crash SIL optimizer while lowering hops to executors.
rdar://88403538
…esult over the GSB
…dyld [Runtime] Support precomputed protocol conformances outside the shared cache.
…he concurrency runtime. Most of the new inspection logic is in Remote Mirror. New code in swift-inspect calls the new Remote Mirror functions and formats the resulting information for display. Specific Remote Mirror changes: * Add a call to check if a given metadata is an actor. * Add calls to get information about actors and tasks. * Add a `readObj` call to MemoryReader that combines the read and the cast, greatly simplifying code chasing pointers in the remote process. * Add a generalized facility to the C shims that can allocate a temporary object that remains valid until at least the next call, which is used to return various temporary arrays from the new calls. Remove the existing `lastString` and `lastChunks` member variables in favor of this new facility. Swift-inspect changes: * Add a new dump-concurrency command. * Add a new `ConcurrencyDumper.swift` file with the implementation. The dumper needs to do some additional work with the results from Remote Mirror to build up the task tree and this keeps it all organized. * Extend `Inspector` to query the target's threads and fetch each thread's current task. Concurrency runtime changes: * Add `_swift_concurrency_debug` variables pointing to the various future adapters. Remote Mirror uses these to provide a better view of a tasks's resume pointer. rdar://85231338
…ent wtables in swift_getWitnessTable (swiftlang#41199)
Enable lazy ClangImporter diagnostics by default
Pulled out a simple check--that CanonicalizeOSSALifetime now uses to determine whether to continue hoisting a destroy_value instruction--into a predicate that can be used by LexicalDestroyFolding.
…ency [RemoteMirror][swift-inspect] Add a command to inspect the state of the concurrency runtime.
…arm64e-test [Reflection] Fix failing arm64e test
Fix misoptimization in OptimizeHopToExecutor
Lower non-optional executors
Remove as much checked math as possible from buffer pointers.
…ISABLED is present on the client side (swiftlang#41177)
rdar://88504525
[SourceKit] Disable a flaky test
In Swift 5 mode, I only warned about the global-actor attribute becoming unnecessary in the future, yet I was still returning None for the global-actor attribute checking request. This led to the attribute remaining unidentified, but also not removed. During module serialization, this problem was manifesting as emitting a typeless attribute, which when deserialized would trigger a segfault.
enums don't and will never have stored properties, so just be direct.
If a struct is a property-wrapper, then global-actor isolation still applies to the `wrappedValue`, even if it's a stored property. This is needed in order to support the propagation of global-actor isolation through the wrapper, even when the programmer has opted to use a stored property instead of a computed one for the `wrappedValue`. Since this propagation is a useful pattern, I think this exception is reasonable.
This patch delays the removal of redundant isolation for inferred global-actor isolation to Swift 6 too, since we only warn about it changing in Swift 5. Otherwise, only isolation that is a byproduct of inference no longer needs an await, which will probably confuse people. This change is with respect to SE-327, which argues that the non-static stored properties of ordinary structs do not need global-actor isolation.
The new utility folds patterns like TOP: // %borrowee is some owned value %lifetime = begin_borrow %borrowee BOTTOM: // %copy is some transitive copy of %borrowee apply %f(%copy) end_borrow %lifetime destroy_value %borrowee into TOP: %move = move_value [lexical] %borrowee %lifetime begin_borrow [lexical] %move BOTTOM: end_borrow %lifetime apply %f(%move) It is intended to be run after ShrinkBorrowScope moves the end_borrow up to just before a relevant apply and after CanonicalizeOSSALifetime moves destroy_value instructions up to just after their last guaranteed use, at which point these patterns will exist.
LexicalDestroyFolding allows us to elide the spurious retain/release that was being tested here. rdar://87255563
…e-block [ClangImporter] Make completion handlers Sendable
…602940 [CodeCompletion] Handle clang async attributes for visibilities
rdar://88510850
[Tests] Add `REQUIRES: asserts` for -swift-version 6 test
This was only passing before because -requirement-machine-protocol-signatures=verify only checked conformance requirements, and it would return the GSB's result if there was a mismatch. It actually never did the right thing with the Requirement Machine. Disable it until rdar://problem/88135912 is fixed.
Fixes rdar://problem/46313629.
…ols-for-stdlib Enable RequirementMachine for the standard library's protocol signatures
[cxx-interop] Re-enable some method tests.
…es/destroy_folding/add [CopyPropagation] Added lexical destroy folding.
MaxDesiatov
approved these changes
Feb 5, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot]
Can you help keep this open source service alive? 💖 Please sponsor : )