Commit Graph

17868 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
David Smith
051d0b68aa Override -_fastUTF8StringContents:utf8Length: to give bridged Strings O(1) access to their UTF8 contents (#83499)
Fixes rdar://157337605
2025-08-04 12:41:51 -07:00
Adrian Prantl
eabcf41a54 Implement reflection support for Symbolic Extended Existential types.
This patch adds a new SymbolicExtendedExistentialTypeRef kind, and
wires it up in TypeDecoder, TypeRefBuilder, TypeLowering, and
ASTDemangler.

This is tested indirectly via the matching LLDB commit.
2025-08-04 08:36:37 -07:00
Alastair Houghton
94058e5e68 [Concurrency] Fix availability problem with UnownedTaskExecutor.
a550080 added a call to the new initializer, but that call
came from a function annotated with `StdlibDeploymentTarget 6.2`,
rather than `SwiftStdlib 6.2`, while the initializer was set to
`SwiftStdlib 6.2`.  This will fail in some build configurations
(specifically where the target being built for is older than that
implied by `SwiftStdlib 6.2`).

rdar://157217460
2025-08-04 14:30:20 +01:00
eeckstein
8335ce577f Merge pull request #83474 from eeckstein/fix-address-of-property-feature
rename the feature AddressOfProperty to AddressOfProperty2
2025-08-01 17:38:19 +02:00
Ben Rimmington
b57b8368ac [stdlib] Update UTF8Span documentation (#83418)
Amend formatting of `Substring.utf8Span` example code.
Use DocC tables in `Unicode.UTF8.ValidationError` overview.

---------

Co-authored-by: Alex Martini <amartini@apple.com>
2025-08-01 06:56:19 -07:00
Max Desiatov
d63bbb9d0c Merge pull request #83456 from MaxDesiatov/enqueue-existential
Embedded WASI: fix some concurrency tests

The test was crashing due to `swift_unreachable("custom executors not supported in embedded Swift")` line in `swift_task_enqueueImpl`, as the corresponding non-embedded codepath was relying on an unspecialized generic function `_swift_task_enqueueOnExecutor` defined in `Executor.swift`. Unspecialized generics are unavailable in Embedded Swift, and such `@silgen_name` function can't be specialized when used from concurrency runtime code written in C/C++. We can redefine this function for Embedded Swift using a class-bound existential instead, and re-enable this codepath with a slightly different call that avoids the use of unavailable `swift_getObjectType` function from the non-embedded runtime.

rdar://156996468
2025-08-01 12:33:51 +01:00
Erik Eckstein
ec8dcc98ad rename the feature AddressOfProperty to AddressOfProperty2
Fixes a build problem when using a mainline compiler with a 6.2 Swift.swiftinterface file.
This was caused by mistakenly cherry-picking the `#if $AddressOfProperty` conditions in the stdlib into 6.2 without the required compiler change.
2025-08-01 08:00:51 +02:00
Max Desiatov
78c85945f6 Actor.cpp: Fix unused variables for non-embedded path 2025-07-31 21:16:40 +01:00
Allan Shortlidge
71a5d9bd74 AST: Re-baseline ValueGenericsNameLookup feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
6dd3e49954 AST: Re-baseline BuiltinEmplaceTypedThrows feature. 2025-07-31 10:21:55 -07:00
Alejandro Alonso
e3d381b557 Merge pull request #83397 from Azoy/atomic-addressofrawlayout
[stdlib] Change the builtin used to get the address for Atomic
2025-07-31 09:47:07 -07:00
Max Desiatov
7ec0837778 Embedded WASI: fix concurrency-deleted-method.swift test
The test was crashing due to `swift_unreachable("custom executors not supported in embedded Swift")` line in `swift_task_enqueueImpl`, as the corresponding non-embedded codepath was relying on an unspecialized generic function `_swift_task_enqueueOnExecutor` defined in `Executor.swift`. Unspecialized generics are unavailable in Embedded Swift, and such `@silgen_name` function can't be specialized when used from concurrency runtime code written in C/C++. We can redefine this function for Embedded Swift as using a class-bound existential instead, and re-enable this codepath with a slightly different call that avoids the use of unavailable `swift_getObjectType` function from the non-embedded runtime.
2025-07-31 16:00:40 +01:00