Commit Graph

136 Commits

Author SHA1 Message Date
Mike Ash
190d3fd22e [Concurrency] Use pthread_specific for thread-local storage on Darwin.
The pthread_specific APIs are better than C++ thread_local storage on Darwin since we can use Swift's reserved pthread keys there.

rdar://79504652
2021-06-29 16:56:59 -04:00
Robert Widmann
0149ccd0ca Add arm64_32 support for Swift
Commit the platform definition and build script work necessary to
cross-compile for arm64_32.

arm64_32 is a variant of AARCH64 that supports an ILP32 architecture.
2021-04-20 14:59:04 -07:00
Joe Groff
13e6566e2e Compatibility50: Use __dso_handle for cheaper main executable check.
rdar://70959417
2021-04-12 13:01:45 -07:00
Eric Miotto
3211817e40 [CMake] Copy legacy layouts for module architectures (#34921)
This supports properly the new dependencies introduced with #34846.

Addresses rdar://71851272
2020-12-02 13:12:09 -08:00
Alejandro Alonso
424802fb34 Revert SE-0283 (#34492)
Reverted despite build failures.
2020-10-29 17:32:06 -07:00
Azoy
48ea83723e Manually define _rawHashValue in compatibility libraries, AST fixes for builtin protocol conformance
Remember to use substituted type in builtin conformance substitution
2020-10-22 18:28:38 -04:00
Azoy
7a6ea99eab [Runtime] Clean up the assembly around Tuple builtin conformances
forgot + 1
2020-10-22 18:28:37 -04:00
Azoy
5e03e333cb [Compatibility53] Backport Tuple Hashable Conformance 2020-10-22 18:28:31 -04:00
Azoy
13b5bf4cfd [Compatibility53] Backport Tuple Comparable Conformance
Add protocol witnesses for Comparable requirements

remove unused table
2020-10-22 18:27:56 -04:00
Azoy
df9778e2e8 [Compatibility53] Add compatibility library for 5.3 and backport tuple Equatable conformance
Fix some comments

Unnecessary cast
2020-10-22 18:27:03 -04:00
Azoy
4b71d6776e [ABI] Introduce MetadataKind TypeRef 2020-10-22 18:24:28 -04:00
John McCall
0fb407943f [NFC] Rename swift_runtime_unreachable to swift_unreachable and make it use LLVM's support when available. 2020-10-03 02:54:56 -04:00
Mike Ash
ecd6d4ddec Add a new ConcurrentReadableHashMap type. Switch the protocol conformance cache
to use it.

ConcurrentReadableHashMap is lock-free for readers, with writers using a lock to
ensure mutual exclusion amongst each other. The intent is to eventually replace
all uses ConcurrentMap with ConcurrentReadableHashMap.

ConcurrentReadableHashMap provides for relatively quick lookups by using a hash
table. Rearders perform an atomic increment/decrement in order to inform writers
that there are active readers. The design attempts to minimize wasted memory by
storing the actual elements out-of-line, and having the table store indices into
a separate array of elements.

The protocol conformance cache now uses ConcurrentReadableHashMap, which
provides faster lookups and less memory use than the previous ConcurrentMap
implementation. The previous implementation caches
ProtocolConformanceDescriptors and extracts the WitnessTable after the cache
lookup. The new implementation directly caches the WitnessTable, removing an
extra step (potentially a quite slow one) from the fast path.

The previous implementation used a generational scheme to detect when negative
cache entries became obsolete due to new dynamic libraries being loaded, and
update them in place. The new implementation just clears the entire cache when
libraries are loaded, greatly simplifying the code and saving the memory needed
to track the current generation in each negative cache entry. This means we need
to re-cache all requested conformances after loading a dynamic library, but
loading libraries at runtime is rare and slow anyway.

rdar://problem/67268325
2020-08-20 13:05:30 -04:00
Anthony Latsis
9fd1aa5d59 [NFC] Pre- increment and decrement where possible 2020-06-01 15:39:29 +03:00
Saleem Abdulrasool
941681fb5d build: hide symbols using CMake
This uses the CMake settings to correctly select the visibility
attribute for the runtime.
2020-05-21 22:31:15 +00:00
Saleem Abdulrasool
f83e537a4e standard library: sort headers
This just is using the standard formatting suggested by clang-format.
This fixes the issue with forward declarations being injected into the
search order.
2020-05-14 13:44:11 -07:00
Saleem Abdulrasool
9dadc0d9c7 standard library: remove use of LLVM.h in the compatibility
Remove the use of the `LLVM.h` forward declarations from the
compatibility shims.  This allows us to fully isolate the target side
from the LLVM namespace ensuring that we prevent ODR violations when
LLVM is linked into the same address space.
2020-05-13 10:46:05 -07:00
Doug Gregor
833d2cd9d3 [5.1 Compatibility library] Add missing #include 2020-05-11 17:21:10 -07:00
Saleem Abdulrasool
198d091efe build: avoid redundant flag specification
Remove the flag being specified in multiple locations unnecessarily.
The flags flow downwards to all the subdirectories.  Use that to apply
the C/C++ flags from the root of the runtime repository.
2020-05-04 14:27:22 -07:00
Eric Miotto
717eeb912d [build] specify deployment targets for compatibility libraries (#31473)
This is needed in situations where the minimum deployment target is
specified in build-script -- these libraries do not to obey to that
since we need to ensure we are able to back deploy those correctly.

Addresses rdar://59249988
2020-05-04 08:22:35 -07:00
Joe Groff
ca48939816 Compatibility51: Backport the 5.2 implementation of the conformance cache.
The runtime that shipped with Swift 5.1 and earlier had a bug that interfered with backward
deployment of binaries that dynamically check for protocol conformances on conditionally-available
tests. This was fixed in the top-of-tree Swift runtime by https://github.com/apple/swift/pull/29887;
however, that doesn't do much good for running binaries on older OSes that don't have that fix.
In order for binaries built with a newer Swift compiler to run successfully on older OSes,
introduce a compatibility hook that replaces the conformance cache implementation in the original
OS runtime with a version based on the current implementation that has the fix for the protocol
conformance bug. Fixes rdar://problem/59460603
2020-04-24 10:52:29 -07:00
Joe Groff
42514f42e0 Start a Compatibility51 library for backporting fixes to Swift 5.1 runtimes 2020-04-17 10:41:48 -07:00
Joe Groff
4c92234662 Compatibility50: Install objc_getClass hook only in main executable
Xcode and other build systems currently link the compatibility libraries into every executable
or dynamic library, which can cause a chain of objc_getClass compatibility hacks to pile up if
a program loads a lot of dynamic libraries. In the static constructor that installs the
objc_getClass compatibility shim, check whether it's running on behalf of the main executable
before installing the shim.
2020-04-07 16:23:29 -07:00
Kuba (Brecka) Mracek
5d918e5ee1 Merge branch 'master' into mracek/arm64e 2020-03-03 08:28:01 -08:00
Saleem Abdulrasool
3a12738ebc stdlib: repair the macOS -stdlib build
When building on macOS without the standard library but building the
extra toolchain content, we would fail to configure due to the missing
include of the `AddSwiftStdlib`.
2020-02-27 20:45:24 -08:00
Kuba Mracek
84c4864911 [arm64e] Add Swift compiler support for arm64e pointer authentication 2020-02-27 16:10:31 -08:00
Mike Ash
c9f9350e74 [Compatibility50] Look up swift_getObjCClassMetadata at runtime.
This is the only dependency it has on libswiftCore. Looking this up at runtime allows its use in programs that don't link libswiftCore but might eventually load and run Swift code, such as xctest.

While we're in there, enable tests in files ending with `.c`.

rdar://problem/55274114
2019-10-10 12:10:39 -04:00
Jonas Devlieghere
61d2efc822 [Compatibility50] Include dlfcn.h 2019-09-18 19:30:03 -07:00
Joe Groff
427ed9c79d Compatibility50: Fix for high-bit characters. 2019-09-06 18:19:19 -04:00
Joe Groff
624ad4fcb0 Compatibility50: Backport objc_getClass hook patch.
We don't want older runtimes trying to chase rogue symbolic references through objc_getClass
either. rdar://problem/55036306
2019-09-05 10:46:15 -07:00
Joe Groff
60b21d4cf5 Disable LLVM ABI checks in the compatibility libraries 2019-08-20 18:27:42 -07:00
Mike Ash
ce26e7f3fd [Runtime] Fix protocol conformances on NULL types when back deploying.
Add code to the 5.0 compatibility library that scans for conformances pointing to a NULL type and rewrites them to point to a dummy type that the 5.0 protocol conformance checking code will safely ignore.
2019-08-14 11:07:31 -04:00
Alex Langford
a16c71cc86 [CMake] Remove TARGET_LIBRARY option from add_swift_target_library
If you're calling add_swift_target_library, you already know it's a
target library.
2019-07-24 14:55:08 -07:00
Ross Bayer
3257761ae0 [Build System: CMake] Move the CompatibilityDynamicReplacements library into the stdlib/toolchain source directory. 2019-07-23 15:34:17 -07:00
Ross Bayer
1a8dff82be [Build System: CMake] Move the Compatibility50 library into the stdlib/toolchain source directory. 2019-07-23 15:34:17 -07:00
Ross Bayer
6d0450a688 [Build System: CMake] Move the legacy_layouts content into stdlib/toolchain, a new directory of content that is installed only in the toolchain. 2019-07-23 14:15:36 -07:00