Skip to content

Commit 62799c0

Browse files
committed
Merge branch 'master' into swift5-version
# Conflicts: # test/api-digester/Outputs/stability-stdlib-source.swift.expected
2 parents 748dae7 + c6874bb commit 62799c0

File tree

322 files changed

+5619
-3248
lines changed

Some content is hidden

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

322 files changed

+5619
-3248
lines changed

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,39 @@ CHANGELOG
2424
Swift 5.0
2525
---------
2626

27+
* [SR-7139][]:
28+
29+
Exclusive memory access is now enforced at runtime by default in
30+
optimized (`-O`/`-Osize`) builds. Programs that violate exclusivity will
31+
trap at runtime with an "overlapping access" diagnostic
32+
message. This can be disabled via a command line flag:
33+
`-enforce-exclusivity=unchecked`, but doing so may result in undefined
34+
behavior.
35+
36+
Runtime violations of exclusivity typically result from
37+
simultaneous access of class properties, global variables (including
38+
variables in top-level code), or variables captured by escaping
39+
closures.
40+
41+
* [SE-0216][]:
42+
43+
The `@dynamicCallable` attribute enables nominal types to be "callable" via a
44+
simple syntactic sugar. The primary use case is dynamic language
45+
interoperability.
46+
47+
Toy example:
48+
49+
```swift
50+
@dynamicCallable
51+
struct ToyCallable {
52+
func dynamicallyCall(withArguments: [Int]) {}
53+
func dynamicallyCall(withKeywordArguments: KeyValuePairs<String, Int>) {}
54+
}
55+
let x = ToyCallable()
56+
x(1, 2, 3) // desugars to `x.dynamicallyCall(withArguments: [1, 2, 3])`
57+
x(label: 1, 2) // desugars to `x.dynamicallyCall(withKeywordArguments: ["label": 1, "": 2])`
58+
```
59+
2760
* [SR-7251][]:
2861

2962
In Swift 5 mode, attempting to declare a static property with the same name as a
@@ -7259,6 +7292,7 @@ Swift 1.0
72597292
[SE-0224]: <https://github.com/apple/swift-evolution/blob/master/proposals/0224-ifswift-lessthan-operator.md>
72607293
[SE-0225]: <https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md>
72617294
[SE-0226]: <https://github.com/apple/swift-evolution/blob/master/proposals/0226-package-manager-target-based-dep-resolution.md>
7295+
[SE-0227]: <https://github.com/apple/swift-evolution/blob/master/proposals/0227-identity-keypath.md>
72627296

72637297
[SR-106]: <https://bugs.swift.org/browse/SR-106>
72647298
[SR-419]: <https://bugs.swift.org/browse/SR-419>
@@ -7270,4 +7304,5 @@ Swift 1.0
72707304
[SR-2394]: <https://bugs.swift.org/browse/SR-2394>
72717305
[SR-2608]: <https://bugs.swift.org/browse/SR-2608>
72727306
[SR-4248]: <https://bugs.swift.org/browse/SR-4248>
7307+
[SR-7139]: <https://bugs.swift.org/browse/SR-7139>
72737308
[SR-7251]: <https://bugs.swift.org/browse/SR-7251>

