Skip to content

Commit e5e25a6

Browse files
author
Marc Rasi
committed
Merge branch 'master' of github.com:apple/swift into ast-nondiff
2 parents 1058a38 + 25949c2 commit e5e25a6

File tree

104 files changed

+2380
-1923
lines changed

Some content is hidden

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

104 files changed

+2380
-1923
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,26 +155,26 @@ First, make sure that you're in the swift directory:
155155

156156
To build using Ninja, run:
157157

158-
swift/utils/build-script --release-debuginfo
158+
utils/build-script --release-debuginfo
159159

160160
When developing Swift, it helps to build what you're working on in a debug
161161
configuration while building the rest of the project with optimizations. Below
162162
are some examples of using debug variants:
163163

164-
swift/utils/build-script --release-debuginfo --debug-swift # Swift frontend built in debug
165-
swift/utils/build-script --release-debuginfo --debug-swift-stdlib # Standard library built in debug
166-
swift/utils/build-script --release-debuginfo --debug-swift --force-optimized-typechecker # Swift frontend sans type checker built in debug
164+
utils/build-script --release-debuginfo --debug-swift # Swift frontend built in debug
165+
utils/build-script --release-debuginfo --debug-swift-stdlib # Standard library built in debug
166+
utils/build-script --release-debuginfo --debug-swift --force-optimized-typechecker # Swift frontend sans type checker built in debug
167167

168168
Limiting the amount of debug code in the compiler has a very large impact on
169169
Swift compile times, and in turn the test execution time. If you want to build
170170
the entire project in debug, you can run:
171171

172-
swift/utils/build-script --debug
172+
utils/build-script --debug
173173

174174
For documentation of all available arguments, as well as additional usage
175175
information, see the inline help:
176176

177-
swift/utils/build-script -h
177+
utils/build-script -h
178178

179179
#### Xcode
180180

benchmark/single-source/NSStringConversion.swift

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import TestsUtils
1717
import Foundation
1818

1919
fileprivate var test:NSString = ""
20+
fileprivate var mutableTest = ""
2021

2122
public let NSStringConversion = [
2223
BenchmarkInfo(name: "NSStringConversion",
@@ -65,7 +66,44 @@ public let NSStringConversion = [
6566
BenchmarkInfo(name: "NSStringConversion.Rebridge.LongUTF8",
6667
runFunction: run_NSStringConversion_longNonASCII_rebridge,
6768
tags: [.validation, .api, .String, .bridging],
68-
setUpFunction: { test = NSString(cString: "Thë qüick bröwn föx jumps over the lazy dög", encoding: String.Encoding.utf8.rawValue)! })]
69+
setUpFunction: { test = NSString(cString: "Thë qüick bröwn föx jumps over the lazy dög", encoding: String.Encoding.utf8.rawValue)! } ),
70+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.UTF8",
71+
runFunction: run_NSStringConversion_nonASCIIMutable,
72+
tags: [.validation, .api, .String, .bridging],
73+
setUpFunction: { mutableTest = "tëst" }),
74+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Medium",
75+
runFunction: run_NSStringConversion_mediumMutable,
76+
tags: [.validation, .api, .String, .bridging],
77+
setUpFunction: { mutableTest = "aaaaaaaaaaaaaaa" } ),
78+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Long",
79+
runFunction: run_NSStringConversion_longMutable,
80+
tags: [.validation, .api, .String, .bridging],
81+
setUpFunction: { mutableTest = "The quick brown fox jumps over the lazy dog" } ),
82+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.LongUTF8",
83+
runFunction: run_NSStringConversion_longNonASCIIMutable,
84+
tags: [.validation, .api, .String, .bridging],
85+
setUpFunction: { mutableTest = "Thë qüick bröwn föx jumps over the lazy dög" } ),
86+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Rebridge",
87+
runFunction: run_NSStringConversion_rebridgeMutable,
88+
tags: [.validation, .api, .String, .bridging],
89+
setUpFunction: { mutableTest = "test" }),
90+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Rebridge.UTF8",
91+
runFunction: run_NSStringConversion_nonASCII_rebridgeMutable,
92+
tags: [.validation, .api, .String, .bridging],
93+
setUpFunction: { mutableTest = "tëst" }),
94+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Rebridge.Medium",
95+
runFunction: run_NSStringConversion_medium_rebridgeMutable,
96+
tags: [.validation, .api, .String, .bridging],
97+
setUpFunction: { mutableTest = "aaaaaaaaaaaaaaa" } ),
98+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Rebridge.Long",
99+
runFunction: run_NSStringConversion_long_rebridgeMutable,
100+
tags: [.validation, .api, .String, .bridging],
101+
setUpFunction: { mutableTest = "The quick brown fox jumps over the lazy dog" } ),
102+
BenchmarkInfo(name: "NSStringConversion.MutableCopy.Rebridge.LongUTF8",
103+
runFunction: run_NSStringConversion_longNonASCII_rebridgeMutable,
104+
tags: [.validation, .api, .String, .bridging],
105+
setUpFunction: { mutableTest = "Thë qüick bröwn föx jumps over the lazy dög" } )
106+
]
69107

