Skip to content

Commit b9fb3ba

Browse files
author
Max Moiseev
committed
Merge remote-tracking branch 'origin/master' into new-integer-protocols
2 parents 4f0c7a5 + 124b293 commit b9fb3ba

File tree

1,016 files changed

+126805
-18882
lines changed

Some content is hidden

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

1,016 files changed

+126805
-18882
lines changed

.dir-locals.el

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
(eval let*
66
((x (dir-locals-find-file default-directory))
77
(this-directory (if (listp x) (car x) (file-name-directory x))))
8-
(unless (featurep 'swift-project-settings)
8+
(unless (or (featurep 'swift-project-settings)
9+
(tramp-tramp-file-p this-directory))
910
(add-to-list 'load-path
1011
(concat this-directory "utils")
1112
:append)

CMakeLists.txt

+23-101
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ option(SWIFT_STDLIB_ENABLE_RESILIENCE
270270
"Build the standard libraries and overlays with resilience enabled; see docs/LibraryEvolution.rst"
271271
FALSE)
272272

273+
option(SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS
274+
"Build the runtime with a copy-on-write implementation for opaque existentials"
275+
FALSE)
276+
273277
option(SWIFT_STDLIB_USE_NONATOMIC_RC
274278
"Build the standard libraries and overlays with nonatomic reference count operations enabled"
275279
FALSE)
@@ -416,10 +420,10 @@ swift_configure_components()
416420
# lipo is used to create universal binaries.
417421
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
418422
include(SwiftDarwin)
419-
if(SWIFT_LIPO)
420-
set(LIPO ${SWIFT_LIPO})
423+
if(CMAKE_LIPO)
424+
set(CMAKE_LIPO ${CMAKE_LIPO})
421425
else()
422-
find_toolchain_tool(LIPO "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" lipo)
426+
find_toolchain_tool(CMAKE_LIPO "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" lipo)
423427
endif()
424428
endif()
425429

@@ -581,18 +585,6 @@ endif()
581585
# Configure SDKs.
582586
#
583587

584-
function(is_sdk_requested name result_var_name)
585-
if("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${name}")
586-
set("${result_var_name}" "TRUE" PARENT_SCOPE)
587-
else()
588-
if("${name}" IN_LIST SWIFT_SDKS)
589-
set("${result_var_name}" "TRUE" PARENT_SCOPE)
590-
else()
591-
set("${result_var_name}" "FALSE" PARENT_SCOPE)
592-
endif()
593-
endif()
594-
endfunction()
595-
596588
if(XCODE)
597589
# FIXME: Cannot cross-compile the standard library using Xcode. Xcode
598590
# insists on passing -mmacosx-version-min to the compiler, and we need
@@ -693,84 +685,7 @@ elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
693685
message(STATUS "${xcode_version}")
694686
message(STATUS "")
695687

696-
is_sdk_requested(OSX swift_build_osx)
697-
if(swift_build_osx)
698-
configure_sdk_darwin(
699-
OSX "OS X" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_OSX}"
700-
macosx macosx macosx "x86_64")
701-
configure_target_variant(OSX-DA "OS X Debug+Asserts" OSX DA "Debug+Asserts")
702-
configure_target_variant(OSX-RA "OS X Release+Asserts" OSX RA "Release+Asserts")
703-
configure_target_variant(OSX-R "OS X Release" OSX R "Release")
704-
endif()
705-
706-
# Compatible cross-compile SDKS for Darwin OSes: IOS, IOS_SIMULATOR, TVOS,
707-
# TVOS_SIMULATOR, WATCHOS, WATCHOS_SIMULATOR (archs hardcoded below).
708-
709-
is_sdk_requested(IOS swift_build_ios)
710-
if(swift_build_ios)
711-
configure_sdk_darwin(
712-
IOS "iOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
713-
iphoneos ios ios "armv7;armv7s;arm64")
714-
configure_target_variant(IOS-DA "iOS Debug+Asserts" IOS DA "Debug+Asserts")
715-
configure_target_variant(IOS-RA "iOS Release+Asserts" IOS RA "Release+Asserts")
716-
configure_target_variant(IOS-R "iOS Release" IOS R "Release")
717-
endif()
718-
719-
is_sdk_requested(IOS_SIMULATOR swift_build_ios_simulator)
720-
if(swift_build_ios_simulator)
721-
configure_sdk_darwin(
722-
IOS_SIMULATOR "iOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
723-
iphonesimulator ios-simulator ios "i386;x86_64")
724-
configure_target_variant(
725-
IOS_SIMULATOR-DA "iOS Debug+Asserts" IOS_SIMULATOR DA "Debug+Asserts")
726-
configure_target_variant(
727-
IOS_SIMULATOR-RA "iOS Release+Asserts" IOS_SIMULATOR RA "Release+Asserts")
728-
configure_target_variant(
729-
IOS_SIMULATOR-R "iOS Release" IOS_SIMULATOR R "Release")
730-
endif()
731-
732-
is_sdk_requested(TVOS swift_build_tvos)
733-
if(swift_build_tvos)
734-
configure_sdk_darwin(
735-
TVOS "tvOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
736-
appletvos tvos tvos "arm64")
737-
configure_target_variant(TVOS-DA "tvOS Debug+Asserts" TVOS DA "Debug+Asserts")
738-
configure_target_variant(TVOS-RA "tvOS Release+Asserts" TVOS RA "Release+Asserts")
739-
configure_target_variant(TVOS-R "tvOS Release" TVOS R "Release")
740-
endif()
741-
742-
is_sdk_requested(TVOS_SIMULATOR swift_build_tvos_simulator)
743-
if(swift_build_tvos_simulator)
744-
configure_sdk_darwin(
745-
TVOS_SIMULATOR "tvOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
746-
appletvsimulator tvos-simulator tvos "x86_64")
747-
configure_target_variant(
748-
TVOS_SIMULATOR-DA "tvOS Debug+Asserts" TVOS_SIMULATOR DA "Debug+Asserts")
749-
configure_target_variant(
750-
TVOS_SIMULATOR-RA "tvOS Release+Asserts" TVOS_SIMULATOR RA "Release+Asserts")
751-
configure_target_variant(
752-
TVOS_SIMULATOR-R "tvOS Release" TVOS_SIMULATOR R "Release")
753-
endif()
754-
755-
is_sdk_requested(WATCHOS swift_build_watchos)
756-
if(swift_build_watchos)
757-
configure_sdk_darwin(
758-
WATCHOS "watchOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
759-
watchos watchos watchos "armv7k")
760-
configure_target_variant(WATCHOS-DA "watchOS Debug+Asserts" WATCHOS DA "Debug+Asserts")
761-
configure_target_variant(WATCHOS-RA "watchOS Release+Asserts" WATCHOS RA "Release+Asserts")
762-
configure_target_variant(WATCHOS-R "watchOS Release" WATCHOS R "Release")
763-
endif()
764-
765-
is_sdk_requested(WATCHOS_SIMULATOR swift_build_watchos_simulator)
766-
if(swift_build_watchos_simulator)
767-
configure_sdk_darwin(
768-
WATCHOS_SIMULATOR "watchOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
769-
watchsimulator watchos-simulator watchos "i386")
770-
configure_target_variant(WATCHOS_SIMULATOR-DA "watchOS Debug+Asserts" WATCHOS_SIMULATOR DA "Debug+Asserts")
771-
configure_target_variant(WATCHOS_SIMULATOR-RA "watchOS Release+Asserts" WATCHOS_SIMULATOR RA "Release+Asserts")
772-
configure_target_variant(WATCHOS_SIMULATOR-R "watchOS Release" WATCHOS_SIMULATOR R "Release")
773-
endif()
688+
include(DarwinSDKs)
774689

775690
# FIXME: guess target variant based on the host.
776691
# if(SWIFT_HOST_VARIANT MATCHES "^macosx")
@@ -800,6 +715,21 @@ endif()
800715
# Should we cross-compile the standard library for Android?
801716
is_sdk_requested(ANDROID swift_build_android)
802717
if(swift_build_android AND NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
718+
# Get the prebuilt suffix to create the correct toolchain path when using the NDK
719+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
720+
set(_swift_android_prebuilt_suffix "darwin-x86_64")
721+
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
722+
set(_swift_android_prebuilt_suffix "linux-x86_64")
723+
endif()
724+
725+
set(SWIFT_ANDROID_PREBUILT_PATH
726+
"${SWIFT_ANDROID_NDK_PATH}/toolchains/arm-linux-androideabi-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_suffix}")
727+
728+
# Resolve the correct linker based on the file name of CMAKE_LINKER (being 'ld' or 'ld.gold' the options)
729+
get_filename_component(SWIFT_ANDROID_LINKER_NAME "${CMAKE_LINKER}" NAME)
730+
set(SWIFT_SDK_ANDROID_ARCH_armv7_LINKER
731+
"${SWIFT_ANDROID_NDK_PATH}/toolchains/arm-linux-androideabi-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_suffix}/bin/arm-linux-androideabi-${SWIFT_ANDROID_LINKER_NAME}")
732+
803733
configure_sdk_unix(ANDROID "Android" "android" "android" "armv7" "armv7-none-linux-androideabi" "${SWIFT_ANDROID_SDK_PATH}")
804734

805735
if (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux"))
@@ -809,14 +739,6 @@ if(swift_build_android AND NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
809739
set(SWIFT_PRIMARY_VARIANT_SDK_default "ANDROID")
810740
set(SWIFT_PRIMARY_VARIANT_ARCH_default "armv7")
811741
endif()
812-
813-
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
814-
set(_swift_android_prebuilt_suffix "darwin-x86_64")
815-
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
816-
set(_swift_android_prebuilt_suffix "linux-x86_64")
817-
endif()
818-
set(SWIFT_ANDROID_PREBUILT_PATH
819-
"${SWIFT_ANDROID_NDK_PATH}/toolchains/arm-linux-androideabi-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_suffix}")
820742
endif()
821743

822744
# Should we cross-compile the standard library for Windows?

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<img src="https://swift.org/assets/images/swift.svg" alt="Swift logo" height="70" >
2+
23
# Swift Programming Language
34

4-
|| **Swift** | **Package** |
5-
|---|---|---|
5+
| | **Swift** | **Package** |
6+
|---|:---:|:---:|
67
|**macOS** |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-osx/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-osx)|[![Build Status](https://ci.swift.org/job/oss-swift-package-osx/badge/icon)](https://ci.swift.org/job/oss-swift-package-osx)|
78
|**Ubuntu 14.04** |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-14_04/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-14_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-14_04/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-14_04)|
89
|**Ubuntu 16.04** |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_04/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_04)|
@@ -53,7 +54,7 @@ discussed below.
5354
macOS, Ubuntu Linux LTS, and the latest Ubuntu Linux release are the current
5455
supported host development operating systems.
5556

56-
For macOS, you need [Xcode 8.3 Beta 3](https://developer.apple.com/xcode/downloads/).
57+
For macOS, you need [Xcode 8.3 Beta 4](https://developer.apple.com/xcode/downloads/).
5758

5859
For Ubuntu, you'll need the following development dependencies:
5960

benchmark/CMakeLists.txt

+14-8
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,22 @@ set(SWIFT_BENCH_MODULES
2929
single-source/ArraySubscript
3030
single-source/BitCount
3131
single-source/ByteSwap
32+
single-source/CString
3233
single-source/Calculator
3334
single-source/CaptureProp
3435
single-source/CharacterLiteralsLarge
3536
single-source/CharacterLiteralsSmall
3637
single-source/Chars
3738
single-source/ClassArrayGetter
3839
single-source/DeadArray
39-
single-source/DictTest
40-
single-source/DictTest2
41-
single-source/DictTest3
4240
single-source/DictionaryBridge
4341
single-source/DictionaryLiteral
4442
single-source/DictionaryRemove
4543
single-source/DictionarySwap
44+
single-source/DictTest
45+
single-source/DictTest2
46+
single-source/DictTest3
47+
single-source/DropLast
4648
single-source/ErrorHandling
4749
single-source/Fibonacci
4850
single-source/GlobalClass
@@ -53,15 +55,16 @@ set(SWIFT_BENCH_MODULES
5355
single-source/Integrate
5456
single-source/IterateData
5557
single-source/Join
58+
single-source/LazyFilter
5659
single-source/LinkedList
5760
single-source/MapReduce
5861
single-source/Memset
5962
single-source/MonteCarloE
6063
single-source/MonteCarloPi
64+
single-source/NopDeinit
6165
single-source/NSDictionaryCastToSwift
6266
single-source/NSError
6367
single-source/NSStringConversion
64-
single-source/NopDeinit
6568
single-source/ObjectAllocation
6669
single-source/ObjectiveCBridging
6770
single-source/ObjectiveCBridgingStubs
@@ -78,11 +81,11 @@ set(SWIFT_BENCH_MODULES
7881
single-source/Prims
7982
single-source/ProtocolDispatch
8083
single-source/ProtocolDispatch2
81-
single-source/RC4
82-
single-source/RGBHistogram
8384
single-source/RangeAssignment
85+
single-source/RC4
8486
single-source/RecursiveOwnedParameter
8587
single-source/ReversedCollections
88+
single-source/RGBHistogram
8689
single-source/SetTests
8790
single-source/SevenBoom
8891
single-source/Sim2DArray
@@ -91,11 +94,14 @@ set(SWIFT_BENCH_MODULES
9194
single-source/StackPromo
9295
single-source/StaticArray
9396
single-source/StrComplexWalk
94-
single-source/StrToInt
9597
single-source/StringBuilder
98+
single-source/StringEdits
9699
single-source/StringInterpolation
100+
single-source/StringMatch
97101
single-source/StringTests
98102
single-source/StringWalk
103+
single-source/StrToInt
104+
single-source/Suffix
99105
single-source/SuperChars
100106
single-source/TwoSum
101107
single-source/TypeFlood
@@ -141,7 +147,7 @@ if(NOT SWIFT_LIBRARY_PATH)
141147
endif()
142148

143149
# If the CMAKE_C_COMPILER is already clang, don't find it again,
144-
# thus allowing the --host-cc build-script argument to work here.
150+
# thus allowing the --cmake-c-compiler build-script argument to work here.
145151
get_filename_component(c_compiler ${CMAKE_C_COMPILER} NAME)
146152

147153
if(${c_compiler} STREQUAL "clang")

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ function (swift_benchmark_compile_archopts)
321321
"-c"
322322
"-o" "${objcfile}")
323323

324+
precondition(CMAKE_CODESIGN MESSAGE "CMAKE_CODESIGN is required, please set it")
324325
add_custom_command(
325326
OUTPUT "${OUTPUT_EXEC}"
326327
DEPENDS
@@ -349,7 +350,7 @@ function (swift_benchmark_compile_archopts)
349350
${objcfile}
350351
"-o" "${OUTPUT_EXEC}"
351352
COMMAND
352-
"codesign" "-f" "-s" "-" "${OUTPUT_EXEC}")
353+
${CMAKE_CODESIGN} "-f" "-s" "-" "${OUTPUT_EXEC}")
353354
set(new_output_exec "${OUTPUT_EXEC}" PARENT_SCOPE)
354355
endfunction()
355356

benchmark/scripts/generate_harness/CMakeLists.txt_template

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ if(NOT SWIFT_LIBRARY_PATH)
6868
endif()
6969

7070
# If the CMAKE_C_COMPILER is already clang, don't find it again,
71-
# thus allowing the --host-cc build-script argument to work here.
71+
# thus allowing the --cmake-c-compiler build-script argument to work here.
7272
get_filename_component(c_compiler ${CMAKE_C_COMPILER} NAME)
7373

7474
if(${c_compiler} STREQUAL "clang")

benchmark/single-source/CString.swift

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//===--- CString.swift -------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 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 TestsUtils
14+
#if os(Linux)
15+
import Glibc
16+
#else
17+
import Darwin
18+
#endif
19+
20+
let ascii = "Swift is a multi-paradigm, compiled programming language created for iOS, OS X, watchOS, tvOS and Linux development by Apple Inc. Swift is designed to work with Apple's Cocoa and Cocoa Touch frameworks and the large body of existing Objective-C code written for Apple products. Swift is intended to be more resilient to erroneous code (\"safer\") than Objective-C and also more concise. It is built with the LLVM compiler framework included in Xcode 6 and later and uses the Objective-C runtime, which allows C, Objective-C, C++ and Swift code to run within a single program."
21+
let japanese = "日本語(にほんご、にっぽんご)は、主に日本国内や日本人同士の間で使われている言語である。"
22+
23+
@inline(never)
24+
public func run_StringWithCString(_ N: Int) {
25+
let str = String(repeating: "x", count: 100 * (1 << 16))
26+
for _ in 0 ..< N {
27+
str.withCString { _ in }
28+
}
29+
}
30+
31+
@inline(never)
32+
public func run_CStringLongAscii(_ N: Int) {
33+
let refResult = 517492
34+
var res: UInt = 0
35+
for _ in 1...N*500 {
36+
// static string to c -> from c to String -> implicit conversion
37+
res &= strlen(ascii.withCString(String.init(cString:)))
38+
}
39+
CheckResults(res == 0, "IncorrectResults in run_CStringLongAscii: \(res) != \(refResult)")
40+
}
41+
42+
@inline(never)
43+
public func run_CStringLongNonAscii(_ N: Int) {
44+
let refResult = 517492
45+
var res: UInt = 0
46+
for _ in 1...N*500 {
47+
res &= strlen(japanese.withCString(String.init(cString:)))
48+
}
49+
CheckResults(res == 0, "IncorrectResults in run_CStringLongAscii: \(res) != \(refResult)")
50+
}
51+
52+
53+
let input = ["-237392", "293715", "126809", "333779", "-362824", "144198",
54+
"-394973", "-163669", "-7236", "376965", "-400783", "-118670",
55+
"454728", "-38915", "136285", "-448481", "-499684", "68298",
56+
"382671", "105432", "-38385", "39422", "-267849", "-439886",
57+
"292690", "87017", "404692", "27692", "486408", "336482",
58+
"-67850", "56414", "-340902", "-391782", "414778", "-494338",
59+
"-413017", "-377452", "-300681", "170194", "428941", "-291665",
60+
"89331", "329496", "-364449", "272843", "-10688", "142542",
61+
"-417439", "167337", "96598", "-264104", "-186029", "98480",
62+
"-316727", "483808", "300149", "-405877", "-98938", "283685",
63+
"-247856", "-46975", "346060", "160085",]
64+
let reference = 517492
65+
66+
@inline(never)
67+
public func run_CStringShortAscii(_ N: Int) {
68+
69+
func DoOneIter(_ arr: [String]) -> Int {
70+
var r = 0
71+
for n in arr {
72+
r += Int(atoi(n))
73+
}
74+
if r < 0 {
75+
r = -r
76+
}
77+
return r
78+
}
79+
80+
var res = Int.max
81+
for _ in 1...100*N {
82+
let strings = input.map {
83+
$0.withCString(String.init(cString:))
84+
}
85+
res = res & DoOneIter(strings)
86+
}
87+
assert(res == reference, "IncorrectResults in StrToInt: \(res) != \(reference)")
88+
}
89+

0 commit comments

Comments
 (0)