Skip to content

Commit 4ba4030

Browse files
authored
---
yaml --- r: 343503 b: refs/heads/master-rebranch c: 52782cf h: refs/heads/master i: 343501: 4e9c019 343499: 512310b 343495: eabe9e0 343487: 017a73a
1 parent 99a3586 commit 4ba4030

File tree

335 files changed

+9187
-7867
lines changed

Some content is hidden

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

335 files changed

+9187
-7867
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: 48a4ddae8b7a0eb54ad9d6a56fe9160dd7d0d597
1458+
refs/heads/master-rebranch: 52782cfd4ea584a1904f9650d51931d3799ea939
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ CHANGELOG
2626
Swift Next
2727
----------
2828

29+
* [SE-0253][]:
30+
31+
Values of types that declare `func callAsFunction` methods can be called
32+
like functions. The call syntax is shorthand for applying
33+
`func callAsFunction` methods.
34+
35+
```swift
36+
struct Adder {
37+
var base: Int
38+
func callAsFunction(_ x: Int) -> Int {
39+
return x + base
40+
}
41+
}
42+
var adder = Adder(base: 3)
43+
adder(10) // returns 13, same as `adder.callAsFunction(10)`
44+
```
45+
46+
* `func callAsFunction` argument labels are required at call sites.
47+
* Multiple `func callAsFunction` methods on a single type are supported.
48+
* `mutating func callAsFunction` is supported.
49+
* `func callAsFunction` works with `throws` and `rethrows`.
50+
* `func callAsFunction` works with trailing closures.
51+
2952
* [SR-4206][]:
3053

3154
A method override is no longer allowed to have a generic signature with
@@ -7711,6 +7734,7 @@ Swift 1.0
77117734
[SE-0244]: <https://github.com/apple/swift-evolution/blob/master/proposals/0244-opaque-result-types.md>
77127735
[SE-0245]: <https://github.com/apple/swift-evolution/blob/master/proposals/0245-array-uninitialized-initializer.md>
77137736
[SE-0252]: <https://github.com/apple/swift-evolution/blob/master/proposals/0252-keypath-dynamic-member-lookup.md>
7737+
[SE-0253]: <https://github.com/apple/swift-evolution/blob/master/proposals/0253-callable.md>
77147738
[SE-0254]: <https://github.com/apple/swift-evolution/blob/master/proposals/0254-static-subscripts.md>
77157739

77167740
[SR-106]: <https://bugs.swift.org/browse/SR-106>

