Skip to content

Commit e9e1d3c

Browse files
authored
---
yaml --- r: 342013 b: refs/heads/rxwei-patch-1 c: be609e8 h: refs/heads/master i: 342011: e83284e
1 parent 023bdf9 commit e9e1d3c

File tree

21 files changed

+449
-123
lines changed

21 files changed

+449
-123
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: 4d57590fa9021e837ff56a54a3a1c64b6ce2a02a
1018+
refs/heads/rxwei-patch-1: be609e82ef1fc60ebe549213bd0a2a024eb03850
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/benchmark/Package.swift

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.2
1+
// swift-tools-version:5.0
22

33
import PackageDescription
44
import Foundation
@@ -9,10 +9,15 @@ unsupportedTests.insert("ObjectiveCBridging")
99
unsupportedTests.insert("ObjectiveCBridgingStubs")
1010
#endif
1111

12-
// This is a stop gap hack so we can edit benchmarks in Xcode.
13-
let singleSourceLibraries: [String] = {
12+
//===---
13+
// Single Source Libraries
14+
//
15+
16+
/// Return the source files in subDirectory that we will translate into
17+
/// libraries. Each source library will be compiled as its own module.
18+
func getSingleSourceLibraries(subDirectory: String) -> [String] {
1419
let f = FileManager.`default`
15-
let dirURL = URL(fileURLWithPath: "single-source").absoluteURL
20+
let dirURL = URL(fileURLWithPath: subDirectory)
1621
let fileURLs = try! f.contentsOfDirectory(at: dirURL,
1722
includingPropertiesForKeys: nil)
1823
return fileURLs.compactMap { (path: URL) -> String? in
@@ -25,27 +30,45 @@ let singleSourceLibraries: [String] = {
2530
return nil
2631
}
2732

28-
let s = String(c[0])
33+
let name = String(c[0])
2934

3035
// We do not support this test.
31-
if unsupportedTests.contains(s) {
36+
if unsupportedTests.contains(name) {
3237
return nil
3338
}
3439

35-
assert(s != "PrimsSplit")
36-
return s
40+
return name
3741
}
38-
}()
42+
}
43+
44+
var singleSourceLibraryDirs: [String] = []
45+
singleSourceLibraryDirs.append("single-source")
46+
47+
var singleSourceLibraries: [String] = singleSourceLibraryDirs.flatMap {
48+
getSingleSourceLibraries(subDirectory: $0)
49+
}
3950

40-
let multiSourceLibraries: [String] = {
51+
//===---
52+
// Multi Source Libraries
53+
//
54+
55+
func getMultiSourceLibraries(subDirectory: String) -> [(String, String)] {
4156
let f = FileManager.`default`
42-
let dirURL = URL(fileURLWithPath: "multi-source").absoluteURL
43-
let fileURLs = try! f.contentsOfDirectory(at: dirURL,
44-
includingPropertiesForKeys: nil)
45-
return fileURLs.map { (path: URL) -> String in
46-
return path.lastPathComponent
47-
}
48-
}()
57+
let dirURL = URL(string: subDirectory)!
58+
let subDirs = try! f.contentsOfDirectory(at: dirURL, includingPropertiesForKeys: nil)
59+
return subDirs.map { (subDirectory, $0.lastPathComponent) }
60+
}
61+
62+
var multiSourceLibraryDirs: [String] = []
63+
multiSourceLibraryDirs.append("multi-source")
64+
65+
var multiSourceLibraries: [(parentSubDir: String, name: String)] = multiSourceLibraryDirs.flatMap {
66+
getMultiSourceLibraries(subDirectory: $0)
67+
}
68+
69+
//===---
70+
// Products
71+
//
4972

5073
var products: [Product] = []
5174
products.append(.library(name: "TestsUtils", type: .static, targets: ["TestsUtils"]))
@@ -54,9 +77,15 @@ products.append(.library(name: "DriverUtils", type: .static, targets: ["DriverUt
5477
products.append(.library(name: "ObjectiveCTests", type: .static, targets: ["ObjectiveCTests"]))
5578
#endif
5679
products.append(.executable(name: "SwiftBench", targets: ["SwiftBench"]))
57-
products.append(.library(name: "PrimsSplit", type: .static, targets: ["PrimsSplit"]))
80+
5881
products += singleSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) }
59-
products += multiSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) }
82+
products += multiSourceLibraries.map {
83+
return .library(name: $0.name, type: .static, targets: [$0.name])
84+
}
85+
86+
//===---
87+
// Targets
88+
//
6089

