Skip to content

Commit 90b06be

Browse files
authored
Merge pull request #10 from apple/master
merge
2 parents 9274bd1 + 9be60dd commit 90b06be

File tree

1,297 files changed

+45000
-94819
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,297 files changed

+45000
-94819
lines changed

CHANGELOG.md

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
| Contents |
88
| :--------------------- |
9+
| [Swift 5.0](#swift-50) |
910
| [Swift 4.2](#swift-42) |
1011
| [Swift 4.1](#swift-41) |
1112
| [Swift 4.0](#swift-40) |
@@ -20,9 +21,61 @@ CHANGELOG
2021

2122
</details>
2223

24+
Swift 5.0
25+
---------
26+
27+
- [SR-419][]
28+
29+
In Swift 5 mode, when setting a property from within its own `didSet` or `willSet` observer, the observer will now only avoid being recursively called if the property is set on `self` (either implicitly or explicitly).
30+
31+
For example:
32+
```swift
33+
class Node {
34+
var children = [Node]()
35+
36+
var depth: Int {
37+
didSet {
38+
if depth < 0 {
39+
// Will not recursively call didSet, as setting depth on self (same
40+
// with `self.depth = 0`).
41+
depth = 0
42+
}
43+
44+
// Will call didSet for each of the children, as we're not setting the
45+
// property on self (prior to Swift 5, this did not trigger property
46+
// observers to be called again).
47+
for child in children {
48+
child.depth = depth + 1
49+
}
50+
}
51+
}
52+
53+
init(depth: Int) {
54+
self.depth = depth
55+
}
56+
}
57+
```
58+
59+
**Add new entries to the top of this section, not here!**
60+
2361
Swift 4.2
2462
---------
2563

64+
* The C `long double` type is now imported as `Float80` on i386 and x86_64
65+
macOS and Linux. The tgmath functions in the Darwin and glibc modules now
66+
 support `Float80` as well as `Float` and `Double`. Several tgmath
67+
functions have been made generic over `[Binary]FloatingPoint` so that they
68+
will automatically be available for any conforming type.
69+
70+
* [SE-0143][]
71+
72+
The standard library types `Optional`, `Array`, `ArraySlice`,
73+
`ContiguousArray`, `Dictionary`, `DictionaryLiteral`, `Range`, and
74+
`ClosedRange` now conform to the `Hashable` protocol when their element or
75+
bound types (as the case may be) conform to `Hashable`. This makes
76+
synthesized `Hashable` implementations available for types that include stored
77+
properties of these types.
78+
2679
* [SE-0196][]
2780

2881
Custom compile-time warnings or error messages can be emitted using the
@@ -55,7 +108,7 @@ Swift 4.2
55108
conditionally conforms to `P`, will succeed when the conditional
56109
requirements are met.
57110

58-
**Add new entries to the top of this file, not here!**
111+
**Add new entries to the top of this section, not here!**
59112

60113
Swift 4.1
61114
---------
@@ -114,12 +167,12 @@ Swift 4.1
114167
s[keyPath: p] // "H"
115168
```
116169

117-
* [SE-0143][] The standard library types `Optional`, `Array`, and
118-
`Dictionary` now conform to the `Equatable` protocol when their element types
119-
conform to `Equatable`. This allows the `==` operator to compose (e.g., one
120-
can compare two values of type `[Int : [Int?]?]` with `==`), as well as use
121-
various algorthims defined for `Equatable` element types, such as
122-
`index(of:)`.
170+
* [SE-0143][] The standard library types `Optional`, `Array`, `ArraySlice`,
171+
`ContiguousArray`, and `Dictionary` now conform to the `Equatable` protocol
172+
when their element types conform to `Equatable`. This allows the `==` operator
173+
to compose (e.g., one can compare two values of type `[Int : [Int?]?]` with
174+
`==`), as well as use various algorithms defined for `Equatable` element
175+
types, such as `index(of:)`.
123176

124177
* [SE-0157][] is implemented. Associated types can now declare "recursive"
125178
constraints, which require that the associated type conform to the enclosing
@@ -276,7 +329,7 @@ Swift 4.0
276329
CFHash and CFEqual as the implementation. This change applies even to "Swift
277330
3 mode", so if you were previously adding this conformance yourself, use
278331
`#if swift(>=3.2)` to restrict the extension to Swift 3.1 and below.
279-
([SR-2388](https://bugs.swift.org/browse/SR-2388))
332+
([SR-2388][])
280333

281334
* [SE-0156][]
282335

@@ -425,7 +478,7 @@ Swift 4.0
425478
slice[i..<j] = buffer[k..<l]
426479
```
427480

428-
* [SR-1529](https://bugs.swift.org/browse/SR-1529):
481+
* [SR-1529][]:
429482

430483
Covariant method overrides are now fully supported, fixing many crashes
431484
and compile-time assertions when defining or calling such methods.
@@ -508,7 +561,7 @@ Swift 3.1
508561
side effects, leading to bugs when Swift code attempted to override
509562
`initialize`.
510563

511-
* [SR-2394](https://bugs.swift.org/browse/SR-2394)
564+
* [SR-2394][]
512565

513566
C functions that "return twice" are no longer imported into Swift. Instead,
514567
they are explicitly made unavailable, so attempting to reference them will
@@ -585,7 +638,7 @@ Swift 3.1
585638
is not guaranteed to work in future versions of Swift, and will
586639
now raise a warning.
587640

588-
* [SR-1446](https://bugs.swift.org/browse/SR-1446)
641+
* [SR-1446][]
589642

590643
Nested types may now appear inside generic types, and nested types may have their own generic parameters:
591644

@@ -605,7 +658,7 @@ Swift 3.1
605658
extension OuterGeneric.InnerGeneric {}
606659
```
607660

608-
* [SR-1009](https://bugs.swift.org/browse/SR-1009):
661+
* [SR-1009][]:
609662

610663
Constrained extensions allow same-type constraints between generic parameters and concrete types. This enables you to create extensions, for example, on `Array` with `Int` elements:
611664

@@ -827,7 +880,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
827880
var x2 = p as! [Int]
828881
```
829882

830-
* [SR-2131](https://bugs.swift.org/browse/SR-2131):
883+
* [SR-2131][]:
831884

832885
The `hasPrefix` and `hasSuffix` functions now consider the empty string to be a prefix and suffix of all strings.
833886

@@ -6915,3 +6968,11 @@ Swift 1.0
69156968
[SE-0197]: <https://github.com/apple/swift-evolution/blob/master/proposals/0197-remove-where.md>
69166969
[SE-0198]: <https://github.com/apple/swift-evolution/blob/master/proposals/0198-playground-quicklook-api-revamp.md>
69176970
[SE-0199]: <https://github.com/apple/swift-evolution/blob/master/proposals/0199-bool-toggle.md>
6971+
6972+
[SR-419]: <https://bugs.swift.org/browse/SR-419>
6973+
[SR-1009]: <https://bugs.swift.org/browse/SR-1009>
6974+
[SR-1446]: <https://bugs.swift.org/browse/SR-1446>
6975+
[SR-1529]: <https://bugs.swift.org/browse/SR-1529>
6976+
[SR-2131]: <https://bugs.swift.org/browse/SR-2131>
6977+
[SR-2388]: <https://bugs.swift.org/browse/SR-2388>
6978+
[SR-2394]: <https://bugs.swift.org/browse/SR-2394>

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ option(SWIFT_STDLIB_ENABLE_SIL_OWNERSHIP
305305

306306
option(SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
307307
"Build the standard libraries, overlays, and runtime with normal arguments at +0"
308-
FALSE)
308+
TRUE)
309309

310310
option(SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS
311311
"Enable runtime function counters and expose the API."

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ supported host development operating systems.
5454

5555
#### macOS
5656

57-
To build for macOS, you need [Xcode 9.3 beta](https://developer.apple.com/xcode/downloads/).
57+
To build for macOS, you need [Xcode 9.3](https://developer.apple.com/xcode/downloads/).
5858
The required version of Xcode changes frequently, and is often a beta release.
5959
Check this document or the host information on <https://ci.swift.org> for the
6060
current required version.
@@ -76,7 +76,7 @@ Instructions for installing CMake and Ninja directly can be found [below](#build
7676

7777
For Ubuntu, you'll need the following development dependencies:
7878

79-
sudo apt-get install git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev autoconf libtool systemtap-sdt-dev tzdata
79+
sudo apt-get install git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev autoconf libtool systemtap-sdt-dev tzdata rsync
8080

8181
**Note:** LLDB currently requires at least `swig-1.3.40` but will successfully build
8282
with version 2 shipped with Ubuntu.

benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ set(SWIFT_BENCH_MODULES
4949
single-source/CSVParsing
5050
single-source/Calculator
5151
single-source/CaptureProp
52+
single-source/ChainedFilterMap
5253
single-source/CharacterLiteralsLarge
5354
single-source/CharacterLiteralsSmall
5455
single-source/CharacterProperties

benchmark/scripts/Benchmark_Driver

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ def run_benchmarks(driver, benchmarks=[], num_samples=10, verbose=False,
192192
compatible with `parse_results`. If `benchmarks` is not empty,
193193
only run tests included in it.
194194
"""
195+
# Set a constant hash seed. Some tests are currently sensitive to
196+
# fluctuations in the number of hash collisions.
197+
#
198+
# FIXME: This should only be set in the environment of the child process
199+
# that runs the tests.
200+
os.environ["SWIFT_DETERMINISTIC_HASHING"] = "1"
201+
195202
(total_tests, total_min, total_max, total_mean) = (0, 0, 0, 0)
196203
output = []
197204
headings = ['#', 'TEST', 'SAMPLES', 'MIN(μs)', 'MAX(μs)', 'MEAN(μs)',

benchmark/scripts/Benchmark_QuickCheck.in

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ class QuickCheckResult(perf_test_driver.Result):
4141

4242
class QuickCheckBenchmarkDriver(perf_test_driver.BenchmarkDriver):
4343

44-
def __init__(self, binary, xfail_list, num_iters):
44+
def __init__(self, binary, xfail_list, num_iters, opt_levels):
4545
perf_test_driver.BenchmarkDriver.__init__(
4646
self, binary, xfail_list,
47-
enable_parallel=True)
47+
enable_parallel=True,
48+
opt_levels=opt_levels)
4849
self.num_iters = num_iters
4950

5051
def print_data_header(self, max_test_len):
51-
fmt = '{:<%d}{:<10}{:}' % (max_test_len + 5)
52-
print(fmt.format('Name', 'Result', 'RC Delta'))
52+
fmt = '{:<%d}{:<10}' % (max_test_len + 5)
53+
print(fmt.format('Name', 'Result'))
5354

5455
# Propagate any data from this class that is needed for individual
5556
# tests. The reason this is needed is to avoid issues with attempting to
@@ -99,15 +100,21 @@ def parse_args():
99100
import argparse
100101
parser = argparse.ArgumentParser()
101102
parser.add_argument(
102-
'-filter', type=str, default=None,
103+
'--filter', type=str, default=None,
103104
help='Filter out any test that does not match the given regex')
104-
parser.add_argument('-num-iters', type=int, default=2)
105+
parser.add_argument('--num-iters', type=int, default=2)
106+
default_opt_levels = perf_test_driver.BenchmarkDriver_OptLevels
107+
parser.add_argument('--opt-level', choices=default_opt_levels)
105108
return parser.parse_args()
106109

107110

108111
if __name__ == "__main__":
109112
args = parse_args()
110-
l = QuickCheckBenchmarkDriver(SWIFT_BIN_DIR, XFAIL_LIST, args.num_iters)
113+
opt_levels = perf_test_driver.BenchmarkDriver_OptLevels
114+
if args.opt_level is not None:
115+
opt_levels = [args.opt_level]
116+
l = QuickCheckBenchmarkDriver(SWIFT_BIN_DIR, XFAIL_LIST, args.num_iters,
117+
opt_levels)
111118
if l.run(args.filter):
112119
sys.exit(0)
113120
else:
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import TestsUtils
2+
3+
public var ChainedFilterMap = [
4+
BenchmarkInfo(name: "ChainedFilterMap", runFunction: run_ChainedFilterMap, tags: [.algorithm]),
5+
BenchmarkInfo(name: "FatCompactMap", runFunction: run_FatCompactMap, tags: [.algorithm])
6+
]
7+
8+
public let first100k = Array(0...100_000-1)
9+
10+
@inline(never)
11+
public func run_ChainedFilterMap(_ N: Int) {
12+
var result = 0
13+
for _ in 1...10*N {
14+
let numbers = first100k.lazy
15+
.filter { $0 % 3 == 0 }
16+
.map { $0 * 2 }
17+
.filter { $0 % 8 == 0 }
18+
.map { $0 / 2 + 1}
19+
result = numbers.reduce(into: 0) { $0 += $1 }
20+
}
21+
22+
CheckResults(result == 416691666)
23+
}
24+
25+
@inline(never)
26+
public func run_FatCompactMap(_ N: Int) {
27+
var result = 0
28+
for _ in 1...10*N {
29+
let numbers = first100k.lazy
30+
.compactMap { (x: Int) -> Int? in
31+
if x % 3 != 0 { return nil }
32+
let y = x * 2
33+
if y % 8 != 0 { return nil }
34+
let z = y / 2 + 1
35+
return z
36+
}
37+
result = numbers.reduce(into: 0) { $0 += $1 }
38+
}
39+
CheckResults(result == 416691666)
40+
}

benchmark/single-source/PopFrontGeneric.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let arrayCount = 1024
2222

2323
// This test case exposes rdar://17440222 which caused rdar://17974483 (popFront
2424
// being really slow).
25-
@_versioned
25+
@usableFromInline
2626
protocol MyArrayBufferProtocol : MutableCollection, RandomAccessCollection {
2727
mutating func myReplace<C>(
2828
_ subRange: Range<Int>,

benchmark/single-source/Queue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public let QueueConcrete = BenchmarkInfo(
2828

2929
// TODO: remove when there is a native equivalent in the std lib
3030
extension RangeReplaceableCollection where Self: BidirectionalCollection {
31-
@_inlineable
31+
@inlinable
3232
public mutating func popLast() -> Element? {
3333
if isEmpty { return nil}
3434
else { return removeLast() }

0 commit comments

Comments
 (0)