Commit Graph

10155 Commits

Author SHA1 Message Date
Doug Gregor
6238923e15 [Function builders] Support multiple Boolean conditions in 'if' statements
Generalize support for function builders to allow 'if' statements that
include multiple Boolean conditions, e.g., "if a, b, c, { ... }".
2020-01-23 17:04:17 -08:00
swift-ci
97af8d7e0b Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 17:24:41 -08:00
David Smith
8e09cd2119 Merge pull request #25864 from Catfish-Man/no-objc-complications-once-more-into-the-breach
Update fast dealloc to use new-style interposing and support objc weak refs
2020-01-22 17:21:34 -08:00
kelvin13
fb4bd68653 Merge branch 'master' into comparable-enums 2020-01-22 18:38:31 -06:00
David Smith
f36a4db856 Update fast dealloc to use new-style interposing and support objc weak refs 2020-01-22 13:55:27 -08:00
Karoy Lorentey
846e957278 [Foundation] Switch to private imports of CoreFoundation shims 2020-01-22 13:26:27 -08:00
swift-ci
7980c7fa10 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 10:43:11 -08:00
Michael Ilseman
38de918213 Merge pull request #29146 from Lukasa/cb-substring-fast-access-2
[stdlib] Re-add withContiguousStorageIfAvailable to SubString.UTF8View
2020-01-22 10:36:58 -08:00
Erik Eckstein
ef007519b1 stdlib: move Dictionary's find functions into __RawDictionaryStorage.
The find functions do not require the generic Value parameter. Moving them to __RawDictionaryStorage allows to define them with only one generic parameter: the Key.
This allows the optimizer to share specializations for dictionaries which have the same Key, but a different Value.
Also, prevent inlining of the find-functions to save some additional code size.
2020-01-22 15:29:32 +01:00
Erik Eckstein
bbfaccda4b Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 08:25:23 +01:00
Devin Coughlin
63ce243437 [CMake] Add initial build system support for macCatalyst
This commit adds initial build system support for macCatalyst,
an Apple technology that enables code targeting iOS
to be recompiled so that it can be executed on macOS while still using
iOS APIs. This is the first in a series of commits building out support for
macCatalyst in the compiler, runtime, standard library, and overlays. Swift
for macCatalyst represents the work of multiple people, including
Devin Coughlin, Ross Bayer, and Brent Royal-Gordon.

Under macCatalyst, compiler-provided shared libraries (including overlays)
are built as one of four kinds (or "flavors") of libraries,
each with different install names and Mach-O load commands. This commit
adds the build system infrastructure to produce these different
library flavors.

**macOS-like Libraries**

A "macOS-like" library (such as the GLKit overlay) is a plain-old macOS library
that can only be loaded into regular macOS processes. It has a macOS slice with
a single load command allowing it to be loaded into normal macOS processes.

**iOS-like Libraries**

An "iOS-like" library, such as the UIKit overlay, is a library with a
macOS slice but with a load command that only allows it be loaded into
macCatalyst processes. iOS-like libraries are produced by passing a new
target tuple to the compiler:

  swiftc ... -target x86_64-apple-ios13.0-macabi ...

Here 'ios' (and an iOS version number) is used for OS portion
of the triple, but the 'macabi' environment tells the compiler
that the library is intended for macCatalyst.

**Zippered Libraries**

A "zippered" library can be loaded into either a macCatalyst process or
a standard macOS process. Since macCatalyst does not introduce a new Mach-O
slice, the same code is shared between both processes. Zippered libraries
are usually relatively low level and with an API surface that is similar
between macOS and iOS (for example, both the Foundation overlay and the Swift
Standard Library/Runtime itself are zippered).

Zippered libraries are created by passing both the usual `-target`
flag to the compiler and an additional `-target-variant` flag:

   swiftc ... -target x86_64-apple-macos10.15 \
              -target-variant x86_64-apple-ios13.0-macabi

Just like the -target flag, -target-variant takes a target tuple.
This tells the compiler to compile the library for the -target tuple but
to add an extra load command, allowing the library to be loaded into processes
of the -target-variant flavor as well.

While a single zippered library and slice is shared between macOS and
macCatalyst, zippered libraries require two separate .swiftinterface/.swiftmodule
files, one for macOS and one for macCatalyst. When a macOS or macCatalyst client
imports the library, it will use module file for its flavor to determine what
symbols are present. This enables a zippered library to expose a subset of its
target APIs to its target-variant.

**Unzippered-Twin Libraries**

"Unzippered Twins" are pairs of libraries with the same name but different
contents and install locations, one for use from macOS processes and one for
use from macCatalyst processes. Unzippered twins are usually libraries that
depend on AppKit on macOS and UIKit on iOS (for example, the MapKit overlay)
and so do not share a common implementation between macOS and macCatalyst.

The macCatalyst version of an unzippered twin is installed in a parallel
directory hierarchy rooted at /System/iOSSupport/. So, for example, while macOS
and zippered Swift overlays are installed in /usr/lib/swift/, iOS-like and
the macCatalyst side of unzippered twins are installed in
/System/iOSSupport/usr/lib/swift. When building for macCatalyst, the build system
passes additional search paths so that the macCatalyst version of libraries is
found before macOS versions.