70108
public func run_NSStringConversion(_ N: Int) {
71109
let test:NSString = NSString(cString: "test", encoding: String.Encoding.ascii.rawValue)!
@@ -103,6 +141,31 @@ public func run_NSStringConversion_longNonASCII(_ N: Int) {
103141
innerLoop(test, N, 300)
104142
}
105143

144+
fileprivate func innerMutableLoop(_ str: String, _ N: Int, _ scale: Int = 5000) {
145+
for _ in 1...N * scale {
146+
let copy = (str as NSString).mutableCopy() as! NSMutableString
147+
for char in (identity(copy) as String).utf8 {
148+
blackHole(char)
149+
}
150+
}
151+
}
152+
153+
public func run_NSStringConversion_nonASCIIMutable(_ N: Int) {
154+
innerMutableLoop(mutableTest, N, 500)
155+
}
156+
157+
public func run_NSStringConversion_mediumMutable(_ N: Int) {
158+
innerMutableLoop(mutableTest, N, 500)
159+
}
160+
161+
public func run_NSStringConversion_longMutable(_ N: Int) {
162+
innerMutableLoop(mutableTest, N, 250)
163+
}
164+
165+
public func run_NSStringConversion_longNonASCIIMutable(_ N: Int) {
166+
innerMutableLoop(mutableTest, N, 150)
167+
}
168+
106169
fileprivate func innerRebridge(_ str: NSString, _ N: Int, _ scale: Int = 5000) {
107170
for _ in 1...N * scale {
108171
let bridged = identity(str) as String
@@ -135,4 +198,33 @@ public func run_NSStringConversion_longNonASCII_rebridge(_ N: Int) {
135198
innerRebridge(test, N, 300)
136199
}
137200

201+
fileprivate func innerMutableRebridge(_ str: String, _ N: Int, _ scale: Int = 5000) {
202+
for _ in 1...N * scale {
203+
let copy = (str as NSString).mutableCopy() as! NSMutableString
204+
let bridged = identity(copy) as String
205+
blackHole(bridged)
206+
blackHole(bridged as NSString)
207+
}
208+
}
209+
210+
public func run_NSStringConversion_rebridgeMutable(_ N: Int) {
211+
innerMutableRebridge(mutableTest, N, 1000)
212+
}
213+
214+
public func run_NSStringConversion_nonASCII_rebridgeMutable(_ N: Int) {
215+
innerMutableRebridge(mutableTest, N, 500)
216+
}
217+
218+
public func run_NSStringConversion_medium_rebridgeMutable(_ N: Int) {
219+
innerMutableRebridge(mutableTest, N, 500)
220+
}
221+
222+
public func run_NSStringConversion_long_rebridgeMutable(_ N: Int) {
223+
innerMutableRebridge(mutableTest, N, 500)
224+
}
225+
226+
public func run_NSStringConversion_longNonASCII_rebridgeMutable(_ N: Int) {
227+
innerMutableRebridge(mutableTest, N, 300)
228+
}
229+
138230
#endif

docs/HighLevelSILOptimizations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Array<Element>, ContiguousArray<Element>, and ArraySlice<Element>
135135
data-structures.
136136

137137
We consider the array state to consist of a set of disjoint elements
138-
and a storage descriptor that encapsulates nonelement data such as the
138+
and a storage descriptor that encapsulates non-element data such as the
139139
element count and capacity. Operations that semantically write state
140140
are always *control dependent*. A control dependent operation is one
141141
that may only be executed on the control flow paths in which the

0 commit comments

Comments
 (0)