Commit Graph

17733 Commits

Author SHA1 Message Date
Anton Korobeynikov
9b6730569c Update differential operators 2025-07-25 15:16:12 -07:00
Anton Korobeynikov
6a0e0d223e Initial support for differentiation of throwing functions 2025-07-23 14:00:56 -07:00
Stephen Canon
ee9b38ca22 Use an explicit unsigned comparison for span index checks (#83150)
LLVM ought to be able to do this transformation for us, but it currently fails to do so. We can code around it easily enough. https://github.com/swiftlang/swift/pull/83172 has a better long-term fix.
2025-07-21 16:06:17 -04:00
Michael Ilseman
bed6408712 Better docs for UTF8Span (#83184)
Co-authored-by: Alex Martini <amartini@apple.com>
2025-07-21 11:02:29 -06:00
Stephen Canon
337b20e8ed Remove some redundant unsafe markings (#83192)
We were getting warnings about these; remove them to cut down on noise.
2025-07-21 11:22:13 -04:00
Guillaume Lessard
b72c4422b8 Merge pull request #81637 from glessard/rdar147780495-OutputSpan-updates
[SE-0485] OutputSpan and OutputRawSpan
2025-07-17 14:14:52 -07:00
Evan Wilde
48fb7cd874 Merge pull request #83087 from etcwilde/ewilde/op-precedence
Fix warning in DispatchGlobalExecutor
2025-07-17 00:41:02 -07:00
Guillaume Lessard
31235db588 [stdlib] add OutputSpan to backdeployment library 2025-07-16 17:15:28 -07:00
Yuta Saito
af85e061dd Merge pull request #83086 from kateinoigakukun/yt/fix-isolated-conformance-static-link 2025-07-17 08:35:52 +09:00
Konrad `ktoso` Malawski
197530d264 Merge pull request #82943 from ktoso/wip-remove-task-startsynchronously-symbol 2025-07-17 06:48:40 +09:00
Yuta Saito
30e0fa5133 [Concurrency] Fix runtime isolated-conformance checks with static stdlib
Most of linkers pull object files from static archives only if any
symbol from that object file is referenced, even if the object contains
a ctor code. `Setup.cpp` didn't have any symbols referenced from
other code, so it was not linked in when the concurrency runtime was
linked in statically. This commit moves the ctor code to `Task.cpp`
to ensure that it is always linked in.
2025-07-16 06:28:04 +00:00
Evan Wilde
38c3ac1d22 Fix warning in DispatchGlobalExecutor
Fixing "warning: '&&' within '||'" -Wlogical-op-parentheses warning
2025-07-15 20:00:32 -07:00
Guillaume Lessard
2689ef31e1 Merge pull request #82959 from glessard/rdar155474776-extracting
[stdlib] Implementation for SE-0488
2025-07-15 13:59:00 -07:00
Valeriy Van
f85b2c5b97 Fix doc comment of DiscontiguousSlice.swift to make it match the code (#82220) 2025-07-15 13:16:49 -07:00
Mike Ash
67506f5045 Merge pull request #82818 from DmT021/wp/conformance-cache-by-descriptor
Protocol conformance cache for generic types
2025-07-15 11:52:49 -04:00
Guillaume Lessard
fa87b3b944 [stdlib] remove bulk-update from MutableRawSpan per SE-0485 2025-07-14 23:04:49 -07:00
Guillaume Lessard
923a6e5292 [stdlib] remove bulk-update from MutableSpan per SE-0485 2025-07-14 23:04:48 -07:00
Guillaume Lessard
97a0bd743a [stdlib] rename MutableRawSpan.extracting functions 2025-07-14 23:04:48 -07:00
Guillaume Lessard
6439a32997 [stdlib] rename MutableSpan.extracting functions 2025-07-14 23:04:48 -07:00
Guillaume Lessard
9e98783ec5 [stdlib] make OutputRawSpan changes from SE-0485 2025-07-14 23:04:48 -07:00
Guillaume Lessard
5f5e6b68c9 [stdlib] make OutputSpan changes from SE-0485 2025-07-14 23:04:47 -07:00
Guillaume Lessard
ada94db18c [stdlib] internal UnsafeRawBufferPointer tweaks 2025-07-14 23:04:47 -07:00
Guillaume Lessard
733a261b28 [stdlib] InlineArray consumed by OutputSpan 2025-07-14 23:04:46 -07:00
Guillaume Lessard
1d776a6b06 [stdlib] in-place initializer for InlineArray 2025-07-14 23:04:46 -07:00
Guillaume Lessard
4ed4f2e63c [stdlib] add OutputRawSpan 2025-07-14 23:04:45 -07:00
Guillaume Lessard
2fce25b53f [stdlib] add OutputSpan 2025-07-14 23:04:45 -07:00
Guillaume Lessard
a2ae072430 [stdlib] alignment-checking functions for pointers
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2025-07-14 23:04:45 -07:00
Saleem Abdulrasool
85228415a8 core: add some additional unsafe markers (#83016)
Mark the `CVAListPointer` construction as unsafe. This resolves some
warnings when building the standard library for Android.
2025-07-13 13:21:18 -05:00
Saleem Abdulrasool
ff114f8fdc Merge pull request #83005 from compnerd/detection
Runtimes: detect the existence of `dispatch_async_swift_job`
2025-07-11 17:07:03 -07:00
Augusto Noronha
d9d7db99dc Merge pull request #82995 from augusto2112/sort-addresses
[RemoteAddress] Handle comparison of addresses in different spaces
2025-07-11 15:34:38 -07:00
Saleem Abdulrasool
326f18d113 Runtimes: detect the existence of dispatch_async_swift_job
This function is used by the executor to help schedule the async job.
While not currently available on Windows on main, this allows correctly
handling the presence of the symbol for static linking.
2025-07-11 11:28:07 -07:00
Augusto Noronha
c97dfd6b05 [RemoteAddress] Handle comparison of addresses in different spaces
Sometimes it makes sense to compares addresses from different address
spaces.

rdar://148361743
2025-07-11 10:05:16 -07:00
Stephen Canon
d10b3f82fc Optimization pass over String and UTF8Span's allASCII helper (#82540)
This ranges between parity (for very small strings) and 5x faster (for
32-63B strings) in benchmarking on M1 MBP. For largeish strings it
delivers a roughly 2x speedup; further increase in blocksize nets a
small win in microbenchmarks that I do not expect would translate to
real world usage due to codesize impact and the fact that most strings
are smallish.

There's some opportunity for further work here; in particular, if people
start building Swift for a baseline of AVX2 or AVX512, we should have
paths for that (and we should also implement them if/when we get better
multiversioning dispatch machinery in the language). Span adoption would
be interesting. It's likely we should have a dedicated "small core"
implementation that uses only aligned accesses. Still, this is a
significant improvement as-is, and we should land it.


![allASCII](https://github.com/user-attachments/assets/ebbc45ba-5ba8-42dd-bf63-31ca77844fca)
2025-07-11 12:08:17 -04:00
Dmitrii Galimzianov
7989dbe24e Protocol conformance cache for generic types
This change adds a new type of cache (cache by type descriptor) to the protocol conformance lookup system. This optimization is beneficial for generic types, where the
same conformance can be reused across different instantiations of the generic type.

Key changes:
- Add a `GetOrInsertManyScope` class to `ConcurrentReadableHashMap` for performing
  multiple insertions under a single lock
- Add type descriptor-based caching for protocol conformances
- Add environment variables for controlling and debugging the conformance cache
- Add tests to verify the behavior of the conformance cache
- Fix for https://github.com/swiftlang/swift/issues/82889

The implementation is controlled by the `SWIFT_DEBUG_ENABLE_CACHE_PROTOCOL_CONFORMANCES_BY_TYPE_DESCRIPTOR`
environment variable, which is enabled by default.
2025-07-11 03:54:42 +02:00
Konrad `ktoso` Malawski
47db5ade76 [Concurrency] Align Task.isolated with proposal (add task executor) (#82913) 2025-07-11 08:42:19 +09:00
Saleem Abdulrasool
817922175d Merge pull request #82932 from compnerd/static-flags
utils: build static runtime with static dispatch and closure
2025-07-10 14:46:09 -07:00
Konrad 'ktoso' Malawski
5996da0c0c [Concurrency] Remove symbols of startSynchronously, make it AEIC
In preparation for removal. This spelling of Task.immediate was before
SE-review and was NOT accepted and therefore we should try to remove it
entirely.
2025-07-10 17:34:29 +09:00
Konrad 'ktoso' Malawski
664be9bd1e [Concurrency] Add missing Task.immediateDetached, which drops task locals 2025-07-10 14:57:44 +09:00
Konrad 'ktoso' Malawski
358c3e9dcf [Concurrency] a few missing overloads for immediate tasks 2025-07-10 12:40:41 +09:00
Guillaume Lessard
1e3d26f8a6 [stdlib] rename RawSpan.extracting functions 2025-07-09 17:36:35 -07:00
Guillaume Lessard
dd833569e0 [stdlib] rename Span.extracting functions 2025-07-09 17:25:27 -07:00
Augusto Noronha
58df5534d2 [NFC][RemoteInspection] Add an opaque AddressSpace field to RemoteAddress
Add an extra opaque field to AddressSpace, which can be used by clients
of RemoteInspection to distinguish between different address spaces.

LLDB employs an optimization where it reads memory from files instead of
the running process whenever it can to speed up memory reads (these can
be slow when debugging something over a network). To do this, it needs
to keep track whether an address originated from a process or a file. It
currently distinguishes addresses by setting an unused high bit on the
address, but because of pointer authentication this is not a reliable
solution. In order to keep this optimization working, this patch adds an
extra opaque AddressSpace field to RemoteAddress, which LLDB can use on
its own implementation of MemoryReader to distinguish between addresses.

This patch is NFC for the other RemoteInspection clients, as it adds
extra information to RemoteAddress, which is entirely optional and if
unused should not change the behavior of the library.

Although this patch is quite big the changes are largely mechanical,
replacing threading StoredPointer with RemoteAddress.

rdar://148361743
2025-07-09 14:52:42 -07:00
Saleem Abdulrasool
8b74c09b8f utils: build static runtime with static dispatch and closure
Although we would like these to be dynamic, we currently cannot build
them properly due to limitations of the build system. Adjust the build
to pass in additional flags to properly build the runtimes for that
environment as a temporary measure.
2025-07-09 14:41:59 -07:00
Guillaume Lessard
7e2697276a Merge pull request #82851 from glessard/rdar154331399-makeReallyContiguous
[stdlib] Make String.makeContiguousUTF8() strictly true
2025-07-09 08:11:30 -07:00
Pavel Yaskevich
72267bb1d4 Merge pull request #82892 from swiftlang/revert-82833-remove-startSynchronously
Revert "[Concurrency] Remove deprecated `Task.startSynchronously` API"
2025-07-09 00:19:08 -07:00
Alex Martini
74c3dbcd24 Revise doc comment for style & clarity
- Move the definition of 'structured concurrency' to the beginning of
  the section.
- Avoid future tense.  Fix some mixed future+present tense errors.
- Write bullet points as individual sentences, not as the clauses of one
  long sentence.
- Apple Style: Use 'since' only in the sense of 'after'.
- Apple Style: Use 'you' instead of 'one'.
- Apple Style: Close up 'non-' except when ambiguous.
- DevPubs style: Avoid bare 'this' for clarity.  Here, 'this guarantee'
  tells the reader what 'this' refers to.
- DevPubs style: Avoid 'may' which can be ambiguous between possibility
  and permission.
2025-07-08 14:31:29 -07:00
Guillaume Lessard
9341973700 [stdlib] update doc-comments 2025-07-08 14:29:21 -07:00
Pavel Yaskevich
8c4f7e97c8 Revert "[Concurrency] Remove deprecated Task.startSynchronously API" 2025-07-08 13:54:23 -07:00
Guillaume Lessard
77f34f4f29 [stdlib] update doc-comment and add a code comment 2025-07-08 13:20:11 -07:00
Guillaume Lessard
62115791c0 [stdlib] make makeContiguousUTF8 stricter 2025-07-08 13:20:11 -07:00