6190
var targets: [Target] = []
6291
targets.append(.target(name: "TestsUtils", path: "utils", sources: ["TestsUtils.swift"]))
@@ -73,7 +102,7 @@ swiftBenchDeps.append(.target(name: "ObjectiveCTests"))
73102
#endif
74103
swiftBenchDeps.append(.target(name: "DriverUtils"))
75104
swiftBenchDeps += singleSourceLibraries.map { .target(name: $0) }
76-
swiftBenchDeps += multiSourceLibraries.map { .target(name: $0) }
105+
swiftBenchDeps += multiSourceLibraries.map { .target(name: $0.name) }
77106

78107
targets.append(
79108
.target(name: "SwiftBench",
@@ -92,20 +121,27 @@ var singleSourceDeps: [Target.Dependency] = [.target(name: "TestsUtils")]
92121
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
93122
singleSourceDeps.append(.target(name: "ObjectiveCTests"))
94123
#endif
95-
targets += singleSourceLibraries.map { x in
96-
return .target(name: x,
124+
125+
targets += singleSourceLibraries.map { name in
126+
return .target(name: name,
97127
dependencies: singleSourceDeps,
98128
path: "single-source",
99-
sources: ["\(x).swift"])
129+
sources: ["\(name).swift"])
100130
}
101-
targets += multiSourceLibraries.map { x in
102-
return .target(name: x,
131+
132+
targets += multiSourceLibraries.map { lib in
133+
return .target(
134+
name: lib.name,
103135
dependencies: [
104136
.target(name: "TestsUtils")
105137
],
106-
path: "multi-source/\(x)")
138+
path: lib.parentSubDir)
107139
}
108140

141+
//===---
142+
// Top Level Definition
143+
//
144+
109145
let p = Package(
110146
name: "swiftbench",
111147
products: products,

branches/rxwei-patch-1/benchmark/README.md

Lines changed: 83 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
Swift Benchmark Suite
2-
=====================
1+
# Swift Benchmark Suite
32

43
This directory contains the Swift Benchmark Suite.
54

6-
Running Swift Benchmarks
7-
------------------------
5+
## Running Swift Benchmarks
86

97
To run Swift benchmarks, pass the `--benchmark` flag to `build-script`. The
108
current benchmark results will be compared to the previous run's results if
@@ -16,8 +14,17 @@ impacting changes, and run the benchmarks again. Upon benchmark completion, the
1614
benchmark results for the development branch will be compared to the most
1715
recent benchmark results for `master`.
1816

19-
Building with build-script
20-
--------------------------
17+
## Building the Swift Benchmarks
18+
19+
The swift benchmark suite currently supports building with CMake and
20+
SwiftPM. We support the following platforms respectively.
21+
22+
* CMake: macOS, iOS, tvOS, watchOS
23+
* SwiftPM: macOS, linux
24+
25+
We describe how to build both standalone and with build-script below.
26+
27+
### build-script invoking CMake
2128

2229
By default, Swift benchmarks for OS X are compiled during the Swift build
2330
process. To build Swift benchmarks for additional platforms, pass the following
@@ -33,8 +40,7 @@ drivers dynamically link Swift standard library dylibs from a path
3340
relative to their run-time location (../lib/swift) so the standard
3441
library should be distributed alongside them.
3542

36-
Building Independently
37-
----------------------
43+
### CMake Standalone (no build-script)
3844

3945
To build the Swift benchmarks using only an Xcode installation: install an
4046
Xcode version with Swift support, install cmake 2.8.12, and ensure Xcode is
@@ -110,8 +116,57 @@ installed libraries instead, enable
110116
This will reflect the performance of the Swift standard library
111117
installed on the device, not the one included in the Swift root.
112118

113-
Using the Benchmark Driver
114-
--------------------------
119+
### build-script using SwiftPM+LLBuild
120+
121+
To build the benchmarks using build-script/swiftpm, one must build both
122+
swiftpm/llbuild as part of one's build and create a "just-built" toolchain. This
123+
toolchain is then used by build-script to compile the benchmarks. This is
124+
accomplished by passing to build-script the following options:
125+
126+
```
127+
swift-source$ swift/utils/build-script --swiftpm --llbuild --install-swift --install-swiftpm --install-llbuild --toolchain-benchmarks
128+
```
129+
130+
build-script will then compile the toolchain and then build the benchmarks 3
131+
times, once for each optimization level, at the path
132+
`./build/benchmarks-$PLATFORM-$ARCH/bin/Benchmark_$OPT`:
133+
134+
### Standalone SwiftPM/LLBuild
135+
136+
The benchmark suite can be built with swiftpm/llbuild without needing any help
137+
from build-script by invoking swift build in the benchmark directory:
138+
139+
```
140+
swift-source/swift/benchmark$ swift build -configuration release
141+
swift-source/swift/benchmark$ .build/release/SwiftBench
142+
#,TEST,SAMPLES,MIN(μs),MAX(μs),MEAN(μs),SD(μs),MEDIAN(μs)
143+
1,Ackermann,1,169,169,169,0,169
144+
2,AngryPhonebook,1,2044,2044,2044,0,2044
145+
...
146+
```
147+
148+
## Editing in Xcode
149+
150+
It is now possible to work on swiftpm benchmarks in Xcode! This is done by using
151+
the ability swiftpm build of the benchmarks to generate an xcodeproject. This is
152+
done by running the commands:
153+
154+
```
155+
swift-source/swift/benchmark$ swift package generate-xcodeproj
156+
generated: ./swiftbench.xcodeproj
157+
swift-source/swift/benchmark$ open swiftbench.xcodeproj
158+
```
159+
160+
Assuming that Xcode is installed on ones system, this will open the project in
161+
Xcode. The benchmark binary is built by the target 'SwiftBench'.
162+
163+
**NOTE: Files added to the Xcode project will not be persisted back to the
164+
package! To add new benchmarks follow the instructions from the section below!**
165+
166+
**NOTE: By default if one just builds/runs the benchmarks in Xcode, the
167+
benchmarks will be compiled with -Onone!**
168+
169+
## Using the Benchmark Driver
115170

116171
### Usage
117172

@@ -154,32 +209,39 @@ You can use test numbers instead of test names like this:
154209
Test numbers are not stable in the long run, adding and removing tests from the
155210
benchmark suite will reorder them, but they are stable for a given build.
156211

157-
Using the Harness Generator
158-
---------------------------
212+
## Using the Harness Generator
159213

160214
`scripts/generate_harness/generate_harness.py` runs `gyb` to automate generation
161215
of some benchmarks.
162216

163217
** FIXME ** `gyb` should be invoked automatically during the
164218
build so that manually invoking `generate_harness.py` is not required.
165219

166-
Adding New Benchmarks
167-
---------------------
220+
## Adding New Benchmarks
168221

169-
The harness generator supports both single and multiple file tests.
222+
Adding a new benchmark requires some boilerplate updates. To ease this (and
223+
document the behavior), a harness generator script is provided for both
224+
single/multiple file tests.
170225

171-
To add a new single file test, execute the following script with the new of the benchmark:
226+
To add a new single file test, execute the following script with the new of the
227+
benchmark:
172228

173229
```
174230
swift-source$ ./swift/benchmark/scripts/create_benchmark.py YourTestNameHere
175231
```
176232

177233
The script will automatically:
234+
178235
1. Add a new Swift file (`YourTestNameHere.swift`), built according to
179236
the template below, to the `single-source` directory.
180237
2. Add the filename of the new Swift file to `CMakeLists.txt`.
181238
3. Edit `main.swift` by importing and registering your new Swift module.
182239

240+
No changes are needed to the Package.swift file since the benchmark's
241+
Package.swift is set to dynamically lookup each Swift file in `single-source`
242+
and translate each of those individual .swift files into individual modules. So
243+
the new test file will be automatically found.
244+
183245
To add a new multiple file test:
184246

185247
1. Add a new directory and files under the `multi-source` directory as
@@ -200,6 +262,9 @@ To add a new multiple file test:
200262

201263
3. Edit `main.swift`. Import and register your new Swift module.
202264

265+
No changes are needed to the swiftpm build since it knows how to infer
266+
multi-source libraries automatically from the library structure.
267+
203268
**Note:**
204269

205270
The benchmark harness will execute the routine referenced by
@@ -244,8 +309,8 @@ public func run_YourTestName(N: Int) {
244309
The current set of tags are defined by the `BenchmarkCategory` enum in
245310
`TestsUtils.swift` .
246311

247-
Testing the Benchmark Drivers
248-
-----------------------------
312+
## Testing the Benchmark Drivers
313+
249314
When working on tests, after the initial build
250315
````
251316
swift-source$ ./swift/utils/build-script -R -B

branches/rxwei-patch-1/include/swift/AST/Decl.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4120,7 +4120,20 @@ class ProtocolDecl final : public NominalTypeDecl {
41204120
Bits.ProtocolDecl.RequiresClass = requiresClass;
41214121
}
41224122

4123-
bool existentialConformsToSelfSlow();
4123+
/// Returns the cached result of \c existentialConformsToSelf or \c None if it
4124+
/// hasn't yet been computed.
4125+
Optional<bool> getCachedExistentialConformsToSelf() const {
4126+
if (Bits.ProtocolDecl.ExistentialConformsToSelfValid)
4127+
return Bits.ProtocolDecl.ExistentialConformsToSelf;
4128+
4129+
return None;
4130+
}
4131+
4132+
/// Caches the result of \c existentialConformsToSelf
4133+
void setCachedExistentialConformsToSelf(bool result) {
4134+
Bits.ProtocolDecl.ExistentialConformsToSelfValid = true;
4135+
Bits.ProtocolDecl.ExistentialConformsToSelf = result;
4136+
}
41244137

41254138
bool existentialTypeSupportedSlow();
41264139

@@ -4134,6 +4147,7 @@ class ProtocolDecl final : public NominalTypeDecl {
41344147
friend class SuperclassTypeRequest;
41354148
friend class RequirementSignatureRequest;
41364149
friend class ProtocolRequiresClassRequest;
4150+
friend class ExistentialConformsToSelfRequest;
41374151
friend class TypeChecker;
41384152

41394153
public:
@@ -4204,13 +4218,7 @@ class ProtocolDecl final : public NominalTypeDecl {
42044218
/// This is only permitted if there is nothing "non-trivial" that we
42054219
/// can do with the metatype, which means the protocol must not have
42064220
/// any static methods and must be declared @objc.
4207-
bool existentialConformsToSelf() const {
4208-
if (Bits.ProtocolDecl.ExistentialConformsToSelfValid)
4209-
return Bits.ProtocolDecl.ExistentialConformsToSelf;
4210-
4211-
return const_cast<ProtocolDecl *>(this)
4212-
->existentialConformsToSelfSlow();
4213-
}
4221+
bool existentialConformsToSelf() const;
42144222

42154223
/// Does this protocol require a self-conformance witness table?
42164224
bool requiresSelfConformanceWitnessTable() const;

branches/rxwei-patch-1/include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4523,6 +4523,9 @@ WARNING(property_wrapper_init_initialValue,none,
45234523
())
45244524
ERROR(property_wrapper_projection_value_missing,none,
45254525
"could not find projection value property %0", (Identifier))
4526+
ERROR(property_wrapper_missing_arg_init, none, "missing argument for parameter "
4527+
"%0 in property wrapper initializer; add 'wrappedValue' and %0 "
4528+
"arguments in '@%1(...)'", (Identifier, StringRef))
45264529

45274530
//------------------------------------------------------------------------------
45284531
// MARK: function builder diagnostics

0 commit comments

Comments
 (0)