dynamic-replacement runtime functions.
The recent change of how we do dynamic replacements added 2 new runtime
functions. This patch adds those functions to the Compatibility50 static
archive.
This will allow backward deployment to a swift 5.0 runtime.
Patch by Erik Eckstein with a modification to call the standard
libraries implementation (marked as weak) when it is available.
This ensures we can change the implementation in the future and are not
ABI locked.
rdar://problem/51601233
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.
* Provide a default implementation of multipliedFullWidth
Previously, [U]Int64 fatalErrored on 32b platforms, which is obviously undesirable. This PR provides a default implementation on FixedWidthInteger, which is not ideally efficient for all types, but is correct, and gives the optimizer all the information that it needs to generate good code in the important case of Int64 arithmetic on 32b platforms. There's still some minor room for improvement, but we'll call that an optimizer bug now.
* Clarify comments somewhat, remove `merge` nested function
I was only using `merge` in one place, so making it a function seems unnecessary. Also got rid of some trucatingIfNeeded inits where the compiler is able to reason that no checks are needed anyway.
* Add some basic test coverage specifically for multipliedFullWidth
* Fix typo, further clarify bounds comments.
* Make new defaulted implementation @_aEIC so we don't need availability.
We have nondeterministic test failures indicating a memory safety issue in ModelIO’s overlay. This switches the overlay’s property implementations to use the new `Array(unsafeUninitializedCount:,initializedWith:)` initializer rather than the potentially unreliable `&values[0]` pattern.
rdar://problem/50449570
Commit e0bba70 added a default implementation, however this is wrong
for non-imported types.
Instead, synthesize the body as before. Since this is one of the few
derived methods that can appear on an imported type, make sure to
build fully type-checked AST.
Fixes <rdar://problem/51322302>.
* [stdlib] Lemire’s nearly divisionless random int
Implementation of Daniel Lemire’s “Fast Random Integer Generation in Interval”
See https://arxiv.org/pdf/1805.10941.pdf
* [stdlib] Simpler, optimized expression
* [stdlib] O'Neill’s modulo optimization
See http://www.pcg-random.org/posts/bounded-rands.html#optimizing-modulo
* [stdlib] Remove modulo optimization
Swift, compared to C, seems unable to generate tightly fused instructions here for some reason (probably the division by zero check?)… removing.
* [stdlib] Keep OpenBSD debiasing method on 32-bit
systems until the https://bugs.swift.org/browse/SR-10910 is resolved.
* [stdlib] TODO FIXME SR-10912
Remove the old OpenBSD generation method, once 32-bit systems support multipliedFullWidth on UInt64.
For odd roots of negative values, we need to take the root of the *magnitude* of the number to avoid a NaN from the platform's implementation of `pow`, then restore the sign afterwards. We had the basic logic in place already, but were missing the step of taking the magnitude first. Also modified a test case to find this error.
This was already being done for the stderr, but not for stdout. Doing
this means that we no longer get spurious carriage returns on the stdout
output stream on Windows. This is needed for supporting the
validation test suite on Windows.
Android doesn't support the GNU backtrace call, but unwind.h is there to
help. The code is a little bit more complicated than a simple backtrace
call, but it is just a callback and the context struct.
Sadly, it seems that -funwind-tables is needed in every piece of code
that the backtrace needs to traverse, which means that at least the
runtime and the stubs need -funwind-tables. However, the flag has been
enabled for all targets (only on Android), just in case some other code
ends up being in the stack. This might only be necessary for ARM
targets, but currently we only build ARM targets in Android. The Swift
parts of the stack seems to have unwind information and can be unwind.
Another problem at the moment is the symbols from the executable are
normally missing. To get symbol names two things need to happen: the
symbol has to be public (so it is an exported symbol, and not just a
local symbol that dladdr seems to not provide the name), and the linker
has to be invoked with -export-dynamic. Without those two pieces, the
addresses are returned (and match the binary just fine), but no names
are printed.
PE/COFF does not permit weak linking semantics. This means that the
expression `&symbol == NULL` is tautologically false. In order to
support this semantic, the symbol needs to be dynamically looked up at
runtime. Since the ObjC runtime is not in use on Windows currently,
just ignore this for the time being. Silences a warning from clang
about the tautological comparison.
When building without assertions, the variable will be unreferenced on
non-ObjC runtimes. Sink the evaluation into the assertion and move the
declaration into the ObjC runtime case.
The pthread dependency has been lifted through the Windows port
generalising the SwiftThreadExtras. Enable building these unit test
binaries which are needed for the validation test suite.