Commit Graph

397 Commits

Author SHA1 Message Date
Stephen Canon
248c554524 Add Float16 to stdlib (#30130)
Add Float16 (IEEE 754 binary16) to the standard library, plus assorted runtime support operations.

Swift Evolution thread: https://forums.swift.org/t/se-0277-float16/33546
2020-04-06 17:57:44 -04:00
Karoy Lorentey
0344f0830e Merge branch 'master' into foundation-no-inlinable-shim-calls 2020-03-31 18:24:59 -07:00
David Smith
40e67b53c9 Merge pull request #30034 from Catfish-Man/what-i-tell-you-three-times-is-true
Avoid mishandling retain_n of immortal objects where n >= 3
2020-03-26 11:00:46 -07:00
David Smith
78c693ba2d Avoid mishandling retain_n of immortal objects where n >= 3 2020-03-25 15:53:31 -07:00
Mishal Shah
e7cd5ab17f Update master to build with Xcode 11.4 2020-03-24 11:30:45 -07:00
Kuba (Brecka) Mracek
ab6533a40f Merge branch 'master' into mracek/arm64e 2020-03-06 15:07:01 -08:00
3405691582
5847726f51 Preliminary support for OpenBSD in the stdlib.
These should hopefully all be uncontroversial, minimal changes to deal
with progressing the build to completion on OpenBSD or addressing minor
portability issues. This is not the full set of changes to get a
successful build; other portability issues will be addressed in future
commits.

Most of this is just adding the relevant clauses to the ifdefs, but of
note in this commit:

* StdlibUnittest.swift: the default conditional in _getOSVersion assumes
  an Apple platform, therefore the explicit conditional and the relevant
  enums need filling out. The default conditional should be #error, but
  we'll fix this in a different commit.

* tgmath.swift.gyb: inexplicably, OpenBSD is missing just lgammal_r.
  Tests are updated correspondingly.

* ThreadLocalStorage.h: we use the pthread implementation, so it
  seems we should typedef __swift_thread_key_t as pthread_key_t.
  However, that's also a tweak for another commit.
2020-03-01 12:50:06 -05:00
Kuba Mracek
84c4864911 [arm64e] Add Swift compiler support for arm64e pointer authentication 2020-02-27 16:10:31 -08:00
David Smith
4bd56334ef Avoid incorrectly asserting when we disable pure Swift deallocation on an object that has a side table 2020-02-18 11:44:37 -08:00
Dmitri Gribenko
3566e6ed7a Merge pull request #29530 from swiftwasm/swiftwasm-ifdefs
[WebAssembly] Add ifdefs for the WASI target
2020-02-13 17:40:45 +01:00
Max Desiatov
67297904ac [WebAssembly] Add ifdefs for the WASI target 2020-02-08 07:37:10 +00:00
Dario Rexin
d913eefcc9 Remove dependency on libatomic on Linux
Due to some unfortunate interplay between clang and libstdc++, clang was
not able to correctly identify to alignment of PoolRange and
SideTableRefCountBits, causing it to emit library calls instead of
inlining atomic operations. This was fixed by adding the appropriate
alignment to those types. In addition to that the march for the Linux
target was set to 'core2', which is the earliest architecture to support
cx16, which is necessary for the atomic operations on PoolRange.
2020-01-31 15:59:54 -08:00
Max Desiatov
44a6475566 [WebAssembly] enable shims and stubs for WASI (#29505)
* [WebAssembly] enable shims and stubs for WASI

* Implement _swift_stdlib_getUnsafeArgvArgc for WASI

* Make include unconditional, add JIRA links
2020-01-28 18:29:52 -08: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
Saleem Abdulrasool
beafad9651 SwiftShims: unify assertion paths (NFC)
Use the C++ spelling for the static assertions.  This is a C11
extension, but GCC and MSVC both object to the reserved spelling
(`_Static_assert`).  Use the compatibility spelling of `static_assert`
on all targets instead.
2019-12-27 10:17:43 -08:00
Karoy Lorentey
15e865f0b5 [Foundation] Remove inlinable shim calls
We want to enable overlays to import their shims as @_implementationOnly, so that the shims disappear from the public interface.

However, this isn’t possible when a shim is called from an @inlinable func, because then the existence (and definition) of the shim needs to be available to all callers of it.

Unfortunately Foundation’s Data has three instances where it calls  _SwiftFoundationOverlayShims._withStackOrHeapBuffer within @inlinable code:

- Data.init<S: Sequence>(_: S)
- Data.append<S: Sequence>(contentsOf: S)
- Data.replaceSubrange<C: Collection>(_: Range<Int>, with: C)

Rewrite the first two to write sequence contents directly into the target Data instance (saving a memcpy and possibly a memory allocation).

In replaceSubrange, add fast paths for contiguous collection cases, falling back to a Swift version of _withStackOrHeapBuffer with a 32-byte inline buffer.

The expectation is that this will be an overall speedup in most cases, with the possible exception of replaceSubrange invocations with a large non-contiguous collection.

rdar://58132561
2019-12-20 20:45:02 -08:00
Alex Langford
d57c841445 [CMake] Correct dependencies for clang headers components
When building swift as a part of LLVM (as opposed to standalone) the components
related to swift headers should explicitly depend on the clang target to produce
those. On LLVM 9 and up, that would be `clang-resource-headers` and on lower
versions it would be `clang-headers`. It is important that we check for
`clang-resource-headers` first because `clang-headers` refers to something
different in LLVM 9 and up.
2019-09-03 09:15:38 -07:00
Stephen Canon
d80b1d39a3 Backout SE-0246 (#26809)
* Revert "Add availability information to the new Math function protocols (#24187)"

This reverts commit d2f695935f.

* Revert "SE-0246: Protocols and static functions (#23824)"

This reverts commit 57a4553832.

* Expected abi changes.
2019-08-23 16:41:17 -04:00
David Smith
f559a94f1b Redo CFStringCreateWithBytes shim 2019-08-12 15:15:10 -07:00
David Smith
5a1f068415 Remove dead shim code 2019-08-07 16:50:47 -07:00
David Smith
c5fc715746 Reimplement the CF stub system using ObjC. The primary effect of this is to break the link-time dependency on the CF symbols, but it also improves performance a bit.
One additional tweak (setting the scalar-aligned bit on foreign indices) had to be made to avoid a performance regression for long non-ASCII foreign strings.
2019-08-01 19:56:45 -07:00
Saleem Abdulrasool
13c1391138 SwiftShims: restrict AArch64 workaround to C++
`RefCount.h` can be included in a C context - e.g. building the
SwiftShims module.  Restrict the C++ overloads to the C++ context only.
This partially improves the build for Windows ARM64.
2019-07-14 14:01:40 -07:00
Daniel Rodríguez Troitiño
c7d7115a58 [android] Remove dependency from SwiftShims to Libc
Seems that SwiftShims cannot import some system headers (checked by a
test in test/ParseableInterface/ModuleCache/SystemDependencies). So
adding <android/api-level.h> is not going to work.

The change reproduces the only piece necessary from the header, which is
interpreting that if no __ANDROID_API__ is defined, the level should be
the maximum allowed.
2019-07-10 16:37:23 -07:00
Daniel Rodríguez Troitiño
da3ff59a27 [android] Include api-level.h for Android and C++ interop.
When the header was used in Android, the usage of __ANDROID_API__ was
not set if the compiler wasn't setting it externally. There was a check
for __ANDROID_API__, which defaulted to zero, and so it didn't pass. The
external function definition was not being done, but in C mode, it
didn't matter because implicit functions are allowed. That's not true in
C++ mode, which fails to compile any code that tries to include this
header.

The solution is including android/api-level.h which will define
__ANDROID_API__ to a very high value if it is not defined already (which
is the default behaviour in the NDK).
2019-07-09 17:15:56 -07:00
Parker Schuh
fa69a73ee4 Add -enable-cxx-interop flag and support for extern "C" {} 2019-07-08 11:43:35 -07:00
Saleem Abdulrasool
c0fb0036a3 Runtime: add a workaround for Windows ARM64
Unfortunately, `std::atomic` in msvcprt as of 14.21.27702 is broken for
double-width atomics on ARM64.  This has been reported to Microsoft and
is going to be fixed in VC++ 2019u3.  For the time being, add a partial
template specialisation for the two double-word sized types temporarily
as a workaround.  This allows the standard library build to get further.
2019-07-03 09:27:59 -07:00
David Smith
a84af6f68b Revert "Revert "Revert "Use the remaining half bit in the refcount to bypass ObjC deallocation overhead"""
This reverts commit c51294671b.
2019-07-01 14:29:40 -07:00
Karoy Lorentey
6cb4e3a2f1 [Shims] Add CoreMedia overlay shims 2019-06-24 16:34:09 -07:00
Saleem Abdulrasool
38995f5d80 Merge pull request #25070 from moatom/fix-include-guard
Fix include guards
2019-06-20 17:26:08 -07:00
David Smith
28dcc915e3 Merge pull request #25418 from Catfish-Man/no-objc-complications-4
Use the remaining half bit in the refcount to bypass ObjC deallocation overhead
2019-06-19 11:08:29 -07:00
David Smith
c51294671b Revert "Revert "Use the remaining half bit in the refcount to bypass ObjC deallocation overhead""
And add availability checking for back deployment

This reverts commit 817ea129f2.
2019-06-18 16:16:38 -07:00
swift-ci
2330d81ad1 Merge pull request #25519 from compnerd/windows-resource-dir 2019-06-17 14:14:28 -07:00
Saleem Abdulrasool
ad9346344c Shims: support clang-cl for building the runtime for Windows
`-print-resource-dir` is not available with `clang-cl` which is required
for building the standard library for Windows on Windows.  Use the
`/clang:-print-resource-dir` spelling instead.  This allows us to build
the standalone runtime for Windows on Windows.
2019-06-17 13:03:07 -07:00
Karoy Lorentey
308d584d4c Merge pull request #25444 from lorentey/ClockKit-overlay
[SDK] Add overlay shims for ClockKit framework
2019-06-17 12:24:26 -07:00
Vlad Gorlov
6370681656 Android cross-compile on macOS: Fix for compile error addressed Float80 data type. (#25502)
* Fixes issue addressed Float80 data type. Float80 is disabled for Intel architectures (i.e. Android Simulator).

* More precise condition check.
2019-06-17 13:40:44 -04:00
Saleem Abdulrasool
5befea4d8d build: query the resource dir when needed
When building the standard library standalone with the host compiler, we
do not have the location of the resource dir available to us nor can it
be computed.  Use `-print-resource-dir` to query the value from the
compiler and use that.  This is needed to cross-compile the standard
library to android from Windows.
2019-06-13 22:55:03 -07:00
Karoy Lorentey
dcda278cb3 [SDK] Add overlay shims for ClockKit framework 2019-06-13 17:05:40 -07:00
Mishal Shah
817ea129f2 Revert "Use the remaining half bit in the refcount to bypass ObjC deallocation overhead" 2019-06-05 23:10:34 -07:00
David Smith
8abffa7d89 Use the remaining half bit in the refcount to bypass ObjC deallocation overhead 2019-06-05 14:10:19 -07:00
moatom
2e95a0d265 Fix include guards 2019-06-02 12:10:43 +09:00
Alex Langford
3d9a28925b [CMake] Modify swift_install_in_component to support cmake install components
CMake supports the notion of installation components. Right now we have some
custom code for supporting swift components. I think that for installation
purposes, it would be nice to use the CMake component system.

This should be a non-functional change. We should still only be generating
install rules for targets and files in components we want to install, and we
still use the install ninja target to install everything.
2019-04-19 14:06:11 -07:00
Stephen Canon
57a4553832 SE-0246: Protocols and static functions (#23824)
This implements the protocols and static functions proposed in SE-0246, plus some initial test coverage. It also has some rough accompanying cleanup of tgmath. It does not include the globals (on scalars or SIMD types) nor does it deprecate much in tgmath.h.
2019-04-17 23:57:33 +02:00
Zhuowei Zhang
5cdb32f624 [stdlib] fix prototype declaration in RuntimeShims.h
_swift_stdlib_getHardwareConcurrency's declaration isn't a proper prototype:
it's missing `void` inside the brackets.

Found while compiling the stdlib to WebAssembly, which fails with:

Functions with 'no-prototype' attribute must take varargs: _swift_stdlib_getHardwareConcurrency

This shouldn't impact existing platforms.
2019-04-15 19:03:28 -07:00
swift-ci
388c21ac64 Merge pull request #24000 from Catfish-Man/thread-specific-doh 2019-04-15 18:08:06 -07:00
David Smith
584fbfc245 Avoid the overhead of looking up the current CFAllocator in String bridging 2019-04-15 15:28:00 -07:00
Ross Bayer
1a31c3ad9c [Build System: CMake] Install the Swift shims in the stdlib component. 2019-04-09 13:00:26 -07:00
Stephen Canon
c5e3f85378 Revert SE-0246 (#23800)
* Revert "Merge pull request #23791 from compnerd/you-know-nothing-clang"

This reverts commit 5150981150, reversing
changes made to 8fc305c03e.

* Revert "Merge pull request #23780 from compnerd/math-is-terrible"

This reverts commit 2d7fedd25f, reversing
changes made to 0205150b8f.

* Revert "Merge pull request #23140 from stephentyrone/mafs"

This reverts commit 777750dc51, reversing
changes made to 0c8920e747.
2019-04-04 19:35:25 -04:00
Saleem Abdulrasool
c697ddd42e Shims: include math.h on Windows
Since we use `_hypotf` on Windows rather than `__builtin_hyptof` due to
a bug in LLVM with the TLI lowering to the wrong builtin, include the
math header to get the proper declaration.
2019-04-04 09:29:58 -07:00
Saleem Abdulrasool
af6d9e3fc3 Shims: use _hypotf on Windows rather than __builtin_hypot
Unfortunately, `hypotf` is an inline in MSVCRT which forwards to
`_hypotf`.  This repairs the Windows build.
2019-04-03 16:11:42 -07:00
Steve (Numerics) Canon
3fda509805 Implementation of ElementaryFunctions / Real protocols.
This commit implements SE-0246, by adding conformance to Real to the Float, CGFloat, Double, and Float80 types, implemented either in terms of the system's C math library, existing standard library functionality, or LLVM intrinsics. It includes basic test coverage for these new functions, and deprecates and obsoletes *some* existing functionality in the Platform overlay. We still need to make a decision about how to handle the remaining "tgmath" functions, because obsoleting them is technically a source-breaking change (if users have unqualified names like "exp(1)", it's fine, but it would break users who have used qualified names like "Darwin.exp(1)".)
2019-04-02 18:49:31 -04:00