Commit Graph

21821 Commits

Author SHA1 Message Date
Alastair Houghton
d0b3d14c68 [Concurrency] Don't expose Dispatch or CF executors directly.
Also add `final` to the `CooperativeExecutor` declaration.
2025-08-26 09:38:13 +01:00
Alastair Houghton
250458f9f6 [Concurrency] Add a couple of comments.
Add some documentation comments to the Dispatch and CF executors,
and update the comments for the allocation and private data APIs.
2025-08-26 09:38:13 +01:00
Alastair Houghton
0fbd382e9c [Concurrency] Fix CooperativeExecutor to not loop forever.
If a job enqueues another job on the executor, we might never leave
the inner `while` loop in the `run()` method.  Fix this by taking
the contents of the run queue and only running those jobs in the
queue at the time we enter the inner loop.
2025-08-26 09:38:13 +01:00
Alastair Houghton
871a062002 [Concurrency] Remove canonicalization code.
I don't think we actually need this.  If you have a non-canonical
(i.e. derived) clock, you can just implement `enqueue` and/or `run`
and call those methods on the clock you're wrapping.
2025-08-26 09:38:13 +01:00
Alastair Houghton
7af5b8d8fd [Concurrency] Add implementations of run and enqueue for built-in clocks.
The built-in clocks should have implementations of `run` and `enqueue`,
to allow derived clocks to call those implementations.
2025-08-26 09:38:13 +01:00
Alastair Houghton
6046286b58 [Concurrency] Updates after second SE pitch.
We no longer attempt to convert timestamps from the passed-in `Clock`
in order to allow any clock to work with any executor.  Instead,
executors that do not recognise a clock should call the `enqueue`
function on that `Clock`, which lets the `Clock` itself decide how
to proceed.

