Skip to content

Commit 613dd1a

Browse files
Resolving conflicts
2 parents f0b7572 + aacc903 commit 613dd1a

File tree

314 files changed

+6266
-7923
lines changed

Some content is hidden

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

314 files changed

+6266
-7923
lines changed

CHANGELOG.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,29 @@ Swift 5.2
5858
(foo as Magic)(5)
5959
```
6060

61+
* [SR-11298][]:
62+
63+
A class-constrained protocol extension, where the extended protocol does
64+
not impose a class constraint, will now infer the constraint implicitly.
65+
66+
```swift
67+
protocol Foo {}
68+
class Bar: Foo {
69+
var someProperty: Int = 0
70+
}
71+
72+
// Even though 'Foo' does not impose a class constraint, it is automatically
73+
// inferred due to the Self: Bar constraint.
74+
extension Foo where Self: Bar {
75+
var anotherProperty: Int {
76+
get { return someProperty }
77+
// As a result, the setter is now implicitly nonmutating, just like it would
78+
// be if 'Foo' had a class constraint.
79+
set { someProperty = newValue }
80+
}
81+
}
82+
```
83+
6184
* [SE-0253][]:
6285

6386
Values of types that declare `func callAsFunction` methods can be called
@@ -83,7 +106,7 @@ Swift 5.2
83106

84107
* [SR-4206][]:
85108

86-
A method override is no longer allowed to have a generic signature with
109+
A method override is no longer allowed to have a generic signature with
87110
requirements not imposed by the base method. For example:
88111

89112
```
@@ -7799,4 +7822,5 @@ Swift 1.0
77997822
[SR-8974]: <https://bugs.swift.org/browse/SR-8974>
78007823
[SR-9043]: <https://bugs.swift.org/browse/SR-9043>
78017824
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>
7825+
[SR-11298]: <https://bugs.swift.org/browse/SR-11298>
78027826
[SR-11429]: <https://bugs.swift.org/browse/SR-11429>

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@ option(SWIFT_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING
377377
"Build stdlibCore with exclusivity checking enabled"
378378
FALSE)
379379

380+
option(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING
381+
"Enable experimental Swift differentiable programming features"
382+
FALSE)
383+
380384
#
381385
# End of user-configurable options.
382386
#

benchmark/scripts/run_smoke_bench

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ def main():
9393
argparser.add_argument(
9494
'-num-samples', type=int,
9595
help='The (minimum) number of samples to run', default=3)
96+
argparser.add_argument(
97+
'-num-reruns', type=int,
98+
help="The number of re-runs until it's assumed to be a real change",
99+
default=8)
96100
argparser.add_argument(
97101
'-platform', type=str,
98102
help='The benchmark build platform', default='macosx')
@@ -120,7 +124,7 @@ def test_opt_levels(args):
120124
if test_performance(opt_level, args.oldbuilddir[0],
121125
args.newbuilddir[0],
122126
float(args.threshold) / 100, args.num_samples,
123-
output_file):
127+
args.num_reruns, output_file):
124128
changes = True
125129

126130
# There is no point in reporting code size for Onone.
@@ -171,7 +175,7 @@ def merge(results, other_results):
171175

172176

