Commit Graph

6024 Commits

Author SHA1 Message Date
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
Stephen Canon
7985896949 Provide an implementation of init?<T:BinaryInteger>(exactly:T) on each stdlib FP type. (#32632)
Previously these always went through the FloatingPoint-provided default implementation, which is not particularly efficient. Also try removing inlinable from the generic _convert hooks, since we probably never want to actually inline them.
2020-06-30 20:59:31 -04:00
Károly Lőrentey
c579759aa7 [stdlib] Use a direct initializer for typed to raw pointer conversion 2020-06-29 19:16:23 -07:00
swift-ci
e25934fa4b Merge pull request #32451 from stephencelis/patch-1 2020-06-28 10:45:46 -07:00
Alex Martini
a3a20d923b Use a shorter example string. (#32557)
Fixes <rdar://problem/64180813>.
2020-06-26 14:18:27 -05:00
Ben Cohen
87df9961a5 Add fast string interpolation for metatypes (#32113) 2020-06-26 09:46:54 -07:00
Mishal Shah
272c466e47 Update master to build with Xcode 12 beta 2020-06-22 15:43:20 -07:00
Robert Widmann
a3b093a8bc Merge pull request #32486 from valeriyvan/FixExampleSnippetSequence
[stdlib] Fixes example snippet in Sequence.swift
2020-06-22 12:42:05 -07:00
Valeriy Van
1560d65561 Fixes example snippet in Sequence.swift 2020-06-21 22:54:00 +02:00
Stephen Celis
e150b377f9 Others 2020-06-19 08:07:25 -04:00
Stephen Celis
3b8d8b776e Update Collection.swift 2020-06-18 15:44:33 -04:00
Stephen Celis
0ce01d5dfe Update Collection.swift 2020-06-18 15:42:22 -04:00
Stephen Celis
ce78396eef Update stdlib/public/core/Collection.swift
Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>
2020-06-18 15:41:35 -04:00
Stephen Celis
099ecbe0b0 Improve performance of Collection.removeFirst(_:) where Self == SubSequence 2020-06-18 15:29:45 -04:00
Valeriy Van
dd237b984b Eliminates redundant buffer zeroing in internal func in UnicodeScalarProperties by using init(unsafeUninitializedCapacity:initializingWith:) 2020-06-11 12:51:18 +02:00
Brian Gontowski
0e7749bcde Fixed comment 2020-06-11 15:11:07 +09:00
Brian Gontowski
3425a6dbb1 Added protocol to support CVarArg objects that need to be retained 2020-06-11 14:45:00 +09:00
nate-chandler
7c5a5e5041 Merge pull request #32174 from nate-chandler/generic-metadata-prespecialization-components/classes-nongeneric-superclasses
[metadata prespecialization] Support classes with non-generic ancestors.
2020-06-09 09:25:21 -07:00
Xiaodi Wu
1888534d22 Merge pull request #30895 from valeriyvan/RemoveRedundantZeroingString
Removes redundant buffer zeroing in lowercased() and uppercased() by using `init(unsafeUninitializedCapacity:initializingWith:)
2020-06-09 09:42:51 -04:00
eeckstein
291373f82a Merge pull request #32134 from eeckstein/cow-support2
stdlib, SIL optimizer: use the SIL copy-on-write representation in the Array types.
2020-06-09 08:45:12 +02:00
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