Commit Graph

22380 Commits

Author SHA1 Message Date
Jonathan Grynspan
7c3d0ddd1d Fix ABI test 2026-01-15 22:04:34 -05:00
Guillaume Lessard
39447fa0e6 [stdlib] fix semantics of span count properties
`@_semantics` isn’t compatible with `@_transparent`. Make sure all the count properties have the appropriate `@_semantics` annotation.
2026-01-15 17:07:35 -08:00
Guillaume Lessard
85799a45e3 [stdlib] add _assumeNonNegative to some count properties 2026-01-15 16:56:17 -08:00
Guillaume Lessard
0381601f00 [stdlib] more early inlining 2026-01-15 16:56:17 -08:00
Guillaume Lessard
d83c99ad14 [stdlib] early inlining in MutableRawSpan 2026-01-15 16:56:17 -08:00
Guillaume Lessard
9d1ec2a6ac [stdlib] allow early inlining in MutableSpan 2026-01-15 16:56:17 -08:00
Owen Voorhees
4f0b627d6d Revert "[Concurrency] Adopt typed throws in Task creation APIs (#84802)"
This reverts commit dc2d6fb4af.
2026-01-15 13:10:36 -08:00
Guillaume Lessard
6daf99b77a [stdlib] add explicit preconditions 2026-01-15 12:51:54 -08:00
Anton Korobeynikov
2ccfb5c946 [AutoDiff] Add throwing versions of differential operators (#86393) 2026-01-15 11:52:44 -08:00
Jonathan Grynspan
f1b73d24e1 Missing unsafe keyword 2026-01-15 13:50:14 -05:00
Jonathan Grynspan
0f471d4e6f You're killing me here, C++ 2026-01-15 12:39:36 -05:00
Jonathan Grynspan
cc3f5e8837 Fix optional 2026-01-15 11:00:55 -05:00
Jonathan Grynspan
07bdca185f Use std::basic_string with swift::cxx_allocator instead of messing with std::unique_ptr (incurs an extra copy but it's a one-time cost so I don't care 2026-01-15 10:59:34 -05:00
Jonathan Grynspan
fdc1bd82be Fixes 2026-01-15 08:58:09 -05:00
Jonathan Grynspan
0ed6e734c9 Conditionalize the result on OpenBSD based on a stat() call 2026-01-14 22:08:10 -05:00
Jonathan Grynspan
71bc3180eb Incorporate feedback and fix build issues 2026-01-14 21:33:06 -05:00
Guillaume Lessard
94f5f2d1f5 [stdlib] doc-comment corrections 2026-01-14 16:44:52 -08:00
Pavel Yaskevich
95040562c5 [stdlib] Replace @export(implementation) with @_AEIC on withTaskCancellationHandler
`@export(implementation)` cannot be widely adopted in stdlib yet,
currently leads to condfail in some configrations. Stick to `@_alwaysEmitIntoClient`
for now.
2026-01-14 16:05:19 -08:00
Doug Gregor
0aac69bd35 [Task cancellation] Adopt nonisolated(nonsending) and sending 2026-01-14 15:57:40 -08:00
Doug Gregor
09c71a29f8 Drop extraneous isolation argument 2026-01-14 15:57:39 -08:00
Doug Gregor
94ec6bc6ed [Concurrency] Adopt typed throws and nonisolated(nonsending) in withTaskCancellationHandler
Replace the use of rethrows and #isolation in
withTaskCancellationHandler with typed throws and
nonisolated(nonsending), respectively.

Fixes rdar://146901428.
2026-01-14 15:57:39 -08:00
Guillaume Lessard
e334d9c1de Merge pull request #83657 from glessard/rdar155660454-array-plus-outputspan
[stdlib, SE-0485] Array functions with OutputSpan
2026-01-14 14:30:05 -08:00
Jonathan Grynspan
01f6992693 Make the property optional and return nil on failure instead of aborting 2026-01-14 17:07:46 -05:00
Jonathan Grynspan
d825b556f9 Merge branch 'main' into jgrynspan/executablePath 2026-01-14 14:01:22 -05:00
Mike Ash
d0017555c7 [Runtime] Faster dynamic exclusivity checking implemented in Swift.
Replace C++ implementation of swift_beginAccess and swift_endAccess with (almost) pure Swift implementation. Helpers remain in C++ for TLS, getting return addresses, and raising a fatal error on violations.

This change also moves the exclusivity access set head from the shared SwiftTLSContext structure to a dedicated TLS key. This improves performance, which is important for exclusivity checking. This is particularly the case where we can inline TLS access with a constant key, as on Darwin ARM64.

The code that bridges exclusivity tracking into Concurrency remains in C++. The new Swift implementation exposes a few helpers for it to use as a replacement for directly manipulating the C++ implementation.

rdar://161122309
2026-01-14 12:23:55 -05:00
Konrad `ktoso` Malawski
40dabefdb4 Reapply: Runtime: expose demangle() in Runtime module (#84788) (#86510) 2026-01-14 21:44:28 +09:00
Konrad `ktoso` Malawski
aa715b2d00 [Concurrency] Avoid @export on withTaskPriorityEscalationHandler (#86504) 2026-01-14 00:15:18 -08:00
Guillaume Lessard
58b0e565f0 [stdlib] preserve items appended until a thrown error 2026-01-13 15:00:49 -08:00
AZero13
38d0284c00 Total output needs to have the last outbuffer pos added to it 2026-01-13 13:09:36 -05:00
Konrad `ktoso` Malawski
dc2d6fb4af [Concurrency] Adopt typed throws in Task creation APIs (#84802) 2026-01-13 20:21:20 +09:00
Tim Kientzle
bd67f95305 FP Parsing: Fix over-eager underflow check
An early check for underflow was a bit too aggressive, resulting in values that
would otherwise round up to the smallest subnormal failing to go through the
regular rounding logic.

Resolves #86462
Resolves rdar://167942063
2026-01-12 11:52:31 -08:00
Daniel Rodríguez Troitiño
b37511ef42 [CMake] Explicitly disable LTO if no LTO option is provided (take 2) (#86187)
This is second version of #85621 which was reverted in #85794 because
the result of `_compute_lto_flag` was used as a boolean in some
contexts.

The differences from the original is that `_compute_lto_flag` is split
into a second function `_is_lto_enabled` which provides an actual
boolean for when LTO is enabled, and the half dozen usages of
`_compute_lto_flag` have been audited for using `_compute_lto_flag`
without considering the return value a boolean, or using the new
`_is_lto_enabled` as a proper boolean. A small clean up of commented out
code is performed (probably just a forgetten clean up from #66077).

The changes have been verified by compiling with
`SWIFT_STDLIB_ENABLE_LTO=thin` and
`SWIFT_STDLIB_BUILD_TYPE=RelWithDebInfo`, and checking the resulting
flags for building the stdlib include both `-flto=thin` and
`-gline-tables-only`, while the Swift tools include `-fno-lto` instead.

The following is the original commit message, which explains why this
change is interesting:

---

When compiling Swift as an LLVM external project (not the non-unified
workflow from the build-script), if one tries to enable LTO for LLVM
projects it will end up affecting Swift and the Swift standard library,
even if the options `SWIFT_TOOLS_ENABLE_LTO` and
`SWIFT_STDLIB_ENABLE_LTO` are disabled or using their default values,
because [HandleLLVMOptions] modifies the `CMAKE_C/CXX_FLAGS` globally.

By setting `-fno-lto` explicitly when those options are disabled or
using their default values, the options from `CMAKE_C/CXX_FLAGS` are
overriden, and the `SWIFT_*_ENABLE_LTO` controls the usage or not of LTO
optimizations and the presence of bitcode in the object files.

[HandleLLVMOptions]:
b58b2a34d5/llvm/cmake/modules/HandleLLVMOptions.cmake (L1278-L1310)
2026-01-12 10:08:42 -08:00
Alastair Houghton
8f68771e4c Merge pull request #85536 from al45tair/eng/PR-164850733
[Backtracing] Add missing availability annotations.
2026-01-12 16:55:07 +00:00
eeckstein
965c55f1ab Merge pull request #86470 from swiftlang/revert-84788-wip-demangle-string
Revert "Runtime: expose demangle() in Runtime module"
2026-01-12 14:45:04 +00:00
Susana Monteiro
412f8ca59a Merge pull request #86199 from susmonteiro/susmonteiro/copyable-unique-ptr
[cxx-interop] Add API Notes for std::unique_ptr
2026-01-12 10:46:15 +00:00
eeckstein
4766678f3f Revert "Runtime: expose demangle() in Runtime module (#84788)"
This reverts commit ab69fc0d2c.
2026-01-12 10:26:14 +01:00
AZero13
72b8dadc0b Always free mutex even on failure 2026-01-11 14:07:53 -05:00
Guillaume Lessard
be9708a547 Merge pull request #86435 from glessard/rdar165001871-span-withUBP-empty
[stdlib] simplify span-family `withUnsafe...` implementations
2026-01-10 11:22:26 -08:00
Doug Gregor
f4aa5c1051 Merge pull request #86424 from DougGregor/unchecked-never-call-beginendaccess
Always suppress swift_(begin|end)Access calls with `-enforce-exclusivity=unchecked`
2026-01-09 22:10:50 -08:00
Guillaume Lessard
49cb3deec3 Merge pull request #86420 from glessard/rdar167661807-mutableBytes-accessor-safety
[stdlib] mark `Span.mutableBytes` as unsafe
2026-01-09 18:37:27 -08:00
Guillaume Lessard
6cdf7b2820 [stdlib] simplify span family withUnsafe… implementations 2026-01-09 18:20:40 -08:00
Meghana Gupta
4a5aa57b31 Merge pull request #85473 from realrajaryan/fix-assertionFailure-assert-config
[stdlib] Fix assertionFailure() not respecting -assert-config Release at -Onone
2026-01-09 10:12:07 -08:00
Konrad `ktoso` Malawski
ab69fc0d2c Runtime: expose demangle() in Runtime module (#84788)
We should expose the demangle functionality; It's been widely used by
calling into internal _swift_demangle and instead we should offer a real
API. It's also already used in the Runtime module already when forming
backtraces.

[Previous
discussions](https://forums.swift.org/t/demangle-function/25416/15)
happened between 2019 and 2024, and just never materialized in a
complete implementation and proposal.

Right now, even more tools are in need of this API, as we are building
continious profiling solutions etc, so it is a good time to revisit this
topic.

This PR is roughly based off @Azoy's

https://github.com/swiftlang/swift/pull/25314/files#diff-fd379a721cc9a1c9ef6486eae713e945da842b42170d4d069029a57334371eba
from 2019, however it brings it over to the new Runtime module which is
a great place to put this functionality - even Backtrace had to recently
reinvent calling the demangling infra in this module.

Pending SE review, [proposal
here](https://github.com/swiftlang/swift-evolution/pull/2989).

cc @azoy @al45tair

---------

Co-authored-by: Alastair Houghton <alastair@alastairs-place.net>
2026-01-09 09:46:19 -08:00
Doug Gregor
d73cd34805 Always suppress swift_(begin|end)Access calls with -enforce-exclusivity=unchecked
The exclusivity enforcement command-line flags currently impact the
generation of SIL within the current module. However, it does not
impact any SIL that was deserialized from another module, which means
that `-enforce-exclusivity=unchecked` doesn't actually remove all of
the dynamic exclusivity checks.

When dynamic exclusivity is disabled, lower SIL
begin_access/end_access instructions to nothing to ensure that we
won't do any dynamic exclusivity checks.

Use this to better model the reality of dynamic exclusivity checking
in Embedded Swift, which effectively turned off all dynamic
exclusivity checking by having empty stub implementations of
swift_(begin|end)Access. Instead, have Embedded Swift default to
`-enforce-exclusivity=unchecked`, so that it never emits calls to
swift_(begin|end)Access. Remove the stub implementations of
swift_(begin|end)Access from the Embedded Swift runtime, since we will
no longer generate calls to them by default.

Moving forward, this will allow us to conditionally enable the new
implementation of dynamic exclusivity checking by specifying
`-enforce-exclusivity=checked` for Embedded Swift builds. We'll stage
that in over time to avoid breaking existing Embedded Swift clients.
2026-01-09 09:26:39 -08:00
Alastair Houghton
e0486a47bd [Backtracing] Add some more availability annotations.
We needed a few more annotations, it turns out.  Also, we need to disable
availability checking when building swift-backtrace.

rdar://164850733
2026-01-09 15:48:37 +00:00
Alastair Houghton
6a6ff87602 [Backtracing] Move availability definition, fix tests.
Move the availability definition to the `.def` file, and then
turn off availability checking in the tests.

rdar://164850733
2026-01-09 11:58:36 +00:00
Alastair Houghton
22a7c8fa0a [Backtracing] More availability annotations required.
Apparently we need some more availability annotations.

rdar://164850733
2026-01-09 11:58:36 +00:00
Alastair Houghton
64fa447210 [Backtracing] Add missing availability annotations.
This is slightly complicated by us currently not supporting this code
on iOS/tvOS/watchOS/visionOS.  We should fix that, at which point we
can use the `SwiftStdlib`/`StdlibDeploymentTarget` macros instead.

rdar://164850733
2026-01-09 11:58:35 +00:00
Guillaume Lessard
48bc818f99 Merge pull request #84673 from valeriyvan/MainActor
Fix typo in MainActor.swift
2026-01-09 02:14:31 -08:00
Guillaume Lessard
8170936050 [stdlib] add required unsafe markers 2026-01-08 21:29:33 -08:00