benchmark/single-source/DataBenchmarks.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,49 +17,49 @@ public let DataBenchmarks = [
1717
BenchmarkInfo(name: "DataCreateEmpty", runFunction: run_createEmpty, tags: [.validation, .api, .Data]),
1818
BenchmarkInfo(name: "DataCreateSmall", runFunction: run_createSmall, tags: [.validation, .api, .Data]),
1919
BenchmarkInfo(name: "DataCreateMedium", runFunction: run_createMedium, tags: [.validation, .api, .Data]),
20-
BenchmarkInfo(name: "DataCreateLarge", runFunction: run_createLarge, tags: [.validation, .api, .Data]),
20+
BenchmarkInfo(name: "DataCreateLarge", runFunction: run_createLarge, tags: [.validation, .api, .Data, .skip]),
2121
BenchmarkInfo(name: "DataCreateEmptyArray", runFunction: run_createEmptyArray, tags: [.validation, .api, .Data]),
2222
BenchmarkInfo(name: "DataCreateSmallArray", runFunction: run_createSmallArray, tags: [.validation, .api, .Data]),
2323
BenchmarkInfo(name: "DataCreateMediumArray", runFunction: run_createMediumArray, tags: [.validation, .api, .Data]),
2424
BenchmarkInfo(name: "DataSubscriptSmall", runFunction: run_SubscriptSmall, tags: [.validation, .api, .Data]),
2525
BenchmarkInfo(name: "DataSubscriptMedium", runFunction: run_SubscriptMedium, tags: [.validation, .api, .Data]),
26-
BenchmarkInfo(name: "DataSubscriptLarge", runFunction: run_SubscriptLarge, tags: [.validation, .api, .Data]),
26+
BenchmarkInfo(name: "DataSubscriptLarge", runFunction: run_SubscriptLarge, tags: [.validation, .api, .Data, .skip]),
2727
BenchmarkInfo(name: "DataCountSmall", runFunction: run_CountSmall, tags: [.validation, .api, .Data]),
2828
BenchmarkInfo(name: "DataCountMedium", runFunction: run_CountMedium, tags: [.validation, .api, .Data]),
29-
BenchmarkInfo(name: "DataCountLarge", runFunction: run_CountLarge, tags: [.validation, .api, .Data]),
29+
BenchmarkInfo(name: "DataCountLarge", runFunction: run_CountLarge, tags: [.validation, .api, .Data, .skip]),
3030
BenchmarkInfo(name: "DataSetCountSmall", runFunction: run_SetCountSmall, tags: [.validation, .api, .Data]),
3131
BenchmarkInfo(name: "DataSetCountMedium", runFunction: run_SetCountMedium, tags: [.validation, .api, .Data]),
32-
BenchmarkInfo(name: "DataSetCountLarge", runFunction: run_SetCountLarge, tags: [.validation, .api, .Data]),
32+
BenchmarkInfo(name: "DataSetCountLarge", runFunction: run_SetCountLarge, tags: [.validation, .api, .Data, .skip]),
3333
BenchmarkInfo(name: "DataAccessBytesSmall", runFunction: run_AccessBytesSmall, tags: [.validation, .api, .Data]),
3434
BenchmarkInfo(name: "DataAccessBytesMedium", runFunction: run_AccessBytesMedium, tags: [.validation, .api, .Data]),
35-
BenchmarkInfo(name: "DataAccessBytesLarge", runFunction: run_AccessBytesLarge, tags: [.validation, .api, .Data]),
35+
BenchmarkInfo(name: "DataAccessBytesLarge", runFunction: run_AccessBytesLarge, tags: [.validation, .api, .Data, .skip]),
3636
BenchmarkInfo(name: "DataMutateBytesSmall", runFunction: run_MutateBytesSmall, tags: [.validation, .api, .Data]),
3737
BenchmarkInfo(name: "DataMutateBytesMedium", runFunction: run_MutateBytesMedium, tags: [.validation, .api, .Data]),
38-
BenchmarkInfo(name: "DataMutateBytesLarge", runFunction: run_MutateBytesLarge, tags: [.validation, .api, .Data]),
38+
BenchmarkInfo(name: "DataMutateBytesLarge", runFunction: run_MutateBytesLarge, tags: [.validation, .api, .Data, .skip]),
3939
BenchmarkInfo(name: "DataCopyBytesSmall", runFunction: run_CopyBytesSmall, tags: [.validation, .api, .Data]),
4040
BenchmarkInfo(name: "DataCopyBytesMedium", runFunction: run_CopyBytesMedium, tags: [.validation, .api, .Data]),
41-
BenchmarkInfo(name: "DataCopyBytesLarge", runFunction: run_CopyBytesLarge, tags: [.validation, .api, .Data]),
41+
BenchmarkInfo(name: "DataCopyBytesLarge", runFunction: run_CopyBytesLarge, tags: [.validation, .api, .Data, .skip]),
4242
BenchmarkInfo(name: "DataAppendBytesSmall", runFunction: run_AppendBytesSmall, tags: [.validation, .api, .Data]),
4343
BenchmarkInfo(name: "DataAppendBytesMedium", runFunction: run_AppendBytesMedium, tags: [.validation, .api, .Data]),
44-
BenchmarkInfo(name: "DataAppendBytesLarge", runFunction: run_AppendBytesLarge, tags: [.validation, .api, .Data]),
44+
BenchmarkInfo(name: "DataAppendBytesLarge", runFunction: run_AppendBytesLarge, tags: [.validation, .api, .Data, .skip]),
4545
BenchmarkInfo(name: "DataAppendArray", runFunction: run_AppendArray, tags: [.validation, .api, .Data]),
4646
BenchmarkInfo(name: "DataReset", runFunction: run_Reset, tags: [.validation, .api, .Data]),
4747
BenchmarkInfo(name: "DataReplaceSmall", runFunction: run_ReplaceSmall, tags: [.validation, .api, .Data]),
4848
BenchmarkInfo(name: "DataReplaceMedium", runFunction: run_ReplaceMedium, tags: [.validation, .api, .Data]),
4949
BenchmarkInfo(name: "DataReplaceLarge", runFunction: run_ReplaceLarge, tags: [.validation, .api, .Data]),
5050
BenchmarkInfo(name: "DataReplaceSmallBuffer", runFunction: run_ReplaceSmallBuffer, tags: [.validation, .api, .Data]),
5151
BenchmarkInfo(name: "DataReplaceMediumBuffer", runFunction: run_ReplaceMediumBuffer, tags: [.validation, .api, .Data]),
52-
BenchmarkInfo(name: "DataReplaceLargeBuffer", runFunction: run_ReplaceLargeBuffer, tags: [.validation, .api, .Data]),
52+
BenchmarkInfo(name: "DataReplaceLargeBuffer", runFunction: run_ReplaceLargeBuffer, tags: [.validation, .api, .Data, .skip]),
5353
BenchmarkInfo(name: "DataAppendSequence", runFunction: run_AppendSequence, tags: [.validation, .api, .Data]),
5454
BenchmarkInfo(name: "DataAppendDataSmallToSmall", runFunction: run_AppendDataSmallToSmall, tags: [.validation, .api, .Data]),
5555
BenchmarkInfo(name: "DataAppendDataSmallToMedium", runFunction: run_AppendDataSmallToMedium, tags: [.validation, .api, .Data]),
5656
BenchmarkInfo(name: "DataAppendDataSmallToLarge", runFunction: run_AppendDataSmallToLarge, tags: [.validation, .api, .Data]),
5757
BenchmarkInfo(name: "DataAppendDataMediumToSmall", runFunction: run_AppendDataMediumToSmall, tags: [.validation, .api, .Data]),
5858
BenchmarkInfo(name: "DataAppendDataMediumToMedium", runFunction: run_AppendDataMediumToMedium, tags: [.validation, .api, .Data]),
59-
BenchmarkInfo(name: "DataAppendDataMediumToLarge", runFunction: run_AppendDataMediumToLarge, tags: [.validation, .api, .Data]),
59+
BenchmarkInfo(name: "DataAppendDataMediumToLarge", runFunction: run_AppendDataMediumToLarge, tags: [.validation, .api, .Data, .skip]),
6060
BenchmarkInfo(name: "DataAppendDataLargeToSmall", runFunction: run_AppendDataLargeToSmall, tags: [.validation, .api, .Data]),
6161
BenchmarkInfo(name: "DataAppendDataLargeToMedium", runFunction: run_AppendDataLargeToMedium, tags: [.validation, .api, .Data]),
62-
BenchmarkInfo(name: "DataAppendDataLargeToLarge", runFunction: run_AppendDataLargeToLarge, tags: [.validation, .api, .Data]),
62+
BenchmarkInfo(name: "DataAppendDataLargeToLarge", runFunction: run_AppendDataLargeToLarge, tags: [.validation, .api, .Data, .skip]),
6363
BenchmarkInfo(name: "DataToStringEmpty", runFunction: run_DataToStringEmpty, tags: [.validation, .api, .Data]),
6464
BenchmarkInfo(name: "DataToStringSmall", runFunction: run_DataToStringSmall, tags: [.validation, .api, .Data]),
6565
BenchmarkInfo(name: "DataToStringMedium", runFunction: run_DataToStringMedium, tags: [.validation, .api, .Data]),

cmake/modules/AddSwift.cmake

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,7 @@ endfunction()
20782078
function(_add_swift_executable_single name)
20792079
# Parse the arguments we were given.
20802080
cmake_parse_arguments(SWIFTEXE_SINGLE
2081-
"EXCLUDE_FROM_ALL;DONT_STRIP_NON_MAIN_SYMBOLS;DISABLE_ASLR"
2081+
"EXCLUDE_FROM_ALL"
20822082
"SDK;ARCHITECTURE"
20832083
"DEPENDS;LLVM_COMPONENT_DEPENDS;LINK_LIBRARIES;LINK_FAT_LIBRARIES;COMPILE_FLAGS"
20842084
${ARGN})
@@ -2121,10 +2121,6 @@ function(_add_swift_executable_single name)
21212121
RESULT_VAR_NAME link_flags
21222122
LIBRARY_SEARCH_DIRECTORIES_VAR_NAME library_search_directories)
21232123

