Commit Graph

658 Commits

Author SHA1 Message Date
Saleem Abdulrasool
c29c42f003 Merge pull request #31560 from compnerd/un-inlined-inlining
runtime: replace `LLVM_ATTRIBUTE_ALWAYS_INLINE` with `SWIFT_INLINE` (…
2020-05-06 08:00:30 -07:00
Saleem Abdulrasool
61ddd09199 runtime: replace LLVM_ATTRIBUTE_ALWAYS_INLINE with SWIFT_INLINE (NFC)
This replaces the `LLVM_ATTRIBUTE_ALWAYS_INLINE` with `SWIFT_INLINE`
which is equivalent but namespaced to Swift instead.  This reduces the
unnecessary reliance on LLVMSupport.
2020-05-05 11:19:15 -07:00
Saleem Abdulrasool
5408593967 Runtime: simplify SWIFT_LIBRARY_VISIBILITY
This removes the GNUC version check as the runtime does require ABI
support which is not present in GCC.  Remove the unnecessary check and
simplify the condition by checking the file format that the visibility
attribute is being applied to and limit it to the ones supporting it.
2020-05-05 09:30:23 -07:00
Joe Groff
9cdfb0edfc Merge pull request #30560 from 3405691582/OpenBSD_StringStorage_AvoidMallocSize
[stdlib] Avoid malloc_size on OpenBSD.
2020-04-29 11:02:06 -07:00
Karoy Lorentey
057b27b31c [shims] Re-add Foundation shims removed in #28918
The current version of the Foundation overlay doesn’t use these, but we should still keep them in case a toolchain snapshot build picks up on overlay module from one of the SDKs in Xcode 11.

rdar://62339802
2020-04-28 15:44:33 -07:00
3405691582
7830028f55 [stdlib] Avoid malloc_size on OpenBSD.
malloc introspection is a platform feature that is unavailable on
OpenBSD. There is no workaround for the feature, so we have to assume
that allocations succeed in allocating exactly the amount of memory
requested, and nothing more.

Here a new mallocSize shim is introduced so the feature check for malloc
introspection is pushed to the shims, rather than using os checks
directly from Swift. Not every use of malloc_size has been converted
yet; ManagedBuffer.swift still remains. However, this module requires
special care to fix, which will be done separately.
2020-04-27 15:52:37 -04:00
Arnold Schwaighofer
048e78ef79 Revert "Merge pull request #30024 from Azoy/calling-metadata-accessor-from-swift!"
This reverts commit 5fd6e98b2f, reversing
changes made to 3aee49d9d0.

Revert "XFAIL test/Interpreter/metadata_access.swift on arm64e"

This reverts commit 8fe216b004.

Revert "XFAIl test on os stdlib bots"

This reverts commit aea5fa4842.
2020-04-24 12:28:24 -07:00
David Smith
e192a7ec0f Merge pull request #30966 from Catfish-Man/tagged-too
Avoid attempting to create SmallStrings for constant tagged CFStrings
2020-04-15 15:37:10 -07:00
David Smith
5ad4b15af6 Avoid attempting to create SmallStrings for constant tagged CFStrings 2020-04-15 12:30:20 -07:00
Robert Widmann
5fd6e98b2f Merge pull request #30024 from Azoy/calling-metadata-accessor-from-swift!
Runtime: Implement wrapper function to call metadata access functions
2020-04-14 19:28:47 -07:00
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
Azoy
f35efee6dd Move metadataAccessorCall to SwiftShims 2020-04-06 17:09:21 -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