It appears that LLVM 15 changed the ABI for _Float16 on x86-64 such that
values are now passed in `xmm0` instead of using integer registers.
Also enable this code for Linux.
rdar://104134160
It turns out that we can just use the Float16 to Float32 conversion and
let the compiler turn that into a long double for us, which means we
can take advantage of the F16C CPU instructions if they're present as well.
rdar://104134160
We crash in ResolveAsSymbolicReference::operator() when a symbolic reference targets a missing symbol. We usually have very little information about what was missing when this happens. Instead of crashing, explicitly check for NULL and fatal error in that case, including information about the location of the symbolic reference that it came from.
`SWIFT_RUNTIME_STDLIB_INTERNAL` does `extern "C"`, so we can't put these
in a namespace and have to use a C-style prefix instead.
Also slightly rearrange the code in `CommandLine.cpp`.
rdar://103397975
Instead of triggering a fatal error on failure, return `nullptr` and
let the caller decide what to do about it. The CommandLine code should
trigger a fatal error, of course.
rdar://103397975
In various places we need to call the Windows API, and because Swift uses UTF-8
for its string representation, we can’t call the ANSI API functions (because the
code page used for the ANSI functions varies depending on the system locale
setting). Instead, we need to use the wide character APIs.
This means that we need to convert UTF-8 to wide character and vice-versa in
various places in the runtime.
rdar://103397975
If the replaced symbol goes away in the original library, the
replacement key in the replacement descriptor will be null. Handle this
by ignoring the replacement entry rather than crashing.
rdar://103307821
When deallocating a class instance, we check the retain count of the instance and error if it's greater than 1.
Self is allowed to be temporarily passed to other code from deinit, but there's no way to extend the lifetime of the object. Retaining it no longer extensd the lifetime. If self escapes from deinit, the result is a dangling pointer and eventual crash.
Instead of crashing randomly due to a dangling pointer, crash deliberately when destroying an object that has escaped.
rdar://93848484
We're supposed to expose bridgeObjectRetain/Release_xN variants, but they were missing. This fixes the custom_rr_abi.swift test. Also remove the redundant extern "C" on the entrypoint definitions, which fixes some warnings.
rdar://102793667 rdar://102783074
Replace the `assert(false)` with `swift_unreachable`.
This is more robust in release builds where the `assert(false)` is a no-op and would result in a wrong fall-though to the next switch case.
Fixes a warning in release builds.
Rearrange the slow paths a bit to make them tail calls, which allows the compiler to emit these functions without frames.
Clang is happy to emit frameless functions on ARM64 if no stack space is needed on all execution paths. However, when there's a fast path which doesn't need stack space, and a slow path which does, clang emits code that pushes a stack frame and then decides which path to take. This is fine, but it means we're paying more than we'd like to on the fast path.
We can work around that by manually outlining the slow path, and ensuring that it's invoked with a tail call. Then the original function doesn't need a stack frame on any path and clang omits the stack frame.
We tweak RefCounts::increment to return the object it's being called on, which allows `swift_retain` to tail-call it. We manually outline the objc_retain call in swift_bridgeObjectRetain, which allows the swift_retain path to be frameless.
rdar://101764509
On ELF platforms we currently output an ELF note but with totally invalid
contents. I tried experimenting to see whether it was possible to do it
properly and tie the result into ReflectionContext, but it turns out to be a
hard problem because of issues to do with cross-segment symbol references and
relocations.
The upshot is that I think for now it's best just to remove it.
We might revisit this in future at some point; it would be good to be able to
reliably find the Swift metadata just from the ELF Phdrs.
rdar://101749382
Fix a potential false positive if we check a class for a protocol conformance and its superclasses aren't yet instantiated.
This was partially fixed before, but we were incorrectly saying that all superclasses had been instantiated if they had been instatiated by the LAST check in conformsToProtocol. That left us open for a possible false positive in an earlier check to go unnoticed.
This change fixes it by checking for uninstantiated superclasses after each iteration over superclasses, not just the last one.
This change also makes the concurrentTypeByName test much more robust. The original test caught this bug only rarely, but the new one catches it it reliably. We now look up 1000 types per test run. Testing locally, we typically hit the race after less than 100 types.
rdar://82364236