Skip to content

Commit 8dff4cd

Browse files
committed
Merge branch 'master' into callable
2 parents 3687d07 + e622ea6 commit 8dff4cd

File tree

590 files changed

+9545
-3398
lines changed

Some content is hidden

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

590 files changed

+9545
-3398
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ Swift 5.1
9999
foo(0) // prints "Any" in Swift < 5.1, "T" in Swift 5.1
100100
```
101101

102+
* [SE-0245][]:
103+
104+
`Array` and `ContiguousArray` now have `init(unsafeUninitializedCapacity:initializingWith:)`,
105+
which provides access to the array's uninitialized storage.
106+
102107
**Add new entries to the top of this section, not here!**
103108

104109
Swift 5.0
@@ -7506,6 +7511,7 @@ Swift 1.0
75067511
[SE-0228]: <https://github.com/apple/swift-evolution/blob/master/proposals/0228-fix-expressiblebystringinterpolation.md>
75077512
[SE-0230]: <https://github.com/apple/swift-evolution/blob/master/proposals/0230-flatten-optional-try.md>
75087513
[SE-0235]: <https://github.com/apple/swift-evolution/blob/master/proposals/0235-add-result.md>
7514+
[SE-0245]: <https://github.com/apple/swift-evolution/blob/master/proposals/0245-array-uninitialized-initializer.md>
75097515

75107516
[SR-106]: <https://bugs.swift.org/browse/SR-106>
75117517
[SR-419]: <https://bugs.swift.org/browse/SR-419>

CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -883,12 +883,11 @@ find_package(PythonInterp REQUIRED)
883883
# Find optional dependencies.
884884
#
885885

886-
# Find libxml.
887-
# FIXME: unify with CLANG_HAVE_LIBXML, which is set in LLVM anyway.
888-
find_package(LibXml2)
889-
option(SWIFT_HAVE_LIBXML
890-
"Whether to build with libxml"
891-
${LIBXML2_FOUND})
886+
if(LLVM_ENABLE_LIBXML2)
887+
find_package(Libxml2 REQUIRED)
888+
else()
889+
find_package(LibXml2)
890+
endif()
892891

893892
# You need libedit linked in order to check if you have el_wgets.
894893
cmake_push_check_state()

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ several hours. Naturally, incremental builds are much faster.
7171
macOS, Ubuntu Linux LTS, and the latest Ubuntu Linux release are the current
7272
supported host development operating systems.
7373

74+
Please make sure you use Python 2.x. Python 3.x is not supported currently.
75+
7476
#### macOS
7577

7678
To build for macOS, you need [Xcode 10.2 beta](https://developer.apple.com/xcode/downloads/).
@@ -295,7 +297,7 @@ To read the compiler documentation, start by installing the
295297
[Sphinx](http://sphinx-doc.org) documentation generator tool by running the
296298
command:
297299

298-
easy_install -U Sphinx
300+
easy_install -U "Sphinx < 2.0"
299301

300302
Once complete, you can build the Swift documentation by changing directory into
301303
[docs](https://github.com/apple/swift/tree/master/docs) and typing `make`. This

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ function (swift_benchmark_compile_archopts)
314314

315315
set(common_options
316316
"-c"
317-
"-Xfrontend" "-verify-sil-ownership"
318317
"-target" "${target}"
319318
"-${BENCH_COMPILE_ARCHOPTS_OPT}" ${PAGE_ALIGNMENT_OPTION})
320319

@@ -344,7 +343,6 @@ function (swift_benchmark_compile_archopts)
344343

345344
set(common_options_driver
346345
"-c"
347-
"-Xfrontend" "-verify-sil-ownership"
348346
"-target" "${target}"
349347
"-${driver_opt}")
350348

benchmark/single-source/NSStringConversion.swift

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,64 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
// <rdar://problem/19003201>
14+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
15+
1416
import TestsUtils
1517
import Foundation
1618

17-
public let NSStringConversion = BenchmarkInfo(
18-
name: "NSStringConversion",
19-
runFunction: run_NSStringConversion,
20-
tags: [.validation, .api, .String, .bridging])
19+
fileprivate var test:NSString = ""
20+
21+
public let NSStringConversion = [
22+
BenchmarkInfo(name: "NSStringConversion",
23+
runFunction: run_NSStringConversion,
24+
tags: [.validation, .api, .String, .bridging]),
25+
BenchmarkInfo(name: "NSStringConversion.UTF8",
26+
runFunction: run_NSStringConversion_nonASCII,
27+
tags: [.validation, .api, .String, .bridging],
28+
setUpFunction: { test = NSString(cString: "tëst", encoding: String.Encoding.utf8.rawValue)! }),
29+
BenchmarkInfo(name: "NSStringConversion.Mutable",
30+
runFunction: run_NSMutableStringConversion,
31+
tags: [.validation, .api, .String, .bridging],
32+
setUpFunction: { test = NSMutableString(cString: "test", encoding: String.Encoding.ascii.rawValue)! }),
33+
BenchmarkInfo(name: "NSStringConversion.Long",
34+
runFunction: run_NSStringConversion_long,
35+
tags: [.validation, .api, .String, .bridging],
36+
setUpFunction: { test = NSString(cString: "The quick brown fox jumps over the lazy dog", encoding: String.Encoding.ascii.rawValue)! } ),
37+
BenchmarkInfo(name: "NSStringConversion.LongUTF8",
38+
runFunction: run_NSStringConversion_longNonASCII,
39+
tags: [.validation, .api, .String, .bridging],
40+
setUpFunction: { test = NSString(cString: "Thë qüick bröwn föx jumps over the lazy dög", encoding: String.Encoding.utf8.rawValue)! })]
2141

2242
public func run_NSStringConversion(_ N: Int) {
23-
#if _runtime(_ObjC)
2443
let test:NSString = NSString(cString: "test", encoding: String.Encoding.ascii.rawValue)!
2544
for _ in 1...N * 10000 {
45+
//Doesn't test accessing the String contents to avoid changing historical benchmark numbers
2646
blackHole(identity(test) as String)
2747
}
28-
#endif
2948
}
49+
50+
fileprivate func innerLoop(_ str: NSString, _ N: Int, _ scale: Int = 5000) {
51+
for _ in 1...N * scale {
52+
for char in (identity(str) as String).utf8 {
53+
blackHole(char)
54+
}
55+
}
56+
}
57+
58+
public func run_NSStringConversion_nonASCII(_ N: Int) {
59+
innerLoop(test, N, 2500)
60+
}
61+
62+
public func run_NSMutableStringConversion(_ N: Int) {
63+
innerLoop(test, N)
64+
}
65+
66+
public func run_NSStringConversion_long(_ N: Int) {
67+
innerLoop(test, N, 1000)
68+
}
69+
70+
public func run_NSStringConversion_longNonASCII(_ N: Int) {
71+
innerLoop(test, N, 300)
72+
}
73+
74+
#endif

benchmark/utils/main.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ import MonteCarloPi
9292
import NibbleSort
9393
import NSDictionaryCastToSwift
9494
import NSError
95+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
9596
import NSStringConversion
97+
#endif
9698
import NopDeinit
9799
import ObjectAllocation
98100
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
@@ -262,7 +264,9 @@ registerBenchmark(MonteCarloE)
262264
registerBenchmark(MonteCarloPi)
263265
registerBenchmark(NSDictionaryCastToSwift)
264266
registerBenchmark(NSErrorTest)
267+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
265268
registerBenchmark(NSStringConversion)
269+
#endif
266270
registerBenchmark(NibbleSort)
267271
registerBenchmark(NopDeinit)
268272
registerBenchmark(ObjectAllocation)

cmake/modules/AddSwift.cmake

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ function(_add_swift_library_single target name)
721721
FILE_DEPENDS
722722
FRAMEWORK_DEPENDS
723723
FRAMEWORK_DEPENDS_WEAK
724+
GYB_SOURCES
724725
INCORPORATE_OBJECT_LIBRARIES
725726
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY
726727
INTERFACE_LINK_LIBRARIES
@@ -810,10 +811,14 @@ function(_add_swift_library_single target name)
810811
"Either SHARED, STATIC, or OBJECT_LIBRARY must be specified")
811812
endif()
812813

813-
handle_gyb_sources(
814-
gyb_dependency_targets
815-
SWIFTLIB_SINGLE_SOURCES
816-
"${SWIFTLIB_SINGLE_ARCHITECTURE}")
814+
if(SWIFTLIB_SINGLE_GYB_SOURCES)
815+
handle_gyb_sources(
816+
gyb_dependency_targets
817+
SWIFTLIB_SINGLE_GYB_SOURCES
818+
"${SWIFTLIB_SINGLE_ARCHITECTURE}")
819+
set(SWIFTLIB_SINGLE_SOURCES ${SWIFTLIB_SINGLE_SOURCES}
820+
${SWIFTLIB_SINGLE_GYB_SOURCES})
821+
endif()
817822

818823
# Remove the "swift" prefix from the name to determine the module name.
819824
if(SWIFTLIB_IS_STDLIB_CORE)
@@ -1620,6 +1625,7 @@ function(add_swift_target_library name)
16201625
FRAMEWORK_DEPENDS_IOS_TVOS
16211626
FRAMEWORK_DEPENDS_OSX
16221627
FRAMEWORK_DEPENDS_WEAK
1628+
GYB_SOURCES
16231629
INCORPORATE_OBJECT_LIBRARIES
16241630
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY
16251631
INTERFACE_LINK_LIBRARIES
@@ -1875,10 +1881,13 @@ function(add_swift_target_library name)
18751881
endforeach()
18761882

18771883
# Add PrivateFrameworks, rdar://28466433
1884+
set(swiftlib_c_compile_flags_all ${SWIFTLIB_C_COMPILE_FLAGS})
18781885
if(sdk IN_LIST SWIFT_APPLE_PLATFORMS AND SWIFTLIB_IS_SDK_OVERLAY)
18791886
set(swiftlib_swift_compile_private_frameworks_flag "-Fsystem" "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}/System/Library/PrivateFrameworks/")
18801887
endif()
18811888

1889+
list(APPEND swiftlib_c_compile_flags_all "-DSWIFT_TARGET_LIBRARY_NAME=${name}")
1890+
18821891
# Add this library variant.
18831892
_add_swift_library_single(
18841893
${VARIANT_NAME}
@@ -1896,7 +1905,7 @@ function(add_swift_target_library name)
18961905
FRAMEWORK_DEPENDS_WEAK ${SWIFTLIB_FRAMEWORK_DEPENDS_WEAK}
18971906
LLVM_COMPONENT_DEPENDS ${SWIFTLIB_LLVM_COMPONENT_DEPENDS}
18981907
FILE_DEPENDS ${SWIFTLIB_FILE_DEPENDS} ${swiftlib_module_dependency_targets}
1899-
C_COMPILE_FLAGS ${SWIFTLIB_C_COMPILE_FLAGS}
1908+
C_COMPILE_FLAGS ${swiftlib_c_compile_flags_all}
19001909
SWIFT_COMPILE_FLAGS ${swiftlib_swift_compile_flags_all} ${swiftlib_swift_compile_flags_arch} ${swiftlib_swift_compile_private_frameworks_flag}
19011910
LINK_FLAGS ${swiftlib_link_flags_all}
19021911
PRIVATE_LINK_LIBRARIES ${swiftlib_private_link_libraries_targets}
@@ -1914,6 +1923,7 @@ function(add_swift_target_library name)
19141923
DEPLOYMENT_VERSION_IOS "${SWIFTLIB_DEPLOYMENT_VERSION_IOS}"
19151924
DEPLOYMENT_VERSION_TVOS "${SWIFTLIB_DEPLOYMENT_VERSION_TVOS}"
19161925
DEPLOYMENT_VERSION_WATCHOS "${SWIFTLIB_DEPLOYMENT_VERSION_WATCHOS}"
1926+
GYB_SOURCES ${SWIFTLIB_GYB_SOURCES}
19171927
)
19181928

19191929
if(NOT SWIFTLIB_OBJECT_LIBRARY)

cmake/modules/SwiftHandleGybSources.cmake

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,35 +131,31 @@ function(handle_gyb_sources dependency_out_var_name sources_var_name arch)
131131
"${SWIFT_SOURCE_DIR}/utils/gyb_sourcekit_support/UIDs.py")
132132

133133
foreach (src ${${sources_var_name}})
134-
string(REGEX REPLACE "[.]gyb$" "" src_sans_gyb "${src}")
135-
if(src STREQUAL src_sans_gyb)
136-
list(APPEND de_gybbed_sources "${src}")
134+
# On Windows (using Visual Studio), the generated project files assume that the
135+
# generated GYB files will be in the source, not binary directory.
136+
# We can work around this by modifying the root directory when generating VS projects.
137+
if ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Visual Studio")
138+
set(dir_root ${CMAKE_CURRENT_SOURCE_DIR})
137139
else()
140+
set(dir_root ${CMAKE_CURRENT_BINARY_DIR})
141+
endif()
138142

139-
# On Windows (using Visual Studio), the generated project files assume that the
140-
# generated GYB files will be in the source, not binary directory.
141-
# We can work around this by modifying the root directory when generating VS projects.
142-
if ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Visual Studio")
143-
set(dir_root ${CMAKE_CURRENT_SOURCE_DIR})
144-
else()
145-
set(dir_root ${CMAKE_CURRENT_BINARY_DIR})
146-
endif()
147-
148-
if (arch)
149-
set(dir "${dir_root}/${ptr_size}")
150-
else()
151-
set(dir "${dir_root}")
152-
endif()
153-
set(output_file_name "${dir}/${src_sans_gyb}")
154-
list(APPEND de_gybbed_sources "${output_file_name}")
155-
handle_gyb_source_single(dependency_target
156-
SOURCE "${src}"
157-
OUTPUT "${output_file_name}"
158-
FLAGS ${extra_gyb_flags}
159-
DEPENDS "${gyb_extra_sources}"
160-
COMMENT "with ptr size = ${ptr_size}")
161-
list(APPEND dependency_targets "${dependency_target}")
143+
if (arch)
144+
set(dir "${dir_root}/${ptr_size}")
145+
else()
146+
set(dir "${dir_root}")
162147
endif()
148+
# get_filename_component(src_sans_gyb ${src} NAME_WLE)
149+
string(REGEX REPLACE "\.gyb$" "" src_sans_gyb ${src})
150+
set(output_file_name "${dir}/${src_sans_gyb}")
151+
list(APPEND de_gybbed_sources "${output_file_name}")
152+
handle_gyb_source_single(dependency_target
153+
SOURCE "${src}"
154+
OUTPUT "${output_file_name}"
155+
FLAGS ${extra_gyb_flags}
156+
DEPENDS "${gyb_extra_sources}"
157+
COMMENT "with ptr size = ${ptr_size}")
158+
list(APPEND dependency_targets "${dependency_target}")
163159
endforeach()
164160
set("${dependency_out_var_name}" "${dependency_targets}" PARENT_SCOPE)
165161
set("${sources_var_name}" "${de_gybbed_sources}" PARENT_SCOPE)

cmake/modules/SwiftSource.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ function(_compile_swift_files
236236
endif()
237237

238238
if(SWIFTFILE_IS_STDLIB)
239-
list(APPEND swift_flags "-Xfrontend" "-verify-sil-ownership")
240239
list(APPEND swift_flags "-Xfrontend" "-enable-mandatory-semantic-arc-opts")
241240
endif()
242241

docs/ABI/Mangling.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ Globals
112112
global ::= nominal-type 'Mn' // nominal type descriptor
113113
global ::= nominal-type 'Mu' // class method lookup function
114114
global ::= nominal-type 'MU' // ObjC metadata update callback function
115+
global ::= nominal-type 'Ms' // ObjC resilient class stub
116+
global ::= nominal-type 'Mt' // Full ObjC resilient class stub (private)
115117
global ::= module 'MXM' // module descriptor
116118
global ::= context 'MXE' // extension descriptor
117119
global ::= context 'MXX' // anonymous context descriptor

0 commit comments

Comments
 (0)