Commit Graph

658 Commits

Author SHA1 Message Date
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
Erik Eckstein
8f35a3eff7 runtime: remove pinning in reference counting and pinning runtime entry points
rdar://problem/35401813
2018-08-25 11:14:18 -07:00
Joe Groff
47f046ef52 Merge pull request #18768 from jckarter/keypath-let
Preserve 'let'-ness of stored properties in key paths.
2018-08-17 14:32:30 -07:00
Joe Groff
00b50ce6ab KeyPaths: Take a bit for encoding "let"-ness of stored properties.
If we know a key path component can be accessed as a stored property, then we should also know whether it's a `let` or not, so it should be safe to encode this in the key path pattern. Stage this change in by changing the number of bits used to store in-line offsets, fixing up the parts of the key path implementation that assumed that it took up the entire payload bitfield.
2018-08-16 13:21:15 -07:00
Mike Ash
195e3807d1 [Runtime] Mark _swift_stdlib_operatingSystemVersion as __attribute__((const)).
This tells the compiler that repeated calls to this function will always generate the same result, which allows the optimizer to coalesce multiple calls, hoist calls out of loops, and other such nice things.

rdar://problem/20690429
2018-08-16 13:24:54 -04:00
Ben Rimmington
2f326bcc88 [stdlib] Remove theGlobalMT19937
SwiftPrivate/PRNG.swift:

- currently uses `theGlobalMT19937`;
- previously used `arc4random` (see #1939);
- is obsoleted by SE-0202: Random Unification.
2018-08-01 13:00:16 +01:00
Mishal Shah
13f5118a92 Update master to build with Xcode 10 beta 5, macOS 10.14, iOS 12, tvOS 12, and watchOS 5 SDKs 2018-07-31 13:05:42 -07:00
Azoy
b8fc8b333c Remove _interface 2018-07-29 10:41:22 -04:00
Joe Groff
4098aa02c7 KeyPaths: Support instantiating property descriptors with captured arguments. 2018-07-25 14:28:33 -07:00
Joe Groff
fceea87bf4 KeyPaths: Support instantiating generic property descriptors from concrete contexts.
This is a bit easier than the fully general case where both the external descriptor and local pattern have captured arguments (because of generics or subscript indices) since we don't have to combine the two argument files in one component.
2018-07-25 11:09:04 -07:00
Joe Groff
b607e549f1 Adjust the key path component tags so that the trivial property descriptor can be zero.
…and thus more likely to be folded with another zero constant in the module and/or put in a zero-initialized page.
2018-07-25 10:49:29 -07:00
Michael Ilseman
95cbf45957 [stubs] Add nullability annotations; NFC 2018-07-20 13:28:33 -07:00
Matt Wright
1ff4ca0d41 dispatch_source_create returns NULL but is marked up as nonnull
dispatch_source_create is marked up as non-null but can actually return
null in programming error issues. In order to maintain the nullabilty
contract, these issues will now cause the overlay to assert and crash
rather than return a null pointer out of a non-null call.

Resolves: <rdar://problem/39937177>
2018-07-13 10:47:09 -07:00
Michael Ilseman
30450671fa Merge pull request #15593 from allevato/unicode-properties
[SE-0211] Add Unicode properties to Unicode.Scalar
2018-07-11 13:27:31 -07:00
Michael Ilseman
5358401d35 [string] Add UText shims; NFC
Add ICU shims for creating UTexts and performing grapheme breaking
using UTexts. This will allow us to explore multi-encoding grapheme
support throughout string.
2018-07-09 10:47:37 -07:00
Tony Allevato
d0e93acb00 Various fixes to Unicode.Scalar.Properties.
- numericValue returns nil instead of .nan for non-numerics
- Remove small-string optimizations from _scalarName that failed on 32-bit archs
- Put case mappings back into U.S.Properties
- Added more sanity tests
2018-07-05 20:42:56 -07:00
Mishal Shah
811b1d0879 Update master to build with Xcode 10 beta 3, OS X 10.14, iOS 12, tvOS 12, and watchOS 5 SDKs 2018-07-05 10:57:03 -07:00
Tony Allevato
8eef50f6a9 Merge branch 'master' into unicode-properties 2018-07-04 08:42:35 -07:00
Joe Groff
3e4e00c163 SILGen: Emit "trivial" property descriptors for properties that withhold no information about their implementation.
Client code can make a best effort at emitting a key path referencing a property with its publicly exposed API, which in the common case will match what the defining module would produce as the canonical key path component representation of the declaration. We can reduce the code size impact of these descriptors by not emitting them when there's no hidden or possibly-resiliently-changed-in-the-past information about a storage declaration, having the property descriptor symbol reference a sentinel value telling client key paths to use their definition of the key path component.
2018-06-21 15:18:24 -07:00
Slava Pestov
4e0e462d23 Rename a few remaining @_inlineable => @inlinable, @_versioned => @usableFromInline 2018-06-09 22:41:54 -07:00
Mishal Shah
3f8ce7d2f9 Update master to build with Xcode 10 beta 1, OS X 10.14, iOS 12, tvOS 12, and watchOS 5 SDKs. 2018-06-04 23:14:19 -07:00
Mike Ash
0e952b45bc Merge pull request #16254 from mikeash/runtime-conformance-scanning-lockless-array
[Runtime] Change protocol conformance scanning to use a concurrent array rather than a locked vector.
2018-05-16 14:03:10 -04:00
Mike Ash
da4fa67d7e [Runtime] Move ConcurrentReadableArray's allocate/deallocate functions into Storage. Mark ConcurrentReadableArray as un-copyable, un-assignable, and un-movable. Use SWIFT_MEMORY_ORDER_CONSUME instead of std::memory_order_consume. Make read() pass a const pointer.
rdar://problem/37173156
2018-05-15 15:27:33 -04:00