173177
def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
174-
output_file):
178+
num_reruns, output_file):
175179
"""Detect performance changes in benchmarks.
176180
177181
Start fast with few samples per benchmark and gradually spend more time
@@ -185,7 +189,7 @@ def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
185189
tests = TestComparator(results[0], results[1], threshold)
186190
changed = tests.decreased + tests.increased
187191

188-
while len(changed) > 0 and unchanged_length_count < 10:
192+
while len(changed) > 0 and unchanged_length_count < num_reruns:
189193
i += 1
190194
if VERBOSE:
191195
log(' test again: ' + str([test.name for test in changed]))

benchmark/single-source/ObjectiveCBridging.swift

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ public let ObjectiveCBridging = [
7979
BenchmarkInfo(name: "UnicodeStringFromCodable",
8080
runFunction: run_UnicodeStringFromCodable, tags: ts,
8181
setUpFunction: setup_UnicodeStringFromCodable),
82+
BenchmarkInfo(name: "NSArray.bridged.objectAtIndex",
83+
runFunction: run_BridgedNSArrayObjectAtIndex, tags: t,
84+
setUpFunction: setup_bridgedArrays),
85+
BenchmarkInfo(name: "NSArray.bridged.mutableCopy.objectAtIndex",
86+
runFunction: run_BridgedNSArrayMutableCopyObjectAtIndex, tags: t,
87+
setUpFunction: setup_bridgedArrays),
88+
BenchmarkInfo(name: "NSArray.nonbridged.objectAtIndex",
89+
runFunction: run_RealNSArrayObjectAtIndex, tags: t,
90+
setUpFunction: setup_bridgedArrays),
91+
BenchmarkInfo(name: "NSArray.nonbridged.mutableCopy.objectAtIndex",
92+
runFunction: run_RealNSArrayMutableCopyObjectAtIndex, tags: t,
93+
setUpFunction: setup_bridgedArrays),
8294
]
8395

8496
#if _runtime(_ObjC)
@@ -773,3 +785,65 @@ public func run_UnicodeStringFromCodable(_ N: Int) {
773785
}
774786
#endif
775787
}
788+
789+
#if _runtime(_ObjC)
790+
var bridgedArray:NSArray! = nil
791+
var bridgedArrayMutableCopy:NSMutableArray! = nil
792+
var nsArray:NSArray! = nil
793+
var nsArrayMutableCopy:NSMutableArray! = nil
794+
#endif
795+
796+
public func setup_bridgedArrays() {
797+
#if _runtime(_ObjC)
798+
var arr = Array(repeating: NSObject(), count: 100) as [AnyObject]
799+
bridgedArray = arr as NSArray
800+
bridgedArrayMutableCopy = (bridgedArray.mutableCopy() as! NSMutableArray)
801+
nsArray = NSArray(objects: &arr, count: 100)
802+
nsArrayMutableCopy = (nsArray.mutableCopy() as! NSMutableArray)
803+
#endif
804+
}
805+
806+
@inline(never)
807+
public func run_BridgedNSArrayObjectAtIndex(_ N: Int) {
808+
#if _runtime(_ObjC)
809+
for _ in 0 ..< N * 50 {
810+
for i in 0..<100 {
811+
blackHole(bridgedArray[i])
812+
}
813+
}
814+
#endif
815+
}
816+
817+
@inline(never)
818+
public func run_BridgedNSArrayMutableCopyObjectAtIndex(_ N: Int) {
819+
#if _runtime(_ObjC)
820+
for _ in 0 ..< N * 100 {
821+
for i in 0..<100 {
822+
blackHole(bridgedArrayMutableCopy[i])
823+
}
824+
}
825+
#endif
826+
}
827+
828+
@inline(never)
829+
public func run_RealNSArrayObjectAtIndex(_ N: Int) {
830+
#if _runtime(_ObjC)
831+
for _ in 0 ..< N * 100 {
832+
for i in 0..<100 {
833+
blackHole(nsArray[i])
834+
}
835+
}
836+
#endif
837+
}
838+
839+
@inline(never)
840+
public func run_RealNSArrayMutableCopyObjectAtIndex(_ N: Int) {
841+
#if _runtime(_ObjC)
842+
for _ in 0 ..< N * 100 {
843+
for i in 0..<100 {
844+
blackHole(nsArrayMutableCopy[i])
845+
}
846+
}
847+
#endif
848+
}
849+

benchmark/single-source/UTF8Decode.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ public let UTF8Decode = [
4242
name: "UTF8Decode_InitFromBytes_ascii",
4343
runFunction: run_UTF8Decode_InitFromBytes_ascii,
4444
tags: [.validation, .api, .String]),
45+
BenchmarkInfo(
46+
name: "UTF8Decode_InitFromData_ascii_as_ascii",
47+
runFunction: run_UTF8Decode_InitFromData_ascii_as_ascii,
48+
tags: [.validation, .api, .String]),
49+
BenchmarkInfo(
50+
name: "UTF8Decode_InitDecoding_ascii_as_ascii",
51+
runFunction: run_UTF8Decode_InitDecoding_ascii_as_ascii,
52+
tags: [.validation, .api, .String]),
53+
BenchmarkInfo(
54+
name: "UTF8Decode_InitFromBytes_ascii_as_ascii",
55+
runFunction: run_UTF8Decode_InitFromBytes_ascii_as_ascii,
56+
tags: [.validation, .api, .String]),
4557
]
4658

4759
// 1-byte sequences
@@ -129,4 +141,26 @@ public func run_UTF8Decode_InitFromBytes_ascii(_ N: Int) {
129141
}
130142
}
131143

144+
@inline(never)
145+
public func run_UTF8Decode_InitFromData_ascii_as_ascii(_ N: Int) {
146+
let input = asciiData
147+
for _ in 0..<1_000*N {
148+
blackHole(String(data: input, encoding: .ascii))
149+
}
150+
}
151+
@inline(never)
152+
public func run_UTF8Decode_InitDecoding_ascii_as_ascii(_ N: Int) {
153+
let input = asciiBytes
154+
for _ in 0..<1_000*N {
155+
blackHole(String(decoding: input, as: Unicode.ASCII.self))
156+
}
157+
}
158+
@inline(never)
159+
public func run_UTF8Decode_InitFromBytes_ascii_as_ascii(_ N: Int) {
160+
let input = asciiBytes
161+
for _ in 0..<1_000*N {
162+
blackHole(String(bytes: input, encoding: .ascii))
163+
}
164+
}
165+
132166

cmake/modules/AddSwift.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@ function(_add_variant_swift_compile_flags
422422
list(APPEND result "-D" "SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS")
423423
endif()
424424

425+
if(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING)
426+
list(APPEND result "-D" "SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING")
427+
endif()
428+
425429
set("${result_var_name}" "${result}" PARENT_SCOPE)
426430
endfunction()
427431

cmake/modules/SwiftHandleGybSources.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,10 @@ function(handle_gyb_sources dependency_out_var_name sources_var_name arch)
118118
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/AttributeNodes.py"
119119
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/AvailabilityNodes.py"
120120
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/CommonNodes.py"
121-
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/CompletionOnlyNodes.py"
122121
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/DeclNodes.py"
123122
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/ExprNodes.py"
124123
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/GenericNodes.py"
125-
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/NodeSerializationCodes.py"
126124
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/PatternNodes.py"
127-
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/SILOnlyNodes.py"
128125
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/StmtNodes.py"
129126
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/TypeNodes.py"
130127
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/Token.py"

cmake/modules/SwiftSource.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ function(_compile_swift_files
333333
"-emit-module-interface-path" "${interface_file}")
334334
endif()
335335

336+
if (NOT SWIFTFILE_IS_STDLIB_CORE)
337+
list(APPEND swift_module_flags
338+
"-Xfrontend" "-experimental-skip-non-inlinable-function-bodies")
339+
endif()
340+
336341
# If we have extra regexp flags, check if we match any of the regexps. If so
337342
# add the relevant flags to our swift_flags.
338343
if (SWIFT_EXPERIMENTAL_EXTRA_REGEXP_FLAGS OR SWIFT_EXPERIMENTAL_EXTRA_NEGATIVE_REGEXP_FLAGS)

docs/WindowsBuild.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ mklink "%VCToolsInstallDir%\include\visualc.apinotes" S:\swift\stdlib\public\Pla
9999
Warning: Creating the above links usually requires administrator privileges. The quick and easy way to do this is to open a second developer prompt by right clicking whatever shortcut you used to open the first one, choosing Run As Administrator, and pasting the above commands into the resulting window. You can then close the privileged prompt; this is the only step which requires elevation.
100100

101101
## 6. Build LLVM/Clang
102-
- This must be done from within a developer command prompt. LLVM and Clang are
103-
large projects, so building might take a few hours. Make sure that the build
102+
- This must be done from within a developer command prompt. Make sure that the build
104103
type for LLVM/Clang is compatible with the build type for Swift. That is,
105104
either build everything `Debug` or some variant of `Release` (e.g. `Release`,
106105
`RelWithDebInfo`).
@@ -126,8 +125,8 @@ ninja
126125
path S:\b\llvm\bin;%PATH%
127126
```
128127
## 7. Build CMark
129-
- This must be done from within a developer command prompt. CMark is a fairly
130-
small project and should only take a few minutes to build.
128+
- This must be done from within a developer command prompt.
129+
131130
```cmd
132131
md "S:\b\cmark"
133132
cd "S:\b\cmark"
@@ -180,8 +179,8 @@ cmake -G "Visual Studio 2017" -A x64 -T "host=x64"^ ...
180179
```
181180

182181
## 9. Build lldb
183-
- This must be done from within a developer command prompt and could take hours
184-
depending on your system.
182+
- This must be done from within a developer command prompt.
183+
185184
```cmd
186185
md "S:\b\lldb"
187186
cd "S:\b\lldb"

include/swift/AST/AnyFunctionRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ class AnyFunctionRef {
5252
}
5353
}
5454

55-
const CaptureInfo &getCaptureInfo() const {
55+
CaptureInfo getCaptureInfo() const {
5656
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>())
5757
return AFD->getCaptureInfo();
5858
return TheFunction.get<AbstractClosureExpr *>()->getCaptureInfo();
5959
}
6060

61-
void setCaptureInfo(const CaptureInfo &captures) const {
61+
void setCaptureInfo(CaptureInfo captures) const {
6262
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
6363
AFD->setCaptureInfo(captures);
6464
return;

0 commit comments

Comments
 (0)