Commit Graph

5263 Commits

Author SHA1 Message Date
Steve (Numerics) Canon
2f7435da7d First non-intrinsic functions. 2019-04-02 18:48:08 -04:00
Steve (Numerics) Canon
b8d1481fc6 WOW\! 100% less gratuitous type machinery at runtime\! 2019-04-02 18:48:08 -04:00
Steve (Numerics) Canon
5e5cd76e8d Work in progress towards "Mathsable"
Fundamental decision to be made; should implementation hooks present like `Float.exp(_ x: Float) -> Float` or like `Float.Maths.exp(_ x: Float) -> Float`? Having the intermediate namespace to group them as in the second is definitely nicer, but it requires a little bit of extra machinery, and much more importantly, there doesn't seem to be any way to make access to the static `Maths` associatedtype transparent.
2019-04-02 18:48:08 -04:00
Karoy Lorentey
1ddf99a9da [stdlib] Set, Dictionary: Unify casting operations 2019-04-02 13:10:55 -07:00
Michael Ilseman
ff39c345fd Merge pull request #22869 from milseman/gab_barg
[SE-0248] String Gaps
2019-04-02 09:28:34 -07:00
Stephen Canon
60fc39e72a Improve codegen for init(signOf: magnitudeOf:) (#23727)
This can map straight to the LLVM copysign intrinsic for builtin types, which both gets us better codgen and lets the compiler plug this operation into other LLVM-level optimizations.
2019-04-02 09:49:18 -04:00
Hiroki Nagasawa
f85ca6c01a Remove redundant space in first(where:) of Sequence (#23365) 2019-04-01 10:56:16 -05:00
Karoy Lorentey
2bd5da539e [stdlib] Fix Set/Dictionary casting issues
- Fix Set/Dictionary up/downcasting with String keys.
- Improve error handling.
2019-03-29 19:15:09 -07:00
Michael Ilseman
3923fb2268 [String] String.Index.init(_:within:) bounds checks
Bounds check the given index for String.Index's generic initializer
that makes sure a passed index is a valid one for the given
StringProtocol.
2019-03-29 15:43:00 -07:00
Michael Ilseman
0ece62d911 [String] Add Substring.base
Adds Substring.base, analogous to Slice.base, to access the entire
String.

Tests added.
2019-03-29 15:43:00 -07:00
Michael Ilseman
aa519362f3 [String] Add Character.UTF16View and Character.UTF8View
Adds these collections, which are just String's views.

Tests added.
2019-03-29 15:43:00 -07:00
Michael Ilseman
b19c2cf9c3 [String] Add generic String.Index and range inits within a String
Adds a generic version of String.Index.init?(_:within:) and
Range<String.Index>.init?(_:in:).

Tests added
2019-03-29 15:43:00 -07:00
Michael Ilseman
4967fc08eb [Unicode] Add convenience APIs to Unicode encodings
Add convenience APIs to the stdlib's Unicode encodings:

* Unicode.UTF16
  * isASCII
  * isSurrogate
* Unicode.UTF8
  * isASCII
  * width
* Unicode.UTF32
  * isASCII
* Unicode.ASCII
  * isASCII

Tests added
2019-03-29 15:43:00 -07:00
Michael Ilseman
b6a158e1fc [stdlib] Add LegacyABI.swift for legacy non-API declarations 2019-03-29 15:43:00 -07:00
Michael Ilseman
751cf26ef5 [Unicode.Scalar] Add RAC UTF8View
This adds new (availability-controlled) API to Unicode.Scalar,
exposing the scalar's UTF-8 code units as a random-access collection
similarly to how it currently exposes UTF-16 code units.

Tests added.
2019-03-29 15:43:00 -07:00
Karoy Lorentey
7b654b372f [stdlib] Fix availability of Dictionary’s bulk-loading initializer (#23643)
Making it @_alwaysEmitIntoClient makes it available in all OS versions.
2019-03-29 12:54:56 -07:00
David Smith
39745a1e5e Merge pull request #21627 from kubamracek/fix-data-race-on-emptyarraystorage
Fix a data race on _swiftEmptyArrayStorage reported by TSan
2019-03-28 17:38:21 -07:00
Daniel Rodríguez Troitiño
28251a7a3b Merge pull request #19846 from drodriguez/android-aarch64-disable-powl
[android] Fix powl test in Android ARMv7/AArch64.
2019-03-28 07:20:51 -07:00
Daniel Rodríguez Troitiño
7455fb748f [android] Fix powl test in Android ARMv7/AArch64.
In Android ARMv7 there was no alias defined for CLongDouble, so
importing anything with long double was failing. Defining the alias
makes the test pass.

AAPCS64 defines long double as 128 bits, which is still unsupported by
Swift (SR-9072). Disable this particular test for Android and Linux in
AArch64 to not fail (but still test all the other tests).
2019-03-27 13:30:17 -07:00
Mike Ash
965953d7a0 Merge pull request #23451 from mikeash/magic-symbols-for-install-name
[Build] Use magic linker symbols to specify an @rpath-relative install name when targeting pre-stable-ABI OSes.
2019-03-27 08:10:30 -07:00
Nate Cook
b6bb9d2f8c [stdlib] Make unsafe array initializer public (#23134)
[stdlib] Make unsafe array initializer public

This implements SE-0245. The public versions of this initializer call
into the existing, underscored version, which avoids the need for
availability constraints.
2019-03-23 13:18:10 -05:00
Mike Ash
4fb99998ae [Build] Use magic linker symbols to specify an @rpath-relative install name when targeting pre-stable-ABI OSes.
Magic symbols of the form $ld$install_name$os9.0$@rpath/libswiftCore.dylib tell the linker to use that install name when targeting that OS version. Use these symbols to specify an @rpath install name for all back-deployment libraries when targeting watchOS 2.0-5.1, iOS 7.0-12.1, and macOS 10.9-10.14.

rdar://problem/45027809
2019-03-22 10:04:39 -04:00
Saleem Abdulrasool
65d4199c7b Merge pull request #23400 from drodriguez/remove-incorrect-docs
[stdlib] Remove documentation piece that it is not longer true.
2019-03-21 09:30:34 -07:00
Michael Gottesman
384882d5f3 Merge pull request #23201 from compnerd/patience-is-not-always-a-virtue
build: introduce and switch to GYB_SOURCES
2019-03-20 13:27:32 -07:00
Stephen Canon
60e86b9361 Some cleanup of SIMDVector and SIMDVectorTypes source files. (#23389)
Bring formatting closer in line with the rest of the standard lib, remove "public" from extensions (moving it onto the contents defined therein). Restore Swift project headers that were apparently lost at some point.
2019-03-19 12:44:35 -04:00
Kyle Murray
cf5bcabd6e Merge pull request #23406 from krilnon/master
[stdlib] Fix a misspelling in a Dictionary doc comment.
2019-03-18 21:35:56 -07:00
Kyle Murray
7eab74c066 [stdlib] Fix a misspelling in a Dictionary doc comment.
Fixes rdar://problem/48759246.
2019-03-18 15:34:50 -07:00
Daniel Rodríguez Troitiño
59c669936d [stdlib] Remove documentation piece that it is not longer true.
Since a4e9109 (#17396), both the hashes and the equality of numeric
types inside of AnyHashable do not follow the rules that this part of
the comment was talking about.

I couldn't find an easy example that shows the same behaviour, so I
decided to remove the comment completely.
2019-03-18 14:10:50 -07:00
Bob Wilson
ef1d9bc7f8 Stop using the _branchHint function
LLVM r355981 changed various intrinsic functions, including expect,
to require immediate arguments. Swift's _branchHint function has an
expected value that is passed in as an argument, so that it cannot
use LLVM's expect intrinsic. The good news is that _branchHint is only
ever used with immediate arguments, so we can just move the intrinsic
into _fastPath and _slowPath and use those instead of _branchHint.

As was noted in the documentation, the _fastPath and _slowPath names are
confusing but we have passed the point where we can simply rename them.
We could add new names but would still need to keep the old ones around
for binary compatibility, and it is not clear that it is worth the
trouble. I have removed that note from the documentation.
2019-03-17 22:13:51 -07:00
iliaskarim
c8cfb2d6eb Update FixedArray.swift.gyb
Fix typo
2019-03-14 14:40:35 -04:00
Mike Ash
48f9ac9de5 [Stdlib] Reconstitute the documentation part of the comment on AnyKeyPath. 2019-03-13 15:56:00 -04:00
Mike Ash
c38f613aec [Stdlib] Remove a / from the comment describing the ObjC runtime name for AnyKeyPath.
With three /'s, it got interpreted as documentation, which it definitely is not meant to be.
2019-03-13 13:59:53 -04:00
Saleem Abdulrasool
8ed5c1a4bc build: introduce and switch to GYB_SOURCES
This avoids us having to pattern match every source file which should
help speed up the CMake generation.  A secondary optimization is
possible with CMake 3.14 which has the ability to remove the last
extension component without having to resort to regular expressions.  It
also helps easily identify the GYB'ed sources.
2019-03-11 13:48:54 -07:00
Stephen Canon
20a1781842 Minor improvement for the documentation of ulp and ulpOfOne. (#23211)
1. Move discussion of `DBL_EPSILON` etc. onto `ulpOfOne` instead of `ulp`.
2. Add text explaining that `ulpOfOne` is a poor value to use for approximate comparison.
2019-03-11 13:06:41 -04:00
USAMI Kosuke
aa9a0d4b16 Fix document : Numeric -> AdditiveArithmetic 2019-03-11 21:58:43 +09:00
Andrew Trick
404cf73ca6 Merge pull request #23111 from atrick/dominating-access-algo
Change the algorithm for the AccessEnforcementDom pass.
2019-03-07 16:51:18 -08:00
swift-ci
74d1322a72 Merge pull request #23119 from ravikandhadai/array-init-semantics 2019-03-07 14:17:34 -08:00
Andrew Trick
3da2cc9e06 Clarify comments. 2019-03-07 13:48:41 -08:00
Andrew Trick
f4c7d4611f Change the algorithm for the AccessEnforcementDom pass.
This adds a mostly flow-insensitive analysis that runs before the
dominator-based transformations. The analysis is simple and efficient
because it only needs to track data flow of currently in-scope
accesses. The original dominator tree walk remains simple, but it now
checks the flow insensitive analysis information to determine general
correctness. This is now correct in the presence of all kinds of nested
static and dynamic nested accesses, call sites, coroutines, etc.

This is a better compromise than:

(a) disabling the pass and taking a major performance loss.

(b) converting the pass itself to full-fledged data flow driven
optimization, which would be more optimal because it could remove
accesses when nesting is involved, but would be much more expensive
and complicated, and there's no indication that it's useful.

The new approach is also simpler than adding more complexity to
independently handle to each of many issues:

- Nested reads followed by a modify without a false conflict.
- Reads nested within a function call without a false conflict.
- Conflicts nested within a function call without dropping enforcement.
- Accesses within a generalized accessor.
- Conservative treatment of invalid storage locations.
- Conservative treatment of unknown apply callee.
- General analysis invalidation.

Some of these issues also needed to be considered in the
LoopDominatingAccess sub-pass. Rather than fix that sub-pass, I just
integrated it into the main pass. This is a simplification, is more
efficient, and also handles nested loops without creating more
redundant accesses. It is also generalized to:
- hoist non-uniquely identified accesses.
- Avoid unnecessarily promoting accesses inside the loop.

With this approach we can remove the scary warnings and caveats in the
comments.

While doing this I also took the opportunity to eliminate quadratic
behavior, make the domtree walk non-recursive, and eliminate cutoff
thresholds.

Note that simple nested dynamic reads to identical storage could very
easily be removed via separate logic, but it does not fit with the
dominator-based algorithm. For example, during the analysis phase, we
could simply mark the "fully nested" read scopes, then convert them to
[static] right after the analysis, removing them from the result
map. I didn't do this because I don't know if it happens in practice.
2019-03-07 12:39:53 -08:00
Ravi Kandhadai
6c662f7a6c [stdlib][Semantics annotation] Add ".empty" suffix to the semantics attribute of
array.init() and add semantics annotation to the compiler-intrinsic:
Array._allocateUninitializedArray
2019-03-05 17:09:34 -08:00
Scott Perry
fcf6550506 Merge branch 'master' into numist/diffing 2019-03-04 21:29:12 -08:00
Patrick Pijnappel
24282df850 [stdlib] Fix typo in comment 2019-03-05 12:05:00 +11:00
Michael Ilseman
dc89cc06e6 Merge pull request #23026 from milseman/client_helper_emitted
[stdlib] Some cleanup enabled by _alwaysEmitIntoClient.
2019-03-04 07:40:17 -08:00
Michael Ilseman
19014a85af [stdlib] Some cleanup enabled by _alwaysEmitIntoClient.
Refactor some copy-pasted code into a helper computed variable and
outline some cold paths.
2019-03-03 14:10:01 -08:00
Saleem Abdulrasool
75e31751ba stdlib: use the correct va_list type on Windows
Windows uses `char *` for the `va_list` type even on x86_64.  Restore
the correct selection of `__VaListBuilder` for Windows x86_64.  This
partially fixes variadic functions.
2019-03-01 14:25:26 -08:00
Michael Ilseman
438010d366 [gardening] Dead File Elimination 2019-02-28 10:11:11 -08:00
Maxim Moiseev
2ce0630b58 Print nil unwrap location in no-assert builds of stdlib
We've been collecting the location info for some time now, but
apparently never printed it in no-assert builds of the stdlib, which
means this functionality was never available to the users.

With this change, the location will be printed depending on the
debug/release build configuration of the program, not stdlib.

Somewhat addresses: <rdar://problem/42980523>
2019-02-27 16:04:30 -08:00
Scott Perry
6e3139b5da Incorporate feedback from @lorentey and @moiseev 2019-02-27 14:05:06 -08:00
Karoy Lorentey
fd32a3d14e [stdlib] Set availability of diffing APIs 2019-02-22 14:28:15 -08:00
Karoy Lorentey
57f4afbf84 [stdlib] Update diffing code to match stdlib coding conventions
- Add an underscore to private/internal symbols
- Make access levels explicit, even when they’re implied from context
- Conform to max line length of 80 characters
- Conformances declared on separate extensions that implement them
- Arrange member declarations so that stored properties appear first
- Expand single-letter function and type parameter names where there is an obvious name that’s more descriptive
- RangeReplaceableCollection.fastApplicationEnumeration → CollectionDifference._fastEnumeratedApply
2019-02-22 14:27:45 -08:00