Commit Graph

4494 Commits

Author SHA1 Message Date
swift-ci
336e42ee2c Merge remote-tracking branch 'origin/master' into master-next 2018-05-17 15:09:01 -07:00
Ben Langmuir
628b6a1fc7 Revert "Turn on ‘as’ bridging on Linux." 2018-05-17 14:54:35 -07:00
swift-ci
e0c8c31b0b Merge remote-tracking branch 'origin/master' into master-next 2018-05-17 14:29:05 -07:00
Erik Eckstein
0868f2864b stdlib: make Sequence -> String inlinable
As this function is generic, it makes a big difference when it can be specialized for concrete sequences, like arrays or unsafe buffers.
This fixes a performance regression of String(decoding:as:), e.g. when constructing a String from a byte buffer.
2018-05-17 13:44:51 -07:00
Lily Vulcano
7b8db8f1fd Remove last vestige of printf debugging. 2018-05-17 10:03:40 -07:00
Lily Vulcano
b9455930ee Turn on ‘as’ bridging on Darwin. 2018-05-17 09:59:39 -07:00
Frederick Pietschmann
a0ea2d326d Fix typo and punctuation mark 2018-05-16 23:03:28 +02:00
swift-ci
32fff5e9c7 Merge remote-tracking branch 'origin/master' into master-next 2018-05-14 12:48:58 -07:00
Michael Ilseman
b2ad5b6f8a [string] Kill _StringGuts.Iterator
_StringGuts is not meant to be an abstraction across all the forms a
String may take. It's meant to abstract the book-keeping and the
visitor is a parameterization over operations.
2018-05-14 07:01:44 -07:00
Michael Ilseman
00e214ec50 [string] Clean up String.UTF8View
Extract slow paths into non-inlinable functions so that fast-paths can
be faster and we don't pay the large code bloat for the Unicode
parsers.