The add_swift_target_library() funciton now take an
optional  MACCATALYST_BUILD_FLAVOR, which enables swift libraries to indicate
which flavor of library they are.
2020-01-21 18:26:13 -08:00
swift-ci
766f6cc3fe Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 08:23:24 -08:00
Saleem Abdulrasool
b855260cae build-script: handle special build rules for non-atomic runtime
Move the special flag handling for the non-atomic runtime into the build
system rather than spreading it across the build system and the helper
utilities.
2020-01-20 14:51:27 -08:00
swift-ci
74e66dcd1f Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-19 13:03:49 -08:00
David Zarzycki
f185dd66f1 [QoI] Fix -Wrange-loop-analysis warnings 2020-01-19 13:29:23 -05:00
swift-ci
97caa01142 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-19 09:43:48 -08:00
Saleem Abdulrasool
f2b6446546 build: always report the status of building Differentiation
This moves the build configuration information into the block which
prints the full configuration details for the Swift runtime.  Simplify
the condition by merging the two blocks for building the standard
library and the `Differentiation` module.
2020-01-18 09:38:50 -08:00
swift-ci
82d07ec70a Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-17 12:43:10 -08:00
tbkka
b8c090d9c6 [SR-3871] Unwrap multiple layers of Any/AnyObject when casting to protocol type (#28835)
SR-3871: Dynamic casting of existentials stored in Obj-C references

Arbitrary Swift objects get packaged into __SwiftValue containers so
that pointers to them can be passed into Obj-C.  (Obviously, Obj-C
code can't do anything particularly useful with such pointers other
than refcount them and give them back to Swift code.)  Those values come
back into Swift as either `Any` (existential box) or `AnyObject`
(anonymous object pointer) values.  Dynamically casting those requires
first inspecting the outer value to get access to the actual type and
value in the __SwiftValue container.

The tryDynamicCastBoxedSwiftValue() function that handles this
was missing a check for the `Any` case, which is why directly
casting from `Any` would routinely fail.

Resolves SR-3871
2020-01-17 12:41:44 -08:00
adrian-prantl
d52ec5d13f Merge pull request #29139 from adrian-prantl/55412775
Reflection: Implement a TypeRef -> Demangle tree adapter
2020-01-16 09:38:42 -08:00
swift-ci
4436721aa2 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-16 03:04:15 -08:00
eeckstein
2715c705f4 Merge pull request #29220 from eeckstein/improve-array-append
stdlib: add a shortcut for Array.append(contentsOf:) in case the argument is an Array, too.
2020-01-16 11:51:20 +01:00
Erik Eckstein
1b312a85bd Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-16 10:39:20 +01:00
Brent Royal-Gordon
99e60b03b2 Merge pull request #29237 from brentdax/revenge-of-the-synth
Revert "Merge pull request #28665 from CodaFi/the-phantom-menace"
2020-01-15 20:09:55 -08:00
Suyash Srijan
c02b95ebf9 [Runtime] A Swift Error bridged to NSError should return its description, rather than NSError.description (#29224) 2020-01-16 00:13:55 +00:00
Brent Royal-Gordon
0c478b6be6 Revert "Merge pull request #28665 from CodaFi/the-phantom-menace"
This reverts commit 43a3ab7e35, reversing
changes made to 4f39d9c749.

# Conflicts:
#	include/swift/AST/Attr.def
#	lib/AST/Attr.cpp
#	lib/Serialization/Deserialization.cpp
#	lib/Serialization/ModuleFormat.h
#	lib/Serialization/Serialization.cpp
2020-01-15 15:28:42 -08:00
Erik Eckstein
172c72b95a stdlib: add a shortcut for Array.append(contentsOf:) in case the argument is an Array, too.
This additional check lets the optimizer eliminate most of the append-code in specializations where the appended sequence is also an Array.
For example, when "adding" arrays, e.g. arr += other_arr
2020-01-15 15:27:25 +01:00
Adrian Prantl
ea2b5eced9 Reflection: Implement a TypeRef -> Demangle tree adapter.
To allow more pervasive use of TypeRefs in LLDB, we need a way to build mangled
names from TypeRef pointers to allow round-tripping between TypeRefs and AST
types. The goal is to experiment with making lldb::CompilerType backed by
TypeRefs instead of AST types.

<rdar://problem/55412775>
2020-01-14 17:50:01 -08:00
swift-ci
e9073f68d7 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-14 09:24:04 -08:00
Arnold Schwaighofer
071bece428 Merge pull request #29167 from aschwaighofer/revert_array_first
Revert "stdlib: Add custom .first to Array"
2020-01-14 09:05:08 -08:00
Cory Benfield
c6dfea6fc4 [stdlib] Re-add withContiguousStorageIfAvailable to SubString.UTF8View
This is a second pass at the original patch, which broke an OS test.

Due to an oversight it seems that we never added a
withContigousStorageIfAvailable implementation to SubString.UTF8View,
which meant that if you sliced a String you lost the ability to get fast
access to the backing storage. There's no good reason for this
functionality to be missing, so this patch adds it in by delegating to
the Slice implementation.

Resolves SR-11999.
2020-01-14 14:01:06 +00:00
swift-ci
e3a8ef8ec9 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-13 16:03:23 -08:00
Ben Cohen
60b4f38660 Eliminate context descriptor cache (#29151) 2020-01-13 15:59:32 -08:00
swift-ci
fc308b648d Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-13 13:44:18 -08:00
Saleem Abdulrasool
ecdaf1704b Merge pull request #29054 from compnerd/defines
swiftMSVCRT: build with `-Xcc -D_USE_MATH_DEFINES`
2020-01-13 13:40:29 -08:00
Arnold Schwaighofer
1386af04a2 Revert "stdlib: Add custom .first to Array"
This reverts commit 3e932c075d.

The compiler does not support @_alwaysEmitIntoClient properties
specially wrt property descriptors. The revert commit would introduce an
ABI incompatability when a keypath to Array.first is formed:

    let greetings = ["hello", "hola"]
    let count = greetings[keyPath: \[String].first?.count]

Runmning on an older runtime would lead to linker errors against $sSa5firstxSgvpMV
the property descriptor for Array.first.

rdar://58484319
2020-01-13 13:07:00 -08:00
swift-ci
52c5ecd291 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-10 16:23:41 -08:00
Michael Ilseman
4194c163b4 Merge pull request #29128 from apple/revert-29094-cb-substring-fast-access
Revert "[stdlib] Add withContiguousStorageIfAvailable to SubString.UTF8View"
2020-01-10 16:17:53 -08:00
swift-ci
5dcb80b599 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-10 15:24:32 -08:00
nate-chandler
1430c04e68 Merge pull request #28610 from nate-chandler/generic-metadata-prespecialization
Generic metadata prespecialization, part 1
2020-01-10 15:08:05 -08:00
Michael Ilseman
70e6db81f1 Revert "[stdlib] Add withContiguousStorageIfAvailable to SubString.UTF8View" 2020-01-10 13:28:03 -08:00
swift-ci
4acddb3ab0 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-10 11:24:26 -08:00
eeckstein
3f71bb864c Merge pull request #29121 from eeckstein/fix-array-remove
stdlib: annotate Array's remove functions with semantic attributes.
2020-01-10 20:23:21 +01:00
Michael Ilseman
6209c97bf7 Merge pull request #29094 from Lukasa/cb-substring-fast-access
[stdlib] Add withContiguousStorageIfAvailable to SubString.UTF8View
2020-01-10 11:16:46 -08:00
Erik Eckstein
dfc5b06819 stdlib: annotate Array's remove functions with semantic attributes.
All mutating Array functions must be annotated with semantics, because otherwise some high level optimizations get confused.
The semantic attributes prevent inlining those functions in high-level-sil.
This is need so that the optimizer sees that the Array is taken as inout and can reason that it's modified.

This restriction is not needed anymore when we’ll have COW representation in SIL.

rdar://problem/58478089
2020-01-10 17:09:47 +01:00
Arnold Schwaighofer
0c99cd9734 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-10 08:00:41 -08:00
Cory Benfield
68f0816daa [stdlib] Add withContiguousStorageIfAvailable to SubString.UTF8View
Due to an oversight it seems that we never added a
withContigousStorageIfAvailable implementation to SubString.UTF8View,
which meant that if you sliced a String you lost the ability to get fast
access to the backing storage. There's no good reason for this
functionality to be missing, so this patch adds it in by delegating to
the Slice implementation.

Resolves SR-11999.
2020-01-10 09:10:09 +00:00
Nate Chandler
edab098067 [runtime] Metadata can be flagged static.
Added a new flag to the GenericMetadataPatternFlags flagset for whether
the metadata has a set of flags at its tail.  When that flag is set,
there will be an extra uint64_t flagset at the end of the metadata.  For
struct metadata, the type of that flagset will be
StructMetadataTrailingFlags.  The first flag in that trailing flagset
indicates whether the metadata was statically specialized.  The second
flag in that trailing flagset indicates whether the metadata is
statically canonical.

When verifying the metadata cache, a check is done for whether the
metadata was statically specialized and whether it was known to be
canonical statically.  If so, verification is skipped.  Skipping it is
necessary because the known-canonical statically specialized metadata
will not be in the cache.  In that case, the canonical statically
specialized metadata will be returned from the metadata accessor and
never be cached.
2020-01-09 17:25:31 -08:00
Erik Eckstein
60a0718922 stdlib: simplify Array/ContiguousArray's withUnsafeMutableBufferPointer and withUnsafeMutableBufferPointer
Again, to reduce code size
2020-01-09 16:17:38 +01:00
Erik Eckstein
bda8af0958 stdlib: simplify Array/ContiguousArray's append(contentsOf:)
Instead of calling ArrayBuffer's _arrayAppendSequence, inline the code. This saves some code size.
2020-01-09 16:17:38 +01:00