Commit Graph

7762 Commits

Author SHA1 Message Date
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
Guillaume Lessard
31235db588 [stdlib] add OutputSpan to backdeployment library 2025-07-16 17:15:28 -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
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
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
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
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
Guillaume Lessard
9341973700 [stdlib] update doc-comments 2025-07-08 14:29:21 -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
Guillaume Lessard
fe6a8fac39 Merge pull request #82866 from glessard/rdar155275054-default-inits-allspans
[stdlib] Default initializers for Span-family types
2025-07-08 09:46:14 -07:00
Guillaume Lessard
37737a10f2 [gardening] conditional compilation spelling tweak 2025-07-08 00:46:26 -07:00
Guillaume Lessard
619ec95693 [stdlib] add no-parameter initializers for Span types
This was an addition in SE-0485.
2025-07-07 17:57:12 -07:00
Guillaume Lessard
9d179716f8 Merge pull request #82828 from glessard/mutableSpan-extractingBug
[stdlib] fix some unsafe errors
2025-07-07 14:28:18 -07:00
Guillaume Lessard
36b5090a98 Merge pull request #82598 from glessard/rdar153654652-now-available
[stdlib] add `span` properties to the backdeployment library
2025-07-07 02:46:10 -07:00
Guillaume Lessard
9ac65cf735 [stdlib] fix some unsafe errors 2025-07-07 02:29:51 -07:00
Alex Martini
c727b0e3bc Merge pull request #82635 from amartini51/typo_154473231
Fix repeated words in documentation

Fixes: rdar://154473231
2025-07-02 19:26:55 -07:00
Stephen Canon
fddd8bd5b9 Mark the concrete SIMD/Scalar comparisons disfavored (#82686)
Adding the concrete versions (https://github.com/swiftlang/swift/pull/81892) introduced an ambiguity for concrete vec .<= .zero comparisons; previously the concrete SIMD .<= SIMD operation would win (because we didn't have a concrete overload for SIMD .<= SIMD.Scalar). We can restore the old behavior by marking these disfavored.
2025-07-02 11:59:07 -04:00
Guillaume Lessard
5d4c445347 [stdlib] some span properties are more available 2025-06-30 17:13:35 -07:00
Stephen Canon
377c66b6e7 Replace some precondition with _precondition in the stdlib. (#82641) 2025-06-30 19:12:00 -04:00
Guillaume Lessard
f97961a86f [stdlib] fix _makeMutableAndUniqueUnchecked() 2025-06-30 16:05:00 -07:00
Alex Martini
3928ddfeb4 Fix repeated text 2025-06-30 09:36:37 -07:00
Henrik G. Olsson
bd11926bf7 [Swiftify] Adjust _SwiftifyImport invocation to align with the signature
of the macro in the currently laoded macro module

Stdlib macros are shipped with the SDK, so we need to make sure that the
way we invoke the macro matches the version of the macro in the SDK.
This patch skips the `spanAvailability` parameter if it isn't present.
There's no good way to test this, because we will always pick up the
current macro in our llvm-lit test suite, but I've tested it manually.

rdar://152278292
2025-06-27 19:10:23 -07:00
David Smith
1a56da655f Native implementation of -lengthOfBytesUsingEncoding, plus handling ASCII-subset MacRoman in a few places (#81791)
Fixes rdar://154341146
2025-06-27 13:48:10 -07:00
Guillaume Lessard
96f6f5e25a Merge pull request #82442 from glessard/rdar147500261-utf8span-32bit 2025-06-27 08:18:46 -07:00
Ben Rimmington
1b1e9d4d80 [stdlib] Update InlineArray documentation (#82363)
Remove misleading big O notation from initializers.
2025-06-27 11:14:24 +01:00
Guillaume Lessard
4927c0c1c8 [stdlib] improve more accessor declarations 2025-06-26 14:57:21 -07:00
Guillaume Lessard
c8092f50d1 [stdlib] simplify borrowing accessors 2025-06-26 14:57:21 -07:00
Guillaume Lessard
bbfe648c54 [stdlib] improve accessor declarations 2025-06-26 14:57:21 -07:00
Guillaume Lessard
791dd4cb0a [stdlib] name your constants better
- computed properties have an ABI impact; a function is fine here
2025-06-25 22:01:28 -07:00
Alejandro Alonso
596b015994 Adjust ABI test and guard address of property 2025-06-25 14:08:53 -07:00
Alejandro Alonso
6953a7c6f9 Update InlineArray.swift 2025-06-25 14:00:16 -07:00
Alejandro Alonso
5ac3a655d4 Update InlineArray.swift 2025-06-25 14:00:15 -07:00