branches/master-rebranch/benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ set(SWIFT_BENCH_MODULES
8787
single-source/Exclusivity
8888
single-source/ExistentialPerformance
8989
single-source/Fibonacci
90+
single-source/FindStringNaive
9091
single-source/FlattenList
9192
single-source/FloatingPointParsing
9293
single-source/FloatingPointPrinting
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
//===--- FindStringNaive.swift --------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import TestsUtils
14+
15+
// Mini benchmark implementing a naive String search algorithm that
16+
// at the moment shows a lot of ARC traffic.
17+
let t: [BenchmarkCategory] = [.String, .refcount]
18+
let N = 100
19+
20+
var longStringFoFoFoFox: String?
21+
var longArrayFoFoFoFox: [UInt8]?
22+
23+
public let FindStringNaive = [
24+
BenchmarkInfo(
25+
name: "FindString.Loop1.Substring",
26+
runFunction: runBenchLoop1Substring,
27+
tags: t,
28+
setUpFunction: {
29+
longStringFoFoFoFox = String(repeating: "fo", count: 5_000) + "fox <-- needle"
30+
}),
31+
BenchmarkInfo(
32+
name: "FindString.Rec3.String",
33+
runFunction: runBenchRecursive3String,
34+
tags: t,
35+
setUpFunction: {
36+
longStringFoFoFoFox = String(repeating: "fo", count: 500) + "fox <-- needle"
37+
}),
38+
BenchmarkInfo(
39+
name: "FindString.Rec3.Substring",
40+
runFunction: runBenchRecursive3Substring,
41+
tags: t,
42+
setUpFunction: {
43+
longStringFoFoFoFox = String(repeating: "fo", count: 500) + "fox <-- needle"
44+
}),
45+
BenchmarkInfo(
46+
name: "FindString.Loop1.Array",
47+
runFunction: runBenchLoop1Array,
48+
tags: t,
49+
setUpFunction: {
50+
longArrayFoFoFoFox = []
51+
longArrayFoFoFoFox!.reserveCapacity(1_100_000)
52+
for _ in 0 ..< 500_000 {
53+
longArrayFoFoFoFox!.append(contentsOf: "fo".utf8)
54+
}
55+
longArrayFoFoFoFox!.append(contentsOf: "fox <-- needle".utf8)
56+
}),
57+
BenchmarkInfo(
58+
name: "FindString.Rec3.Array",
59+
runFunction: runBenchRecursive3ArrayOfUTF8,
60+
tags: t,
61+
setUpFunction: {
62+
longArrayFoFoFoFox = []
63+
longArrayFoFoFoFox!.reserveCapacity(11_000)
64+
for _ in 0 ..< 5_000 {
65+
longArrayFoFoFoFox!.append(contentsOf: "fo".utf8)
66+
}
67+
longArrayFoFoFoFox!.append(contentsOf: "fox <-- needle".utf8)
68+
}),
69+
]
70+
71+
func findOne<S: StringProtocol>(
72+
_ string: S,
73+
needle: Character
74+
) -> String.Index? {
75+
var index = string.startIndex
76+
while index < string.endIndex {
77+
let nextIndex = string.index(after: index)
78+
if string[index] == needle {
79+
return index
80+
}
81+
index = nextIndex
82+
}
83+
return nil
84+
}
85+
86+
func findThreeRecursive<S: StringProtocol>(
87+
_ string: S,
88+
needle1: Character,
89+
needle2: Character?,
90+
needle3: Character?
91+
) -> String.Index? {
92+
var index = string.startIndex
93+
while index < string.endIndex {
94+
let nextIndex = string.index(after: index)
95+
if string[index] == needle1 {
96+
// Check subsequent needles recursively (if applicable)
97+
guard let needle2 = needle2 else { return index }
98+
99+
if findThreeRecursive(
100+
string[nextIndex...].prefix(2), needle1: needle2, needle2: needle3, needle3: nil
101+
) == nextIndex {
102+
return index
103+
}
104+
}
105+
index = nextIndex
106+
}
107+
return nil
108+
}
109+
110+
func findOneOnUTF8Collection<Bytes: Collection>(
111+
_ string: Bytes,
112+
needle: UInt8
113+
) -> Bytes.Index? where Bytes.Element == UInt8 {
114+
var index = string.startIndex
115+
while index < string.endIndex {
116+
let nextIndex = string.index(after: index)
117+
if string[index] == needle {
118+
return index
119+
}
120+
index = nextIndex
121+
}
122+
return nil
123+
}
124+
125+
func findThreeOnUTF8Collection<Bytes: Collection>(
126+
_ string: Bytes,
127+
needle1: UInt8,
128+
needle2: UInt8?,
129+
needle3: UInt8?
130+
) -> Bytes.Index? where Bytes.Element == UInt8 {
131+
var index = string.startIndex
132+
while index < string.endIndex {
133+
let nextIndex = string.index(after: index)
134+
if string[index] == needle1 {
135+
// Check subsequent needles recursively (if applicable)
136+
guard let needle2 = needle2 else { return index }
137+
138+
if findThreeOnUTF8Collection(
139+
string[nextIndex...].prefix(2), needle1: needle2, needle2: needle3, needle3: nil
140+
) == nextIndex {
141+
return index
142+
}
143+
}
144+
index = nextIndex
145+
}
146+
return nil
147+
}
148+
149+
@inline(never)
150+
func runBenchLoop1Substring(iterations: Int) {
151+
for _ in 0 ..< iterations {
152+
precondition(findOne(longStringFoFoFoFox![...], needle: "x") != nil)
153+
}
154+
}
155+
156+
@inline(never)
157+
func runBenchLoop1Array(iterations: Int) {
158+
for _ in 0 ..< iterations {
159+
precondition(findOneOnUTF8Collection(longArrayFoFoFoFox!, needle: UInt8(ascii: "x")) != nil)
160+
}
161+
}
162+
163+
@inline(never)
164+
func runBenchRecursive3Substring(iterations: Int) {
165+
for _ in 0 ..< iterations {
166+
precondition(findThreeRecursive(longStringFoFoFoFox![...], needle1: "f", needle2: "o", needle3: "x") != nil)
167+
}
168+
}
169+
170+
@inline(never)
171+
func runBenchRecursive3String(iterations: Int) {
172+
for _ in 0 ..< iterations {
173+
precondition(findThreeRecursive(longStringFoFoFoFox!, needle1: "f", needle2: "o", needle3: "x") != nil)
174+
}
175+
}
176+
177+
@inline(never)
178+
func runBenchRecursive3ArrayOfUTF8(iterations: Int) {
179+
for _ in 0 ..< iterations {
180+
precondition(findThreeOnUTF8Collection(longArrayFoFoFoFox!,
181+
needle1: UInt8(ascii: "f"),
182+
needle2: UInt8(ascii: "o"),
183+
needle3: UInt8(ascii: "x")) != nil)
184+
}
185+
}

branches/master-rebranch/benchmark/utils/main.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import ErrorHandling
7575
import Exclusivity
7676
import ExistentialPerformance
7777
import Fibonacci
78+
import FindStringNaive
7879
import FlattenList
7980
import FloatingPointParsing
8081
import FloatingPointPrinting
@@ -253,6 +254,7 @@ registerBenchmark(ErrorHandling)
253254
registerBenchmark(Exclusivity)
254255
registerBenchmark(ExistentialPerformance)
255256
registerBenchmark(Fibonacci)
257+
registerBenchmark(FindStringNaive)
256258
registerBenchmark(FlattenListLoop)
257259
registerBenchmark(FlattenListFlatMap)
258260
registerBenchmark(FloatingPointParsing)

branches/master-rebranch/cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,7 @@ function(_add_swift_executable_single name)
23702370
# NOTE(compnerd) use the C linker language to invoke `clang` rather than
23712371
# `clang++` as we explicitly link against the C++ runtime. We were previously
23722372
# actually passing `-nostdlib++` to avoid the C++ runtime linkage.
2373-
if(SWIFTEXE_SINGLE_SDK STREQUAL ANDROID)
2373+
if(${SWIFTEXE_SINGLE_SDK} STREQUAL ANDROID)
23742374
set_property(TARGET "${name}" PROPERTY
23752375
LINKER_LANGUAGE "C")
23762376
else()

branches/master-rebranch/cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ function(_compile_swift_files
229229
# The standard library and overlays are always built resiliently.
230230
if(SWIFTFILE_IS_STDLIB)
231231
list(APPEND swift_flags "-enable-library-evolution")
232+
list(APPEND swift_flags "-Xfrontend" "-enable-ownership-stripping-after-serialization")
232233
endif()
233234

234235
if(SWIFT_STDLIB_USE_NONATOMIC_RC)

branches/master-rebranch/docs/ABI/Mangling.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,11 @@ Types
551551
type ::= assoc-type-name 'Qz' // shortcut for 'Qyz'
552552
type ::= assoc-type-list 'QY' GENERIC-PARAM-INDEX // associated type at depth
553553
type ::= assoc-type-list 'QZ' // shortcut for 'QYz'
554+
555+
#if SWIFT_RUNTIME_VERSION >= 5.2
556+
type ::= type assoc-type-name 'Qx' // associated type relative to base `type`
557+
type ::= type assoc-type-list 'QX' // associated type relative to base `type`
558+
#endif
554559

555560
protocol-list ::= protocol '_' protocol*
556561
protocol-list ::= empty-list

0 commit comments

Comments
 (0)