Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into unicode-rethink
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Abrahams committed Mar 19, 2017
2 parents fbc96e9 + f61612c commit 435a67a
Show file tree
Hide file tree
Showing 654 changed files with 10,296 additions and 11,352 deletions.
91 changes: 1 addition & 90 deletions CMakeLists.txt
Expand Up @@ -585,18 +585,6 @@ endif()
# Configure SDKs.
#

function(is_sdk_requested name result_var_name)
if("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${name}")
set("${result_var_name}" "TRUE" PARENT_SCOPE)
else()
if("${name}" IN_LIST SWIFT_SDKS)
set("${result_var_name}" "TRUE" PARENT_SCOPE)
else()
set("${result_var_name}" "FALSE" PARENT_SCOPE)
endif()
endif()
endfunction()

if(XCODE)
# FIXME: Cannot cross-compile the standard library using Xcode. Xcode
# insists on passing -mmacosx-version-min to the compiler, and we need
Expand Down Expand Up @@ -697,84 +685,7 @@ elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
message(STATUS "${xcode_version}")
message(STATUS "")

is_sdk_requested(OSX swift_build_osx)
if(swift_build_osx)
configure_sdk_darwin(
OSX "OS X" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_OSX}"
macosx macosx macosx "x86_64")
configure_target_variant(OSX-DA "OS X Debug+Asserts" OSX DA "Debug+Asserts")
configure_target_variant(OSX-RA "OS X Release+Asserts" OSX RA "Release+Asserts")
configure_target_variant(OSX-R "OS X Release" OSX R "Release")
endif()

# Compatible cross-compile SDKS for Darwin OSes: IOS, IOS_SIMULATOR, TVOS,
# TVOS_SIMULATOR, WATCHOS, WATCHOS_SIMULATOR (archs hardcoded below).

is_sdk_requested(IOS swift_build_ios)
if(swift_build_ios)
configure_sdk_darwin(
IOS "iOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
iphoneos ios ios "armv7;armv7s;arm64")
configure_target_variant(IOS-DA "iOS Debug+Asserts" IOS DA "Debug+Asserts")
configure_target_variant(IOS-RA "iOS Release+Asserts" IOS RA "Release+Asserts")
configure_target_variant(IOS-R "iOS Release" IOS R "Release")
endif()

is_sdk_requested(IOS_SIMULATOR swift_build_ios_simulator)
if(swift_build_ios_simulator)
configure_sdk_darwin(
IOS_SIMULATOR "iOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
iphonesimulator ios-simulator ios "i386;x86_64")
configure_target_variant(
IOS_SIMULATOR-DA "iOS Debug+Asserts" IOS_SIMULATOR DA "Debug+Asserts")
configure_target_variant(
IOS_SIMULATOR-RA "iOS Release+Asserts" IOS_SIMULATOR RA "Release+Asserts")
configure_target_variant(
IOS_SIMULATOR-R "iOS Release" IOS_SIMULATOR R "Release")
endif()

is_sdk_requested(TVOS swift_build_tvos)
if(swift_build_tvos)
configure_sdk_darwin(
TVOS "tvOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
appletvos tvos tvos "arm64")
configure_target_variant(TVOS-DA "tvOS Debug+Asserts" TVOS DA "Debug+Asserts")
configure_target_variant(TVOS-RA "tvOS Release+Asserts" TVOS RA "Release+Asserts")
configure_target_variant(TVOS-R "tvOS Release" TVOS R "Release")
endif()

is_sdk_requested(TVOS_SIMULATOR swift_build_tvos_simulator)
if(swift_build_tvos_simulator)
configure_sdk_darwin(
TVOS_SIMULATOR "tvOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
appletvsimulator tvos-simulator tvos "x86_64")
configure_target_variant(
TVOS_SIMULATOR-DA "tvOS Debug+Asserts" TVOS_SIMULATOR DA "Debug+Asserts")
configure_target_variant(
TVOS_SIMULATOR-RA "tvOS Release+Asserts" TVOS_SIMULATOR RA "Release+Asserts")
configure_target_variant(
TVOS_SIMULATOR-R "tvOS Release" TVOS_SIMULATOR R "Release")
endif()

is_sdk_requested(WATCHOS swift_build_watchos)
if(swift_build_watchos)
configure_sdk_darwin(
WATCHOS "watchOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
watchos watchos watchos "armv7k")
configure_target_variant(WATCHOS-DA "watchOS Debug+Asserts" WATCHOS DA "Debug+Asserts")
configure_target_variant(WATCHOS-RA "watchOS Release+Asserts" WATCHOS RA "Release+Asserts")
configure_target_variant(WATCHOS-R "watchOS Release" WATCHOS R "Release")
endif()

