Commit Graph

480 Commits

Author SHA1 Message Date
John McCall
190943ea05 Revert "Future-proof the ARM64 ABI by not reserving the entire top byte."
This reverts commit d44851304b.
This patch does not work with our current assumptions about BridgeObject.
2018-12-12 12:01:22 -05:00
Saleem Abdulrasool
41d9c2cc59 stdlib: restructure for OS family layout of SDK overlay
The SDK directory is now confusing as the Windows target also has a SDK
overlay.  In order to make this more uniform, move the SDK directory to
Darwin which covers the fact that this covers the XNU family of OSes.
The Windows directory contains the SDK overlay for the Windows target.
2018-12-06 11:32:05 -08:00
John McCall
d44851304b Future-proof the ARM64 ABI by not reserving the entire top byte.
Targets that want to use armv8.5a memory tagging will need this.
Hopefully nobody comes up with a brilliant reason they need to use
anything else.
2018-12-04 01:43:08 -05:00
Xiaodi Wu
f9e8b6363e [gardening] Make edits for stdlib style [NFC] 2018-12-02 15:26:35 -05:00
Harlan Haskins
01bfdc162e Merge pull request #20835 from nordicio/stdlib-NSStringGetCString-nullability
[stdlib] adds nullability type specifier to NSStringGetCStringTrampoline
2018-11-30 11:24:55 -08:00
swift-ci
e012655e57 Merge pull request #20623 from Catfish-Man/bridgecleanup 2018-11-28 17:03:49 -08:00
David Smith
8b57921905 Assorted bridging changes:
• Convert _AbstractStringStorage to a protocol, and the free functions used to deduplicate implementations to extensions on that protocol.
• Move 'start' into the abstract type and use that to simplify some code
• Move the ASCII fast path for length into UTF16View.
• Add a weirder but faster way to check which (if any) of our NSString subclasses a given object is, and adopt it
2018-11-28 16:04:34 -08:00
Andreas Jönsson
452230ae33 [stdlib] adds nullability type specifier to NSStringGetCStringTrampoline 2018-11-28 21:08:58 +01:00
Michael Ilseman
9a96666ef8 [ABI] Define generic 64-bit address space and spare bits.
Define a generic 64-bit address space ABI which is capped at 56
bits. Switch ppc64 and s390x over to it.

This also allows String to have (roughly) the same representation
across 64-bit platforms.
2018-11-28 09:48:03 -08:00
David Smith
8bb6b78e36 Use super trampolines to let us override several more NSString methods (-UTF8String, -cStringUsingEncoding:, and -getCString:maxLength:encoding:) for performance 2018-11-15 17:10:51 -08:00
David Smith
96691208e9 Bridged Strings should have some different/additional overrides for performance 2018-11-08 11:08:03 -08:00
Mike Ash
66563ed6c5 Merge pull request #20372 from mikeash/remove-swiftprivate-swiftdarwin-dependency
[Stdlib] Remove SwiftPrivate's dependency on Darwin.
2018-11-07 11:04:52 -05:00
Daniel Rodríguez Troitiño
15c6b378ac [android] Fix function signature to match usage in libdispatch.
The function signature in libdispatch doesn't use a dispatch_function_t
so compiling for Android should have fail, since the Swift code uses the
function without any parameters.

See
https://github.com/apple/swift-corelibs-libdispatch/blob/master/private/queue_private.h#L345
in which the function is defined with the signatured used in this
change.
2018-11-06 17:34:30 -08:00
Mike Ash
45693049bf [Stdlib] Remove SwiftPrivate's dependency on Darwin.
Revert #20194, which seems to be more trouble than it's worth. Instead, move the functions that SwiftPrivate needs back into LibcShims.h/cpp as SPI.

