Commit Graph

505 Commits

Author SHA1 Message Date
swift-ci
513183633e Merge remote-tracking branch 'origin/main' into rebranch 2022-01-14 16:53:12 -08:00
Holly Borla
992a871a73 [Type Reconstruction] Re-construct existential types with ExistentialType
by propagating whether the decoded type is for a requirement through
TypeDecoder.
2022-01-13 19:31:37 -08:00
swift-ci
3fb96c900e Merge remote-tracking branch 'origin/main' into rebranch 2022-01-09 07:13:54 -08:00
Konrad `ktoso` Malawski
9438cf6b2e [Distributed] Func metadata operations and implement executeDistributedTarget entry (#40605)
* [Distributed] Implement func metadata and executeDistributedTarget

dont expose new entrypoints

able to get all the way to calling _execute

* [Distributed] reimplement distributed get type info impls

* [Distributed] comment out distributed_actor_remoteCall for now

* [Distributed] disable test on linux for now
2022-01-09 23:55:06 +09:00
swift-ci
834e655ae3 Merge remote-tracking branch 'origin/main' into rebranch 2022-01-08 18:54:28 -08:00
Michael Gottesman
5dc8b3879b [move-function] SILCloner/mangling changes to support converting inout_aliasable defer parameters to out parameters after move analysis. 2022-01-08 13:41:05 -08:00
swift-ci
59e21f8a71 Merge remote-tracking branch 'origin/main' into rebranch 2022-01-07 16:00:06 -08:00
Doug Gregor
61d35f07a4 Merge pull request #40766 from DougGregor/mangle-multiple-opaque-types
Introduce a mangling for multiple opaque types within the declaration.
2022-01-07 15:45:38 -08:00
Doug Gregor
f89ff0485f Introduce a mangling for multiple opaque types within the declaration.
The `Qr` mangling is used to refer to the opaque type within the
declaration that produces the opaque type. When there are multiple
opaque types, e.g., due to structural or named opaque result types, it
does not specify which of the opaque type parameters it refers to.

Introduce a new mangling `QR INDEX` for opaque type parameters after
the first, retaining the `Qr` mangling for the first opaque type
parameter. This way, existing (non-structural) uses of opaque result
types retain the same manglings, but uses of structural or named
opaque result types (new features) will have distinct manglings.

Note that this mangling within a declaration is only used for the
declaration itself, and not for references to the opaque type of the
declaration, so there is no impact on the runtime demangler.
2022-01-07 10:43:45 -08:00
swift-ci
f63372b795 Merge remote-tracking branch 'origin/main' into rebranch 2022-01-06 01:13:44 -08:00
Pavel Yaskevich
d516281da9 [Distributed] NFC: Remove Method from accessor APIs
The API is not constrained to methods only, it should support
computed properties as well.
2021-12-23 14:10:05 -08:00
swift-ci
134e17c8ec Merge remote-tracking branch 'origin/main' into rebranch 2021-12-17 16:54:09 -08:00
Pavel Yaskevich
8e1aa19188 [Mangling] Define mangling for runtime accessible function records 2021-12-17 10:52:56 -08:00
Pavel Yaskevich
b8358b26fe [Mangling] Add mangling for distributed method accessors
`Distributed Method Accessor` is a global helper function
to get access to particular `distributed method` on an actor
from outside the process.
2021-12-17 10:52:55 -08:00
Ben Barham
a051a181b9 [rebranch] Include C++ std headers where required
These appear to be implicitly included somewhere by MacOS but not by
Linux. Add explicitly.
2021-12-01 15:45:06 +10:00
swift-ci
6efbfb5c26 Merge remote-tracking branch 'origin/main' into rebranch 2021-11-18 17:54:19 -08:00
Ben Barham
8e9999242f [rebranch] Add missing string include 2021-11-16 23:46:47 +10:00
Mike Ash
9fa76e2f4f [swift-inspect] Add a command to dump information about allocated arrays in the target process. 2021-11-04 16:15:15 -04:00
Zoe Carver
c209f52b9c Merge pull request #39911 from zoecarver/decouple-swift-shims
[cxx-interop][nfc] Remove internal header dependency on swift shims.
2021-10-25 21:56:21 -07:00
zoecarver
2546406de8 [cxx-interop][nfc] Remove internal header dependency on runtime/stdlib/shims.
The internal compiler headers should not include swift shim headers. Removing this dependency allows libSwift to import Swift compiler headers (otherwise, we get name conflics, because we import SwiftShims headers twice: from the source includes and build includes).
2021-10-25 14:56:45 -07:00
Alastair Houghton
e339feb2da [Runtime] Add format string attributes.
Added some attributes to mark functions as taking format strings.

rdar://84571859
2021-10-25 13:46:05 +01:00
Doug Gregor
142973b653 Use a non-conflicting mangling for distributed thunks.
Distributed thunks were using the same mangling as direct method
reference thunks (i.e., for "super" calls). Although not technically
conflicting so long as actors never gain inheritance, it's confusing
and could cause problems in the future. So, introduce a distinct
mangling for distributed thunks and plumb them through the demangling
and remangler.
2021-10-15 23:15:43 -07:00
Saleem Abdulrasool
1d46e09909 Demangling: degrade better with VS2017
`_Pragma` support was added to VS with VS2019 U6, version 16.6, toolset
14.26.  Add a conditional to avoid the use of `_Pragma` prior to that
version.
2021-10-12 13:06:58 -07:00
Alex Hoppen
6e07ee8f90 Fix a couple of build warning
Fixes a couple of compiler warnings that occur frequently when building the compiler:
- Copy the nullability annotation definitions from `Visibility.h` to `BridgedSwiftObject.h` and wrap all code that contains nullability annotations in `SWIFT_BEGIN_NULLABILITY_ANNOTATIONS` and `SWIFT_END_NULLABILITY_ANNOTATIONS` (supressing the warning `type nullability specifier '_Nullable' is a Clang extension [-Wnullability-extension]`)
- Suppress warnings about using `$` (mangling prefix) as an identifier using pragmas (supressing the warning `'$' in identifier [-Wdollar-in-identifier-extension]`)
- Change the macro condition of `SWIFT_NODISCARD` from `__cplusplus >= 201402l` (which checked for >= C++14) to `__cplusplus > 201402l`. This appears to have been a copy-paste error from `LLVM_NODISCARD` (supressing the warning `use of the 'nodiscard' attribute is a C++17 extension [-Wc++17-extensions]`)
2021-10-08 10:11:33 +02:00
Kuba Mracek
d0e05003f5 For individual runtime records for types/protocols/conformances, add and use new mangling suffixes 2021-09-29 13:14:58 -07:00
Alastair Houghton
8be084f30a Merge pull request #39187 from al45tair/problem/79725187
[Demangler] Improve remangler error handling
2021-09-27 17:03:49 +01:00
Doug Gregor
7f2117690c Skip standard substitutions for _Concurrency types when back-deploying.
When back-deploying concurrency support, do not use the standard
substitutions for _Concurrency-defined types (such as `Task`) in type
metadata because older Swift runtimes will not be able to demangle
them. Instead, use the full mangled names so the runtime can still
demangle them appropriately.

Addresses rdar://82931890.
2021-09-09 13:23:19 -07:00
Alastair Houghton
22f8e13c80 [Demangling] Include the necessary header for SWIFT_NODISCARD.
This became an issue because git clang-format reorganised the includes
in one of the other files.

rdar://79725187
2021-09-07 11:49:49 +01:00
Alastair Houghton
b8a879954a [Demangler] Tidy up a bit, and add line numbers to ManglingErrors.
Because DEMANGLER_ASSERT() might cause the remanglers to return a ManglingError
with the code ManglingError::AssertionFailed, it's useful to have a line number
in the ManglingError as well as the other information.  This is also potentially
helpful for other cases where the code is used multiple times in the remanglers.

rdar://79725187
2021-09-06 17:49:55 +01:00
Alastair Houghton
227b438963 [Demangling] Added DEMANGLER_ASSERT to replace assert() calls.
This returns an error code if we're in the runtime, rather than assert()ing.

rdar://79725187
2021-09-06 17:49:50 +01:00
Alastair Houghton
cc869b90b1 [Demangling] Remangling error handling for the OldRemangler.
First pass at adding error handling to the OldRemangler.  Still pondering
assert() calls.

rdar://79725187
2021-09-06 17:49:09 +01:00
Alastair Houghton
fbf082b6cb [Demangling] Make Demangle::getUnspecialized() return errors too.
This lets us completely remove the unreachable() function from Remangler.cpp.

rdar://79725187
2021-09-06 17:49:09 +01:00
Alastair Houghton
fc3322f9fc [Demangling] More remangler error handling.
First pass at adding error handling to the actual Remangler.  There are
still some assert() calls at this point that I'm thinking about.

rdar://79725187
2021-09-06 17:49:09 +01:00
Alastair Houghton
3f01f853a6 [Demangling] Add error handling to the remangler.
Mangling can fail, usually because the Node structure has been built
incorrectly or because something isn't supported with the old remangler.
We shouldn't just terminate the program when that happens, particularly
if it happens because someone has passed bad data to the demangler.

rdar://79725187
2021-09-06 17:49:09 +01:00
Argyrios Kyrtzidis
325d8b3c21 [Demangle.h] Remove the swift_demangle declaration from Demangle.h since it's not needed there
Also allows removing the "swift/Runtime/Config.h" include from that header.
2021-09-03 18:19:10 -07:00
Alastair Houghton
4b2e31654e [Demangler][Tests] Re-add getObjcClassByMangledName test.
This was reverted in ec3ccd72 because it broke the iOS simulator build.
2021-08-17 09:46:21 +01:00
Mishal Shah
34350e45cd Revert "[Demangler][Tests] Add an explicit test for getObjCClassByMangledName." 2021-08-16 14:00:39 -07:00
Alastair Houghton
8db56f09a3 [Demangler][Tests] Add an explicit test for getObjCClassByMangledName.
Added a special test for getObjCClassByMangledName; this needs testing
separately as it uses the DecodedMetadataBuilder, which doesn't get exercised
by the normal demangling tests.

Added all the test cases from rdar://63485806, rdar://63488139, rdar://63496478,
rdar://63410196 and rdar://68449341.  The test cases from rdar://63485806 are
disabled for now because the problem there is the error handling mechanism (or
lack thereof), rather than us not handling errors.

Fixes the remaining cases from

rdar://63488139
rdar://63496478
2021-08-04 16:21:32 +01:00
Alastair Houghton
8f717d2c50 [Demangler] Prevent stack overflow by limiting recursion depth.
It's trivially easy to drive the remanglers, the type decoder and the node
printer into a situation where they will overflow the process's stack.  For the
compiler, this is fine (though not great), but for the runtime it's a no-no.

This changeset imposes recursion depth limits to prevent uncontrolled stack
overruns.

rdar://68449341
2021-07-01 11:11:59 +01:00
Doug Gregor
58f49692ed Add mangling, metadata, and reflection support for "isolated" parameters.
Isolated parameters are part of function types. Encode them in function
type manglings and metadata, and ensure that they round-trip through
the various mangling and metadata facilities. This nails down the ABI
for isolated parameters.
2021-06-08 00:00:11 -07:00
Doug Gregor
b814e225dd Implement (de-)mangling and type metadata for global actor function types.
Implement name mangling, type metadata, runtime demangling, etc. for
global-actor qualified function types. Ensure that the manglings
round-trip through the various subsystems.

Implements rdar://78269642.
2021-06-02 23:34:22 -07:00
Doug Gregor
b57a73ab42 [Concurrency ABI] Add standard substitutions for _Concurrency types.
Introduce a second level of standard substitutions to the mangling,
all of the form `Sc<character>`, and use it to provide standard
substitutions for most of the _Concurrency types.

This is a precursor to rdar://78269642 and a good mangling-size
optimization in its own right.
2021-06-01 17:15:02 -07:00
Joe Groff
92f56e7ec8 Allow conversions from actor-bound sync function type to unbound async function type.
For `async` function types, an actor constraint can be enforced by the callee by hopping executors,
unlike with `sync` functions, so doesn't need to influence the outward type of the function.

rdar://76248452
2021-05-21 14:17:50 -07:00
Dave Lee
07686979db Demangling: Add option for printing simplified async resume functions 2021-04-20 16:15:11 -07:00
Richard Wei
fb66de6126 Unify mangling operators for async, @Sendable, @differentiable and @noDerivative.
Repurpose mangling operator `Y` as an umbrella operator that covers new attributes on function types. Free up operators `J`, `j`, and `k`.

```
async ::= 'Ya'                             // 'async' annotation on function types
sendable ::= 'Yb'                          // @Sendable on function types
throws ::= 'K'                             // 'throws' annotation on function types
differentiable ::= 'Yjf'                   // @differentiable(_forward) on function type
differentiable ::= 'Yjr'                   // @differentiable(reverse) on function type
differentiable ::= 'Yjd'                   // @differentiable on function type
differentiable ::= 'Yjl'                   // @differentiable(_linear) on function type
```

Resolves rdar://76299796.
2021-04-07 17:49:10 -07:00
Richard Wei
82886bf77a [AutoDiff] Fix mangling of '@noDerivative' in function types.
`@noDerivative` was not mangled in function types, and was resolved incorrectly when there's an ownership specifier. It is fixed by this patch with the following changes:

* Add `NoDerivative` demangle node represented by a `k` operator.
    ```
    list-type ::= type identifier? 'k'? 'z'? 'h'? 'n'? 'd'?  // type with optional label, '@noDerivative', inout convention, shared convention, owned convention, and variadic specifier
    ```
* Fix `NoDerivative`'s overflown offset in `ParameterTypeFlags` (`7` -> `6`).
* In type decoder and type resolver where attributed type nodes are processed, add support for nested attributed nodes, e.g. `inout @noDerivative T`.
* Add `TypeResolverContext::InoutFunctionInput` so that when we resolve an `inout @noDerivative T` parameter, the `@noDerivative T` checking logic won't get a `TypeResolverContext::None` set by the caller.

Resolves rdar://75916833.
2021-04-07 15:42:12 -07:00
Nate Chandler
3243def046 Revert "[IRGen] Mangling for async, non-constant partial_apply thunks."
This reverts commit efaaee3656.
2021-04-06 15:51:33 -07:00
Nate Chandler
19d9ebd761 Revert "[AST] De/mangling for functions with generic sigs."
This reverts commit dbe689a3f2.
2021-04-06 15:41:43 -07:00
Richard Wei
d997526948 Fix function differentiability kind metadata and mangling. (#36601)
* Move differentiability kinds from target function type metadata to trailing objects so that we don't exhaust all remaining bits of function type metadata.
  * Differentiability kind is now stored in a tail-allocated word when function type flags say it's differentiable, located immediately after the normal function type metadata's contents (with proper alignment in between).
  * Add new runtime function `swift_getFunctionTypeMetadataDifferentiable` which handles differentiable function types.
* Fix mangling of different differentiability kinds in function types. Mangle it like `ConcurrentFunctionType` so that we can drop special cases for escaping functions.
    ```
    function-signature ::= params-type params-type async? sendable? throws? differentiable? // results and parameters
    ...
    differentiable ::= 'jf'                    // @differentiable(_forward) on function type
    differentiable ::= 'jr'                    // @differentiable(reverse) on function type
    differentiable ::= 'jd'                    // @differentiable on function type
    differentiable ::= 'jl'                    // @differentiable(_linear) on function type
    ```

Resolves rdar://75240064.
2021-03-30 09:59:06 -07:00
Doug Gregor
52096a640e SE-0302: Rename ConcurrentValue/@concurrent to Sendable/@Sendable. 2021-03-18 23:48:21 -07:00