Commit Graph

64 Commits

Author SHA1 Message Date
Andrew Trick
64a48d08e1 Update tests for strict @lifetime type checking 2025-03-19 11:59:04 -07:00
Jonathan Grynspan
9489564e07 Just like #76041, but for ~Escapable instead of ~Copyable.
Resolves rdar://145945680.
2025-03-03 14:06:30 -05:00
Mike Ash
9ae3f881a8 [Test] Fix assertion failure building demangleToMetadata.swift.
The direct call to _getTypeByMangledName made the compiler angry when doing an optimizd simulator build. Instead, use _typeByName with a string that has an embedded NUL to achieve the same effect.

rdar://139264622
2024-11-06 20:49:38 -05:00
Mike Ash
4a5dc2a6a9 [Demangler] Accept overly short type names if they are NUL terminated
swift_getTypeByMangledNameInContext takes a pointer and a length, but some programs pass a pointer to a NUL-terminated C string and an excessive length, implicitly relying on the terminator to end the string early. This worked previously, but commit 7fe2befd31 made the demangler more strict about bad data. This changes the demangler to successfully parse a name by terminating the name string at a 0 byte encountered where it expects to find an operator. All other cases of bad data continue to be rejected.

rdar://137430048
2024-11-04 11:21:54 -05:00
Allan Shortlidge
cb578172ea Tests: Remove -disable-availability-checking in more tests that use concurrency.
Use the `%target-swift-5.1-abi-triple` substitution to compile the tests for
deployment to the minimum OS versions required for use of _Concurrency APIs,
instead of disabling availability checking.
2024-10-19 12:35:20 -07:00
Jonathan Grynspan
db7a030a71 Extend internal _mangledTypeName() function to take non-copyable types. (#76041)
`_mangledTypeName()` returns the Swift-mangled typename of a given type. This PR extends it to take non-copyable types as well.

Related to our use case in Swift Testing, but not to the PR directly: #69146 #69147 #71112

Resolves rdar://134278607.
2024-09-11 16:11:58 -04:00
Erik Eckstein
7fe2befd31 Demangler: handle errors in demangleType
Makes sure that invalid runtime type strings result in errors and not fail silently.
In worst case this could lead to wrong reconstructed metatypes which can result in all kind of memory corruption.

relates to rdar://129861211
2024-07-05 11:37:15 +02:00
Mishal Shah
af112c1591 Update the Swift version to 6.0 from 5.11 2024-02-19 17:47:16 -08:00
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Doug Gregor
b9c5aca15f Enable SE-0413 "Typed Throws" by default 2024-01-02 15:34:07 -08:00
Alejandro Alonso
8ac7f0b10f Merge pull request #69138 from Azoy/generics-are-hard
[Runtime] Refactor _gatherWrittenGenericParameters
2023-11-06 19:27:54 -08:00
Alejandro Alonso
d73c812a2d Simplify _gatherWrittenGenericParameters 2023-11-06 12:51:06 -08:00
Doug Gregor
1b42ca3673 Handle any Error and Never thrown error types during runtime uniquing.
When forming runtime metadata for a function type that has either `any
Error` or `Never` as the specified thrown error type, drop the thrown
error type and normalize down to (untyped) `throws` or non-throwing,
as appropriate.
2023-10-29 19:29:09 -07:00
Doug Gregor
40e07cf900 [Typed throws] IR generation and runtime support for function type metadata
Extend function type metadata with an entry for the thrown error type,
so that thrown error types are represented at runtime as well. Note
that this required the introduction of "extended" function type
flags into function type metadata, because we would have used the last
bit. Do so, and define one extended flag bit as representing typed
throws.

Add `swift_getExtendedFunctionTypeMetadata` to the runtime to build
function types that have the extended flags and a thrown error type.
Teach IR generation to call this function to form the metadata, when
appropriate.

Introduce all of the runtime mangling/demangling support needed for
thrown error types.
2023-10-29 09:12:32 -07:00
Konrad `ktoso` Malawski
41f99fc2ae [Executors][Distributed] custom executors for distributed actor (#64237)
* [Executors][Distributed] custom executors for distributed actor

* harden ordering guarantees of synthesised fields

* the issue was that a non-default actor must implement the is remote check differently

* NonDefaultDistributedActor to complete support and remote flag handling

* invoke nonDefaultDistributedActorInitialize when necessary in SILGen

* refactor inline assertion into method

* cleanup

* [Executors][Distributed] Update module version for NonDefaultDistributedActor

* Minor docs cleanup

* we solved those fixme's

* add mangling test for non-def-dist-actor
2023-03-15 23:42:55 +09:00
Josh Soref
a01f6f8724 spelling: satisfied
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-05-01 04:32:22 -04:00
Karoy Lorentey
e2cfab4f28 [stdlib][test] Adopt availability macros in tests 2021-10-31 15:00:58 -07:00
Karoy Lorentey
47956908b7 [Concurrency] SwiftStdlib 5.5 ⟹ SwiftStdlib 5.1 (usages)
The concurrency runtime now deploys back to macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, which corresponds to the 5.1 release of the stdlib.

Adjust macro usages accordingly.
2021-10-28 14:36:36 -07:00
Doug Gregor
1e2012d816 Disable availability checking in tests that use concurrency 2021-07-20 12:46:26 -07: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
ff24437b3b [IRGen] Emit calls to swift_getFunctionTypeMetadataGlobalActor as appropriate 2021-06-03 11:59:49 -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
685983b219 Test runtime demangling of Concurrency standard substitutions 2021-06-01 17:20:59 -07:00
Arnold Schwaighofer
0e2f63a12c Disable some tests that will fail on back deployment library configurations
rdar://76567524
rdar://76567105
2021-04-13 07:48:03 -07:00
Doug Gregor
eb6e74a0a6 Handle demangling/remangling for concurrency-related builtin types.
Fixes rdar://75990281.
2021-04-08 23:49:37 -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
Doug Gregor
52096a640e SE-0302: Rename ConcurrentValue/@concurrent to Sendable/@Sendable. 2021-03-18 23:48:21 -07:00
Doug Gregor
ba8819eb58 [Concurrent] Introduce concurrent function types.
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
2021-01-27 14:22:32 -08:00
John McCall
a8464dcaf1 Implicitly import _Concurrency under -enable-experimental-concurrency 2020-10-22 00:53:15 -04:00
Rintaro Ishizaki
4e003dc8cc [Tests] Mark two test cases 'UNSUPPORTED: use_os_stdlib'
test/Runtime/demangleToMetadata.swift
test/stdlib/Casts.swift

rdar://problem/66394834
rdar://problem/66394791
2020-07-31 16:02:49 -07:00
Doug Gregor
06d322b211 [Concurrency] Rename -enable-experimental-async.
Use the more general name `-enable-experimental-concurrency` instead,
since async is one part of the model.
2020-07-28 09:38:54 -07:00
Doug Gregor
f6e9f352f0 [Concurrency] Add async to the Swift type system.
Add `async` to the type system. `async` can be written as part of a
function type or function declaration, following the parameter list, e.g.,

  func doSomeWork() async { ... }

`async` functions are distinct from non-`async` functions and there
are no conversions amongst them. At present, `async` functions do not
*do* anything, but this commit fully supports them as a distinct kind
of function throughout:

* Parsing of `async`
* AST representation of `async` in declarations and types
* Syntactic type representation of `async`
* (De-/re-)mangling of function types involving 'async'
* Runtime type representation and reconstruction of function types
involving `async`.
* Dynamic casting restrictions for `async` function types
* (De-)serialization of `async` function types
* Disabling overriding, witness matching, and conversions with
differing `async`
2020-07-27 18:18:03 -07:00
Mishal Shah
272c466e47 Update master to build with Xcode 12 beta 2020-06-22 15:43:20 -07:00
Konrad `ktoso` Malawski
5faf82c553 Improve usability of _mangledTypeName with Any.Type arguments 2020-04-05 12:27:50 +09:00
Konrad `ktoso` Malawski
33444489e5 Add _mangledTypeName to allow round trips T->mangledName->T 2020-03-10 12:20:08 +09:00
fischertony
f14604e225 Demangle: Test demangling of nested types with contextual where clauses 2020-03-05 07:29:28 +03:00
Doug Gregor
a53b2e285c [Standard library] Drop _typeByMangledName().
This underscored function was only intended for testing; drop it from the
ABI. We’re keeping _typeByName because it’s used by Foundation.
2018-11-15 11:06:52 -08:00
Doug Gregor
e87dea480c [IRGen] Make (most) builtin type metadata round-trippable.
Rather than mapping all of the builtin floating-point and vector
types down to the type metadata symbols for power-of-two integers,
map down to the type metadata symbols provided by the runtime.
This allows us to round-trip type metadata <-> mangled name for all of
the builtin types that have such symbols. When we don’t have a runtime
symbol, we will fail to link if that builtin type gets referenced.
2018-10-26 16:09:21 -07:00
Doug Gregor
65d5d15fc1 [Runtime] Extend known builtin metadata for floating point and vector types.
Expose symbols for metadata for the various builtin floating point types
and vector types. This is used by the demangler to handle builtin names.

This is a narrow fix for rdar://problem/45569984 (where we couldn’t
demangle a builtin vector type). A more extensive fix will require us
to add a general runtime facility for creating opaque type metadata
with specific size/alignment/stride/uniquing name.
2018-10-26 16:05:31 -07:00
Doug Gregor
7d88a7d335 [Runtime] Demangle @autoclosure function types to metadata.
@autoclosure is currently represented in mangled names, but the
demangle-to-metadata path did not handle it. Add basic support for it
so we can round-trip.
2018-10-18 21:53:48 -07:00
Doug Gregor
cf2a47e14c [Runtime] Handle non-key generic parameters when demangling to metadata.
When forming metadata for a nested generic type, gather all of the
generic arguments from the parent type “as written”, so that we can directly
map generic parameters to those generic arguments when they occur within
requirements. This allows us to demangle nested types within extensions
that have same-type constraints on generic parameters into type metadata.

Fixes rdar://problem/37170296.
2018-09-26 14:41:04 -07:00
Arnold Schwaighofer
db0597ec68 Codesign test/Runtime 2018-08-13 07:45:16 -07:00
Joe Groff
0d438c91c4 [Demangle to metadata] Support simple extension contexts.
Support demangling for types nested within some simple extension contexts.
Still does not support nested types within constrained extensions that
involve same-type constraints among generic parameters, nor
deeply-nested types in extensions. However, it fixes
rdar://problem/40071688.
2018-05-10 23:36:01 -07:00
Huon Wilson
e7002b6413 [AST] ParenType needs enough bits to store ValueOwnership::Owned.
The truncation here meant func foo(_: __owned X) {} was the same as
foo(_: X), so @guaranteed when that's the default.

Fixes rdar://problem/38390524.
2018-03-13 10:18:40 +11:00
Doug Gregor
90afecfda8 [Runtime] Dynamically evaluate superclass constraints. 2018-02-01 17:35:47 -08:00
Doug Gregor
9445839208 [Runtime] Evaluate layout constraints at runtime. 2018-02-01 17:20:44 -08:00
Doug Gregor
5c59e81480 [Runtime] Evaluate same-type requirements at runtime.
Extend the runtime's ability for evaluating generic requirements to
handle same-type requirements, demangling/substituting the name from
the generic requirement metadata.
2018-02-01 17:00:51 -08:00
Doug Gregor
f8c769c4ae [Demangle-to-type] Handle type arguments and requirements for nested generics.
Extend the support for mangled-name-to-type-metadata's handling of generic
types to handle nested types, including gathering type arguments from
parent contents and checking generic requirements.
2018-02-01 14:45:13 -08:00
Pavel Yaskevich
86916cf4d8 [Mangled name -> metadata] Add built-in types support 2018-01-24 00:29:24 -08:00
Doug Gregor
59c98e6ecf [Mangled name -> type metadata] Support arbitrary # of generic args.
Now that we have a suitable calling convention for the access function
of a generic nominal type descriptor with > 3 arguments, add support
for calling with an arbitrary number of generic arguments.
2018-01-13 22:34:51 -08:00