Commit Graph

6693 Commits

Author SHA1 Message Date
Richard Wei
39d0827ec4 Fix typo in 'KeyedEncodingContainer.superEncoder' documentation. (#32252)
"returns A new encoder" -> "returns a new encoder"

Resolves rdar://64136400.
2020-06-08 19:25:58 -07:00
Nate Chandler
8ec75d4933 [metadata prespecialization] Support classes with non-generic ancestors.
Previously, metadata prespecialization for classes only occurred when
all of a specialized generic class's ancestors were themselves generic.
Here, that requirement is lifted so that generic classes with concrete
ancestors are also eligible for prespecialization.
2020-06-08 14:57:50 -07:00
Erik Eckstein
f0711367b5 stdlib: temporarily disable COW support runtime checks.
Some lldb tests are failing with that.
2020-06-08 20:27:37 +02:00
Erik Eckstein
71a642e51b stdlib, SIL optimizer: use the SIL copy-on-write representation in the Array types.
Use the new builtins for COW representation in Array, ContiguousArray and ArraySlice.
The basic idea is to strictly separate code which mutates an array buffer from code which reads from an array.
The concept is explained in more detail in docs/SIL.rst, section "Copy-on-Write Representation".

The main change is to use beginCOWMutation() instead of isUniquelyReferenced() and insert endCOWMutation() at the end of all mutating functions. Also, reading from the array buffer must be done differently, depending on if the buffer is in a mutable or immutable state.

All the required invariants are enforced by runtime checks - but only in an assert-build of the library: a bit in the buffer object side-table indicates if the buffer is mutable or not.

Along with the library changes, also two optimizations needed to be updated: COWArrayOpt and ObjectOutliner.
2020-06-08 15:02:22 +02:00
Erik Eckstein
3bfebf10f7 runtime lib: a mechanism to set an "immutable" flag on an object for COW buffer runtime checking.
In an assert built of the library, store an extra boolean flag (isImmutable) in the object side-buffer table.
This flag can be set and get by the Array implementation to sanity check the immutability status of the buffer object.
2020-06-08 15:01:29 +02:00
Erik Eckstein
1559fe333f SIL: a new library intrinsic to "finalize" array literals
For COW support in SIL it's required to "finalize" array literals.
_finalizeUninitializedArray is a compiler known stdlib function which is called after all elements of an array literal are stored.
This runtime function marks the array literal as finished.

  %uninitialized_result_tuple = apply %_allocateUninitializedArray(%count)
  %mutable_array = tuple_extract %uninitialized_result_tuple, 0
  %elem_base_address = tuple_extract %uninitialized_result_tuple, 1
  ...
  store %elem_0 to %elem_addr_0
  store %elem_1 to %elem_addr_1
  ...
  %final_array = apply %_finalizeUninitializedArray(%mutable_array)

In this commit _finalizeUninitializedArray is still a no-op because the COW support is not used in the Array implementation yet.
2020-06-08 10:24:29 +02:00
Xiaodi Wu
a99d7ea849 Merge pull request #31333 from valeriyvan/_applyMappingUnicodeScalarProperties
Refactors internal func _applyMapping using _FixedArray16
2020-06-04 16:35:02 -04:00
swift-ci
66311e1ea2 Merge pull request #32115 from eunjiChung/example-result 2020-06-04 08:07:24 -07:00
eunjiChung
ffe471ada8 [stdlib] Add flatMap example in Result.swift 2020-06-04 21:39:12 +09:00
Anthony Latsis
84d376ae77 Merge pull request #32117 from AnthonyLatsis/redundant-generic-param
[NFC] stdlib: Drop a redundant generic parameter
2020-06-03 17:42:17 +03:00
Saleem Abdulrasool
68a5343273 Merge pull request #32109 from compnerd/behold-the-future
Python 2/3 compat: gyb, gyb_sourcekit_support, gyb_syntax_support, li…
2020-06-01 14:17:51 -07:00
Anthony Latsis
c4690aa467 stdlib: Drop a redundant generic parameter 2020-06-01 14:01:22 +03:00
Saleem Abdulrasool
23f2d34272 stdlib: make the FloatingPoint GYB Python3 friendly 2020-05-31 14:23:07 -07:00
Gwynne Raskind
2127cbf5e8 Python 2/3 compat: Swift stdlib 2020-05-31 14:23:07 -07:00
eunjiChung
cf9fcb975d [stdlib] Add flatMap example in Result.swift 2020-05-31 17:43:22 +09:00
Saleem Abdulrasool
fb58228f62 runtime: extract swiftDemangling into a support library
`swiftDemangling` was built three times:
1. swiftc
2. swiftRuntime
3. swiftReflection

Fold the last two instances into a single build, sharing the objects
across both the target libraries.  This ensures that `swiftDemangling`
is built with the same compiler as the target libraries and that the
target library build remains self-contained.
2020-05-30 12:26:57 -07:00
Joe Groff
124808ddb6 Merge pull request #32088 from jckarter/final-keypath-methods
Make an internal KeyPath helper final.
2020-05-29 18:44:56 -07:00
Erik Eckstein
68728dcb7d stdlib: move the new-buffer creation function from Array to ArrayBuffer
This has two advantages:
1. It does not force the Array in memory (to pass it as inout self to the non-inlinable _createNewBuffer).
2. The new _consumeAndCreateNew is annotated to consume self. This helps to reduce unnecessary retains/releases.

The change applies for Array and ContiguousArray.
2020-05-29 08:46:54 +02:00
Erik Eckstein
f6ec448583 stdlib: Prevent storing into the empty array singleton when replacing an array sub-sequence.
In the corner case of a 0 sized replacement in an empty array, we did write the 0 count back to the array singleton.
This is not a big problem right now, because it would just overwrite a 0 with a 0, but it shouldn't be done.
But with COW representation in Array, it would break the sanity checks.
2020-05-29 08:46:54 +02:00
Erik Eckstein
93ff8b0d96 stdlib: make sure that SetAlgebra.init(sequence) is on the fast path.
In order to fully optimize OptionSet literals, it's important that this function is inlined and fully optimized.
So far this was done by chance, but with COW representation it needs a hint to the optimizer.
2020-05-29 08:46:54 +02:00
Joe Groff
be8674ea73 Make an internal KeyPath helper final.
And remove an unnecessary override, so that further work will allow this method not to need a
vtable entry.
2020-05-28 18:19:03 -07:00
Robert Widmann
b78bd2e061 Merge pull request #31911 from valeriyvan/FixRangeReplaceableCollectionFilter
[SR-12648] Fixes filter function of RangeReplaceableCollection.
2020-05-28 10:58:22 -07:00
Ben Cohen
5ec1e3ed7b Refactor Mirror to reduce metadata allocation (#32041)
- Refactor Mirror.descendents

- Add _Either sequence

- Create custom reflected children type

- Switch Mirror to use _Either
2020-05-28 10:51:57 -07:00
Valeriy Van
04e6373f28 Removes redundant buffer zeroing in lowercased() and uppercased() 2020-05-27 22:24:17 +02:00
NevinBR
e146d3f626 Changed @inlinable to @_alwaysEmitIntoClient 2020-05-26 16:23:08 -04:00
NevinBR
6ce51ed1ac Update stdlib/public/core/Indices.swift
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2020-05-26 16:22:32 -04:00
NevinBR
e99b6463ea Update stdlib/public/core/Indices.swift
Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>
2020-05-26 12:46:18 -04:00
NevinBR
55b1a4d0a8 Update stdlib/public/core/Indices.swift
Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>
2020-05-26 12:45:58 -04:00
NevinBR
2857ec9496 [SR-12881] DefaultIndices dynamic dispatch
As seen in SR-12881, `DefaultIndices` was not properly dispatching certain `Collection` requirements through conditional conformances to `BidirectionalCollection` and `RandomAccessCollection`.  This should fix that.
2020-05-26 10:55:31 -04:00
Valeriy Van
b5392e8fb3 Refactors internal func _applyMapping using _FixedArray16 2020-05-26 02:00:30 +02:00
Alex Binary
7ea09a9032 Fix comments on _compactMap(_:) 2020-05-24 10:59:47 +02:00
Wowbagger and his liquid lunch
f8c58036a4 fix typo in remove(_:)'s documentation
"newMember" → "member"
2020-05-22 16:17:34 -04:00
Ben Cohen
e67e8ab0b2 Prespecialize common metadata (#31925) 2020-05-21 03:50:34 -07:00
Valeriy Van
a0b6517272 Fixes filter function of RangeReplaceableCollection. Addresses ticket SR-12648 2020-05-20 14:08:26 +02:00
Gwynne Raskind
3ae3a7b459 Restore documentation for the pattern-matching operator as applied to RangeExpressions
The previous documentation of this operator in `Range` context was lost sometime during 2017. This new version is a simplified version of the original copy, with substantial inspiration taken from the present-day documentation of the same operator on `Optional`.

Fixes [SR-12842](https://bugs.swift.org/browse/SR-12842).
2020-05-20 03:46:48 -05:00
Saleem Abdulrasool
1e74c202ef build: optimize the build of LLVMSupport
Rather than build multiple copies of LLVMSupport (4x!) build it one and
merge it into the various targets.  This would ideally not be needed to
be named explicitly everywhere, but that requires using `add_library`
rather than `add_swift_target_library`.
2020-05-19 17:04:59 +00:00
Meghana Gupta
0a77ce33b2 Remove @inline(always) from Array's nonNative getter
This forces it to be inlined even in cold paths
2020-05-18 14:36:20 -07:00
Meghana Gupta
a461a48862 stdlib: Make non-native ArrayBuffer.capacity smaller
Similar to #28486 in motivation.
Before this change 'count' got lowered to multiple 'endIndex' calls

Fixes rdar://46702232
2020-05-18 13:17:57 -07:00
Robert Widmann
616a787c6b Merge pull request #31797 from valeriyvan/FixExampleSnippetsSet.swift
Fix example snippets Set.swift
2020-05-15 14:16:46 -07:00
Valeriy Van
d57cbce3c0 Fixes example snippets in Set.swift 2020-05-15 06:55:07 +02:00
Robert Widmann
43d1ba9ed9 [Gardening] Shepherd a Fix To SetAlgebra Docs 2020-05-14 11:50:35 -07:00
Alex Martini
710897852a Remove stray backtick in doc comment.
Fixes <rdar://problem/63195315>
2020-05-13 13:11:29 -07:00
Valeriy Van
d6b2d06420 Fixes snippet 2020-05-12 13:51:54 +02:00
Valeriy Van
b59e689b95 Fixes example snippets in FloatingPoint.swift
In terms of Swift [-9.5, 2.5, 3.0, 21.25, .nan] != [-9.5, 2.5, 3.0, 21.25, .nan] because Double.nan != Double.nan
2020-05-12 13:47:03 +02:00
Valeriy Van
68ee82c132 Fixes example snippet in Slice.swift 2020-05-11 23:42:24 +02:00
Ben Rimmington
ff264da966 [stdlib] Remove unneeded numericCasts 2020-05-08 06:03:49 +01:00
Joe Groff
c5863ac0f3 SILOptimizer: Constant fold the _kvcKeyPathString of literal key paths.
Eliminate the intermediate key path object when a literal key path is passed to a function that
just wants its KVC string to pass down to an ObjC API.
2020-05-07 13:33:01 -07:00
Valeriy Van
9f2e196db0 Fixes example snippets in FloatingPoint.swift 2020-05-05 23:19:09 +02:00
Robert Widmann
23fdde73ac Merge pull request #31499 from valeriyvan/FixExampleSnippetResult.swift
Fixes example snippet in Result.swift
2020-05-04 11:36:04 -07:00
Valeriy Van
5669dbc9d9 Fixes example snippets in UTF16.swift (#31520) 2020-05-04 12:52:46 -05:00