Skip to content

Commit 048fa64

Browse files
committed
Merge branch 'main' into just-one-more-benchmark-suite
2 parents 0a1a32a + 71f8d49 commit 048fa64

File tree

208 files changed

+33528
-11529
lines changed

Some content is hidden

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

208 files changed

+33528
-11529
lines changed

.github/workflows/pull_request.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Pull request
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
jobs:
8+
tests:
9+
name: Test
10+
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
11+
with:
12+
linux_exclude_swift_versions: '[{"swift_version": "5.9"}, {"swift_version": "5.10"}]'
13+
enable_windows_checks: false
14+
enable_macos_checks: false
15+
soundness:
16+
name: Soundness
17+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
18+
with:
19+
license_header_check_project_name: "Swift.org"
20+
unacceptable_language_check_enabled: false
21+
format_check_enabled: false
22+
bench:
23+
name: Benchmark
24+
runs-on: ubuntu-latest
25+
env:
26+
BUILD_CMD: swift build -c release
27+
BENCH_CMD: .build/release/RegexBenchmark
28+
BASELINE_FILE: benchmark-baseline
29+
COMPARE_FILE: benchmark-pr
30+
COMPARE_OUT_FILE: benchmark-results.txt
31+
steps:
32+
- name: Check out baseline branch
33+
uses: actions/checkout@v4
34+
with:
35+
ref: ${{ github.event.pull_request.base.sha }}
36+
path: base
37+
fetch-depth: 0
38+
- name: Build baseline branch
39+
working-directory: base
40+
run: |
41+
set -euo pipefail
42+
eval "$BUILD_CMD"
43+
- name: Run baseline benchmark
44+
working-directory: base
45+
run: |
46+
set -euo pipefail
47+
eval "$BENCH_CMD --save $RUNNER_TEMP/$BASELINE_FILE"
48+
test -s "$RUNNER_TEMP/$BASELINE_FILE" || { echo "Baseline not created at $BASELINE_FILE"; exit 1; }
49+
- name: Check out PR branch
50+
uses: actions/checkout@v4
51+
with:
52+
ref: ${{ github.event.pull_request.head.sha }}
53+
path: pr
54+
fetch-depth: 0
55+
- name: Build PR branch
56+
working-directory: pr
57+
run: |
58+
set -euo pipefail
59+
eval "$BUILD_CMD"
60+
- name: Run PR benchmark
61+
working-directory: pr
62+
run: |
63+
set -euo pipefail
64+
eval "$BENCH_CMD --save $RUNNER_TEMP/$COMPARE_FILE"
65+
test -s "$RUNNER_TEMP/$COMPARE_FILE" || { echo "Comparison not created at $COMPARE_FILE"; exit 1; }
66+
eval "$BENCH_CMD --compare $RUNNER_TEMP/$BASELINE_FILE" | tee "$RUNNER_TEMP/$COMPARE_OUT_FILE"
67+
- name: 📊 Compare benchmarks
68+
working-directory: pr
69+
run: |
70+
set -euo pipefail
71+
eval "$BENCH_CMD --load $RUNNER_TEMP/$COMPARE_FILE --compare $RUNNER_TEMP/$BASELINE_FILE --compare-compile-time $RUNNER_TEMP/$BASELINE_FILE" | tee "$RUNNER_TEMP/$COMPARE_OUT_FILE"
72+
- name: Upload benchmark artifacts
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: benchmark-results
76+
path: |
77+
${{ runner.temp }}/${{ env.BASELINE_FILE }}
78+
${{ runner.temp }}/${{ env.COMPARE_FILE }}
79+
${{ runner.temp }}/${{ env.COMPARE_OUT_FILE }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,6 @@ fastlane/test_output
9393
# https://github.com/johnno1962/injectionforxcode
9494

9595
iOSInjectionProject/
96+
97+
# DocC build folder
98+
*.docc-build

.license_header_template

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@@===----------------------------------------------------------------------===@@
2+
@@
3+
@@ This source file is part of the Swift.org open source project
4+
@@
5+
@@ Copyright (c) YEARS 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+
@@
10+
@@===----------------------------------------------------------------------===@@

.licenseignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.gitignore
2+
**/.gitignore
3+
.licenseignore
4+
.gitattributes
5+
.git-blame-ignore-revs
6+
.mailfilter
7+
.mailmap
8+
.spi.yml
9+
.swift-format
10+
.editorconfig
11+
.github/*
12+
.build
13+
*.py
14+
*.yml
15+
*.yaml
16+
*.cmake
17+
*.cmake.in
18+
Package.swift
19+
**/Package.swift
20+
Package@*.swift
21+
**/Package@*.swift
22+
Package.resolved
23+
**/Package.resolved
24+
.unacceptablelanguageignore
25+
-a*/Snapshots/*

CMakeLists.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

Documentation/ProgrammersManual.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Programmer's Manual
2+
3+
## Programming patterns
4+
5+
### Engine quick checks and fast paths
6+
7+
In the engine nomenclature, a quick-check results in a yes/no/maybe while a thorough check always results in a definite answer.
8+
9+
The nature of quick checks and fast paths is that they bifurcate testing coverage. One easy way to prevent this in simple cases is to assert that a definite quick result matches the thorough result.
10+
11+
One example of this pattern is matching against a builtin character class. The engine has a `_matchBuiltinCC`
12+
13+
```swift
14+
func _matchBuiltinCC(...) -> Input.Index? {
15+
// Calls _quickMatchBuiltinCC, if that gives a definite result
16+
// asserts that it is the same as the result of
17+
// _thoroughMatchBuiltinCC and returns it. Otherwise returns the
18+
// result of _thoroughMatchBuiltinCC
19+
}
20+
21+
@inline(__always)
22+
func _quickMatchBuiltinCC(...) -> QuickResult<Input.Index?>
23+
24+
@inline(never)
25+
func _thoroughMatchBuiltinCC(...) -> Input.Index?
26+
```
27+
28+
The thorough check is never inlined, as it is a lot of cold code. Note that quick and thorough functions should be pure, that is they shouldn't update processor state.
29+
30+

Package.swift

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,23 @@ let availabilityDefinition = PackageDescription.SwiftSetting.unsafeFlags([
77
"-Xfrontend",
88
"-define-availability",
99
"-Xfrontend",
10-
"SwiftStdlib 5.7:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999",
10+
"SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0",
11+
"-Xfrontend",
12+
"-define-availability",
13+
"-Xfrontend",
14+
"SwiftStdlib 5.8:macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4",
15+
"-Xfrontend",
16+
"-define-availability",
17+
"-Xfrontend",
18+
"SwiftStdlib 5.9:macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0",
19+
"-Xfrontend",
20+
"-define-availability",
21+
"-Xfrontend",
22+
"SwiftStdlib 5.10:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999",
23+
"-Xfrontend",
24+
"-define-availability",
25+
"-Xfrontend",
26+
"SwiftStdlib 6.0:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999",
1127
])
1228

1329
/// Swift settings for building a private stdlib-like module that is to be used
@@ -42,9 +58,10 @@ let package = Package(
4258
.executable(
4359
name: "VariadicsGenerator",
4460
targets: ["VariadicsGenerator"]),
61+
// Disable to work around rdar://126877024
4562
.executable(
46-
name: "RegexBenchmark",
47-
targets: ["RegexBenchmark"])
63+
name: "RegexBenchmark",
64+
targets: ["RegexBenchmark"])
4865
],
4966
dependencies: [
5067
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
@@ -75,18 +92,28 @@ let package = Package(
7592
name: "RegexBuilder",
7693
dependencies: ["_StringProcessing", "_RegexParser"],
7794
swiftSettings: publicStdlibSettings),
95+
.target(name: "TestSupport",
96+
swiftSettings: [availabilityDefinition]),
7897
.testTarget(
7998
name: "RegexTests",
80-
dependencies: ["_StringProcessing"],
99+
dependencies: ["_StringProcessing", "RegexBuilder", "TestSupport"],
81100
swiftSettings: [
82-
.unsafeFlags(["-Xfrontend", "-disable-availability-checking"]),
101+
availabilityDefinition
83102
]),
84103
.testTarget(
85104
name: "RegexBuilderTests",
105+
dependencies: ["_StringProcessing", "RegexBuilder", "TestSupport"],
106+
swiftSettings: [
107+
availabilityDefinition
108+
]),
109+
.testTarget(
110+
name: "DocumentationTests",
86111
dependencies: ["_StringProcessing", "RegexBuilder"],
87112
swiftSettings: [
88-
.unsafeFlags(["-Xfrontend", "-disable-availability-checking"])
113+
availabilityDefinition,
114+
.unsafeFlags(["-enable-bare-slash-regex"]),
89115
]),
116+
90117
// FIXME: Disabled due to rdar://94763190.
91118
// .testTarget(
92119
// name: "Prototypes",
@@ -114,7 +141,8 @@ let package = Package(
114141
.product(name: "ArgumentParser", package: "swift-argument-parser"),
115142
"_RegexParser",
116143
"_StringProcessing"
117-
]),
144+
],
145+
swiftSettings: [availabilityDefinition]),
118146
.executableTarget(
119147
name: "RegexBenchmark",
120148
dependencies: [

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ See [Declarative String Processing Overview][decl-string]
88

99
## Requirements
1010

11-
- [Swift Trunk Development Snapshot](https://www.swift.org/download/#snapshots) DEVELOPMENT-SNAPSHOT-2022-04-20 or later.
11+
- Currently tested with [Swift Trunk Development Snapshot](https://www.swift.org/download/#snapshots) DEVELOPMENT-SNAPSHOT-2025-09-14 or later.
1212

1313
## Trying it out
1414

@@ -27,7 +27,7 @@ For example, in a `Package.swift` file's target declaration:
2727

2828
## Integration with Swift
2929

30-
`_RegexParser` and `_StringProcessing` are specially integrated modules that are built as part of apple/swift.
30+
`_RegexParser` and `_StringProcessing` are specially integrated modules that are built as part of [apple/swift](https://github.com/apple/swift).
3131

3232
Specifically, `_RegexParser` contains the parser for regular expression literals and is built both as part of the compiler and as a core library. `_CUnicode` and `_StringProcessing` are built together as a core library named `_StringProcessing`.
3333

@@ -39,17 +39,14 @@ Specifically, `_RegexParser` contains the parser for regular expression literals
3939

4040
### Branching scheme
4141

42-
#### Development branch
43-
4442
The `main` branch is the branch for day-to-day development. Generally, you should create PRs against this branch.
4543

46-
#### Swift integration branches
47-
4844
Branches whose name starts with `swift/` are Swift integration branches similar to those in [apple/llvm-project](https://github.com/apple/llvm-project). For each branch, dropping the `swift/` prefix is the corresponding branch in [apple/swift](https://github.com/apple/swift).
4945

46+
This package's `main` branch automatically integrates with Swift's `main` branch.
47+
5048
| apple/swift branch | apple/swift-experimental-string-processing branch |
5149
| ------------------- | ----------------------------------------------------- |
52-
| main | swift/main |
5350
| release/5.7 | swift/release/5.7 |
5451
| ... | swift/... |
5552

@@ -59,11 +56,13 @@ A pair of corresponding branches are expected to build successfully together and
5956

6057
To integrate the latest changes in apple/swift-experimental-string-processing to apple/swift, carefully follow the workflow:
6158

62-
- Create pull requests.
63-
- Create a branch from a commit on `main` that you would like to integrate into `swift/main`.
64-
- Create a pull request in apple/swift-experimental-string-processing from that branch to `swift/main`, e.g. "[Integration] main (<commit>) -> swift/main".
65-
- If apple/swift needs to be modified to work with the latest `main` in apple/swift-experimental-string-processing, create a pull request in apple/swift. **Note:** Since CI in apple/swift-experimental-string-processing has not yet been set up to run full toolchain tests, you should create a PR in apple/swift regardless; if the integartion does not require changing apple/swift, create a dummy PR in apple/swift by changing the README and just not merge it in the end.
66-
- Trigger CI.
59+
- Run package CI
60+
- In the pull request, trigger package CI using
61+
```
62+
@swift-ci please test
63+
```
64+
- Run full Swift CI for any changes to public or SPI interfaces or the `_RegexParser` module.
65+
- If apple/swift needs to be modified to work with the latest `main` in apple/swift-experimental-string-processing, create a pull request in apple/swift. **Note:** Since CI in apple/swift-experimental-string-processing has not yet been set up to run full toolchain tests, you should create a PR in apple/swift regardless; if the integration does not require changing apple/swift, create a dummy PR in apple/swift by changing the README and close it in the end instead of merging.
6766
- In the apple/swift-experimental-string-processing pull request, trigger CI using the following command (replacing `<PR NUMBER>` with the apple/swift pull request number, if any):
6867
```
6968
apple/swift#<PR NUMBER> # use this line only if there is an corresponding apple/swift PR
@@ -75,7 +74,9 @@ To integrate the latest changes in apple/swift-experimental-string-processing to
7574
@swift-ci please test
7675
```
7776
- Merge when approved.
78-
- Merge the pull request in apple/swift-experimental-string-processing as a **merge commit**.
77+
- Merge the PR in apple/swift-experimental-string-processing:
78+
- as a squash or rebase if against main (the development branch).
79+
- as a merge commit if it's a merge from main to swift/release/x.y.
7980
- Merge the pull request in apple/swift (if any).
8081
8182
### Development notes

0 commit comments

Comments
 (0)