Commit Graph

3150 Commits

Author SHA1 Message Date
Mike Ash
ad09919891 [Runtime] Expose the protocol conformance state as a _swift_debug variable.
Have Remote Mirror look that up instead of the C++ mangled name.

rdar://problem/55481578
2020-05-29 08:31:03 -07:00
Mike Ash
b73b325e10 [Runtime] Only enable metadata allocation tracking when requested with an environment variable.
Expose _swift_debug variables for Remote Mirror to use for tracking metadata allocation, and adopt them in Remote Mirror.

rdar://problem/55481578
2020-05-29 08:31:03 -07:00
Mike Ash
2dd3b94852 [Runtime] Remove inactive code that looked up entries in the protocol conformance cache by type descriptor 2020-05-29 08:31:03 -07:00
Mike Ash
2c7f09cef7 [Tools] Add some metadata printing to swiftdt.
rdar://problem/55481578
2020-05-29 08:31:03 -07:00
Mike Ash
22cfe461ec [Tools] Super rough draft of swiftdt dumping MetadataAllocator contents.
rdar://problem/55481578
2020-05-29 08:31:03 -07:00
Saleem Abdulrasool
c050a26aeb runtime: further isolate runtime from LLVMSupport
This cleans up some more `llvm::` leakage in the runtime when built into
a static library.  With this change we are down to 3 leaking symbols in
the static library related to a missed ADT (`StringSwitch`).
2020-05-28 12:42:11 -07:00
David Zarzycki
97c89d8d3a Remove three ObjC fields from non-ObjC runtime 2020-05-22 09:21:21 -07:00
Saleem Abdulrasool
1e74c202ef build: optimize the build of LLVMSupport
Rather than build multiple copies of LLVMSupport (4x!) build it one and
merge it into the various targets.  This would ideally not be needed to
be named explicitly everywhere, but that requires using `add_library`
rather than `add_swift_target_library`.
2020-05-19 17:04:59 +00:00
Saleem Abdulrasool
f0413f6170 build: remove last llvm:: reference in stdlib
This removes the last reference to the `llvm::` namespace in the
standard library.  All uses of the LLVMSupport library now are
namespaced into the `__swift::__runtime` namespace.  This allows us to
incrementally vend the LLVMSupport library and make the separation
explicit.
2020-05-18 11:41:57 -07:00
John McCall
677f42db5d Merge pull request #31820 from rjmccall/unused-associated-type-elimination
[NFC] initAssociatedTypeWitness is now unused in non-ptrauth builds
2020-05-15 17:27:34 -04:00
Dario Rexin
73d954566a Merge pull request #31817 from compnerd/bashful
runtime: generate the link arguments in CMake
2020-05-15 13:46:11 -07:00
John McCall
0a41ac9a7c [NFC] initAssociatedTypeWitness is now unused in non-ptrauth builds 2020-05-15 13:22:35 -04:00
Saleem Abdulrasool
6244af5167 runtime: generate the link arguments in CMake
Rather than invoke a bash script to generate the file, write the file
statically from CMake.  This allows us to cross-compile for platforms
which require the static library arguments on platforms which do not
have bash.
2020-05-15 10:15:03 -07:00
Saleem Abdulrasool
bb102707ed runtime: prune LLVMSupport
Reduce LLVMSupport to the subset required for the runtime.  This reduces
the TCB and the overheads of the runtime.  The inline namespace's
preservation ensures that ODR violations do not occur.
2020-05-15 09:55:37 -07:00
Saleem Abdulrasool
3fa1d1fe3f runtime: ingest LLVMSupport into the runtime
This adds a new copy of LLVMSupport into the runtime.  This is the final
step before changing the inline namespace for the runtime support.  This
will allow us to avoid the ODR violations from the header definitions of
LLVMSupport.

LLVMSupport forked at: 22492eead218ec91d349c8c50439880fbeacf2b7
Changes made to LLVMSupport from that revision:
  process.inc forward declares `_beginthreadex` due to compilation issues due to custom flag handling

API changes required that we alter the `Deallocate` routine to account
for the alignment.