is_sdk_requested(WATCHOS_SIMULATOR swift_build_watchos_simulator)
if(swift_build_watchos_simulator)
configure_sdk_darwin(
WATCHOS_SIMULATOR "watchOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
watchsimulator watchos-simulator watchos "i386")
configure_target_variant(WATCHOS_SIMULATOR-DA "watchOS Debug+Asserts" WATCHOS_SIMULATOR DA "Debug+Asserts")
configure_target_variant(WATCHOS_SIMULATOR-RA "watchOS Release+Asserts" WATCHOS_SIMULATOR RA "Release+Asserts")
configure_target_variant(WATCHOS_SIMULATOR-R "watchOS Release" WATCHOS_SIMULATOR R "Release")
endif()
include(DarwinSDKs)

# FIXME: guess target variant based on the host.
# if(SWIFT_HOST_VARIANT MATCHES "^macosx")
Expand Down
19 changes: 11 additions & 8 deletions benchmark/CMakeLists.txt
Expand Up @@ -29,21 +29,22 @@ set(SWIFT_BENCH_MODULES
single-source/ArraySubscript
single-source/BitCount
single-source/ByteSwap
single-source/CString
single-source/Calculator
single-source/CaptureProp
single-source/CharacterLiteralsLarge
single-source/CharacterLiteralsSmall
single-source/Chars
single-source/ClassArrayGetter
single-source/CString
single-source/DeadArray
single-source/DictTest
single-source/DictTest2
single-source/DictTest3
single-source/DictionaryBridge
single-source/DictionaryLiteral
single-source/DictionaryRemove
single-source/DictionarySwap
single-source/DictTest
single-source/DictTest2
single-source/DictTest3
single-source/DropLast
single-source/ErrorHandling
single-source/Fibonacci
single-source/GlobalClass
Expand All @@ -54,15 +55,16 @@ set(SWIFT_BENCH_MODULES
single-source/Integrate
single-source/IterateData
single-source/Join
single-source/LazyFilter
single-source/LinkedList
single-source/MapReduce
single-source/Memset
single-source/MonteCarloE
single-source/MonteCarloPi
single-source/NopDeinit
single-source/NSDictionaryCastToSwift
single-source/NSError
single-source/NSStringConversion
single-source/NopDeinit
single-source/ObjectAllocation
single-source/ObjectiveCBridging
single-source/ObjectiveCBridgingStubs
Expand All @@ -79,11 +81,11 @@ set(SWIFT_BENCH_MODULES
single-source/Prims
single-source/ProtocolDispatch
single-source/ProtocolDispatch2
single-source/RC4
single-source/RGBHistogram
single-source/RangeAssignment
single-source/RC4
single-source/RecursiveOwnedParameter
single-source/ReversedCollections
single-source/RGBHistogram
single-source/SetTests
single-source/SevenBoom
single-source/Sim2DArray
Expand All @@ -92,13 +94,14 @@ set(SWIFT_BENCH_MODULES
single-source/StackPromo
single-source/StaticArray
single-source/StrComplexWalk
single-source/StrToInt
single-source/StringBuilder
single-source/StringEdits
single-source/StringInterpolation
single-source/StringMatch
single-source/StringTests
single-source/StringWalk
single-source/StrToInt
single-source/Suffix
single-source/SuperChars
single-source/TwoSum
single-source/TypeFlood
Expand Down
86 changes: 86 additions & 0 deletions benchmark/single-source/DropLast.swift
@@ -0,0 +1,86 @@
//===--- DropLast.swift ---------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import TestsUtils

let reps = 1
let sequenceCount = 4096
let prefixCount = 1024
let dropCount = sequenceCount - prefixCount
let sumCount = prefixCount * (prefixCount-1) / 2

@inline(never)
public func run_DropLastCountableRange(_ N: Int) {
let s = 0 ..< sequenceCount
for _ in 1...20*N {
for _ in 1...reps {
var result = 0
for element in s.dropLast(dropCount) {
result += element
}
CheckResults(result == sumCount,
"IncorrectResults in DropLastCountableRange: \(result) != \(sumCount)")
}
}
}

fileprivate struct MySequence: Sequence {
let range: CountableRange<Int>
public func makeIterator() -> IndexingIterator<CountableRange<Int>> {
return range.makeIterator()
}
}

@inline(never)
public func run_DropLastSequence(_ N: Int) {
let s = MySequence(range: 0 ..< sequenceCount)
for _ in 1...20*N {
for _ in 1...reps {
var result = 0
for element in s.dropLast(dropCount) {
result += element
}
CheckResults(result == sumCount,
"IncorrectResults in DropLastSequence: \(result) != \(sumCount)")
}
}
}

@inline(never)
public func run_DropLastAnySequence(_ N: Int) {
let s = AnySequence(0 ..< sequenceCount)
for _ in 1...20*N {
for _ in 1...reps {
var result = 0
for element in s.dropLast(dropCount) {
result += element
}
CheckResults(result == sumCount,
"IncorrectResults in DropLastAnySequence: \(result) != \(sumCount)")
}
}
}

@inline(never)
public func run_DropLastArray(_ N: Int) {
let s = Array(0 ..< sequenceCount)
for _ in 1...20*N {
for _ in 1...reps {
var result = 0
for element in s.dropLast(dropCount) {
result += element
}
CheckResults(result == sumCount,
"IncorrectResults in DropLastArray: \(result) != \(sumCount)")
}
}
}
38 changes: 38 additions & 0 deletions benchmark/single-source/LazyFilter.swift
@@ -0,0 +1,38 @@
//===--- LazyFilter.swift -------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

// This test checks performance of creating an array from lazily filtered
// collections.
import TestsUtils

@inline(never)
public func run_LazilyFilteredRange(_ N: Int) {
var res = 123
let c = (1..<1_000_000).lazy.filter { $0 % 7 == 0 }
for _ in 1...N {
res += Array(c).count
res -= Array(c).count
}
CheckResults(res == 123, "Wrong result in LazilyFilteredRange 123 != \(res)")
}

@inline(never)
public func run_LazilyFilteredArrays(_ N: Int) {
var res = 123
let c = (1..<1_000_000).map({[$0]}).lazy.filter { $0.first! % 7 == 0 }
for _ in 1...N {
res += Array(c).count
res -= Array(c).count
}
CheckResults(res == 123, "Wrong result in LazilyFilteredArray 123 != \(res)")
}

1 change: 1 addition & 0 deletions benchmark/single-source/PopFrontGeneric.swift
Expand Up @@ -17,6 +17,7 @@ let arrayCount = 1024

// This test case exposes rdar://17440222 which caused rdar://17974483 (popFront
// being really slow).
@_versioned
protocol MyArrayBufferProtocol : MutableCollection, RandomAccessCollection {
associatedtype Element

Expand Down
85 changes: 85 additions & 0 deletions benchmark/single-source/Suffix.swift
@@ -0,0 +1,85 @@
//===--- Suffix.swift ---------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import TestsUtils

let reps = 1
let sequenceCount = 4096
let suffixCount = 1024
let sumCount = suffixCount * (2 * sequenceCount - suffixCount - 1) / 2

@inline(never)
public func run_SuffixCountableRange(_ N: Int) {
let s = 0 ..< sequenceCount
for _ in 1...20*N {
for _ in 1...reps {
var result = 0
for element in s.suffix(suffixCount) {
result += element
}
CheckResults(result == sumCount,
"IncorrectResults in SuffixCountableRange: \(result) != \(sumCount)")
}
}
}

fileprivate struct MySequence: Sequence {
let range: CountableRange<Int>
public func makeIterator() -> IndexingIterator<CountableRange<Int>> {
return range.makeIterator()
}
}

@inline(never)
public func run_SuffixSequence(_ N: Int) {
let s = MySequence(range: 0 ..< sequenceCount)
for _ in 1...20*N {
for _ in 1...reps {
var result = 0
for element in s.suffix(suffixCount) {
result += element
}
CheckResults(result == sumCount,
"IncorrectResults in SuffixSequence: \(result) != \(sumCount)")
}
}
}

@inline(never)
public func run_SuffixAnySequence(_ N: Int) {
let s = AnySequence(0 ..< sequenceCount)
for _ in 1...20*N {
for _ in 1...reps {
var result = 0
for element in s.suffix(suffixCount) {
result += element
}
CheckResults(result == sumCount,
"IncorrectResults in SuffixAnySequence: \(result) != \(sumCount)")
}
}
}

@inline(never)
public func run_SuffixArray(_ N: Int) {
let s = Array(0 ..< sequenceCount)
for _ in 1...20*N {
for _ in 1...reps {
var result = 0
for element in s.suffix(suffixCount) {
result += element
}
CheckResults(result == sumCount,
"IncorrectResults in SuffixArray: \(result) != \(sumCount)")
}
}
}

0 comments on commit 435a67a

Please sign in to comment.