Skip to content

Commit 16addd9

Browse files
authored
Merge pull request #8 from apple/master
merge
2 parents d5b2ef5 + 912e08b commit 16addd9

File tree

868 files changed

+17786
-8512
lines changed

Some content is hidden

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

868 files changed

+17786
-8512
lines changed

CHANGELOG.md

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CHANGELOG
66

77
| Contents |
88
| :--------------------- |
9-
| [Swift 5.0](#swift-50) |
9+
| [Swift 4.2](#swift-42) |
1010
| [Swift 4.1](#swift-41) |
1111
| [Swift 4.0](#swift-40) |
1212
| [Swift 3.1](#swift-31) |
@@ -20,9 +20,22 @@ CHANGELOG
2020

2121
</details>
2222

23-
Swift 5.0
23+
Swift 4.2
2424
---------
2525

26+
* [SE-0196][]
27+
28+
Custom compile-time warnings or error messages can be emitted using the
29+
`#warning(_:)` and `#error(_:)` directives.
30+
31+
```swift
32+
#warning("this is incomplete")
33+
34+
#if MY_BUILD_CONFIG && MY_OTHER_BUILD_CONFIG
35+
#error("MY_BUILD_CONFIG and MY_OTHER_BUILD_CONFIG cannot both be set")
36+
#endif
37+
```
38+
2639
* Public classes may now have internal `required` initializers. The rule for
2740
`required` initializers is that they must be available everywhere the class
2841
can be subclassed, but previously we said that `required` initializers on
@@ -42,9 +55,30 @@ Swift 5.0
4255
conditionally conforms to `P`, will succeed when the conditional
4356
requirements are met.
4457

58+
**Add new entries to the top of this file, not here!**
59+
4560
Swift 4.1
4661
---------
4762

63+
* [SE-0075][]
64+
65+
Compile-time testing for the existence and importability of modules is now
66+
implemented as a build configuration test. The `canImport` test allows
67+
the development of features that require a possibly-failing import
68+
declaration across multiple platforms.
69+
70+
```swift
71+
#if canImport(UIKit)
72+
import UIKit
73+
class MyView : UIView {}
74+
#elseif canImport(AppKit)
75+
import AppKit
76+
class MyView : NSView {}
77+
#else
78+
class MyView : CustomView {}
79+
#endif
80+
```
81+
4882
* [SE-0189][]
4983

5084
If an initializer is declared in a different module from a struct, it must
@@ -93,17 +127,19 @@ Swift 4.1
93127
recursive constraints. For example, the `SubSequence` associated type of
94128
`Sequence` follows the enclosing protocol:
95129

96-
protocol Sequence {
97-
associatedtype Element
98-
associatedtype SubSequence: Sequence
99-
where SubSequence.Element == Element,
100-
SubSequence.SubSequence == SubSequence
101-
// ...
102-
}
130+
```swift
131+
protocol Sequence {
132+
associatedtype Element
133+
associatedtype SubSequence: Sequence
134+
where SubSequence.Element == Element,
135+
SubSequence.SubSequence == SubSequence
136+
// ...
137+
}
103138

104-
protocol Collection: Sequence where Self.SubSequence: Collection {
105-
// ...
106-
}
139+
protocol Collection: Sequence where Self.SubSequence: Collection {
140+
// ...
141+
}
142+
```
107143

108144
As a result, a number of new constraints have been introduced into the
109145
standard library protocols:
@@ -167,8 +203,6 @@ Swift 4.1
167203

168204
If you wish to provide your own implementation of `==`/`hashValue`, you still can; a custom implementation will replace the one synthesized by the compiler.
169205

170-
**Add new entries to the top of this file, not here!**
171-
172206
Swift 4.0
173207
---------
174208

@@ -6875,3 +6909,9 @@ Swift 1.0
68756909
[SE-0191]: <https://github.com/apple/swift-evolution/blob/master/proposals/0191-eliminate-indexdistance.md>
68766910
[SE-0192]: <https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md>
68776911
[SE-0193]: <https://github.com/apple/swift-evolution/blob/master/proposals/0193-cross-module-inlining-and-specialization.md>
6912+
[SE-0194]: <https://github.com/apple/swift-evolution/blob/master/proposals/0194-derived-collection-of-enum-cases.md>
6913+
[SE-0195]: <https://github.com/apple/swift-evolution/blob/master/proposals/0195-dynamic-member-lookup.md>
6914+
[SE-0196]: <https://github.com/apple/swift-evolution/blob/master/proposals/0196-diagnostic-directives.md>
6915+
[SE-0197]: <https://github.com/apple/swift-evolution/blob/master/proposals/0197-remove-where.md>
6916+
[SE-0198]: <https://github.com/apple/swift-evolution/blob/master/proposals/0198-playground-quicklook-api-revamp.md>
6917+
[SE-0199]: <https://github.com/apple/swift-evolution/blob/master/proposals/0199-bool-toggle.md>

CMakeLists.txt

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY
128128
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
129129
# can be reused when a new version of Swift comes out (assuming the user hasn't
130130
# manually set it as part of their own CMake configuration).
131-
set(SWIFT_VERSION "4.1")
131+
set(SWIFT_VERSION "4.2")
132132

133133
set(SWIFT_VENDOR "" CACHE STRING
134134
"The vendor name of the Swift compiler")
@@ -194,14 +194,16 @@ set(SWIFT_ANDROID_DEPLOY_DEVICE_PATH "" CACHE STRING
194194
#
195195

196196
foreach(sdk ANDROID;FREEBSD;LINUX;WINDOWS;HAIKU)
197-
set(SWIFT_${sdk}_ICU_UC "" CACHE STRING
198-
"Path to a directory containing the icuuc library for ${sdk}")
199-
set(SWIFT_${sdk}_ICU_UC_INCLUDE "" CACHE STRING
200-
"Path to a directory containing headers for icuuc for ${sdk}")
201-
set(SWIFT_${sdk}_ICU_I18N "" CACHE STRING
202-
"Path to a directory containing the icui18n library for ${sdk}")
203-
set(SWIFT_${sdk}_ICU_I18N_INCLUDE "" CACHE STRING
204-
"Path to a directory containing headers icui18n for ${sdk}")
197+
foreach(arch aarch64;armv6;armv7;i686;powerpc64;powerpc64le;s390x;x86_64)
198+
set(SWIFT_${sdk}_${arch}_ICU_UC "" CACHE STRING
199+
"Path to a directory containing the icuuc library for ${sdk}")
200+
set(SWIFT_${sdk}_${arch}_ICU_UC_INCLUDE "" CACHE STRING
201+
"Path to a directory containing headers for icuuc for ${sdk}")
202+
set(SWIFT_${sdk}_${arch}_ICU_I18N "" CACHE STRING
203+
"Path to a directory containing the icui18n library for ${sdk}")
204+
set(SWIFT_${sdk}_${arch}_ICU_I18N_INCLUDE "" CACHE STRING
205+
"Path to a directory containing headers icui18n for ${sdk}")
206+
endforeach()
205207
endforeach()
206208

207209
#
@@ -820,20 +822,23 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" AND NOT CMAKE_CROSSCOMPILING)
820822
endif()
821823

822824
message(STATUS "Building host Swift tools for ${SWIFT_HOST_VARIANT_SDK} ${SWIFT_HOST_VARIANT_ARCH}")
823-
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
824-
message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}")
825-
message(STATUS " LTO: ${SWIFT_TOOLS_ENABLE_LTO}")
825+
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
826+
message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}")
827+
message(STATUS " LTO: ${SWIFT_TOOLS_ENABLE_LTO}")
828+
message(STATUS " +0 Normal Args: ${SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS}")
826829
message(STATUS "")
827830

828831
if (SWIFT_BULID_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
829832

830833
message(STATUS "Building Swift standard library and overlays for SDKs: ${SWIFT_SDKS}")
831-
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
832-
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
834+
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
835+
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
836+
message(STATUS " +0 Normal Args: ${SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS}")
833837
message(STATUS "")
834838

835839
message(STATUS "Building Swift runtime with:")
836840
message(STATUS " Leak Detection Checker Entrypoints: ${SWIFT_RUNTIME_ENABLE_LEAK_CHECKER}")
841+
message(STATUS " +0 Normal Args: ${SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS}")
837842
message(STATUS "")
838843

839844
else()

benchmark/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ set(SWIFT_BENCH_MODULES
4141
single-source/ArraySetElement
4242
single-source/ArraySubscript
4343
single-source/BinaryFloatingPointConversionFromBinaryInteger
44+
single-source/BinaryFloatingPointProperties
4445
single-source/BitCount
4546
single-source/ByteSwap
4647
single-source/COWTree
@@ -225,6 +226,17 @@ if(NOT SWIFT_OPTIMIZATION_LEVELS)
225226
${SWIFT_EXTRA_BENCH_CONFIGS})
226227
endif()
227228

229+
set(SWIFT_BENCHMARK_EXTRA_FLAGS "" CACHE STRING
230+
"Extra options to pass to swiftc when building the benchmarks")
231+
232+
if (SWIFT_BENCHMARK_BUILT_STANDALONE)
233+
# This option's value must match the value of the same option used when
234+
# building the swift runtime.
235+
option(SWIFT_RUNTIME_ENABLE_LEAK_CHECKER
236+
"Should the runtime be built with support for non-thread-safe leak detecting entrypoints"
237+
FALSE)
238+
endif()
239+
228240
set(SWIFT_BENCHMARK_NUM_O_ITERATIONS "" CACHE STRING
229241
"Number of iterations to perform when running -O benchmarks via cmake")
230242
set(SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS "" CACHE STRING
@@ -289,6 +301,7 @@ message("--")
289301
message("-- Swift Benchmark Suite:")
290302
message("-- SWIFT_BENCHMARK_BUILT_STANDALONE = ${SWIFT_BENCHMARK_BUILT_STANDALONE}")
291303
message("-- SWIFT_EXEC = ${SWIFT_EXEC}")
304+
message("-- SWIFT_BENCHMARK_EXTRA_FLAGS = ${SWIFT_BENCHMARK_EXTRA_FLAGS}")
292305
message("-- SWIFT_LIBRARY_PATH = ${SWIFT_LIBRARY_PATH}")
293306
message("-- CLANG_EXEC = ${CLANG_EXEC}")
294307
message("-- SWIFT_OPTIMIZATION_LEVELS = ${SWIFT_OPTIMIZATION_LEVELS}")

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ function (swift_benchmark_compile_archopts)
319319
${extra_options}
320320
"-parse-as-library"
321321
${bench_flags}
322+
${SWIFT_BENCHMARK_EXTRA_FLAGS}
322323
"-module-name" "${module_name}"
323324
"-emit-module-path" "${swiftmodule}"
324325
"-I" "${objdir}"
@@ -336,6 +337,7 @@ function (swift_benchmark_compile_archopts)
336337
${common_swift4_options}
337338
"-parse-as-library"
338339
${bench_flags}
340+
${SWIFT_BENCHMARK_EXTRA_FLAGS}
339341
"-module-name" "${module_name}"
340342
"-I" "${objdir}"
341343
"-emit-sib"
@@ -363,7 +365,7 @@ function (swift_benchmark_compile_archopts)
363365
SOURCE_DIR "${srcdir}"
364366
OBJECT_DIR "${objdir}"
365367
SOURCES ${${module_name}_sources}
366-
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags}
368+
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags} ${SWIFT_BENCHMARK_EXTRA_FLAGS}
367369
DEPENDS ${bench_library_objects} ${stdlib_dependencies})
368370
precondition(objfile_out)
369371
list(APPEND SWIFT_BENCH_OBJFILES "${objfile_out}")
@@ -381,7 +383,7 @@ function (swift_benchmark_compile_archopts)
381383
SOURCE_DIR "${srcdir}"
382384
OBJECT_DIR "${objdir}"
383385
SOURCES ${${module_name}_sources}
384-
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags}
386+
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags} ${SWIFT_BENCHMARK_EXTRA_FLAGS}
385387
DEPENDS ${bench_library_objects} ${stdlib_dependencies})
386388
precondition(objfiles_out)
387389
list(APPEND SWIFT_BENCH_OBJFILES ${objfiles_out})
@@ -399,7 +401,7 @@ function (swift_benchmark_compile_archopts)
399401
SOURCE_DIR "${srcdir}"
400402
OBJECT_DIR "${objdir}"
401403
SOURCES ${${module_name}_sources}
402-
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags}
404+
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags} ${SWIFT_BENCHMARK_EXTRA_FLAGS}
403405
DEPENDS ${bench_library_objects} ${stdlib_dependencies})
404406
precondition(objfile_out)
405407
list(APPEND SWIFT_BENCH_OBJFILES "${objfile_out}")
@@ -417,7 +419,7 @@ function (swift_benchmark_compile_archopts)
417419
SOURCE_DIR "${srcdir}"
418420
OBJECT_DIR "${objdir}"
419421
SOURCES ${${module_name}_sources}
420-
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags}
422+
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags} ${SWIFT_BENCHMARK_EXTRA_FLAGS}
421423
DEPENDS ${bench_library_objects} ${stdlib_dependencies})
422424
precondition(objfiles_out)
423425
list(APPEND SWIFT_BENCH_OBJFILES ${objfiles_out})
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//===--- BinaryFloatingPointProperties.swift ------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2018 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+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import Foundation
14+
import TestsUtils
15+
16+
public let BinaryFloatingPointPropertiesBinade = BenchmarkInfo(
17+
name: "BinaryFloatingPointPropertiesBinade",
18+
runFunction: run_BinaryFloatingPointPropertiesBinade,
19+
tags: [.validation, .algorithm]
20+
)
21+
22+
public let BinaryFloatingPointPropertiesNextUp = BenchmarkInfo(
23+
name: "BinaryFloatingPointPropertiesNextUp",
24+
runFunction: run_BinaryFloatingPointPropertiesNextUp,
25+
tags: [.validation, .algorithm]
26+
)
27+
28+
public let BinaryFloatingPointPropertiesUlp = BenchmarkInfo(
29+
name: "BinaryFloatingPointPropertiesUlp",
30+
runFunction: run_BinaryFloatingPointPropertiesUlp,
31+
tags: [.validation, .algorithm]
32+
)
33+
34+
@inline(never)
35+
public func run_BinaryFloatingPointPropertiesBinade(_ N: Int) {
36+
var xs = [Double]()
37+
xs.reserveCapacity(N)
38+
for _ in 1...N {
39+
var x = 0 as Double
40+
for i in 0..<10000 {
41+
x += Double(getInt(i)).binade
42+
}
43+
xs.append(x)
44+
}
45+
CheckResults(xs[getInt(0)] == 37180757)
46+
}
47+
48+
@inline(never)
49+
public func run_BinaryFloatingPointPropertiesNextUp(_ N: Int) {
50+
var xs = [Int]()
51+
xs.reserveCapacity(N)
52+
for _ in 1...N {
53+
var x = 0 as Int
54+
for i in 0..<10000 {
55+
x += Int(Double(getInt(i)).nextUp)
56+
}
57+
xs.append(x)
58+
}
59+
CheckResults(xs[getInt(0)] == 49995000)
60+
}
61+
62+
@inline(never)
63+
public func run_BinaryFloatingPointPropertiesUlp(_ N: Int) {
64+
var xs = [Int]()
65+
xs.reserveCapacity(N)
66+
for _ in 1...N {
67+
var x = 0 as Int
68+
for i in 0..<10000 {
69+
x += Int(Double(getInt(i)).ulp)
70+
}
71+
xs.append(x)
72+
}
73+
CheckResults(xs[getInt(0)] == 0)
74+
}

0 commit comments

Comments
 (0)