This is a temporary state, meant to simplify the process.  We do not use
the entire LLVMSupport library and there is no value in keeping the
entire library.  Subsequent commits will prune the library to the needs
for the runtime.
2020-05-15 09:55:36 -07:00
John McCall
1c75b3c543 Merge pull request #31768 from rjmccall/associated-witness-atomics
Make the lazy assignment of an assoociated type/wtable atomic
2020-05-14 00:38:04 -04:00
John McCall
6200df1d88 Make the lazy assignment of an assoociated type/wtable atomic.
Should fix SR-12760.
2020-05-13 20:37:41 -04:00
Saleem Abdulrasool
e72b43f374 runtime: namespace SmallVectorImpl for inline namespace
This adjusts the use of `SmallVectorImpl` to allow the runtime to use
inline namespaces for its local copy of LLVMSupport.
2020-05-13 11:10:47 -07:00
Saleem Abdulrasool
96313ce3e1 runtime: explicitly namespace ArrayRef in shared headers
There are a set of headers shared between the Swift compiler and the
runtime.  Ensure that we explicitly use `llvm::ArrayRef` rather than
`ArrayRef` which is aliased to `::llvm::ArrayRef`.  Doing so enables us
to replace the `ArrayRef` with an inline namespaced version fixing ODR
violations when the swift runtime is loaded into an address space with
LLVM.
2020-05-13 08:42:06 -07:00
Saleem Abdulrasool
c721cf12f5 Merge pull request #31635 from compnerd/completely-impartial
runtime: remove use of `swift/LLVM.h` (NFC)
2020-05-09 11:28:04 -07:00
Saleem Abdulrasool
4fc0419e1c Merge pull request #31634 from compnerd/no-support-structure
runtime: remove `llvm/Support` header usage
2020-05-09 11:27:43 -07:00
Saleem Abdulrasool
00ff1c3552 Merge pull request #31632 from compnerd/nyhow-ou-ave-n-problems
runtime: remove dependency on `LLVM_ENABLE_THREADS`
2020-05-07 16:46:21 -07:00
Saleem Abdulrasool
ec31346c4b Merge pull request #31629 from compnerd/fall-into-the-gap
runtime: add and switch to `SWIFT_FALLTHROUGH` (NFC)
2020-05-07 14:16:27 -07:00
Saleem Abdulrasool
2ea11b5428 runtime: remove use of swift/LLVM.h (NFC)
Rather than using the forward declaration for the LLVMSupport types,
expect to be able to use the full declaration.  Because these are
references in the implementation, there is no reason to use a forward
declaration as the full types need to be declared for use.  The LLVM
headers will provide the declaration and definition for the types.  This
is motivated by the desire to ensure that the LLVMSupport symbols are
properly namespaced to avoid ODR violations in the runtime.
2020-05-07 13:37:31 -07:00
Saleem Abdulrasool
04eeff5b8d runtime: remove llvm/Support header usage
This reduces the dependency on `LLVMSupport`.  This is the first step
towards helping move towards a local fork of the LLVM ADT to ensure that
static linking of the Swift runtime and core library does not result in
ODR violations.
2020-05-07 13:36:13 -07:00
Saleem Abdulrasool
70bd271e99 runtime: remove dependency on LLVM_ENABLE_THREADS
This removes the LLVMSupport usage for thread local.  This effectively
is a no-op as the runtime requires that it is built with clang, which
provides the C++11 `thread_local` support on all the targets.  In the
case that the target does not support `thread_local`, clang would
fallback to `__declspec(thread)` on MSVC and `__thread` on other modes.
However, because the runtime is always built in C++14 mode, the
`thread_local` support should be assumed to be present.  Remove the
unnecessary condition and inline the single use of the macro for
`thread_local`.
2020-05-07 12:48:57 -07:00
Saleem Abdulrasool
a7415423e6 runtime: add and switch to SWIFT_FALLTHROUGH (NFC)
This duplicates and switches the uses of `LLVM_FALLTHROUGH` to a local
macro for the same annotation.
2020-05-07 11:50:22 -07:00
Saleem Abdulrasool
e0b0d20cd8 runtime: add and switch to SWIFT_NORETURN (NFC)
Remove the use of the `LLVM_ATTRIBUTE_NORETURN` to trim dependencies on
LLVMSupport.
2020-05-07 09:22:39 -07:00
Saleem Abdulrasool
fe9751f988 Merge pull request #31585 from compnerd/likely
runtime: replace `LLVM_LIKELY` with `SWIFT_LIKELY` (NFC)
2020-05-07 09:21:58 -07:00
Saleem Abdulrasool
b74f42602a runtime: add and switch to SWIFT_USED (NFC)
This further trims dependencies to LLVMSupport by introducing the
equivalent `SWIFT_USED` macro.
2020-05-06 21:19:14 -07:00
Saleem Abdulrasool
f465ec0345 runtime: add and switch to SWIFT_NOINLINE (NFC)
This switches the `LLVM_ATTRIBUTE_NOINLINE` to a local copy which is
namespaced in Swift.
2020-05-06 14:07:20 -07:00
Saleem Abdulrasool
e7996a770a runtime: replace LLVM_LIKELY with SWIFT_LIKELY (NFC)
Use the Swift namespaced version of the macro and reduce the dependency
on LLVMSupport.
2020-05-06 09:11:32 -07:00
Saleem Abdulrasool
9731704cc7 runtime: replace LLVM_LIBRARY_VISIBILITY with SWIFT_LIBRARY_VISIBILITY (NFC)
This replaces `LLVM_LIBRARY_VISIBILITY` with `SWIFT_LIBRARY_VISIBILTIY`
througout the runtime.  The purpose of this attribution is unclear -
building with `-fvisibility=hidden` would accomplish this.  This is an
entirely mechanical change replacing the macro with the Swift namespaced
variant instead.
2020-05-06 08:30:17 -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
d14bb1eed5 Driver: sink the static-stdlib-args.lnk generation
This moves the standard library response file into the standard library
generation rather than in the driver.  Although the driver consumes this
file, it is part of the standard library as it knows its dependencies.