Some tests proactively extended to highlight UTF8View of multiple
kinds of Strings.
2018-05-14 07:01:38 -07:00
swift-ci
1c2dcbf398 Merge remote-tracking branch 'origin/master' into master-next 2018-05-13 16:46:06 -07:00
Michael Ilseman
6b7d316f50 [string] Fix 32-bit small string compilation failure 2018-05-13 07:38:55 -07:00
Michael Ilseman
4a368ab46c [string] Drop many @inlinable from big API.
Drop append-related @inlinable annotations for String, StringGuts,
StringStorage, and the Views. Drop several for larger operations, such
as case conversion. Drop as many as we can from StringGuts for now.
2018-05-13 07:38:55 -07:00
Michael Ilseman
b62241aba4 [string] Cleanup and remove init-from-CString inlinability 2018-05-13 07:38:55 -07:00
Michael Ilseman
459833725e [String] Streamline more String creation logic.
Streamline and de-genericize non-inlinable internal functions to
create a String from UTF-8 efficiently.
2018-05-13 07:38:55 -07:00
swift-ci
fbc685494f Merge remote-tracking branch 'origin/master' into master-next 2018-05-12 07:10:06 -07:00
Stephen Canon
f9f2fc34d9 Streamline integer-range randomElement. (#16501)
This is a small performance win; mainly I'm interested in simplifying the code so that there are fewer weird corners for bugs to creep in. Nonetheless, it seems to be about 5% faster with the (fast, dumb) LCG generator.
2018-05-12 07:06:46 -07:00
swift-ci
f58a0f2454 Merge remote-tracking branch 'origin/master' into master-next 2018-05-12 02:49:52 -07:00
Slava Pestov
89e48ff2e8 stdlib: change a var to a let to squash a warning 2018-05-12 01:48:29 -07:00
Slava Pestov
5385db2519 stdlib: Even more old spellings of @inlinable / @usableFromInline have snuck in 2018-05-12 01:48:24 -07:00
swift-ci
bed7dc124d Merge remote-tracking branch 'origin/master' into master-next 2018-05-10 16:09:03 -07:00
Andrew Trick
6a48b2d02d Merge pull request #16491 from atrick/enforce-keypath-exclusivity-as-error
Enforce keypath exclusivity as an error.
2018-05-10 16:03:01 -07:00
swift-ci
76c225ea0e Merge remote-tracking branch 'origin/master' into master-next 2018-05-10 10:49:15 -07:00
ravikandhadai
1c0d598a84 [stdlib] update the fatal error message displayed during invalid int-to-int conversions (<rdar://39542040>) (#16480) 2018-05-10 10:30:39 -07:00
swift-ci
8733e2bdaf Merge remote-tracking branch 'origin/master' into master-next 2018-05-10 09:49:16 -07:00
Saleem Abdulrasool
f4c24d6e2e Merge pull request #16403 from lanza/inspect-arch-sdk
Configure the swiftImageInspectionShared to generate arch & sdk speci…
2018-05-10 09:42:35 -07:00
swift-ci
6ac4a46348 Merge remote-tracking branch 'origin/master' into master-next 2018-05-10 09:29:08 -07:00
Doug Gregor
7cb8c18838 SE-0210: improve documentation comments per @natecook1000's comments. 2018-05-10 09:18:28 -07:00
swift-ci
b88aa1dfd0 Merge remote-tracking branch 'origin/master' into master-next 2018-05-10 03:49:16 -07:00
Karoy Lorentey
d282b1c541 Merge pull request #16413 from Azoy/random-unification
[stdlib] Random unification
2018-05-10 11:41:48 +01:00
Andrew Trick
e8c65b37ef Remove the optimize.sil.preserve_exclusivity attribute. 2018-05-09 23:10:35 -07:00
swift-ci
c82c4cd4e7 Merge remote-tracking branch 'origin/master' into master-next 2018-05-09 18:09:07 -07:00
swift-ci
0eb5131669 Merge pull request #15519 from jckarter/key-path-offset 2018-05-09 18:00:21 -07:00
Karoy Lorentey
54b3b8be5e [stdlib] Random: don't randomize FixedWidthIntegers by overwriting their raw memory
Custom FixedWidthInteger types may not support this.

Introduce a new (non-public) FixedWidthInteger requirement for generating random values; implement it using &<</+ in the generic case, and specialize it using RandomNumberGenerator._fill(bytes) for the builtin types.
2018-05-09 18:02:34 +01:00
Karoy Lorentey
12a2b32644 [stdlib] Add & implement Random._fill(bytes:) requirement 2018-05-09 17:51:36 +01:00
swift-ci
02710ad6fe Merge remote-tracking branch 'origin/master' into master-next 2018-05-09 08:09:20 -07:00
Dave Abrahams
ec9b402605 Slightly clarify removeAll(where:) (#16459)
* Slightly clarify removeAll(where:)

Improve parameter naming, use "guard" to reduce nesting
2018-05-09 07:57:28 -07:00
Ben Rimmington
b65d0c1d11 Consolidate _stdlib_random functions (#2)
* Use the `__has_include` and `GRND_RANDOM` macros

* Use `getentropy` instead of `getrandom`

* Use `std::min` from the <algorithm> header

* Move `#if` out of the `_stdlib_random` function

* Use `getrandom` with "/dev/urandom" fallback

* Use `#pragma comment` to import "Bcrypt.lib"

* <https://docs.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp>
* <https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions>

* Use "/dev/urandom" instead of `SecRandomCopyBytes`

* Use `swift::StaticMutex` for shared "/dev/urandom"

* Add `getrandom_available`; use `O_CLOEXEC` flag

Add platform impl docs

Update copyrights

Fix docs

Add _stdlib_random test

Update _stdlib_random test

Add missing &

Notice about _stdlib_random

Fix docs

Guard on upperBound = 0

Test full range of 8 bit integers

Remove some gyb

Clean up integerRangeTest

Remove FixedWidthInteger constraint

Use arc4random universally

Fix randomElement

Constrain shuffle to RandomAccessCollection

warning instead of error

Move Apple's implementation

Fix failing test on 32 bit systems
2018-05-09 00:21:44 -05:00
swift-ci
17045afe85 Merge remote-tracking branch 'origin/master' into master-next 2018-05-08 16:09:15 -07:00
Erik Eckstein
b519d1d873 stdlib: Speed up UTF8View -> Array conversion by using _copyContents 2018-05-08 13:52:05 -07:00
swift-ci
545a6e97bc Merge remote-tracking branch 'origin/master' into master-next 2018-05-08 10:49:30 -07:00
Karoy Lorentey
d1fb8e2683 Merge pull request #16310 from koher/fast-keys-contains
Improve Dictionary.Keys.contains(_:)
2018-05-08 18:31:41 +01:00
swift-ci
477630546a Merge remote-tracking branch 'origin/master' into master-next 2018-05-07 17:09:15 -07:00
Erik Eckstein
f430738b6e stdlib: fix performance regression for long string appends.
Re-wrote the inner memcpy loops so that they can be vectorized.
Also added a few inline(__always).

Since we removed some @inlineable attributes this string-append code is not code generated in the client anymore.
The code generation in the stdlib binary is different because all the precondition checks are not folded away.
Using explicit loop control statements instead of for-in-range removes the precondition-overhead for those time critical memcpy loops.
2018-05-07 14:48:04 -07:00
swift-ci
886c954d97 Merge remote-tracking branch 'origin/master' into master-next 2018-05-07 10:09:22 -07:00
Ben Cohen
f421ec6082 [stdlib] Undeprecate Countable*Range (#16360)
* Undeprecate Countable*Range

* Remove check for deprecation warnings
2018-05-07 09:52:52 -07:00
Nate Cook
f146d17214 Revise documentation, add benchmarks (#3)
* [stdlib] Revise documentation for new random APIs

* [stdlib] Fix constraints on random integer generation

* [test] Isolate failing Random test

* [benchmark] Add benchmarks for new random APIs

Fix Float80 test

Value type generators

random -> randomElement

Fix some docs

One more doc fix

Doc fixes & bool fix

Use computed over explicit
2018-05-04 21:03:50 -05:00
Ben Rimmington
a5df0ef83d Add _stdlib_random for more platforms (#1)
* Remove refs to Countable ranges

* Add `_stdlib_random` for more platforms

* Use `getrandom` (if available) for Android, Cygwin

* Reorder the `_stdlib_random` functions

* Also include <features.h> on Linux

* Add `#error TODO` in `_stdlib_random` for Windows

* Colon after Fatal Error

Performance improvement for Random

gybify ranges

Fix typo in 'basic random numbers'
Add _stdlib_random as a testable method

Switch to generic constraints

Hopefully link against bcrypt

Fix some implementation details

1. Uniform distribution is now uniform
2. Apply Jens' method for uniform floats

Fix a lineable attribute
2018-05-04 21:03:38 -05:00
Azoy
d23d219e95 Add shims for stdlib random
Initial random api

Use C syscall for I/O

1. Fixed an issue where integers would would result in an infinite loop if they were unsigned, or signed integers always returning negative numbers.
2. Fixed an issue with Bool initialization

Add shuffle functions

Add documentation to Random API

Fix a few typos within the documentation

Fixes more typos

Also states that the range for floating points is from 0 to 1 inclusive

Update API to reflect mailing list discussions

Remove unnecessary import

Make sure not to return upperBound on Range

Use SecRandomCopyBytes on older macOS

Update API to match mailing list discussion, add tests

Added pick(_:) to collection
Added random(in:using:) to Randomizable
Added tests

Fix typo in Randomizable documentation

Rename pick to sampling

Move sampling below random

Update docs

Use new Libc naming

Fix Random.swift with new Libc naming

Remove sampling

gybify signed integer creation

Make FloatingPoint.random exclusive

Refactor {Closed}Range.random

Fix FloatingPoint initialization

Precondition getting a random number from range

Fix some doc typos

Make .random a function

Update API to reflect discussion

Make .random a function
Remove .random() in favor of .random(in:) for all numeric types

Fix compile errors

Clean up _stdlib_random

Cleanup around API

Remove `.random()` requirement from `Collection`

Use generators

Optimize shuffle()

Thread safety for /dev/urandom

Remove {Closed}Range<BinaryFloatingPoint>.random()

Add Collection random requirement

Refactor _stdlib_random

Remove whitespace changes

Clean linux shim

Add shuffle and more tests

Provide finishing tests and suggestions

Remove refs to Countable ranges

Revert to checking if T is > UInt64
2018-05-04 21:02:57 -05:00
swift-ci
8ee09ae579 Merge remote-tracking branch 'origin/master' into master-next 2018-05-04 11:09:35 -07:00