Skip to content

Commit d8364bc

Browse files
authored
---
yaml --- r: 343353 b: refs/heads/master-rebranch c: 2ad0360 h: refs/heads/master i: 343351: 4b110fc
1 parent a6b21d7 commit d8364bc

File tree

727 files changed

+68808
-62411
lines changed

Some content is hidden

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

727 files changed

+68808
-62411
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: 00c0a0363758c1e4694b3fb99ebffb5e138de1b6
1458+
refs/heads/master-rebranch: 2ad0360d44587b884e76f47df3fc952e4325b736
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/CMakeLists.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,18 @@ include(CMakePushCheckState)
499499

500500
print_versions()
501501

502+
include(SwiftSharedCMakeConfig)
503+
504+
# NOTE: We include this before SwiftComponents as it relies on some LLVM CMake
505+
# functionality.
506+
# Support building Swift as a standalone project, using LLVM as an
507+
# external library.
508+
if(SWIFT_BUILT_STANDALONE)
509+
swift_common_standalone_build_config(SWIFT)
510+
else()
511+
swift_common_unified_build_config(SWIFT)
512+
endif()
513+
502514
include(SwiftComponents)
503515
include(SwiftHandleGybSources)
504516
include(SwiftSetIfArchBitness)
@@ -527,16 +539,6 @@ if(NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
527539
OUTPUT_STRIP_TRAILING_WHITESPACE)
528540
endif()
529541

530-
include(SwiftSharedCMakeConfig)
531-
532-
# Support building Swift as a standalone project, using LLVM as an
533-
# external library.
534-
if(SWIFT_BUILT_STANDALONE)
535-
swift_common_standalone_build_config(SWIFT)
536-
else()
537-
swift_common_unified_build_config(SWIFT)
538-
endif()
539-
540542
get_filename_component(SWIFT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} REALPATH)
541543
set(SWIFT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
542544
set(SWIFT_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
@@ -1051,6 +1053,7 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH)
10511053
else()
10521054
set(SOURCEKIT_RUNTIME_DIR lib)
10531055
endif()
1056+
add_dependencies(sourcekit-inproc BlocksRuntime dispatch)
10541057
swift_install_in_component(FILES
10551058
$<TARGET_FILE:dispatch>
10561059
$<TARGET_FILE:BlocksRuntime>

branches/master-rebranch/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Please make sure you use Python 2.x. Python 3.x is not supported currently.
8787

8888
#### macOS
8989

90-
To build for macOS, you need [Xcode 11 beta 5](https://developer.apple.com/xcode/downloads/).
90+
To build for macOS, you need [Xcode 11 beta 6](https://developer.apple.com/xcode/downloads/).
9191
The required version of Xcode changes frequently, and is often a beta release.
9292
Check this document or the host information on <https://ci.swift.org> for the
9393
current required version.

branches/master-rebranch/apinotes/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ add_custom_target("copy_apinotes" ALL
2626
COMMENT "Copying API notes to ${output_dir}"
2727
SOURCES "${sources}")
2828

29+
add_dependencies(compiler copy_apinotes)
2930
swift_install_in_component(DIRECTORY "${output_dir}"
3031
DESTINATION "lib/swift/"
3132
COMPONENT compiler)

branches/master-rebranch/benchmark/CMakeLists.txt

Lines changed: 2 additions & 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
@@ -151,6 +152,7 @@ set(SWIFT_BENCH_MODULES
151152
single-source/SetTests
152153
single-source/SevenBoom
153154
single-source/Sim2DArray
155+
single-source/SortArrayInClass
154156
single-source/SortIntPyramids
155157
single-source/SortLargeExistentials
156158
single-source/SortLettersInPlace

branches/master-rebranch/benchmark/README.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,17 @@ The following build options are available:
7070

7171
The following build targets are available:
7272

73-
1. `swift-benchmark-macosx-x86_64`
74-
2. `swift-benchmark-iphoneos-arm64`
75-
3. `swift-benchmark-iphoneos-armv7`
76-
4. `swift-benchmark-appletvos-arm64`
77-
5. `swift-benchmark-watchos-armv7k`
73+
* `swift-benchmark-macosx-x86_64`
74+
* `swift-benchmark-iphoneos-arm64`
75+
* `swift-benchmark-iphoneos-armv7`
76+
* `swift-benchmark-appletvos-arm64`
77+
* `swift-benchmark-watchos-armv7k`
7878

7979
Build steps (with example options):
8080

81-
1. `$ cd benchmark`
82-
2. `$ mkdir build`
83-
3. `$ cd build`
84-
4. `$ cmake ../benchmark -G Ninja -DSWIFT_EXEC=[path to built swiftc]`
85-
5. `$ ninja swift-benchmark-macosx-x86_64`
81+
1. `$ mkdir build; cd build`
82+
2. `$ cmake [path to swift src]/benchmark -G Ninja -DSWIFT_EXEC=[path to built swiftc]`
83+
3. `$ ninja swift-benchmark-macosx-x86_64`
8684

8785
Benchmark binaries are placed in `bin`.
8886

@@ -96,12 +94,12 @@ relative to the benchmark binary at the time it was executed
9694
For example, to benchmark against a locally built `swiftc`, including
9795
any standard library changes in that build, you might configure using:
9896

99-
cmake ../benchmark -G Ninja -DSWIFT_EXEC=<src>/swift/build/swift-macosx-x86_64/bin/swiftc
97+
cmake <src>/benchmark -G Ninja -DSWIFT_EXEC=<build>/swift-macosx-x86_64/bin/swiftc
10098
ninja swift-benchmark-iphoneos-arm64
10199

102100
To build against the installed Xcode, simply omit SWIFT_EXEC:
103101

104-
cmake ../benchmark -G Ninja
102+
cmake <src>/benchmark -G Ninja
105103
ninja swift-benchmark-iphoneos-arm64
106104

107105
In both examples above, to run the benchmarks on a device, the dynamic
@@ -110,7 +108,7 @@ relative to `swiftc`. To benchmark against the target machine's
110108
installed libraries instead, enable
111109
`SWIFT_BENCHMARK_USE_OS_LIBRARIES`.
112110

113-
cmake ../benchmark -G Ninja -DSWIFT_BENCHMARK_USE_OS_LIBRARIES=ON
111+
cmake <src>/benchmark -G Ninja -DSWIFT_BENCHMARK_USE_OS_LIBRARIES=ON
114112
ninja swift-benchmark-iphoneos-arm64
115113

116114
This will reflect the performance of the Swift standard library
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+
}

0 commit comments

Comments
 (0)