This removes the last of the ICU references in the toolchain.
2020-05-02 19:52:35 -07:00
nate-chandler
c9912c5964 Merge pull request #31056 from nate-chandler/generic-metadata-prespecialization-components/rdar61465515
[metadata prespecialization] Zero trailing flags field.
2020-04-23 20:39:42 -07:00
Nate Chandler
d87a734a50 [Runtime] In debug builds, dirty metadata records.
To facilitate debugging metadata records which are not properly
initialized, upon allocation fill them with a regular byte pattern
(0xAA) so that on subsequent inspection it is obvious if part of the
record is not initialized.
2020-04-23 18:18:40 -07:00
Nate Chandler
47943f8304 [Runtime] Fixed zeroing of extra data padding for values.
See also bcc309efa1 .
2020-04-15 17:22:26 -07:00
Nate Chandler
82b668f1f3 [Runtime] Assert dynamic metadata is not static.
Added an assertion that a generic metadata record that is instantiated
at runtime is not a prespecialized metadata record.
2020-04-15 17:22:23 -07:00
Saleem Abdulrasool
dbbd6c95df runtime: extend shims to x86
The android x86 target exposed the fact that the FP16 support routines
were not being emitted for x86, only x86_64.
2020-04-14 11:10:41 -07:00
Saleem Abdulrasool
c8e8b177fa runtime: fix a UBSAN issue
This was identified by UBSAN: signed-integer-overflow.  Explicitly mark
the value as unsigned to ensure that the value does not overflow.  There
is a second instance of a raw literal, however, because it is a `*=` the
value is implicitly understood to be unsigned.
2020-04-09 12:21:20 -07:00
tbkka
110e5136c1 Float16 optimal formatting (#30862)
Extend SwiftDtoa to provide optimal formatting for Float16 and use that for `Float16.description` and `Float16.debugDescription`.

Notes on signaling NaNs: LLVM's Float16 support passes Float16s on x86
by legalizing to Float32.  This works well for most purposes but incidentally
loses the signaling marker from any NaN (because it's a conversion as far
as the hardware is concerned), with a side effect that the print code never
actually sees a true sNaN.  This is similar to what happens with Float and
Double on i386 backends.  The earlier code here tried to detect sNaN in a
different way, but that approach isn't guaranteed to work so we decided to
make this code use the correct detection logic -- sNaN printing will just be
broken until we can get a better argument passing convention.

Resolves rdar://61414101
2020-04-09 09:37:38 -04:00
Saleem Abdulrasool
dce9614bf4 runtime: provide AEABI shims for floating point conversion
Android NDK <r21 does not provide the AEABI mandated `__aeabi_d2h`
functions in the compiler runtime.  Add shims to ensure that the
functions are available for building the standard library.
2020-04-08 11:16:40 -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
nate-chandler
feba039217 Merge pull request #30785 from nate-chandler/rdar60790020
[Runtime] Handle incomplete class metadata in _checkGenericRequirements.
2020-04-03 15:32:53 -07:00
nate-chandler
afc963aa82 Merge pull request #30793 from nate-chandler/generic-metadata-prespecialization-components/prepare-for-classes
[prespecialized metadata] Note classes are complete.
2020-04-03 14:00:45 -07:00
Nate Chandler
2863f1964d [Runtime] Handle incomplete class metadata in _checkGenericRequirements.
When constructing the metadata for a type Gen<T : Super>
where Super is a superclass constraint, the generic argument K at which
the metadata for Gen is being instantiated is verified to be a subclass
of Super via _checkGenericRequirements.

Previously, that check was done using swift_dynamicCastMetatype.  That
worked for the most part but provided an incorrect answer if the
metadata for K was not yet complete.  These classes are incomplete more
often thanks to __swift_instantiateConcreteTypeFromMangledNameAbstract.

That issue occurred concretely in the following case:

  Framework with Library Evolution enabled:

    open class Super { ... }
    public struct Gen<T : Super> {
    }

  Target in a different resilience domain from that framework:

    class Sub : Super {
      var gen: Gen<Sub>?
    }

Here, the mechanism for checking whether the generic argument K at which
the metadata for Gen is being instantiated handles the case where K's
metadata is incomplete.  At worst, every superclass name from super(K)
up to Super are demangled to instantiate metadata.  A number of faster
paths are included as well.

rdar://problem/60790020
2020-04-03 13:28:54 -07:00
Nate Chandler
a1e2fb019e [prespecialized metadata] Note classes are complete.
In preparation for the prespecialization of metadata for generic
classes, make checkMetadataState always return that the state of
prespecialized class metadata is complete, as is done for generic
structs and enums already.
2020-04-03 11:46:54 -07:00
Mike Ash
f4e635320a [Mirror] Don't destroy and reconstitute enums when reflecting them.
It's possible to get multiple threads reading from the same enum at the same time, and the result can be bad data extracted or even permanent corruption of the value in memory. Instead, copy the enum value, then project the data from the copy.

rdar://problem/59493486
2020-04-02 13:44:19 -04:00
Joe Groff
026b8b31c9 Merge pull request #30318 from ktoso/wip-mangledTypeName
Add _mangledTypeName to allow round trips T->mangledName->T
2020-03-30 18:13:56 -07:00