Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into warn-weak-insta-d…
Browse files Browse the repository at this point in the history
…ealloc
  • Loading branch information
hamishknight committed Apr 2, 2018
2 parents 48f08bd + 8247af8 commit 92931b7
Show file tree
Hide file tree
Showing 1,966 changed files with 67,052 additions and 39,330 deletions.
122 changes: 99 additions & 23 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,7 @@ CHANGELOG

| Contents |
| :--------------------- |
| [Swift 5.0](#swift-50) |
| [Swift 4.2](#swift-42) |
| [Swift 4.1](#swift-41) |
| [Swift 4.0](#swift-40) |
Expand All @@ -20,9 +21,74 @@ CHANGELOG

</details>

Swift 5.0
---------

- [SR-419][]

In Swift 5 mode, when setting a property from within its own `didSet` or `willSet` observer, the observer will now only avoid being recursively called if the property is set on `self` (either implicitly or explicitly).

For example:
```swift
class Node {
var children = [Node]()

var depth: Int {
didSet {
if depth < 0 {
// Will not recursively call didSet, as setting depth on self (same
// with `self.depth = 0`).
depth = 0
}

// Will call didSet for each of the children, as we're not setting the
// property on self (prior to Swift 5, this did not trigger property
// observers to be called again).
for child in children {
child.depth = depth + 1
}
}
}

init(depth: Int) {
self.depth = depth
}
}
```

**Add new entries to the top of this section, not here!**

Swift 4.2
---------

* The C `long double` type is now imported as `Float80` on i386 and x86_64
macOS and Linux. The tgmath functions in the Darwin and glibc modules now
 support `Float80` as well as `Float` and `Double`. Several tgmath
functions have been made generic over `[Binary]FloatingPoint` so that they
will automatically be available for any conforming type.

* [SE-0143][]

The standard library types `Optional`, `Array`, `ArraySlice`,
`ContiguousArray`, `Dictionary`, `DictionaryLiteral`, `Range`, and
`ClosedRange` now conform to the `Hashable` protocol when their element or
bound types (as the case may be) conform to `Hashable`. This makes
synthesized `Hashable` implementations available for types that include stored
properties of these types.

* [SE-0196][]

Custom compile-time warnings or error messages can be emitted using the
`#warning(_:)` and `#error(_:)` directives.

```swift
#warning("this is incomplete")

#if MY_BUILD_CONFIG && MY_OTHER_BUILD_CONFIG
#error("MY_BUILD_CONFIG and MY_OTHER_BUILD_CONFIG cannot both be set")
#endif
```

* Public classes may now have internal `required` initializers. The rule for
`required` initializers is that they must be available everywhere the class
can be subclassed, but previously we said that `required` initializers on
Expand All @@ -42,7 +108,7 @@ Swift 4.2
conditionally conforms to `P`, will succeed when the conditional
requirements are met.

**Add new entries to the top of this file, not here!**
**Add new entries to the top of this section, not here!**

Swift 4.1
---------
Expand Down Expand Up @@ -101,30 +167,32 @@ Swift 4.1
s[keyPath: p] // "H"
```

* [SE-0143][] The standard library types `Optional`, `Array`, and
`Dictionary` now conform to the `Equatable` protocol when their element types
conform to `Equatable`. This allows the `==` operator to compose (e.g., one
can compare two values of type `[Int : [Int?]?]` with `==`), as well as use
various algorthims defined for `Equatable` element types, such as
`index(of:)`.
* [SE-0143][] The standard library types `Optional`, `Array`, `ArraySlice`,
`ContiguousArray`, and `Dictionary` now conform to the `Equatable` protocol
when their element types conform to `Equatable`. This allows the `==` operator
to compose (e.g., one can compare two values of type `[Int : [Int?]?]` with
`==`), as well as use various algorithms defined for `Equatable` element
types, such as `index(of:)`.

* [SE-0157][] is implemented. Associated types can now declare "recursive"
constraints, which require that the associated type conform to the enclosing
protocol. The standard library protocols have been updated to make use of
recursive constraints. For example, the `SubSequence` associated type of
`Sequence` follows the enclosing protocol:

protocol Sequence {
associatedtype Element
associatedtype SubSequence: Sequence
where SubSequence.Element == Element,
SubSequence.SubSequence == SubSequence
// ...
}
```swift
protocol Sequence {
associatedtype Element
associatedtype SubSequence: Sequence
where SubSequence.Element == Element,
SubSequence.SubSequence == SubSequence
// ...
}

protocol Collection: Sequence where Self.SubSequence: Collection {
// ...
}
protocol Collection: Sequence where Self.SubSequence: Collection {
// ...
}
```

As a result, a number of new constraints have been introduced into the
standard library protocols:
Expand Down Expand Up @@ -261,7 +329,7 @@ Swift 4.0
CFHash and CFEqual as the implementation. This change applies even to "Swift
3 mode", so if you were previously adding this conformance yourself, use
`#if swift(>=3.2)` to restrict the extension to Swift 3.1 and below.
([SR-2388](https://bugs.swift.org/browse/SR-2388))
([SR-2388][])

* [SE-0156][]

Expand Down Expand Up @@ -410,7 +478,7 @@ Swift 4.0
slice[i..<j] = buffer[k..<l]
```

* [SR-1529](https://bugs.swift.org/browse/SR-1529):
* [SR-1529][]:

Covariant method overrides are now fully supported, fixing many crashes
and compile-time assertions when defining or calling such methods.
Expand Down Expand Up @@ -493,7 +561,7 @@ Swift 3.1
side effects, leading to bugs when Swift code attempted to override
`initialize`.
* [SR-2394](https://bugs.swift.org/browse/SR-2394)
* [SR-2394][]
C functions that "return twice" are no longer imported into Swift. Instead,
they are explicitly made unavailable, so attempting to reference them will
Expand Down Expand Up @@ -570,7 +638,7 @@ Swift 3.1
is not guaranteed to work in future versions of Swift, and will
now raise a warning.

* [SR-1446](https://bugs.swift.org/browse/SR-1446)
* [SR-1446][]

Nested types may now appear inside generic types, and nested types may have their own generic parameters:

Expand All @@ -590,7 +658,7 @@ Swift 3.1
extension OuterGeneric.InnerGeneric {}
```

* [SR-1009](https://bugs.swift.org/browse/SR-1009):
* [SR-1009][]:

Constrained extensions allow same-type constraints between generic parameters and concrete types. This enables you to create extensions, for example, on `Array` with `Int` elements:

Expand Down Expand Up @@ -812,7 +880,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
var x2 = p as! [Int]
```

* [SR-2131](https://bugs.swift.org/browse/SR-2131):
* [SR-2131][]:

The `hasPrefix` and `hasSuffix` functions now consider the empty string to be a prefix and suffix of all strings.

Expand Down Expand Up @@ -6900,3 +6968,11 @@ Swift 1.0
[SE-0197]: <https://github.com/apple/swift-evolution/blob/master/proposals/0197-remove-where.md>
[SE-0198]: <https://github.com/apple/swift-evolution/blob/master/proposals/0198-playground-quicklook-api-revamp.md>
[SE-0199]: <https://github.com/apple/swift-evolution/blob/master/proposals/0199-bool-toggle.md>

[SR-419]: <https://bugs.swift.org/browse/SR-419>
[SR-1009]: <https://bugs.swift.org/browse/SR-1009>
[SR-1446]: <https://bugs.swift.org/browse/SR-1446>
[SR-1529]: <https://bugs.swift.org/browse/SR-1529>
[SR-2131]: <https://bugs.swift.org/browse/SR-2131>
[SR-2388]: <https://bugs.swift.org/browse/SR-2388>
[SR-2394]: <https://bugs.swift.org/browse/SR-2394>
23 changes: 11 additions & 12 deletions CMakeLists.txt
Expand Up @@ -128,7 +128,7 @@ set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
# can be reused when a new version of Swift comes out (assuming the user hasn't
# manually set it as part of their own CMake configuration).
set(SWIFT_VERSION "4.1")
set(SWIFT_VERSION "4.2")

set(SWIFT_VENDOR "" CACHE STRING
"The vendor name of the Swift compiler")
Expand Down Expand Up @@ -295,10 +295,6 @@ option(SWIFT_RUNTIME_ENABLE_LEAK_CHECKER
"Should the runtime be built with support for non-thread-safe leak detecting entrypoints"
FALSE)

option(SWIFT_STDLIB_ENABLE_RESILIENCE
"Build the standard libraries and overlays with resilience enabled; see docs/LibraryEvolution.rst"
FALSE)

option(SWIFT_STDLIB_USE_NONATOMIC_RC
"Build the standard libraries and overlays with nonatomic reference count operations enabled"
FALSE)
Expand All @@ -309,7 +305,7 @@ option(SWIFT_STDLIB_ENABLE_SIL_OWNERSHIP

option(SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
"Build the standard libraries, overlays, and runtime with normal arguments at +0"
FALSE)
TRUE)

option(SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS
"Enable runtime function counters and expose the API."
Expand Down Expand Up @@ -822,20 +818,23 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" AND NOT CMAKE_CROSSCOMPILING)
endif()

message(STATUS "Building host Swift tools for ${SWIFT_HOST_VARIANT_SDK} ${SWIFT_HOST_VARIANT_ARCH}")
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}")
message(STATUS " LTO: ${SWIFT_TOOLS_ENABLE_LTO}")
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}")
message(STATUS " LTO: ${SWIFT_TOOLS_ENABLE_LTO}")
message(STATUS " +0 Normal Args: ${SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS}")
message(STATUS "")

if (SWIFT_BULID_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
if (SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)

message(STATUS "Building Swift standard library and overlays for SDKs: ${SWIFT_SDKS}")
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
message(STATUS " +0 Normal Args: ${SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS}")
message(STATUS "")

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

else()
Expand Down
17 changes: 17 additions & 0 deletions benchmark/CMakeLists.txt
Expand Up @@ -41,26 +41,30 @@ set(SWIFT_BENCH_MODULES
single-source/ArraySetElement
single-source/ArraySubscript
single-source/BinaryFloatingPointConversionFromBinaryInteger
single-source/BinaryFloatingPointProperties
single-source/BitCount
single-source/ByteSwap
single-source/COWTree
single-source/CString
single-source/CSVParsing
single-source/Calculator
single-source/CaptureProp
single-source/ChainedFilterMap
single-source/CharacterLiteralsLarge
single-source/CharacterLiteralsSmall
single-source/CharacterProperties
single-source/Chars
single-source/ClassArrayGetter
single-source/Combos
single-source/DataBenchmarks
single-source/DeadArray
single-source/DictOfArraysToArrayOfDicts
single-source/DictTest
single-source/DictTest2
single-source/DictTest3
single-source/DictTest4
single-source/DictionaryBridge
single-source/DictionaryCopy
single-source/DictionaryGroup
single-source/DictionaryLiteral
single-source/DictionaryRemove
Expand All @@ -74,6 +78,7 @@ set(SWIFT_BENCH_MODULES
single-source/Exclusivity
single-source/ExistentialPerformance
single-source/Fibonacci
single-source/FloatingPointPrinting
single-source/Hanoi
single-source/Hash
single-source/HashQuadratic
Expand Down Expand Up @@ -225,6 +230,17 @@ if(NOT SWIFT_OPTIMIZATION_LEVELS)
${SWIFT_EXTRA_BENCH_CONFIGS})
endif()

set(SWIFT_BENCHMARK_EXTRA_FLAGS "" CACHE STRING
"Extra options to pass to swiftc when building the benchmarks")

if (SWIFT_BENCHMARK_BUILT_STANDALONE)
# This option's value must match the value of the same option used when
# building the swift runtime.
option(SWIFT_RUNTIME_ENABLE_LEAK_CHECKER
"Should the runtime be built with support for non-thread-safe leak detecting entrypoints"
FALSE)
endif()

set(SWIFT_BENCHMARK_NUM_O_ITERATIONS "" CACHE STRING
"Number of iterations to perform when running -O benchmarks via cmake")
set(SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS "" CACHE STRING
Expand Down Expand Up @@ -289,6 +305,7 @@ message("--")
message("-- Swift Benchmark Suite:")
message("-- SWIFT_BENCHMARK_BUILT_STANDALONE = ${SWIFT_BENCHMARK_BUILT_STANDALONE}")
message("-- SWIFT_EXEC = ${SWIFT_EXEC}")
message("-- SWIFT_BENCHMARK_EXTRA_FLAGS = ${SWIFT_BENCHMARK_EXTRA_FLAGS}")
message("-- SWIFT_LIBRARY_PATH = ${SWIFT_LIBRARY_PATH}")
message("-- CLANG_EXEC = ${CLANG_EXEC}")
message("-- SWIFT_OPTIMIZATION_LEVELS = ${SWIFT_OPTIMIZATION_LEVELS}")
Expand Down
10 changes: 6 additions & 4 deletions benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake
Expand Up @@ -319,6 +319,7 @@ function (swift_benchmark_compile_archopts)
${extra_options}
"-parse-as-library"
${bench_flags}
${SWIFT_BENCHMARK_EXTRA_FLAGS}
"-module-name" "${module_name}"
"-emit-module-path" "${swiftmodule}"
"-I" "${objdir}"
Expand All @@ -336,6 +337,7 @@ function (swift_benchmark_compile_archopts)
${common_swift4_options}
"-parse-as-library"
${bench_flags}
${SWIFT_BENCHMARK_EXTRA_FLAGS}
"-module-name" "${module_name}"
"-I" "${objdir}"
"-emit-sib"
Expand Down Expand Up @@ -363,7 +365,7 @@ function (swift_benchmark_compile_archopts)
SOURCE_DIR "${srcdir}"
OBJECT_DIR "${objdir}"
SOURCES ${${module_name}_sources}
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags}
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags} ${SWIFT_BENCHMARK_EXTRA_FLAGS}
DEPENDS ${bench_library_objects} ${stdlib_dependencies})
precondition(objfile_out)
list(APPEND SWIFT_BENCH_OBJFILES "${objfile_out}")
Expand All @@ -381,7 +383,7 @@ function (swift_benchmark_compile_archopts)
SOURCE_DIR "${srcdir}"
OBJECT_DIR "${objdir}"
SOURCES ${${module_name}_sources}
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags}
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags} ${SWIFT_BENCHMARK_EXTRA_FLAGS}
DEPENDS ${bench_library_objects} ${stdlib_dependencies})
precondition(objfiles_out)
list(APPEND SWIFT_BENCH_OBJFILES ${objfiles_out})
Expand All @@ -399,7 +401,7 @@ function (swift_benchmark_compile_archopts)
SOURCE_DIR "${srcdir}"
OBJECT_DIR "${objdir}"
SOURCES ${${module_name}_sources}
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags}
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags} ${SWIFT_BENCHMARK_EXTRA_FLAGS}
DEPENDS ${bench_library_objects} ${stdlib_dependencies})
precondition(objfile_out)
list(APPEND SWIFT_BENCH_OBJFILES "${objfile_out}")
Expand All @@ -417,7 +419,7 @@ function (swift_benchmark_compile_archopts)
SOURCE_DIR "${srcdir}"
OBJECT_DIR "${objdir}"
SOURCES ${${module_name}_sources}
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags}
LIBRARY_FLAGS ${common_swift4_options} ${bench_flags} ${SWIFT_BENCHMARK_EXTRA_FLAGS}
DEPENDS ${bench_library_objects} ${stdlib_dependencies})
precondition(objfiles_out)
list(APPEND SWIFT_BENCH_OBJFILES ${objfiles_out})
Expand Down
7 changes: 7 additions & 0 deletions benchmark/scripts/Benchmark_Driver
Expand Up @@ -192,6 +192,13 @@ def run_benchmarks(driver, benchmarks=[], num_samples=10, verbose=False,
compatible with `parse_results`. If `benchmarks` is not empty,
only run tests included in it.
"""
# Set a constant hash seed. Some tests are currently sensitive to
# fluctuations in the number of hash collisions.
#
# FIXME: This should only be set in the environment of the child process
# that runs the tests.
os.environ["SWIFT_DETERMINISTIC_HASHING"] = "1"

(total_tests, total_min, total_max, total_mean) = (0, 0, 0, 0)
output = []
headings = ['#', 'TEST', 'SAMPLES', 'MIN(μs)', 'MAX(μs)', 'MEAN(μs)',
Expand Down

0 comments on commit 92931b7

Please sign in to comment.