Commit Graph

5543 Commits

Author SHA1 Message Date
David Smith
149080c526 Merge pull request #25771 from Catfish-Man/very-normal-hash
Remove a retain release pair in foreign string hashing
2019-06-26 14:21:45 -07:00
Michael Ilseman
93d65fc9c3 [gardening] Remove trailing whitespace 2019-06-26 09:22:17 -07:00
Michael Ilseman
f52a865570 [String] Slice contents before asking ICU
ICU will return different results if we call with an offset into a
code unit buffer vs if we slice the buffer first and provide an offset
of zero. Slicing more closely models the semantics of SE-0180, so use
that.

Test case coming in subsequent commit enforcing index
scalar-alignment.
2019-06-26 09:22:17 -07:00
t.ae
f96cbb8a36 Make AdditiveArithmetic.zero @_transparent (#25658) 2019-06-26 09:07:30 -04:00
David Smith
75185aa556 Remove a retain release pair in foreign string hashing 2019-06-25 18:17:39 -07:00
Joe Groff
a868cfb237 Merge pull request #25329 from linux-on-ibm-z/s390x-keypathmultimodule-fix
Fix for KeyPathMultiModule test failure
2019-06-25 09:41:51 -07:00
Lei Zhang
6ac15e9348 Fix for KeyPathMultiModule test failure 2019-06-24 16:17:39 -04:00
David Smith
460a5213fc Revert "[stdlib] AutoreleasingUnsafeMutablePointer: Switch subscripts to _read accessors"
This was an ABI break, since it didn't make it into 5.0. Using _read here is unimportant, so we're just going to revert rather than try being fancy.

This reverts commit 04586e3916.
2019-06-24 11:33:36 -07:00
Ed Greenaway
a92357ab05 Update documentation for CommandLine.arguments (#25304)
Addresses SR-6776 Documentation comment for CommandLine.arguments contains implementation remarks
2019-06-19 15:47:17 -07:00
Vlad Gorlov
6370681656 Android cross-compile on macOS: Fix for compile error addressed Float80 data type. (#25502)
* Fixes issue addressed Float80 data type. Float80 is disabled for Intel architectures (i.e. Android Simulator).

* More precise condition check.
2019-06-17 13:40:44 -04:00
Nate Cook
e730bd1256 Remove residual gyb bits from LazyPrefixWhileCollection. 2019-06-13 11:39:15 -05:00
Stephen Canon
2df36527d3 Provide a default implementation of multipliedFullWidth (#25346)
* 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.
2019-06-11 22:02:48 -07:00
Karoy Lorentey
fd39f2f9d2 Merge pull request #25301 from fassko/SR_10094_withContiguousStorageIfAvailable_docs
[Doc] [SR-10094]  Add missing documentation for SE-0237
2019-06-11 11:52:50 -07:00
Stephen Canon
bbd44a186f Replace two #ifs with #if/#else in new integer random algorithm (#25352)
Swift gets used on archs other than 32 and 64b Intel and ARM (e.g. IBM's systems); as written this would fail to compile there.
2019-06-11 14:36:43 -04:00
Pavol Vaskovic
2bc648c26b [stdlib] Lemire’s Nearly Divisionless Random Integer Generation (#25286)
* [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.
2019-06-10 22:44:09 -04:00
Steve (Numerics) Canon
4b5a85a34d Fix a bug in root and add a test case for it.
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.
2019-06-10 11:50:36 -04:00
Kristaps Grinbergs
f0e3a99f97 [Doc] [SR-10094] Add missing documentation for SE-0237
https://bugs.swift.org/browse/SR-10094
2019-06-07 14:32:42 -07:00
Slava Pestov
ec4c597156 stdlib: ManagedBuffer.init(_doNotCallMe:) was ABI in Swift 5 and should be @usableFromInline 2019-06-01 00:08:05 -04:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Steve (Numerics) Canon
957384129a It turns out that _SmallBuffer<T> simply isn't used at all
... so that's another vestigial static-buffer we can eliminate.
2019-05-29 19:43:39 -04:00
Steve (Numerics) Canon
27ccf1b914 De-GYB FixedArray.swift
It turns out that 16 is the only size that the stdlib actually uses, so the .gyb isn't eliminating any boilerplate anyway.
2019-05-29 19:19:54 -04:00
Slava Pestov
3917268b35 stdlib: Work around associated type inference bugs 2019-05-28 22:08:31 -04:00
Sho Ikeda
44f0e93747 Merge pull request #25067 from ikesyo/avoid-fallthrough-where-appropriate
[gardening] Avoid fallthrough where appropriate (for readability/understandability)
2019-05-29 00:27:05 +09:00
Sho Ikeda
2019a97e55 Merge pull request #25066 from ikesyo/use-isempty-over-count
[gardening] Use `Collection.isEmpty` over `Collection.count`
2019-05-29 00:24:48 +09:00
Turushan Aktay
c61691919b Fix documentation typos. 2019-05-26 14:17:45 +02:00
Sho Ikeda
c1bb945124 [gardening] Avoid fallthrough where appropriate (for readability/understandability) 2019-05-26 09:50:02 +09:00
Sho Ikeda
a35c9f0c60 [gardening] Use Collection.isEmpty over Collection.count 2019-05-26 09:35:20 +09:00
Federico Zanetello
afcf4b6991 fix documentation typo (#25061) 2019-05-25 12:43:49 -05:00
David Smith
803227a46b Avoid O(n) character accesses in String.UTF8View._foreignCount 2019-05-21 13:22:42 -07:00
Ted Kremenek
4beb673b8e Bump compiler version to Swift 5.1 (#24671)
* Bump version to Swift 5.1

* Update tests with compiler version bump

* Undo flatMap and math obsolescences
2019-05-13 07:32:39 -07:00
Xiaodi Wu
da9f67c781 [docs] Update trailingZeroBitCount documentation (#24713)
* [docs] Update `trailingZeroBitCount` documentation

Document the required behavior for `trailingZeroBitCount` when the value is zero. Namely, in that scenario, `trailingZeroBitCount` should be equal to `bitWidth`.

* [docs] Address reviewer comments on `trailingZeroBitCount` docs
2019-05-13 08:53:28 -04:00
Patrick Pijnappel
70be266440 Merge pull request #23293 from PatrickPijnappel/range-overlaps-performance-impl
[stdlib] Refactor Range Overlaps for Performance
2019-05-13 22:00:23 +10:00
Nate Cook
841eb4cf5e [stdlib] Revise collection difference documentation (#24675)
* Revise CollectionDifference documentation.
2019-05-10 20:57:46 +02:00
Nate Cook
ab5846c8a9 Shorten parameter name in doc example. 2019-05-10 03:34:44 +02:00
Mike Ash
3ad6e46930 [Stdlib] Fix warnings about designated initializers in SwiftNativeXXX classes. 2019-05-06 17:15:53 -04:00
Nicholas Maccharoli
cd5055711a Fix syntax error in comment code
Closing parentheses is missing in the example code.
2019-05-06 01:38:47 +09:00
David Smith
1192b914d2 Merge pull request #24457 from Catfish-Man/two-by-two-length-of-blue
Fix bounds check in bridged ASCII String comparison
2019-05-03 18:28:55 -07:00
Patrick Pijnappel
87f02b173b [stdlib] Refactor range overlaps for performance 2019-05-04 09:15:21 +10:00
David Smith
008699e52d Fix bounds check in bridged ASCII String comparison 2019-05-03 15:55:58 -07:00
Ravi Kandhadai
a7b7db7854 [Constant Evaluator] Move "string.append" semantics attribute from
`String.+=` function to `String.append` function, and use a new
semantics attribute for String.+=.

Teach the constant evaluator about `String.Append` instead of `String.+=`.
2019-04-30 14:26:06 -07:00
David Smith
b6d0362204 Merge pull request #24289 from Catfish-Man/bulk-discount
SR-10555 foreignCopyUTF8 should do bulk access
2019-04-29 22:17:29 -07:00
David Smith
fd0d4d858e SR-10555 foreignCopyUTF8 should do bulk access 2019-04-29 16:23:55 -07:00
Stephen Canon
d2f695935f Add availability information to the new Math function protocols (#24187)
* Add availability information to the new Math function protocols

The protocols ElementaryFunctions, RealFunctions, and Real are new in Swift 5.1 and accordingly need to have availability attached to them for platforms that are ABI-stable. The actual implementation hooks (static functions) are unconditionally defined on scalar types and marked @_alwaysEmitIntoClient, so they are available even when targeting older library versions, but the protocols themselves, and anything defined in terms of them (the global functions and the SIMD extensions) is only available when targeting library versions that have the new protocols.

* Additionally provide concrete implementations of signGamma for each stdlib-builtin floating-point type.

* Remove Real[Functions] protocols pending re-review

Temporarily pull these back so we can make minor tweaks to the design and get a re-review on SE.
2019-04-29 17:39:33 -04:00
Ben Cohen
1096179aaa Merge pull request #24186 from AnthonyLatsis/fix-reversed-index-alias
Stdlib: Fix ReversedIndex compatibility alias
2019-04-26 14:43:55 -07:00
Michael Ilseman
102a3a816a Merge pull request #24198 from troughton/floating-point-parsing-utf8
[stdlib] Use String’s underlying UTF-8 view for Float parsing
2019-04-26 13:28:49 -07:00
Saleem Abdulrasool
f88be05394 Merge pull request #24240 from compnerd/bridge-to-terabithia
WIP: bridge BOOL to Bool
2019-04-26 11:13:41 -07:00
Stephen Canon
ba0888df5b Really remove static min and max on simd. One slipped through. (#24283) 2019-04-26 07:41:49 -04:00
Saleem Abdulrasool
83b290438c Windows: bridge BOOL to Bool
This allows the conversion of the Windows `BOOL` type to be converted to
`Bool` implicitly.  The implicit bridging allows for a more ergonomic
use of the native Windows APIs in Swift.

Due to the ambiguity between the Objective C `BOOL` and the Windows
`BOOL`, we must manually map the `BOOL` type to the appropriate type.
This required lifting the mapping entry for `ObjCBool` from the mapped
types XMACRO definition into the inline definition in the importer.

Take the opportunity to simplify the mapping code.

Adjust the standard library usage of the `BOOL` type which is now
eclipsed by the new `WindowsBool` type, preferring to use `Bool`
whenever possible.

Thanks to Jordan Rose for the suggestion to do this and a couple of
hints along the way.
2019-04-25 17:52:08 -07:00
Stephen Canon
9850150c91 Restore elementwise min/max on SIMD, with explicit naming. (#24136)
* Restore elementwise min/max on SIMD, but as statics instead of free functions.

Having these as free functions causes expression too complex issues due to overload vis-a-vis min<Collection>. There are (at least) three plausible solutions:

1. Fix the typechecker. This is infeasable in the short term; or more precisely, we do not know how much work is involved.

2. Give these operations different names. Candidates discussed with core team include "pointwiseMin", "elementwiseMin", "lanewiseMin"; these all suffer from the flaw that when someone writes "min" in a SIMD context, they are essentially always looking for either the horizontal minimum (reduction) on a single vector or--more often--the lanewise minimum of two vectors (this operation). It would be odd to give the operation that people actually want the unnecessarily verbose name.

3. Make these operations static; this is, in effect, a different name, but it's one which frequently allows eliding the qualifier:

  let x = v + .min(v, w)

This isn't perfect; you will still need to spell out SIMD4.min( ) fairly often, but that's more concise than any of the proposed alternatives, and at least allows elision some of the time. Also, if you squint, you can pretend that the "." prefix is like ".<" and ".&" and indicates lanewise operation.
2019-04-25 14:52:03 -04:00
Nate Cook
3be8321675 [stdlib] Fix the example in LazySequenceProtocol docs.
I'm not sure this code ever worked, but this new version does. Also
includes some style revisions to the surrounding text.
2019-04-25 10:39:24 -05:00