Commit Graph

4464 Commits

Author SHA1 Message Date
Karoy Lorentey
7e66a38af8 [stdlib] De-gyb SipHash; implement full Hasher API 2018-04-18 17:33:24 +01:00
Joe Groff
62771a0c9d stdlib: Add withUnsafeBytes(of:) and withUnsafePointer(to:) for immutable arguments.
Since the functions produce pointers with tightly-scoped lifetimes there's no formal reason these have to only work on `inout` things.  Now that arguments can be +0, we can even do this without copying values that we already have at +0.
2018-04-18 09:13:45 -07:00
Karoy Lorentey
ccdc218cbd [stdlib] _Hasher: append => combine 2018-04-18 14:18:44 +01:00
swift-ci
563d33a207 Merge remote-tracking branch 'origin/master' into master-next 2018-04-17 15:49:54 -07:00
Ben Cohen
ca7aea02e9 [stdlib] Add compatibility typealias for CountablePartialRangeFrom (#15989)
* Add compatibility typealias for CountablePartialRangeFrom
2018-04-17 15:48:54 -07:00
swift-ci
51d049d9bd Merge remote-tracking branch 'origin/master' into master-next 2018-04-17 15:09:51 -07:00
Karoy Lorentey
6c5a6a6a16 [stdlib] Make sure _SwiftNewtypeWrapper hashes the same way as its RawValue
_SwiftNewtypeWrapper forwarded hashValue to its rawValue, but it failed to do the same for _hash(into:), which resulted in the wrapper struct having subtly different hashing than the raw value.

This violated an implicit invariant when dictionaries/sets of such types were bridged to Objective-C through AnyHashable, leading to nondeterministic but frequent crashes.

rdar://problem/39398060
2018-04-17 22:04:55 +01:00
swift-ci
1261e6b6dd Merge remote-tracking branch 'origin/master' into master-next 2018-04-12 15:20:06 -07:00
Max Moiseev
02aef12281 Merge pull request #15815 from Moximillian/SR-7266-avoid-nesting-reversed
SR-7266: Avoid nesting of ReversedCollection
2018-04-12 15:05:54 -07:00
swift-ci
ba62fe78a1 Merge remote-tracking branch 'origin/master' into master-next 2018-04-11 13:32:51 -07:00
Michael Gottesman
f5ed323b7d Merge pull request #15865 from gottesmm/pr-64a51a9306ab1faab72f4e6bb58d6d062f984dcf
Add build-script flag --enable-exclusivity-checking to enable exclusi…
2018-04-11 13:15:09 -07:00
Nate Cook
69ce965881 Merge pull request #15794 from natecook1000/nc-fixes-83-1
[stdlib] Documentation revisions
2018-04-11 15:07:04 -05:00
swift-ci
09541e4da8 Merge remote-tracking branch 'origin/master' into master-next 2018-04-11 13:06:58 -07:00
Nate Cook
61c79f33c0 [stdlib] Address feedback from @airspeedswift and @CodaFi 2018-04-11 13:03:36 -05:00
Nate Cook
a63f5bf788 [stdlib] Revise masking shift and unsafe operation docs 2018-04-11 11:34:59 -05:00
Nate Cook
b6a0d9ed26 [stdlib] Documentation revisions
- Make RawRepresentable Codable abstracts distinguishable
- Make the UnboundedRange example a little more user friendly
- Correct the RangeReplaceableCollection example description
- Revise CaseIterable discussion
2018-04-11 11:34:51 -05:00
Michael Gottesman
e071e46068 Add build-script flag --enable-exclusivity-checking to enable exclusivity checking always when we compile stdlibCore.
It is off by default.

rdar://39335800
2018-04-11 09:23:06 -07:00
swift-ci
533c77156e Merge remote-tracking branch 'origin/master' into master-next 2018-04-11 08:07:02 -07:00
Karoy Lorentey
cff4eb77ef [stdlib] {Set,Dictionary}.init(minimumCapacity:) Update docs
Avoid describing the exact algorithm that these collections use to allocate storage. (It is a private implementation detail that we want to be able to change.)

rdar://problem/36619317
2018-04-11 12:25:51 +01:00
swift-ci
e0ef0a8300 Merge remote-tracking branch 'origin/master' into master-next 2018-04-10 13:12:33 -07:00
Mox
b859cdc173 SR-7266: Avoid nesting of ReversedCollection
Applying reversed() two times should return identity.
2018-04-10 17:06:14 +03:00
crea
247ee7a82f fix documentation comment of flatMap<SegmentOfResult : Sequence> 2018-04-10 01:20:15 -07:00
swift-ci
6eb8aa31e2 Merge remote-tracking branch 'origin/master' into master-next 2018-04-09 19:25:09 -07:00
Slava Pestov
14654590dc stdlib: remove some @_inlineable that snuck in recently 2018-04-09 18:00:58 -07:00
swift-ci
906bf7c41a Merge remote-tracking branch 'origin/master' into master-next 2018-04-09 12:29:46 -07:00
swift-ci
65b22697ae Merge pull request #15770 from dcci/refcount-obj 2018-04-09 12:12:32 -07:00
swift-ci
c79b2f5eb3 Merge remote-tracking branch 'origin/master' into master-next 2018-04-06 17:46:16 -07:00
swift-ci
3430f38563 Merge pull request #11576 from airspeedswift/remove-elements 2018-04-06 17:45:54 -07:00
Davide Italiano
6535d8cec8 [DebuggerSupport] Expose a way to query the reference counts.
lldb will use it to reimplement `language swift refcount <obj>`
which is currently not working. Asking the compiler allows us
to avoid maintinaing a bunch of information in the debugger which
are likely to change and break.

<rdar://problem/30538363>
2018-04-06 13:12:53 -07:00
swift-ci
430744b2f3 Merge remote-tracking branch 'origin/master' into master-next 2018-04-06 12:12:17 -07:00
Tony Allevato
95dc229d17 [stdlib] Fix age property and update case mappings
Using &foo.0 is not a suitable shortcut for getting a mutable
pointer to the first element of a tuple.
2018-04-06 06:29:50 -07:00
Slava Pestov
2e5aef9c8d stdlib: Remove redundant @usableFromInline attributes 2018-04-06 00:02:30 -07:00
swift-ci
880857452c Merge remote-tracking branch 'origin/master' into master-next 2018-04-05 15:59:28 -07:00
Slava Pestov
61280ef951 stdlib: @_versioned was renamed to @usableFromInline 2018-04-05 14:31:47 -07:00
swift-ci
71503c41f6 Merge remote-tracking branch 'origin/master' into master-next 2018-04-04 11:34:02 -07:00
Mark Lacey
e137da5184 Merge pull request #15730 from rudkx/rdar33781464
stdlib: Collapse some multi-line closures to single-line closures.
2018-04-04 11:27:06 -07:00
swift-ci
df70a77b65 Merge remote-tracking branch 'origin/master' into master-next 2018-04-04 00:29:13 -07:00
Tony Allevato
f06af77e01 [stdlib] Lift case mappings directly into Unicode.Scalar 2018-04-03 23:02:15 -07:00
Mark Lacey
32d006de4a stdlib: Collapse some multi-line closures to single-line closures.
The change in CheckMutableCollectionType.swift.gyb previously resulted
in a runtime failure, and before that a compiler crash.

It appears that whatever type checker bug(s) were causing the issue
have been resolved in the last few months, so I'm returning this
closure to a single-expression form and cleaning up a couple other
places where we had an unneeded temporary as well.

Resolves rdar://problem/33781464.
2018-04-03 22:26:33 -07:00
Tony Allevato
56d04befd1 [stdlib] Rewrite _scalarName to fully use a small string 2018-04-03 19:20:38 -07:00
Pavel Yaskevich
78822bc23e [IRGen] Adjust element size of offset vector to 32-bit for structs
Type of elements contained by field offsets vector can be adjusted
to 32-bit integers (from being pointer sized) to safe space in the
binary since segment size is limited to 4 GB.

Resolves: rdar://problem/36560486
2018-04-03 13:32:06 -07:00
swift-ci
e65bed999f Merge remote-tracking branch 'origin/master' into master-next 2018-04-03 11:43:13 -07:00
Jordan Rose
9be6519f5a [SILGen] Show a message when an unexpected enum value is switched on (#15614)
Builds on 36eae9d4f6 to emit a message instead of just trapping
when a switch over a non-frozen enum ends up not matching anything.
If the enum is known to be an @objc enum, the message is

  unexpected enum case 'MyEnum(rawValue: -42)'

and if it's anything else (a Swift enum, a tuple containing enums,
whatever), it's a more opaque

  unexpected enum case while switching on value of type 'MyEnum'

The reason for this is to avoid calling String(describing:) or
String(reflecting:) an arbitrary value when the enum might conform to
CustomStringConvertible and therefore /itself/ have a switch that's
going to fall off the end. By handling plain @objc enums (using a
bitcast), we've at least covered the 90% case.

rdar://problem/37728359
2018-04-03 11:21:36 -07:00
Tony Allevato
47deadc2fb [stdlib] Compute scalar's UTF-16 on demand instead of caching 2018-04-02 21:38:54 -07:00
Tony Allevato
5a7d7d3929 [stdlib] Update case mappings to use small strings if possible 2018-04-02 21:12:08 -07:00
Tony Allevato
4a1794074a [stdlib] Update documentation for case mappings 2018-04-01 19:41:43 -07:00
Tony Allevato
5807bb9436 [stdlib] Fix _scalarName to use small string if possible 2018-04-01 19:29:26 -07:00
swift-ci
eca55d95da Merge remote-tracking branch 'origin/master' into master-next 2018-04-01 17:09:25 -07:00
tbkka
97a934c412 SR-106: New floating-point description implementation (#15474)
* SR-106: New floating-point `description` implementation

This replaces the current implementation of `description` and
`debugDescription` for the standard floating-point types with a new
formatting routine based on a variation of Florian Loitsch' Grisu2
algorithm with changes suggested by Andrysco, Jhala, and Lerner's 2016
paper describing Errol3.

Unlike the earlier code based on `sprintf` with a fixed number of
digits, this version always chooses the optimal number of digits.  As
such, we can now use the exact same output for both `description` and
`debugDescription` (except of course that `debugDescription` provides
full detail for NaNs).

The implementation has been extensively commented; people familiar with
Grisu-style algorithms should find the code easy to understand.

This implementation is:

* Fast.  It uses only fixed-width integer arithmetic and has constant
  memory and time requirements.

* Simple. It is only a little more complex than Loitsch' original
  implementation of Grisu2.  The digit decomposition logic for double is
  less than 300 lines of standard C (half of which is common arithmetic
  support routines).

* Always Accurate. Converting the decimal form back to binary (using an
  accurate algorithm such as Clinger's) will always yield exactly the
  original binary value.  For the IEEE 754 formats, the round-trip will
  produce exactly the same bit pattern in memory.  This is an essential
  requirement for JSON serialization, debugging, and logging.

* Always Short.  This always selects an accurate result with the minimum
  number of decimal digits.  (So that `1.0 / 10.0` will always print
  `0.1`.)

* Always Close.  Among all accurate, short results, this always chooses
  the result that is closest to the exact floating-point value. (In case
  of an exact tie, it rounds the last digit even.)

This resolves SR-106 and related issues that have complained
about the floating-point `description` properties being inexact.

* Remove duplicate infinity handling

* Use defined(__SIZEOF_INT128__) to detect uint128_t support

* Separate `extracting` the integer part from `clearing` the integer part

The previous code was unnecessarily obfuscated by the attempt to combine
these two operations.

* Use `UINT32_MAX` to mask off 32 bits of a larger integer

* Correct the expected NaN results for 32-bit i386

* Make the C++ exceptions here consistent

Adding a C source file somehow exposed an issue in an unrelated C++ file.
Thanks to Joe Groff for the fix.

* Rename SwiftDtoa to ".cpp"

Having a C file in stdlib/public/runtime causes strange
build failures on Linux in unrelated C++ files.

As a workaround, rename SwiftDtoa.c to .cpp to see
if that avoids the problems.

* Revert "Make the C++ exceptions here consistent"

This reverts commit 6cd5c20566.
2018-04-01 16:52:48 -07:00
Tony Allevato
fb9f7ecca1 Merge branch 'master' into unicode-properties 2018-03-31 09:54:18 -07:00