Commit Graph

5783 Commits

Author SHA1 Message Date
David Smith
257c93a183 Use -[NSSet getObjects:] instead of -[NSSet getObjects:count:] to maintain compatibility with existing code passing NSArrays into this function 2019-12-16 15:43:16 -08:00
Karoy Lorentey
d83a4257f0 [stdlib] Don’t use assert() in the stdlib
assert() is designed to be used in user code only; the equivalent stdlib function is called _internalInvariant().

rdar://57101013
2019-12-11 19:23:46 -08:00
Luciano Almeida
392baefc47 [stdlib][Qol] SR-11295 Removing stdlib unnecessary coercions (#27165)
* Removing unnecessary casts from stdlib

* Minor adjustments

* [stdlib][qol] Clean up error variable assign NSError

* Removing unnecessary coercions after removing DeclRefExpr restriction.
2019-12-11 07:30:25 -08:00
Robert Widmann
43a3ab7e35 Merge pull request #28665 from CodaFi/the-phantom-menace
Explicitly State CodingKeys as a Codable Requirement
2019-12-10 21:06:01 -08:00
Karoy Lorentey
2e17867774 Merge pull request #28378 from JacobMao/fix/SR-11283
SR-11283: Amend OptionSet.remove method
2019-12-10 17:41:45 -08:00
Robert Widmann
3bda241b11 State CodingKeys as an explicit requirement
The presence of this attribute will be used to guide the protocol derivation machinery to synthesize CodingKeys.
2019-12-10 16:28:51 -08:00
Azoy
e3a440186a Reorder conformances in cake test 2019-12-07 14:53:13 -05:00
Azoy
eebf8825f9 post de-gyb formatting 2019-12-07 11:05:45 -05:00
Azoy
0c4aa6055f de-gyb unavailablestringapis 2019-12-07 11:05:45 -05:00
Azoy
3f5c7162cc de-gyb runtime 2019-12-07 11:05:45 -05:00
Azoy
73250ad93a de-gyb mirrors 2019-12-07 11:05:45 -05:00
Azoy
48672551c9 de-gyb existentialcollection 2019-12-07 11:05:44 -05:00
Azoy
eb8bd16ca5 de-gyb codable 2019-12-07 11:05:44 -05:00
Azoy
5469cd2c62 de-gyb builtinmath 2019-12-07 11:05:44 -05:00
Robert Widmann
5725984dc6 Merge pull request #28462 from dtorres/patch-1
[LazyFilterSequence] Preserve order of predicates
2019-12-03 19:37:36 -08:00
Erik Eckstein
3e932c075d stdlib: Add custom .first to Array
This makes Array.first much small and more efficient.
Without this, Array.first compiled down to RandomAccessCollection.first, which ended up in pretty unefficient code.

rdar://problem/46291397
2019-11-27 09:55:27 +01:00
Erik Eckstein
87298c07c8 stdlib: make the non-native Array.count smaller more efficient.
Use _CocoaArrayWrapper.endIndex which returns the NSArray.count.
In the old version, "count" translated to RandomAccessCollection.count, which ended up in multiple calls to endIndex.
2019-11-26 18:20:39 +01:00
Diego Torres
3c4eeadc83 Preserve order of predicates
Fixes https://bugs.swift.org/browse/SR-11841
2019-11-24 15:42:33 +01:00
zhuowei
b9c1deff5f [stdlib] fix return type of getNumRuntimeFunctionCounters (#24182)
The return type of getNumRuntimeFunctionCounters is defined as uint64_t in RuntimeInvocationsTracking.cpp, but it has return type Int in RuntimeFunctionCounters.swift.

Found when compiling the stdlib for WebAssembly, as WebAssembly validates return types. uint64_t corresponds to i64, but Int is i32, so the program fails validation.
2019-11-22 13:44:56 -05:00
Stephen Canon
671df74418 Use the truncatingIfNeeded init on the result of these runtime funcs. (#28426)
The swift_floatNToString, swift_int64ToString, and swift_uint64ToString functions all return a uint64_t from c++. This is a historical accident, but these are SWIFT_RUNTIME_STDLIB_API, which means that we can't trivially change the return type. The result should naturally be size_t or int (it's always small enough to fit into *any* c integer type). However, we can elide the check in the caller at the point that the result is converted to Int, because we know that the check will always pass. This makes it so that the only overhead the wrong type introduces on 32b platforms is zeroing a register, which is free or nearly-free.
2019-11-21 20:45:04 -05:00
zhuowei
8b3a15babf [stdlib] Fix return type of swift_{uint64,int64,float*}ToString (#24181)
The return type of these functions are uint64_t in Stubs.cpp but UInt in the Swift code; this changes the Swift code to match the C++ return type.

Found when compiling the stdlib for WebAssembly, which requires that all return types match: UInt maps to i32 while uint64_t maps to i64, so functions calling these functions fail the validation.
2019-11-21 17:21:22 -05:00
Robert Widmann
b9fe66e0e8 Add documentation to _DependenceToken 2019-11-21 10:48:18 -08:00
Mao ZiJun
d5e2533cef improved OptionSet.remove's code style 2019-11-21 14:55:39 +09:00
Mao ZiJun
a8fd973876 fixed OptionSet's remove method 2019-11-21 11:25:41 +09:00
swift-ci
598042b521 Merge pull request #21550 from valeriyvan/patch-1 2019-11-18 15:27:40 -08:00
Slava Pestov
50872964dd Merge pull request #28289 from slavapestov/generic-parameters-are-unreliable-witnesses
Revert "Sema: Look for generic parameters first when inferring an associated type"
2019-11-16 01:56:16 -05:00
Nate Cook
8bfe519413 [stdlib] Use RRC.filter in removeAll(where: _) (#18825) 2019-11-15 16:24:27 -06:00
Slava Pestov
55e3797471 Revert "Sema: Look for generic parameters first when inferring an associated type"
This breaks source compatibility a little bit more than we'd like, so
reverting it for now.

Fixes <rdar://problem/57213598>.

This reverts commit 04fbcc0149.
2019-11-15 14:32:13 -05:00
Nate Cook
7c0ed24867 [stdlib] Document Windows implementation of SystemRandomNumberGenerator (#28268) 2019-11-15 10:38:44 -06:00
Slava Pestov
04fbcc0149 Sema: Look for generic parameters first when inferring an associated type
Previously we did this as a last resort if inference fails. The new
behavior is technically source-breaking, but I suspect nobody
relied on the old behavior.

This can help avoid cycles by eliminating some unnecessary validation work.

Fixes <https://bugs.swift.org/browse/SR-11407>, <rdar://problem/54979757>.
2019-11-13 23:42:08 -05:00
Michael Ilseman
1d63710a06 Merge pull request #28016 from milseman/swept_under_the_bridge
[stdlib] [gardening] Refactor bridging from StringStorage.swift
2019-11-06 13:43:32 -08:00
Dan Zheng
53e61a9587 [AutoDiff upstream] Add the _Differentiation module. (#27511)
The `_Differentiation` module is the experimental support library for
differentiable programming. It is built when the build-script flag
`--enable-experimental-differentiable-programming` is enabled.

The `Differentiable` protocol generalizes all types that work with
differentiation. It is a core piece of the differentiable programming
project. Other parts depending on the `Differentiable` protocol will
be upstreamed piece by piece.

The `Differentiable` protocol is compiler-known and will be used during
type-checking, SILGen, and the SIL differentiation transform.
2019-11-06 11:31:12 -08:00
Hamish Knight
1bc56dcc11 [stdlib] Mark some parameters @_nonEphemeral
These include the pointer-to-pointer and pointer-to-buffer-pointer
initialiser parameters amongst a couple of others, such as
`Unmanaged.fromOpaque`, and the source for the `move[...]` family of
methods.
2019-11-03 08:42:26 -08:00
Michael Ilseman
8463e53df3 [stdlib] [gardening] Refactor bridging from StringStorage.swift
Add StringStorageBridge.swift to separate out ObjC interop
functionality.

NFC
2019-11-01 17:25:08 -07:00
David Smith
ed1f9b30ef Implement both -isEqual: and -isEqualToString: to directly call the internal _isEqual, to avoid a redundant ObjC message send + type check 2019-10-28 16:36:13 -07:00
David Smith
637af2f9fe Merge pull request #27709 from Catfish-Man/bridge-to-the-future
Optimize accessing Swift arrays via ObjC
2019-10-23 00:19:06 -07:00
David Smith
d9cef0afef Optimize accessing Swift Arrays from ObjC 2019-10-22 20:57:36 -07:00
Julian Lettner
e819acdc29 Merge pull request #27808 from apple/tsan-empty-array-storage
[TSan] Do not report benign race on `_swiftEmptyArrayStorage`
2019-10-21 18:39:36 -07:00
David Smith
282e0c858b Merge pull request #27826 from Catfish-Man/last-object-standing
Bridging fidelity: allow removeLastObject() on empty NSMutableArrays
2019-10-21 18:32:24 -07:00
David Smith
da6adc8ba2 Bridging fidelity: allow removeLastObject() on empty NSMutableArrays 2019-10-21 17:20:32 -07:00
Julian Lettner
381dcc24fc [TSan] Do not report benign race on _swiftEmptyArrayStorage
A previous commit [1] identified and fixed a benign race on
`_swiftEmptyArrayStorage`.  Unfortunately, we have some code duplication
and the fix was not applied to all the necessary places.  Essentially,
we need to ensure that the "empty array storage" object that backs many
"array like types" is never written to.

I tried to improve the test to capture this, however, it is very
finicky.  Currently, it does not go red on my system even when I remove
the check to avoid the benign race in Release mode.

Relevant classes: Array, ArraySlice, ContiguousArray, ArrayBuffer,
ContiguousArrayBuffer, SliceBuffer.

[1] b9b4c789f3

rdar://55161564
2019-10-21 11:22:25 -07:00
David Smith
a1c1779c9f Guard against passing endIndex to foreignScalarAlign when back-deploying to 5.0 stdlibs 2019-10-18 14:24:23 -07:00
swift-ci
a91d4aaa52 Merge pull request #27670 from Catfish-Man/fastscii-2 2019-10-15 18:39:45 -07:00
David Smith
007ff00617 Add fast paths for String(decoding:…, as: Unicode.ASCII.self) 2019-10-15 17:26:23 -07:00
Dan Zheng
2bd55f6755 [Autodiff upstream] Add build-script flag for differentiable programming. (#27595)
Add `--enable-experimental-differentiable-programming` build-script flag.

The build-script flag enables/disables standard library additions
related to differentiable programming. This will allow official Swift
releases to disable these additions.

The build-script flag is on by default to ensure testing of
differentiable programming standard library additions. An additional
driver flag must be enabled to use differentiable programming features:
https://github.com/apple/swift/pull/27446
2019-10-14 14:34:48 -07:00
David Smith
3d321c1905 Fix the new Swift NSMutableArray subclass to match edge case behavior in two more cases 2019-10-02 15:47:51 -07:00
own2pwn
3ec5e76ee3 Update FloatingPointTypes.swift.gyb (#27461)
Corrects intent that this type seems to be available only on MacOS targets.
2019-10-02 15:41:42 -04:00
swift-ci
d1c87f3c93 Merge pull request #24270 from natecook1000/nc_lazyscan_fix 2019-09-28 20:53:45 -07:00
Nate Cook
f6547cc828 Address feedback from @amartini51. 2019-09-26 13:25:15 -05:00
David Smith
1cce12f20c Add an Array-based NSMutableArray subclass 2019-09-24 18:15:33 -07:00