2124-
if(SWIFTEXE_SINGLE_DISABLE_ASLR)
2125-
list(APPEND link_flags "-Wl,-no_pie")
2126-
endif()
2127-
21282124
if(${SWIFTEXE_SINGLE_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
21292125
list(APPEND link_flags
21302126
"-Xlinker" "-rpath"
@@ -2205,7 +2201,7 @@ endfunction()
22052201
function(add_swift_target_executable name)
22062202
# Parse the arguments we were given.
22072203
cmake_parse_arguments(SWIFTEXE_TARGET
2208-
"EXCLUDE_FROM_ALL;DONT_STRIP_NON_MAIN_SYMBOLS;DISABLE_ASLR;BUILD_WITH_STDLIB"
2204+
"EXCLUDE_FROM_ALL;;BUILD_WITH_STDLIB"
22092205
""
22102206
"DEPENDS;LLVM_COMPONENT_DEPENDS;LINK_FAT_LIBRARIES"
22112207
${ARGN})
@@ -2215,12 +2211,6 @@ function(add_swift_target_executable name)
22152211
translate_flag(${SWIFTEXE_TARGET_EXCLUDE_FROM_ALL}
22162212
"EXCLUDE_FROM_ALL"
22172213
SWIFTEXE_TARGET_EXCLUDE_FROM_ALL_FLAG)
2218-
translate_flag(${SWIFTEXE_TARGET_DONT_STRIP_NON_MAIN_SYMBOLS}
2219-
"DONT_STRIP_NON_MAIN_SYMBOLS"
2220-
SWIFTEXE_TARGET_DONT_STRIP_NON_MAIN_SYMBOLS_FLAG)
2221-
translate_flag(${SWIFTEXE_TARGET_DISABLE_ASLR}
2222-
"DISABLE_ASLR"
2223-
SWIFTEXE_DISABLE_ASLR_FLAG)
22242214

22252215
# All Swift executables depend on the standard library.
22262216
list(APPEND SWIFTEXE_TARGET_LINK_FAT_LIBRARIES swiftCore)
@@ -2263,9 +2253,7 @@ function(add_swift_target_executable name)
22632253
SDK "${sdk}"
22642254
ARCHITECTURE "${arch}"
22652255
LINK_FAT_LIBRARIES ${SWIFTEXE_TARGET_LINK_FAT_LIBRARIES}
2266-
${SWIFTEXE_TARGET_EXCLUDE_FROM_ALL_FLAG_CURRENT}
2267-
${SWIFTEXE_TARGET_DONT_STRIP_NON_MAIN_SYMBOLS_FLAG}
2268-
${SWIFTEXE_DISABLE_ASLR_FLAG})
2256+
${SWIFTEXE_TARGET_EXCLUDE_FROM_ALL_FLAG_CURRENT})
22692257

22702258
if(${sdk} IN_LIST SWIFT_APPLE_PLATFORMS)
22712259
add_custom_command_target(unused_var2

docs/ABI/Mangling.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ The following symbolic reference kinds are currently implemented:
9090
dependent-associated-conformance ::= '\x05' .{4} // Reference points directly to associated conformance descriptor (NOT IMPLEMENTED)
9191
dependent-associated-conformance ::= '\x06' .{4} // Reference points indirectly to associated conformance descriptor (NOT IMPLEMENTED)
9292

93+
associated-conformance-acceess-function ::= '\x07' .{4} // Reference points directly to associated conformance access function relative to the protocol
94+
associated-conformance-acceess-function ::= '\x08' .{4} // Reference points directly to associated conformance access function relative to the conforming type
95+
keypath-metadata-access-function ::= '\x09' {.4} // Reference points directly to keypath type metadata access function
96+
9397
Globals
9498
~~~~~~~
9599

@@ -289,8 +293,8 @@ Entities
289293
ACCESSOR ::= 'p' // pseudo accessor referring to the storage itself
290294

291295
ADDRESSOR-KIND ::= 'u' // unsafe addressor (no owner)
292-
ADDRESSOR-KIND ::= 'O' // owning addressor (non-native owner)
293-
ADDRESSOR-KIND ::= 'o' // owning addressor (native owner)
296+
ADDRESSOR-KIND ::= 'O' // owning addressor (non-native owner), not used anymore
297+
ADDRESSOR-KIND ::= 'o' // owning addressor (native owner), not used anymore
294298
ADDRESSOR-KIND ::= 'p' // pinning addressor (native owner), not used anymore
295299

296300
decl-name ::= identifier

docs/ABIStabilityManifesto.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ ABI stability means nailing down type layout and making decisions about how to h
213213

214214
For all of the areas discussed above, more aggressive layout improvements may be invented in the post-ABI stability future. For example, we may want to explore rearranging and packing nested type data members with outer type data members. Such improvements would have to be done in an ABI-additive fashion through deployment target and/or min-version checking. This may mean that the module file will need to track per-type ABI versioning information.
215215

216-
A potentially out of date description of Swift's current type layout can be found in the [Type Layout docs](https://github.com/apple/swift/blob/master/docs/ABI.rst#type-layout).
216+
A potentially out of date description of Swift's current type layout can be found in the [Type Layout docs](https://github.com/apple/swift/blob/master/docs/ABI/TypeLayout.rst).
217217

218218

219219
## <a name="metadata"></a>Type Metadata
@@ -230,7 +230,7 @@ Metadata has many historical artifacts in its representation that we want to cle
230230

231231
Stabilizing the ABI means producing a precise technical specification for the fixed part of the metadata layout of all language constructs so that future compilers and tools can continue to read and write them. A prose description is not necessarily needed, though explanations are useful. We will also want to carve out extra space for areas where it is likely to be needed for future functionality [[SR-3731](https://bugs.swift.org/browse/SR-3731)].
232232

233-
For more, but potentially out of date, details see the [Type Metadata docs](https://github.com/apple/swift/blob/master/docs/ABI.rst#type-metadata).
233+
For more, but potentially out of date, details see the [Type Metadata docs](https://github.com/apple/swift/blob/master/docs/ABI/TypeMetadata.rst).
234234

235235
### Generic Parameters
236236

@@ -284,7 +284,7 @@ In addition to common metadata entries, function type metadata stores informatio
284284

285285
Mangling is used to produce unique symbols. It applies to both external (public) symbols as well as internal or hidden symbols. Only the mangling scheme for external symbols is part of ABI.
286286

287-
ABI stability means a stable mangling scheme, fully specified so that future compilers and tools can honor it. For a potentially out-of-date specification of what the mangling currently looks like, see the [Name Mangling docs](https://github.com/apple/swift/blob/master/docs/ABI.rst#mangling).
287+
ABI stability means a stable mangling scheme, fully specified so that future compilers and tools can honor it. For a potentially out-of-date specification of what the mangling currently looks like, see the [Name Mangling docs](https://github.com/apple/swift/blob/master/docs/ABI/Mangling.rst).
288288

289289
There are some corner cases currently in the mangling scheme that should be fixed before declaring ABI stability. We need to come up with a canonicalization of generic and protocol requirements to allow for order-agnostic mangling [[SR-3733](https://bugs.swift.org/browse/SR-3733)]. We also may decide to more carefully mangle variadicity of function parameters, etc [[SR-3734](https://bugs.swift.org/browse/SR-3734)]. Most often, though, mangling improvements focus on reducing symbol size.
290290

include/swift/ABI/Metadata.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,11 +625,27 @@ struct TargetMetadata {
625625
getValueWitnesses()->_asEVWT()->destructiveInjectEnumTag(value, tag, this);
626626
}
627627

628+
size_t vw_size() const {
629+
return getValueWitnesses()->getSize();
630+
}
631+
632+
size_t vw_alignment() const {
633+
return getValueWitnesses()->getAlignment();
634+
}
635+
636+
size_t vw_stride() const {
637+
return getValueWitnesses()->getStride();
638+
}
639+
628640
/// Allocate an out-of-line buffer if values of this type don't fit in the
629641
/// ValueBuffer.
630642
/// NOTE: This is not a box for copy-on-write existentials.
631643
OpaqueValue *allocateBufferIn(ValueBuffer *buffer) const;
632644

645+
/// Get the address of the memory previously allocated in the ValueBuffer.
646+
/// NOTE: This is not a box for copy-on-write existentials.
647+
OpaqueValue *projectBufferFrom(ValueBuffer *buffer) const;
648+
633649
/// Deallocate an out-of-line buffer stored in 'buffer' if values of this type
634650
/// are not stored inline in the ValueBuffer.
635651
void deallocateBufferIn(ValueBuffer *buffer) const;
@@ -4127,6 +4143,8 @@ class DynamicReplacementDescriptor {
41274143
RelativeDirectPointer<DynamicReplacementChainEntry, false> chainEntry;
41284144
uint32_t flags;
41294145

4146+
enum : uint32_t { EnableChainingMask = 0x1 };
4147+
41304148
public:
41314149
/// Enable this replacement by changing the function's replacement chain's
41324150
/// root entry.
@@ -4143,6 +4161,8 @@ class DynamicReplacementDescriptor {
41434161
void disableReplacement() const;
41444162

41454163
uint32_t getFlags() const { return flags; }
4164+
4165+
bool shouldChain() const { return (flags & EnableChainingMask); }
41464166
};
41474167

41484168
/// A collection of dynamic replacement records.

0 commit comments

Comments
 (0)