Commit Graph

7182 Commits

Author SHA1 Message Date
Guillaume Lessard
fd7ced19ea [gardening] a simplification 2023-06-28 16:37:41 -07:00
Alejandro Alonso
141fa804b1 Make _createOffsetBasedKeyPath and _rerootKeyPath only available with reflection 2023-06-26 23:09:39 -07:00
eeckstein
c8ec463312 Merge pull request #66920 from eeckstein/managedbuffer-inlinable-deinit
stdlib: make deinit of `ManagedBuffer` inlinable
2023-06-27 06:52:48 +02:00
Erik Eckstein
a5744b2bb5 stdlib: make deinit of ManagedBuffer inlinable
This allows to eliminate dead allocations of a ManagedBuffer object.

https://github.com/apple/swift/issues/66496
2023-06-26 12:10:15 +02:00
Alejandro Alonso
d9d26eec9d Add support for classes in _createOffsetBasedKeyPath 2023-06-22 14:07:41 -07:00
Stephen Canon
185820a148 Fix sign of fractional units in Duration initializers from Double. (#66582)
* Fix sign of fractional units in Duration initializers from Double.

When separating a double duration into integral and fractional parts, we got the sign wrong. This fixes that bug.

* Fixup variable name.
2023-06-13 08:46:46 -04:00
Yuta Saito
8124738fc2 [stdlib] Fix calling convention mismatch for debugger utility functions
The functions `swift_retainCount`, `swift_unownedRetainCount`, and
`swift_weakRetainCount` are declared in `HeapObject.h` as using
the C calling convention, but the Swift declarations referenced them
by `@_silgen_name`, which uses the Swift calling convention. This
patch fixes the mismatch without any ABI/API breakage by calling the
utility functions through C interop.
2023-06-10 07:40:50 +00:00
Doug Gregor
feb5c09d93 Remove OptionSet macro from the standard library. 2023-06-06 23:37:38 -07:00
Jager-yoo
aca5038625 Change word order for clarity in Unicode handling doc 2023-06-04 17:05:50 +09:00
Lucy Satheesan
8b8f5472a4 Merge pull request #66085 from oxy/gh56321
[stdlib] don't copy array contents on `removeAll(keepingCapacity: true)`
2023-05-25 09:00:38 -07:00
Stephen Canon
db0a7287a5 Rework the .seconds, .milliseconds, and .microseconds constructors to preserve exact values (#66111)
When constructing a Duration from Double, we should do it in such a way that exact integer inputs are preserved exactly, so long as they are represented as a Duration. This was not previously the case. Now it is.
2023-05-24 23:07:17 -04:00
Lucy Satheesan
ff76106177 [stdlib] don't copy array contents on removeAll(keepingCapacity: true) 2023-05-24 07:52:39 -07:00
Lucy Satheesan
492da020cf [gardening] remove superfluous #if 2023-05-24 07:52:38 -07:00
David Smith
e342ac4ee3 Don't reserveCapacity in append(contentsOf:), it breaks API guarantees of asymptotic complexity (#65927)
Don't reserveCapacity in append(contentsOf:), it breaks API guarantees of asymptotic complexity. Fixes rdar://109577273
2023-05-19 12:13:55 -07:00
swift-ci
dabfcb284c Merge pull request #65778 from Catfish-Man/contiguous-conundrum
Try using withContiguousStorageIfAvailable in RangeReplaceableCollection.append(contentsOf:) before falling back to a slow element-by-element loop.
2023-05-19 04:10:56 -07:00
Doug Gregor
ac5cd478ee Merge pull request #65982 from DougGregor/fix-generic-param-shadowing 2023-05-17 15:34:07 -07:00
Doug Gregor
8b4fe6be18 Eliminate some unnecessary shadowing generic parameters 2023-05-17 11:04:11 -07:00
Nate Cook
23c19333df [stdlib] Fix String.reserveCapacity underallocation (#65902)
When called on a string that is not uniquely referenced,
`String.reserveCapacity(_:)` ignores the current capacity, using
the passed-in capacity for the size of its new storage. This can
result in an underallocation and write past the end of the new
buffer.

This fix changes the new size calculation to use the current UTF-8
count as the minimum. Non-native or non-unique strings
now allocate the requested capacity (or space enough for the
current contents, if that's larger than what's requested).

rdar://109275875
Fixes #53483
2023-05-17 12:11:23 -05:00
David Smith
5efc2da08d _onFastPath, in inlineable code, will end up applying to the caller. We don't want that, so omit it 2023-05-15 12:53:58 -07:00
Nate Cook
89b9e48eae [stdlib] Implement Never conformance to Codable (#64899)
Proposed as SE-0396: Conform Never to Codable;
approved on 5/5/2023.
2023-05-09 13:10:10 -05:00
David Smith
465aa22b81 Try using withContiguousStorageIfAvailable in RangeReplaceableCollection.append(contentsOf:) before falling back to a slow element-by-element loop. Fixes rdar://109059874 2023-05-08 17:03:35 -07:00
Max Obermeier
ecf9775233 [stdlib] _Int128: fix invalid overflow crash
fix bug where multiplication of negative value with zero would result in overflow precondition being triggered
2023-05-05 09:52:35 -07:00
Allan Shortlidge
0366c42293 Merge pull request #65557 from tshortli/unavailable-decl-optimization-stub
Introduce `stub` mode for `-unavailable-decl-optimization`
2023-05-05 09:11:41 -07:00
Alejandro Alonso
73e749d985 Merge pull request #65594 from Azoy/identitycastthing
[stdlib] Add a conditional identity cast
2023-05-03 16:17:45 -07:00
Allan Shortlidge
d1416ddd56 SILGen: Stub unavailable functions.
When `-unavailable-decl-optimization=stub` is specified, insert a call to
`_diagnoseUnavailableCodeReached()` at the beginning of the function to cause
it to trap if executed at run time.

Part of rdar://107388493
2023-05-03 15:19:31 -07:00
eeckstein
607f4ebb9f Merge pull request #65612 from eeckstein/inline-array-count
stdlib: force inlining of `ContiguousArray.endIndex` and `ContiguousArray._getCount`
2023-05-03 21:09:25 +02:00
Alejandro Alonso
4c8c828889 Rename to _specialize 2023-05-03 09:41:09 -07:00
Erik Eckstein
5d43f75173 stdlib: force inlining of ContiguousArray.endIndex and ContiguousArray._getCount
This let the optimizer generate efficient code for generic array loops (note that generic functions are not inlined by default).
Note that the same change is not done for `Array` because this might increase code size due to Array's bridging code.

rdar://108746069
2023-05-03 15:07:37 +02:00
Mike Ash
a6bab7332d [Reflection] Handle -disable-reflection-names in _forEachField.
Invoke our callback with an empty name string when reflection names are disabled, rather than throwing a fatal error.

rdar://108709009
2023-05-03 08:55:28 -04:00
Alejandro Alonso
e381815580 Add a conditional identity cast 2023-05-02 13:37:08 -07:00
Karoy Lorentey
298ab208d8 [stdlib][nfc] Prefer to put the _pointerBitWidth(_64) case first, as that is far more common 2023-04-27 16:33:50 -07:00
Karoy Lorentey
b82ce9c3be [stdlib] Adopt _pointerBitWidth conditional 2023-04-27 13:33:24 -07:00
Alex Martini
86319f139a Merge pull request #62235 from bradleymackey/feature/never-doc
stdlib: Improve Never documentation
2023-04-27 09:44:07 -07:00
Alejandro Alonso
d90134c981 Merge pull request #65384 from ojun9/more-readable-of-lexicographicallyPrecedes
[stdlib] Improve readability by replacing `if let` with `guard let` in lexicographicallyPrecedes method
2023-04-26 09:54:01 -07:00
Alejandro Alonso
3360e41c9c Add SPI to reroot a keypath for a given superclass 2023-04-24 17:15:28 -07:00
TappediOS
52adf77ab9 [stdlib] more readable of lexicographicallyPrecedes 2023-04-23 19:27:02 +09:00
Alejandro Alonso
6ec8a8c60f Merge pull request #64904 from Azoy/keypath-create-spi
[stdlib] Create an offset based keypath at runtime
2023-04-12 09:24:40 -07:00
Karoy Lorentey
a1dae65528 [stdlib] Adjust availability of _CharacterRecognizer conformances
These never made it to 5.8, so their availability needs to be bumped to 5.9.
2023-04-11 16:43:06 -07:00
Alejandro Alonso
e9c0b32497 Remove class support 2023-04-04 09:54:09 -07:00
Alejandro Alonso
3522a338a2 Create function to create an offset based keypath at runtime 2023-04-04 09:44:18 -07:00
nate-chandler
5e0267b9b7 Merge pull request #64553 from nate-chandler/eagermove_collections
[stdlib] Collection types are eagerMove.
2023-03-30 16:16:26 -07:00
Nate Chandler
cda365ca8d [stdlib] Collection types are eagerMove.
Types that have "value semantics" should not have lexical lifetimes.
Value types are not expected to have custom deinits. Are not expected to
expose unsafe interior pointers. And cannot have weak references because
they are structs. Therefore, deinitialization barriers are irrelevant.

rdar://107076869
2023-03-30 11:04:47 -07:00
Alejandro Alonso
aa3fd951d2 Merge pull request #64731 from Azoy/update-unicode-15
[stdlib] Update the stdlib to use Unicode 15 data
2023-03-29 22:49:38 -07:00
Alejandro Alonso
cc62bb1ddc Update copyright years 2023-03-29 10:35:30 -07:00
Alejandro Alonso
f16f0c3c23 Update the stdlib to use Unicode 15 data 2023-03-29 10:18:16 -07:00
Erik Eckstein
661264034b stdlib: fix the #if guard for Builtin.unprotectedStackAlloc
rdar://107274878
2023-03-28 20:16:40 +02:00
Doug Gregor
e13b104357 Add #warning and #error macro declarations to the standard library 2023-03-09 22:29:49 -08:00
Jonathan Grynspan
59d6f5c99c Make Zip2Sequence sendable (#64150) 2023-03-07 12:06:21 -05:00
Doug Gregor
2ac6aba256 Use proper feature check style for this 2023-03-06 12:29:20 -08:00
Doug Gregor
56249ccd47 Enable "Macros" feature in stdlib/Observation for older compilers 2023-03-06 08:50:30 -08:00