rdar://problem/45817565
2018-11-06 17:41:56 -05:00
Joe Groff
65a4531467 IRGen/Runtime: Make key path pattern format true-const.
Use relative references instead of pointers so that the pattern can be true-const. Instead of trying
to instantiate a constant key path literal in-place, point to a cache variable that we can store
a pointer to the shared instance into when instantiated. Now that the pattern format has diverged
significantly from the instance format, simplify and refactor the instantiation code using a walker
for the pattern format instead of trying to reuse the code for working with instantiated instances.
rdar://problem/42674576
2018-11-05 12:30:49 -08:00
rposts
ab2dd1098e Towards s390x support (#19822)
* Towards s390x support

* Fix case index on Big Endian
2018-10-29 09:37:02 -07:00
Saleem Abdulrasool
1e89bf01ea shims: adjust dispatch shim for LLP64
Adjust the block type to use `intptr_t` which is a register-wide integral type.
This allows the same declaration to be portable across LP64 and LLP64
environents.
2018-10-18 14:03:38 -07:00
Arnold Schwaighofer
42af92112c Make _swift_dispatch_block_create_with_qos_class NS_RETURNS_RETAINED
Otherwise, we return in the autorelease pool and this can keep the block
alive longer than a surrounding withoutActuallyEscaping expression
causing verification failures.

rdar://45226617
SR-8955
2018-10-12 10:53:59 -07:00
Mike Ash
794ff31d73 Merge pull request #19794 from mikeash/fix-instruments-and-retain-counts
[Runtime] Fix swift_retainCount for deiniting objects and BridgeObject tagged values. Make swift_bridgeObjectRetain/Release bail out early for tagged values.
2018-10-11 14:32:43 -04:00
Mike Ash
1afd079b78 [Runtime] Fix swift_retainCount for deiniting objects and BridgeObject tagged values. Make swift_bridgeObjectRetain/Release bail out early for tagged values.
The Allocations Instrument overrides swift_retain with a function that records the retain count by calling swift_retainCount. Its assert for bits.getIsDeiniting() is incorrect in that case, so remove it.

The recent change to ObjC tagged pointer bits on x86-64 also caused the various bridgeObjectRetain/Release functions to call through to swift_retain for BridgeObject tagged values on Mac. swift_retain ignored those values so there was no functional change, except when Instruments overrode it and passed them to swift_retainCount, which tried to dereference them and crashed. Modify bridgeObjectRetain/Release to bail out early again. Also modify swift_retainCount to ignore those values in case anything else expects retainCount to work on any pointer swift_retain accepts.

rdar://problem/45102538
2018-10-09 10:04:06 -04:00
Saleem Abdulrasool
66a84617c7 Merge pull request #19770 from compnerd/bionic-malloc
stdlib: correct declaration for `malloc_usable_size` on android
2018-10-08 15:19:34 -07:00
Saleem Abdulrasool
04185aacdf stdlib: correct declaration for malloc_usable_size on android
`malloc_usable_size` is provided on Android with API Level 17 or newer.
However, the signature between bionic and glibc is slightly different, with
android marking the parameter as `const`.  This results in a type mismatch error
when building the standard library for android.  Adjust it to match the target
system.
2018-10-08 11:59:57 -07:00
Saleem Abdulrasool
92ef7e46dc stdlib: use some clever C11 to define ssize_t
`ssize_t` is not universally available as it is not a standard type.
However, we require clang to build the runtime due to custom calling
convention support.  As a result, we know that the compiler will support
the `_Generic` keyword from the C11 standard.  Use this with an
expansion to map the type appropriately for all targets.  This avoids
having to have a sanity check in the runtime that the type definition
matches the underlying system.
2018-10-08 11:49:02 -07:00
Saleem Abdulrasool
a5ed7fc34f stdlib: use __swift_ssize_t instead of ssize_t (NFC)
`ssize_t` is not available on Windows.  We have an internal type definition
`__swift_ssize_t` which allows us to use the type.  Switch to that spelling.
2018-10-05 11:19:07 -07:00
Saleem Abdulrasool
72be1dcda9 stdlib: use "C" style casts in the overlay shims
When this header is used to create a module, it is used in a "C" environment,
which means that we cannot use the C++ style casts.  Switch to the
old-style-cast.  If we need to, we can always use `-Wno-old-style-casts` to
silence the warnings in C++ mode.
2018-10-05 11:18:00 -07:00
Mike Ash
f4db1dd7a4 Merge pull request #19614 from mikeash/no-internal-export
[Stdlib] Change SWIFT_RUNTIME_STDLIB_INTERNAL to not export the symbol.
2018-10-05 09:26:03 -04:00
Mike Ash
3c2096f433 Merge pull request #19540 from mikeash/reserved-bits-refinement
[IRGen][Runtime] Adjust the ObjC reserved bits on x86-64 to exactly match what the target uses.
2018-10-04 17:06:08 -04:00
Mike Ash
fa4178c5e8 [IRGen][Runtime] Adjust the ObjC reserved bits on x86-64 to exactly match what the target uses.
Previously we had a single mask for all x86-64 targets which included both the top and bottom bits. This accommodated simulators, which use the top bit, while macOS uses the bottom bit, but reserved one bit more than necessary on each. This change breaks out x86-64 simulators from non-simulators and reserves only the one bit used on each.

rdar://problem/34805348 rdar://problem/29765919
2018-10-04 12:34:08 -04:00
Mike Ash
1e9741a3f8 [Stdlib] Fix Linux detection for malloc_size. Silence const cast warnings. Fix Linux implementation in Random.cpp to actually compile. 2018-10-03 14:31:39 -04:00
Mike Ash
4113697bfd [Stdlib] Delete a stray ß in LibcShims.h 2018-10-03 11:34:53 -04:00
Mike Ash
1e8c35d8bb [Stdlib] Move the declaration of __swift_ssize_t to SwiftStddef.h so Random.h/cpp can use it. 2018-10-03 10:48:45 -04:00
Mike Ash
c4d5db404b [Stdlib] Change _swift_stdlib_random SPI to swift_stdlib_random API. 2018-10-03 09:55:34 -04:00
Mike Ash
5f17b450c3 [Stdlib] Make all the functions in LibcShims.h either INTERNAL or inline. Move LibcShimsInline.h to LibcOverlayShims.h for more consistent naming. Fix up several tests that needed the mock Darwin overlay built. Fix one SourceKit test that no longer produces is_system: 1 on an import Darwin line. 2018-10-03 09:55:34 -04:00
Mike Ash
ec25f928ff [Stdlib] Move _swift_stdlib_read/write/close into LibcShimsInline.h. 2018-10-03 09:55:34 -04:00
Mike Ash
b2675280c7 [Stdlib] Move the shims used by Platform.swift into a separate header and make them static inline. This avoids exposing them as exported symbols in libswiftCore. 2018-10-03 09:55:34 -04:00
Mike Ash
6926fbd363 [Stdlib] Pull _swift_stdlib_random into a separate file. 2018-10-03 09:55:34 -04:00
Mike Ash
e18e03171f [Stdlib] Change SWIFT_RUNTIME_STDLIB_INTERNAL to not export the symbol.
The functions in LibcShims are used externally, some directly and some through @inlineable functions. These are changed to SWIFT_RUNTIME_STDLIB_SPI to better match their actual usage. Their names are also changed to add "_swift" to the front to match our naming conventions.

Three functions from SwiftObject.mm are changed to SPI and get a _swift prefix.

A few other support functions are also changed to SPI. They already had a prefix and look like they were meant to be SPI anyway. It was just hard to notice any mixup when they were #defined to the same thing.

rdar://problem/35863717
2018-10-03 09:55:33 -04:00
Jordan Rose
c3b1143b15 Merge pull request #19607 from Kaiede/debianHost
Enable i686 as a Host Platform
2018-10-02 16:24:58 -07:00
Adam Thayer
cafa822738 [i686 Linux] Fix undefined ‘__swift_ssize_t’ 2018-09-28 10:14:44 -07:00
Karoy Lorentey
911d4ab5a4 [runtime] Update empty singletons for Set/Dictionary
Also add static_assert for Set/Dictionary storage header size.
2018-09-27 01:49:50 +01:00
Karoy Lorentey
6d81663716 [stdlib] Make Hashable._rawHashValue(seed:) safer and more convenient
- Don’t expose the raw execution seed to _rawHashValue.
- Change the type of _rawHashValue’s seed from (UInt64,UInt64) to a single Int. Working with a pair of UInt64s is unwieldy, and overkill in practice. Int as a seed also integrates nicely with Int as a hash value.
- Remove _HasherCore._generateSeed(). Instead, simply call finalize() on a copy of the hasher to get a seed suitable for _rawHashValue.
- Update Set and Dictionary to store a single Int as the seed value.

Note that this doesn’t affect the core hasher, which still mixes in the actual 128-bit execution seed during its initialization. To reduce the potential of confusion, use the name “rawSeed” to refer to an actual 128-bit seed value.
2018-09-24 13:30:05 +01:00
Karoy Lorentey
ace19fd106 [runtime] Fix layout of empty Set/Dictionary singletons 2018-09-22 02:04:11 +01:00
Karoy Lorentey
098275f3c7 [stdlib] Clean up Set and Dictionary
- Use _HashTable to unify low-level hashing operations across Set and Dictionary.
- Store the capacity directly inside the storage header. This allows the maximum load factor to be controlled by non-inlinable code.
- Introduce a dedicated class for the empty singleton.
- Add _BridgingHashBuffer, a standalone flat hash buffer for use in deferred bridging. Use it to eliminate the need to support non-hashable storage/wrapper variants and to improve memory use in cases where Key or Value are verbatim bridged.
- Eliminate the “TypedNative*Storage” class and _NativeSet/_NativeDictionary’s support for non-hashable keys.
- Rename storage classes as follows:

_RawNativeSetStorage ⟹ _RawSetStorage
_RawNativeDictionaryStorage ⟹ _RawDictionaryStorage
_TypedNativeSetStorage ⟹ (removed)
_TypedNativeDictionaryStorage ⟹ (removed)
_HashableTypedNativeSetStorage ⟹ _SetStorage
_HashableTypedNativeDictionaryStorage ⟹ _DictionaryStorage

The new names make it obvious which ivar layout is in use.
2018-09-22 02:04:07 +01:00
Karoy Lorentey
edb8a73203 [stdlib] Set, Dictionary: New storage classes for the empty singletons
This allows us to move the empty NSSet/NSDictionary overrides out of the root storage class; they don’t really belong there. More importantly, it makes empty sets/dictionaries super obvious to lldb and other runtime tools.
2018-09-22 02:04:05 +01:00
Saleem Abdulrasool
f9af5cb685 Merge pull request #19462 from compnerd/what-is-in-a-name
stdlib: check for ARM/ARM64 more thoroughly (NFC)
2018-09-21 14:19:47 -07:00
Saleem Abdulrasool
2d04b8491b stdlib: check for ARM/ARM64 more thoroughly (NFC)
Update the instances of checks for architectures to be more broad for different
spellings of the architecture macro.  Certain targets use `_M_ARM` and others
use `__arm__`.  Similarly, arm64/aarch64 has `_M_ARM64`, `__arm64__` and
`__aarch64__` as spellings.  This just mechanically goes through and encodes the
various spellings.

Take the opportunity to replace some raw checks with `defined` checks which
avoids a pedantic warning due to the undefined macro when performing the check
as the preprocessor may warn about an undefined condition evaluating to `0`.
2018-09-21 11:24:03 -07:00
Saleem Abdulrasool
8e6d86e074 shims: correct __swift_mode_t for android-aarch64
android on AArch64 will alias `mode_t` to `__kernel_mode_t` which is aliased to
`unsigned int` rather than `unsigned short` like it is on the other targets.
Update the condition to reflect that.
2018-09-20 10:26:59 -07:00
Mike Ash
f4818ea81e Merge pull request #19289 from mikeash/thread-local-storage-dedicated-keys
[Runtime][Stdlib] Use dedicated thread-local storage keys when possible.
2018-09-14 10:45:04 -04:00
Mike Ash
29ff3de4ab [Runtime][Stdlib] Use dedicated thread-local storage keys when possible.
rdar://problem/32275323 rdar://problem/44104305
2018-09-13 14:36:57 -04:00
Saleem Abdulrasool
d8efe22eaf stdlib: adjust the shims for MSVC mode compilation
The SwiftStdint.h header is used in the compiler as well.  The compiler may be
built with cl (Visual Studio) on Windows, which does not define
`__INTPTR_TYPE__` nor does it define `__INTPTR_WIDTH__`.  Simply define the
`__swift_{,u}intptr_t` typedefs as Microsoft does on that platform when building
with Visual Studio.
2018-09-12 11:48:41 -07:00