Skip to content

Commit 38486cf

Browse files
authored
Merge pull request #1821 from swiftwasm/master
[pull] swiftwasm from master
2 parents 60b22ce + 3c386d8 commit 38486cf

36 files changed

+455
-118
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ license](https://swift.org/LICENSE.txt).
66
---
77

88
Before submitting the pull request, please make sure you have [tested your
9-
changes](https://github.com/apple/swift/blob/master/docs/ContinuousIntegration.md)
9+
changes](https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md)
1010
and that they follow the Swift project [guidelines for contributing
1111
code](https://swift.org/contributing/#contributing-code).

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ more links in the SwiftWasm ecosystem.
1414
# Swift Programming Language
1515

1616

17-
| | **Architecture** | **Master** | **Package** |
17+
| | **Architecture** | **main** | **Package** |
1818
|---|:---:|:---:|:---:|
1919
| **macOS** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-osx/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-osx)|[![Build Status](https://ci.swift.org/job/oss-swift-package-osx/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-osx)|
2020
| **Ubuntu 16.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_04)|
@@ -100,7 +100,7 @@ We also have an [FAQ](/docs/HowToGuides/FAQ.md) that answers common questions.
100100
#### Building
101101

102102
Swift toolchains are created using the script
103-
[build-toolchain](https://github.com/apple/swift/blob/master/utils/build-toolchain). This
103+
[build-toolchain](https://github.com/apple/swift/blob/main/utils/build-toolchain). This
104104
script is used by swift.org's CI to produce snapshots and can allow for one to
105105
locally reproduce such builds for development or distribution purposes. A typical
106106
invocation looks like the following:

benchmark/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ To run Swift benchmarks, pass the `--benchmark` flag to `build-script`. The
88
current benchmark results will be compared to the previous run's results if
99
available. Results for each benchmark run are logged for future comparison.
1010

11-
For branch based development, take a baseline benchmark on the Swift `master`
11+
For branch based development, take a baseline benchmark on the Swift `main`
1212
branch, switch to a development branch containing potentially performance
1313
impacting changes, and run the benchmarks again. Upon benchmark completion, the
1414
benchmark results for the development branch will be compared to the most
15-
recent benchmark results for `master`.
15+
recent benchmark results for `main`.
1616

1717
## Building the Swift Benchmarks
1818

@@ -181,7 +181,7 @@ benchmarks will be compiled with -Onone!**
181181
* `--list`
182182
* Print a list of available tests matching specified criteria
183183
* `--tags`
184-
* Run tests that are labeled with specified [tags](https://github.com/apple/swift/blob/master/benchmark/utils/TestsUtils.swift#L19)
184+
* Run tests that are labeled with specified [tags](https://github.com/apple/swift/blob/main/benchmark/utils/TestsUtils.swift#L19)
185185
(comma separated list); multiple tags are interpreted as logical AND, i.e.
186186
run only test that are labeled with all the supplied tags
187187
* `--skip-tags`

benchmark/scripts/Benchmark_Driver

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,9 @@ def parse_args(args):
975975
)
976976
compare_parser.add_argument(
977977
"--baseline-branch",
978-
default="master",
978+
default="main",
979979
help="attempt to compare results to baseline results for specified "
980-
"branch (default: master)",
980+
"branch (default: main)",
981981
)
982982
compare_parser.set_defaults(func=compare)
983983

benchmark/single-source/ChaCha.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import TestsUtils
2222
enum ChaCha20 { }
2323

2424
extension ChaCha20 {
25+
@inline(never)
2526
public static func encrypt<Key: Collection, Nonce: Collection, Bytes: MutableCollection>(bytes: inout Bytes, key: Key, nonce: Nonce, initialCounter: UInt32 = 0) where Bytes.Element == UInt8, Key.Element == UInt8, Nonce.Element == UInt8 {
2627
var baseState = ChaChaState(key: key, nonce: nonce, counter: initialCounter)
2728
var index = bytes.startIndex
@@ -347,13 +348,28 @@ public let ChaCha = BenchmarkInfo(
347348
runFunction: run_ChaCha,
348349
tags: [.runtime, .cpubench])
349350

351+
@inline(never)
352+
func checkResult(_ plaintext: [UInt8]) {
353+
CheckResults(plaintext.first! == 6 && plaintext.last! == 254)
354+
var hash: UInt64 = 0
355+
for byte in plaintext {
356+
// rotate
357+
hash = (hash &<< 8) | (hash &>> (64 - 8))
358+
hash ^= UInt64(byte)
359+
}
360+
CheckResults(hash == 0xa1bcdb217d8d14e4)
361+
}
350362

351363
@inline(never)
352364
public func run_ChaCha(_ N: Int) {
353-
var plaintext = Array(repeating: UInt8(0), count: 30720) // Chosen for CI runtime
354365
let key = Array(repeating: UInt8(1), count: 32)
355366
let nonce = Array(repeating: UInt8(2), count: 12)
356367

368+
var checkedtext = Array(repeating: UInt8(0), count: 1024)
369+
ChaCha20.encrypt(bytes: &checkedtext, key: key, nonce: nonce)
370+
checkResult(checkedtext)
371+
372+
var plaintext = Array(repeating: UInt8(0), count: 30720) // Chosen for CI runtime
357373
for _ in 1...N {
358374
ChaCha20.encrypt(bytes: &plaintext, key: key, nonce: nonce)
359375
blackHole(plaintext.first!)

benchmark/single-source/FloatingPointConversion.swift

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ public let FloatingPointConversion = [
1818
runFunction: run_ConvertFloatingPoint_MockFloat64ToDouble,
1919
tags: [.validation, .api],
2020
setUpFunction: { blackHole(mockFloat64s) }),
21+
BenchmarkInfo(
22+
name: "ConvertFloatingPoint.MockFloat64Exactly",
23+
runFunction: run_ConvertFloatingPoint_MockFloat64Exactly,
24+
tags: [.validation, .api],
25+
setUpFunction: { blackHole(mockFloat64s) }),
26+
BenchmarkInfo(
27+
name: "ConvertFloatingPoint.MockFloat64Exactly2",
28+
runFunction: run_ConvertFloatingPoint_MockFloat64Exactly2,
29+
tags: [.validation, .api],
30+
setUpFunction: { blackHole(mockFloat64s) }),
2131
BenchmarkInfo(
2232
name: "ConvertFloatingPoint.MockFloat64ToInt64",
2333
runFunction: run_ConvertFloatingPoint_MockFloat64ToInt64,
@@ -130,6 +140,11 @@ struct MockFloat64: MockBinaryFloatingPoint {
130140
init(_ _value: Double) { self._value = _value }
131141
}
132142

143+
struct MockFloat32: MockBinaryFloatingPoint {
144+
var _value: Float
145+
init(_ _value: Float) { self._value = _value }
146+
}
147+
133148
let doubles = [
134149
1.8547832857295, 26.321549267719135, 98.9544480962058, 73.70286973782363,
135150
82.04918555938816, 76.38902969312758, 46.35647857011161, 64.0821426030317,
@@ -147,20 +162,40 @@ let doubles = [
147162

148163
let mockFloat64s = doubles.map { MockFloat64($0) }
149164

165+
// See also: test/SILOptimizer/floating_point_conversion.swift
166+
167+
@inline(never)
168+
public func run_ConvertFloatingPoint_MockFloat64ToDouble(_ N: Int) {
169+
for _ in 0..<(N * 100) {
170+
for element in mockFloat64s {
171+
let f = Double(identity(element))
172+
blackHole(f)
173+
}
174+
}
175+
}
176+
150177
@inline(__always)
151178
func convert<
152179
T: BinaryFloatingPoint, U: BinaryFloatingPoint
153-
>(_ value: T, to: U.Type) -> U {
154-
U(value)
180+
>(exactly value: T, to: U.Type) -> U? {
181+
U(exactly: value)
155182
}
156183

157-
// See also: test/SILOptimizer/floating_point_conversion.swift
184+
@inline(never)
185+
public func run_ConvertFloatingPoint_MockFloat64Exactly(_ N: Int) {
186+
for _ in 0..<(N * 25) {
187+
for element in mockFloat64s {
188+
let f = convert(exactly: identity(element), to: Double.self)
189+
blackHole(f)
190+
}
191+
}
192+
}
158193

159194
@inline(never)
160-
public func run_ConvertFloatingPoint_MockFloat64ToDouble(_ N: Int) {
161-
for _ in 0..<(N * 100) {
195+
public func run_ConvertFloatingPoint_MockFloat64Exactly2(_ N: Int) {
196+
for _ in 0..<(N * 25) {
162197
for element in mockFloat64s {
163-
let f = Double(identity(element))
198+
let f = convert(exactly: identity(element), to: MockFloat32.self)
164199
blackHole(f)
165200
}
166201
}

docs/ABI/RegisterUsage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 64-Bit Architecture Register Usage
22

3-
From Swift 5, the calling convention register allocation for 64-bit architectures is largely based on [existing](https://developer.apple.com/library/content/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html) [standards](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/LowLevelABI/140-x86-64_Function_Calling_Conventions/x86_64.html), with the addition of the context and error return registers discussed in the [ABI stability manifesto](https://github.com/apple/swift/blob/master/docs/ABIStabilityManifesto.md):
3+
From Swift 5, the calling convention register allocation for 64-bit architectures is largely based on [existing](https://developer.apple.com/library/content/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html) [standards](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/LowLevelABI/140-x86-64_Function_Calling_Conventions/x86_64.html), with the addition of the context and error return registers discussed in the [ABI stability manifesto](https://github.com/apple/swift/blob/main/docs/ABIStabilityManifesto.md):
44

55
| Register Purpose | ARM64 | x86_64 |
66
| ------------- |:-------------:| ----- |

0 commit comments

Comments
 (0)