Commit Graph

7762 Commits

Author SHA1 Message Date
3405691582
cd7570fdee ManagedBuffer capacity is unavailable on OpenBSD.
On OpenBSD, malloc introspection (e.g., malloc_usable_size or
malloc_size) is not provided by the platform allocator. Since allocator
introspection is currently a load-bearing piece of functionality for
ManagedBuffer and ManagedBufferPointer, pending any API changes, as a
stopgap measure, this commit marks methods in ManagedBuffer and
ManagedBufferPointer calling _swift_stdlib_malloc_size and methods
dependent thereon unavailable on OpenBSD.

This may induce some compatibility issues for some files, but at least
this change ensures that we can get stdlib to build on this platform
until the evolution process addresses this problem more thoroughly.
2020-09-09 18:57:58 -04:00
Valeriy Van
ed30712ff3 Fixes example snippet in OutputStream.swift (#33844) 2020-09-08 13:36:21 -05:00
Xiaodi Wu
643834e7f5 [stdlib] Simplify generic floating-point conversion fast paths 2020-09-08 12:08:08 -04:00
Xiaodi Wu
45d69d58d0 [stdlib] Use 'truncatingIfNeeded:' in floating-point conversion fast paths 2020-09-08 11:32:09 -04:00
Xiaodi Wu
9a6900ad3a [stdlib] Refactor generic floating-point conversion fast paths 2020-09-07 18:47:01 -04:00
Xiaodi Wu
f40fd369cd [stdlib] Add another fast path for generic floating-point conversion 2020-09-07 18:47:01 -04:00
Xiaodi Wu
f0a6d6f69e Merge pull request #33803 from xwu/fp-init-specialization
[stdlib] Make use of protocol requirements to convert from concrete floating-point types
2020-09-05 11:37:21 -04:00
Xiaodi Wu
b6046352de 🤮 2020-09-04 17:51:39 -04:00
Xiaodi Wu
70b68d6ba9 [stdlib] Include Float16 among source types recognized for generic conversion 2020-09-04 16:16:10 -04:00
Xiaodi Wu
502258e6a1 Merge pull request #33610 from valeriyvan/Array-snippet
Fixes example snippet in Array.swift adding missing parameter label
2020-09-04 14:32:08 -04:00
Xiaodi Wu
42f79b0e87 [stdlib] Make use of protocol requirements to convert from concrete types 2020-09-04 14:23:53 -04:00
Benjamin Barnard
0bc48dea75 [stdlib] NFC: Fix typo in comment. 2020-09-01 19:09:39 -04:00
Stephen Canon
294bde951b Documentation fix: remainder matches sign of lhs, not rhs. 2020-08-31 08:46:24 -04:00
Valeriy Van
9d08f164ca Fixes example snippet in Array.swift adding missing parameter label 2020-08-30 19:19:05 +02:00
tbkka
524cfae1b2 [Dynamic Casting] Overhauled Runtime (#33561)
* Dynamic Cast Rework: Runtime

This is a completely refactored version of the core swift_dynamicCast
runtime method.

This fixes a number of bugs, especially in the handling of multiply-wrapped
types such as Optional within Any.  The result should be much closer to the
behavior specified by `docs/DynamicCasting.md`.

Most of the type-specific logic is simply copied over from the
earlier implementation, but the overall structure has been changed
to be uniformly recursive.  In particular, this provides uniform
handling of Optional, existentials, Any and other common "box"
types along all paths.  The consistent structure should also be
easier to update in the future with new general types.

Benchmarking does not show any noticable performance implications.

**Temporarily**, the old implementation is still available.  Setting the
environment variable `SWIFT_OLD_DYNAMIC_CAST_RUNTIME` before launching a program
will use the old runtime implementation.  This is only to facilitate testing;
once the new implementation is stable, I expect to completely remove the old
implementation.
2020-08-27 11:06:40 -07:00
Kyle Macomber
d71d92eced Merge pull request #31105 from valeriyvan/RemoveRedundantBufferZeroingUnicodeHelpers
[stdlib] Removes redundant buffer zeroing in foreignErrorCorrectedGrapheme func by using `init(unsafeUninitializedCapacity:initializingWith:)
2020-08-24 14:53:03 -07:00
Valeriy Van
84928c611d Fixes example snippet in Array.swift
Uses URL instead of NSURL, otherwise example deson't compile
2020-08-24 13:43:25 +02:00
Brian Gontowski
515c371be4 Avoid a warning when not modifying arg 2020-08-22 13:08:12 +09:00
Brian Gontowski
17c77ba703 Only use _CVarArgObject on non-ObjC platforms 2020-08-22 11:36:15 +09:00
NevinBR
a62bf48e68 [stdlib] [NFC] FloatingPointRandom.swift created (#33463)
* Moved `random` methods out of FloatingPoint.swift

* Added `random` methods to FloatingPointRandom.swift

* Added FloatingPointRandom.swift to CMakeLists.txt

* Added FloatingPointRandom.swift to GroupInfo.json

* Moved filename within CMakeLists.txt
2020-08-18 18:12:35 -04:00
Kuba (Brecka) Mracek
7a9f894c88 Avoid using -sil-inline-generics and -sil-partial-specialization when building MinSizeRel stdlib to save ~15% on codesize (#33444) 2020-08-17 20:58:54 -07:00
Stephen Canon
457b9990e9 Add checks that the endpoints of partial ranges are not-NaN. (#33378)
We can't actually check for NaN (because the notion doesn't exist for Comparable), but we can require that the endpoint is non-exceptional by checking if it equals itself.
2020-08-10 14:06:46 -04:00
Slava Pestov
3ae31d5173 Sema: Don't need to derive CaseIterable's AllCases associated type
Just declaring a default in the standard library works fine.
2020-08-07 16:48:40 -04:00
Ben Rimmington
d3f0de804d [SE-0163] Migrate from deprecated Unicode APIs (part 3) (#33175) 2020-08-06 23:44:55 +01:00
Erik Eckstein
e7efa6cb15 stdlib: Make Result methods inlinable
The "Result" type is expected to have no overhead when used.
This requires the member functions to be inlinable.
Which is probably okay for library evolution, because it's unlikely that those methods change in an incompatible way.
2020-07-29 21:57:51 +02:00
Vedant Kumar
2308bb18b1 Add _getMetadataSection{,Count,Name} to API digester allow list (#33138)
These APIs are needed to build SwiftReflectionTest.swift when testing
Release builds.

This rolls back 014918c0, which hid these APIs in non-asserts builds
causing a failure:

  https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64/5708/consoleText

rdar://66103895
2020-07-28 15:19:18 -07:00
eeckstein
5fffeb81fb Merge pull request #33128 from eeckstein/string-optimization
SIL optimizer: Add a new string optimization
2020-07-28 10:17:28 +02:00
Mishal Shah
3a50f93c60 Merge pull request #33142 from natecook1000/nate/stdlib-stability-abi
[stdlib] Only include _getMetadataSection functions in stdlib builds w/ assertions
2020-07-28 00:03:53 -07:00
Nate Cook
014918c0ca Only include _getMetadataSection functions in stdlib builds w/ assertions 2020-07-27 17:12:27 -05:00
Erik Eckstein
b42bce4ba4 stdlib: changes for the StringOptimization
To be able to constant fold string interpolation, the right semantic attributes must be in place.
Also, the interpolation's write function must be inlinable.
For the _typeName constant folding, a semantic attribute is required.
2020-07-27 21:32:56 +02:00
Robert Widmann
d1ae69383d Merge pull request #32312 from valeriyvan/RemoveRedundantBufferZeroingUnicodeScalarProperties
[stdlib] Eliminates redundant buffer zeroing in UnicodeScalarProperties
2020-07-26 12:53:23 -07:00
Augusto Noronha
3cb8f9b6fc Add entrypoints to the runtime that exposes metadata necessary for reflection tests on Linux (#32339) 2020-07-24 15:26:15 -07:00
Erik Eckstein
666c5e087c stdlib: enable COW sanity checks with an environment variable
Instead of doing the sanity checks by default (with an assert-build of the stdlib), only do the checks if the environment variable SWIFT_DEBUG_ENABLE_COW_SANITY_CHECKS is set to true.

The checks can give false alarms in case a binary is built against a no-assert stdlib but run with an assert-stdlib.
Therefore only do the checks if it's explicitly enabled at runtime.

rdar://problem/65475776
2020-07-20 11:23:42 +02:00
Brent Royal-Gordon
4394e92c3f Merge pull request #32700 from brentdax/magical-and-evolutionary
Revise #file changes from SE-0274
2020-07-17 01:57:23 -07:00
swift-ci
1224d8b2d3 Merge pull request #32915 from airspeedswift/transparent-stringpointer 2020-07-16 10:53:54 -07:00
Erik Eckstein
0102fe8b15 stdlib: remove some inlinable annotations from Substring's and String's subscript
Inlining those operations does not really give any benefit.
Those operations are complex and most likely, cannot be folded into simpler patterns after inlining, anyway.
Reduces some code size for cases where those functions were inlined (due to a not perfect inlining heuristics).
2020-07-16 12:46:42 +02:00
Ben Cohen
7adafcaaaa Make _convertConstStringToUTF8PointerArgument transparent 2020-07-15 17:27:33 -07:00
Stephen Canon
103961a7d5 Make Float16 unavailable on macOS and macCatalyst, mirroring Xcode's Swift. (#32868)
LLVM doesn't have a stable ABI for Float16 on x86 yet; we're working with Intel to get that fixed, but we don't want to make the type available on macOS until a stable ABI is actually available, because we'd break binaries compiled before any calling convention changes if we do.
2020-07-14 20:42:12 -04:00
Nate Cook
3af1deb447 [stdlib] Add _forEachField(of:options:body:) function (#32873)
This function walks all the fields of a struct, class, or tuple, and calls
`body` with the name, offset, and type of each field. `body` can perform
any required work or validation, returning `true` to continue walking fields
or `false` to stop immediately.
2020-07-14 16:31:32 -05:00
Karoy Lorentey
40d7da4fad Merge pull request #32019 from NevinBR/patch-1
[SR-12881] DefaultIndices dynamic dispatch
2020-07-14 12:05:12 -07:00
Brent Royal-Gordon
327ea8bce2 [Staging] Force stdlib into “Swift 6 mode” for #file
We ultimately want to explicitly change standard library uses of #file to #fileID, but once we do, previous compilers won’t be able to build the standard library. So instead, we will temporarily build the standard library with -enable-experimental-concise-pound-file, which should have the same effect, but will back-deploy to compilers going back several months.
2020-07-13 14:06:55 -07:00
Florian Friedrich
67073c7a67 Fix typo in comparison in comments and help text 2020-07-09 18:05:25 +02:00
swift-ci
cbe2dfc119 Merge pull request #32729 from valeriyvan/snippencharacter 2020-07-07 13:36:35 -07:00
Valeriy Van
adeb97a102 Fixes example snippet in Character.swift 2020-07-07 00:00:21 +02:00
Valeriy Van
b7076e4116 Fixes example snippets in Bool.swift 2020-07-06 23:45:31 +02:00
Erik Eckstein
bc27356d73 stdlib: enable runtime checking for COW support by default in assert builds.
This was blocked by an LLDB problem, which is now fixed (https://github.com/apple/llvm-project/pull/1333)
2020-07-03 15:56:50 +02:00
Varun Gandhi
cacfb01f97 Revert subset of "[Gardening] Clean Up OS-Test Patterns Across The Codebase"
Removes usage of #canImport(Darwin) from stdlib/public.

This reverts a subset of commit cddf73ecdb.
2020-07-01 15:47:18 -07:00
Robert Widmann
b766544327 Merge pull request #32642 from CodaFi/ossignpost
[Gardening] Clean Up OS Conditionals With canImport and Vendor=apple
2020-07-01 12:08:15 -07:00
Nate Cook
ba968d40e3 [stdlib] Fix removeLast(_:) performance for non-random-access collections (#32599)
This replaces the `count` comparison precondition with a limited index
offset, which converts the method from O(n) to O(k).
2020-07-01 03:06:32 -05:00
Robert Widmann
cddf73ecdb [Gardening] Clean Up OS-Test Patterns Across The Codebase
Clean up a few general patterns that are now obviated by canImport

This aligns more generally with the cleanup that the Swift Package
Manager has already done in their automated XCTest-plumbing tool in
apple/swift-package-manager#1826.
2020-06-30 22:55:58 -07:00