Additionally, rename `SchedulableExecutor` to `SchedulingExecutor`.
2025-08-26 09:38:11 +01:00
David Smith
0038b92e2b Speed up -isEqual:/isEqualToString: (#83894)
Fixes rdar://159058877
2025-08-25 18:03:54 -07:00
Eric Miotto
732a216c7e CMake: readd StringProcessing dependency to StdlibUnittest
This reverts commit 4a95275bde.

I remove the dependency looking at the modules that StdlibUnittest
directly imports -- but it turns out we import StringProcessing
indirectly as a result of importing Foundation from e.g. the underlying
Apple SDKs.

Addresses rdar://158797152
2025-08-20 13:52:17 -07:00
Arnold Schwaighofer
0b5233fa63 stdlib: Mark UnsafeRawBufferPointer's withContiguousStorageIfAvailable as @inline(__always)
The body seems to only reinterpret pointer types (`withMemoryRebound`).
Inlining it should not lead to code size gains and has shown to reduce code size.
2025-08-20 09:19:56 -07:00
Jaap Wijnen
a5ef5fe226 Improve differentiableMap vjp performance (#83807)
Improve differentiableMap vjp performance by reserving capacity for the values and pullbacks arrays.
2025-08-19 17:08:14 -07:00
Max Desiatov
900c7c9d7b Platform/CMake: use arch instead of arch_subdir
This fixes wasi-libc.modulemap not found after installation
2025-08-19 11:25:14 +01:00
Max Desiatov
e227e50704 Platform/CMake: remove unused message func, mod var 2025-08-18 20:42:45 +01:00
Max Desiatov
4299bca9d6 Platform/CMake: add embedded-stdlib-${mod} dependency 2025-08-18 20:28:59 +01:00
Max Desiatov
6582ad92bc Embedded Wasm: enable import WASILibc
WASILibc wasn't built for the embedded stdlib in `stdlib/public/Platform/CMakeLists.txt`. New `copy_wasilibc_modulemap_embedded_resource` and `embedded-stdlib-platform-${triple}` targets are added, the latter for `wasm32-unknown-wasip1` only for now. Also added a `wasilibc_functions.swift` test to verify the result.

Resolves https://github.com/swiftlang/swift/issues/83513

rdar://157467412
2025-08-18 18:41:10 +01:00
Eric Miotto
3fc59c439f Merge pull request #83730 from edymtt/edymtt/fix-deployment-target-versions-for-more-private-libraries
CMake: allow more private libraries to be used on older OSes
2025-08-18 06:46:02 -07:00
Anthony Latsis
a482f37944 Merge pull request #83650 from muukii/patch-1
Fix typo in Observations.swift
2025-08-16 13:23:58 +01:00
Guillaume Lessard
c9a3fdf722 Merge pull request #83771 from glessard/rdar158440246 2025-08-16 02:40:16 -07:00
Guillaume Lessard
476491392b [stdlib] guard against underflow 2025-08-15 17:24:06 -07:00
Dmitrii Galimzianov
4509b22415 Revert "Protocol conformance cache for generic types"
This reverts commit 7989dbe24e merged in https://github.com/swiftlang/swift/pull/82818
2025-08-16 01:39:16 +02:00
Egor Zhdan
0f963d7819 Merge pull request #83727 from egorzhdan/egorzhdan/std-string-ctor
[cxx-interop] Simplify `std::string` construction in the overlay
2025-08-15 10:47:01 +01:00
Konrad `ktoso` Malawski
5857afebd8 Merge pull request #83726 from edymtt/edymtt/use-darwin-os-lock-in-distributed 2025-08-15 09:23:39 +09:00
Eric Miotto
2c5fdec56a Merge pull request #83725 from edymtt/edymtt/use-darwin-os-lock-in-observation
Observation: do not import all of Darwin to implement locking facilities
2025-08-14 17:00:31 -07:00
Guillaume Lessard
709156b215 Merge pull request #83686 from glessard/legacy-abi-rethrows
[stdlib] apply the legacy ABI pattern to 3 functions
2025-08-14 15:53:17 -07:00
Eric Miotto
1a8cca247d CMake: allow more private libraries to be used on older OSes
I missed a few when tackling #83602

Take the chance to ensure swiftStdlibUnittestFoundationExtras builds
zippered.

Addresses rdar://158264124
2025-08-14 10:52:15 -07:00
Egor Zhdan
7dc8873266 [cxx-interop] Simplify std::string construction in the overlay
libc++ provides a 2-parameter constructor of `std::string`, so we can apply the logic under `#if os(Windows)` on Apple platforms too.

This avoids deserialization issues when building some complex projects that are still under investigation.

rdar://145939013
2025-08-14 17:45:19 +01:00
Eric Miotto
eab65319f9 Distributed: do not import all of Darwin to implement locking facilities
At the same time, drop that dependency in the new build system, so that
we don't add an additional linkage for Darwin platforms compared to what
we are doing in the current build system.

Addresses rdar://158314427
2025-08-14 08:51:36 -07:00
Eric Miotto
4da993f368 Observation: do not import all of Darwin to implement locking facilities
At the same time, drop that dependency in the new build system, so that
we don't add an additional linkage for Darwin platforms compared to what
we are doing in the current build system.

Addresses rdar://158313871
2025-08-14 08:35:06 -07:00
Saleem Abdulrasool
4a54598bbb Merge pull request #83699 from compnerd/include
build: adjust the system include directory flag for Windows
2025-08-14 08:12:56 -07:00
Gábor Horváth
8558931bd0 Merge pull request #83638 from Xazax-hun/swift-span-for-cxx-string 2025-08-14 07:42:57 +01:00
Anthony Latsis
8b27282324 Merge pull request #83675 from swiftlang/jepa-rebranch2
runtime: Silence a `-Wglobal-constructors` error than appears with upstream clang on Windows
2025-08-14 00:04:21 +01:00
Saleem Abdulrasool
162df1d5f4 Merge pull request #83643 from compnerd/mirror-warnings
SwiftRemoteMirror: adjust for Windows
2025-08-13 13:34:12 -07:00
Saleem Abdulrasool
cf2993ca94 build: adjust the system include directory flag for Windows
This adjusts the flag to be `clang-cl` compatible rather than `clang`
compatible on Windows. `-Isystem` would cause the include search path to
be ignored, whereas `-imsvc` allows us to honour the path. This is
important when using the external dispatch.
2025-08-13 13:00:16 -07:00
Gabor Horvath
2bd8684868 [cxx-interop] Add span accessors to std.string variants
rdar://146944876
2025-08-13 15:49:39 +01:00
Anthony Latsis
311ff73a7f runtime: Silence a -Wglobal-constructors error than appears with upstream clang on Windows
Landing this on main to minimize rebranch-specific changes.
2025-08-13 00:32:23 +01:00
Guillaume Lessard
d1f7140357 [stdlib] apply the legacy ABI pattern to 3 functions 2025-08-12 16:15:13 -07:00
Erik Eckstein
e28125b106 stdlib: specialize OptionSet.insert for FixedWidthInteger raw-values
This lets the generated code boil down to a single or-instruction.

rdar://157958188
2025-08-12 08:05:49 +02:00
Hiroshi Kimura
db7717f411 Update Observations.swift 2025-08-12 06:15:56 +09:00
Karoy Lorentey
14b9b80746 Merge pull request #83314 from lorentey/pushing-word-boundaries
[stdlib] Fix implementation of Unicode text segmentation for word boundaries
2025-08-11 11:28:39 -07:00
Saleem Abdulrasool
d5412665e0 SwiftRemoteMirror: adjust for Windows
This cleans up the warnings when building on Windows. It is cleaning up
the warnings related to deprecated POSIX APIs.
2025-08-11 09:50:23 -07:00
Eric Miotto
9d7d3a15cb Merge pull request #83602 from edymtt/edymtt/ensure-private-libraries-can-run-on-older-oses
CMake: allow private libraries to be used on older OSes
2025-08-11 06:37:48 -07:00
Alex Martini
4b292b30f2 Merge pull request #83049 from amartini51/object_id_149961845
Update docs for ObjectIdentifier to mention actors

Fixes: rdar://149961845
2025-08-08 11:54:29 -07:00
Gábor Horváth
35b5c817b2 Merge pull request #83520 from Xazax-hun/check-safety-function-types 2025-08-08 06:39:39 +01:00
Eric Miotto
332fe6a475 CMake: allow private libraries to be used on older OSes
To do so, use the deployment target versions used for tests.

Addresses rdar://157622116
2025-08-07 15:12:47 -07:00
Eric Miotto
4a95275bde CMake: do not link StringProcessing into StdlibUnittest
Since #64187 we are not importing automatically StringProcessing when
building the stdlib -- this is especially important for StdlibUnittest,
since it needs to run on older OSes.

Addresses rdar://157622116
2025-08-07 15:06:52 -07:00
Saleem Abdulrasool
21d8afdc41 Merge pull request #83553 from compnerd/nodiscard
Runtimes: resync from branch (NFCI)
2025-08-07 10:59:59 -07:00
Karoy Lorentey
3e18a07187 [stdlib] Fix implementation of Unicode text segmentation for word boundaries
Carefully overhaul our word breaking implementation to follow the recommendations of Unicode Annex #29. Start exposing the core primitives (as well as `String`-level interfaces), so that folks can prototype proper API for these concepts.

- Fix `_wordIndex(after:)` to always advance forward. It now requires its input index to be on a word boundary. Remove the `@_spi` attribute, exposing it as a (hidden, but) public entry point.
- The old SPIs `_wordIndex(before:)` and `_nearestWordIndex(atOrBelow:)` were irredemably broken; follow the Unicode recommendation for implementing random-access text segmentation and replace them both with a new public `_wordIndex(somewhereAtOrBefore:)` entry pont.
- Expose handcrafted low-level state machines for detecting word boundaries (_WordRecognizer`, `_RandomAccessWordRecognizer`), following the design of `_CharacterRecognizer`.
- Add tests to reliably validate that the two state machine flavors always produce consistent results.

rdar://155482680
2025-08-05 20:04:46 -07:00
Saleem Abdulrasool
e637ccd708 Runtimes: resync from branch (NFCI)
This restores the `LLVM_NODISCARD` macro from the branch point
(retaining the header inclusion changes). This is required to build
SwiftRemoteMirror without injecting another LLVM build.
2025-08-05 16:31:07 -07:00
fahadnayyar
9a01358132 [C++ Interop] Deprecate Optional argument overloads of std.string initializer in Swift’s C++ Stdlib Overlay (#83223)
This patch addresses potential ambiguity and unsafe behavior by
deprecating initializer overloads for `std.string` that accept optional
arguments (`string?`). These overloads previously allowed implicit
initialization from optional pointers (`UnsafePointer<CChar>?`), causing
unclear or unintended behavior.

- Deprecated: `init(_ string: UnsafePointer<CChar>?)`, guiding users
toward the explicit, non-optional initializer.
- Unavailable: `init(_ string: String?)`, explicitly preventing misuse
from optional Swift strings.

rdar://148041893
2025-08-05 15:22:02 -07:00
Adrian Prantl
52fa6a1ceb Merge pull request #82389 from adrian-prantl/153934495
Implement reflection support for Symbolic Extended Existential types.
2025-08-05 09:42:19 -07:00
Gabor Horvath
402ad33463 [StrictMemorySafety] Check the safety of return types of calls
Previously, we skipped checking the return type of a function for safety
as we expected to warn at the use of the returned value:

  let x = returnsUnsafe()
  usesUnsafe(x) // warn here

Unfortunately, this resulted in missing some unsafe constructs that can
introduce memory safety issues when the use of the return value had a
different shape resulting in false negatives for cases like:

  return returnsUnsafe()

or

  usesUnsafe(returnsUnsafe())

This PR changes the analysis to always take return types of function
calls into account.

rdar://157237301
2025-08-05 12:16:44 +01:00