Commit Graph

5263 Commits

Author SHA1 Message Date
Saleem Abdulrasool
f58155924c stdlib: repair the Windows build
The recent change to enable the stack traces requires a dependency on
DbgHelp which we were not linking against.  Add the link.
2019-02-21 16:03:53 -08:00
Michael Ilseman
f87960746c Merge pull request #22108 from milseman/en_gadus_offset
[String.Index] Obsolete encodedOffset var/init
2019-02-19 14:43:26 -08:00
Michael Ilseman
de86e4f79e Merge pull request #22663 from milseman/indigenous_characters
[String] Naturalize Character
2019-02-19 10:52:04 -08:00
Michael Ilseman
83e1137e21 [String] Naturalize Character
Characters should always be native, and never shared.
2019-02-15 16:50:38 -08:00
Mike Ash
de805c0112 [Stdlib] Special-case major version 9999 as always available.
rdar://problem/43776049
2019-02-15 16:23:03 -05:00
swift-ci
98543efd03 Merge pull request #22575 from ktoso/wip-SR-9915-ktoso 2019-02-14 16:44:07 -08:00
Michael Ilseman
c4ff5a1a9f [NFC] Update StringObject comments 2019-02-13 20:12:39 -08:00
Michael Ilseman
5ba5be3f43 [String] Speed up UTF-8 initialization from non-stdlib types
Avoid generic code paths if initializing for UTF-8 (the vast majority
of the time) from a non-stdlib type (such as Data).
2019-02-13 20:12:39 -08:00
Michael Ilseman
415cc8fb0c [String.Index] Deprecate encodedOffset var/init
String.Index has an encodedOffset-based initializer and computed
property that exists for serialization purposes. It was documented as
UTF-16 in the SE proposal introducing it, which was String's
underlying encoding at the time, but the dream of String even then was
to abstract away whatever encoding happend to be used.

Serialization needs an explicit encoding for serialized indices to
make sense: the offsets need to align with the view. With String
utilizing UTF-8 encoding for native contents in Swift 5, serialization
isn't necessarily the most efficient in UTF-16.

Furthermore, the majority of usage of encodedOffset in the wild is
buggy and operates under the assumption that a UTF-16 code unit was a
Swift Character, which isn't even valid if the String is known to be
all-ASCII (because CR-LF).

This change introduces a pair of semantics-preserving alternatives to
encodedOffset that explicitly call out the UTF-16 assumption. These
serve as a gentle off-ramp for current mis-uses of encodedOffset.
2019-02-13 18:42:40 -08:00
Konrad `ktoso` Malawski
f2baa7aa73 [docs][SR-9915] Compilation fix of docs snippet of type(of:)
Compilation of code sample snippets was broken due to using the same
identifier as the `type` function itself to store its result resulting
in:

```swift
func printGenericInfo<T>(_ value: T) {
    let type = type(of: value)
    print("'\(value)' of type '\(type)'")
}

// error: repl.swift:2:16: error: variable used within its own initial
// value
//    let type = type(of: value)
//               ^
```

Result:

- Snippets are more copy&paste friendly.
- Resolves https://bugs.swift.org/browse/SR-9915
2019-02-14 11:29:06 +09:00
swift-ci
aead660d91 Merge pull request #22147 from ravikandhadai/consteval-string-append 2019-02-12 16:11:41 -08:00
Andrew Trick
c90838a055 Merge pull request #22541 from atrick/speedup-array-init
Fix performance of array initialization from a generic sequence.
2019-02-12 12:45:30 -08:00
Ben Cohen
f15892c1a8 Merge pull request #22288 from airspeedswift/safe-conversion
[stdlib] Remove overly-permissive UnsafePointer init
2019-02-12 11:47:06 -08:00
swift-ci
498b72270b Merge pull request #22527 from Catfish-Man/literally-empty 2019-02-11 22:35:33 -08:00
Andrew Trick
6d3397337d Fix performance of array initialization from a generic sequence.
This fixes a major perform bug involving array initialization from any
contiguously stored collection.	 This is not a recent regression. This fix
results in a 10,000X speedup (that's 4 zeros) for this code path:

func initializeFromSlice(_ a: [Int]) -> [Int] {
  return Array<Int>(a[...])
}

A benchmark is included.
2019-02-11 19:41:45 -08:00
David Smith
bf32e78737 Make bridged empty NSDictionary and NSSet instances bridge to the empty singletons 2019-02-11 15:54:19 -08:00
David Smith
bf09c28b39 Make empty set literals use the singleton 2019-02-11 15:45:16 -08:00
David Smith
2a9aa16b3f Make empty dictionary literals use the singleton 2019-02-11 15:38:22 -08:00
Andrew Trick
28a529ceed Fix crashes in Unsafe[Raw]BufferPointer with nil baseAddress.
This fix updates various initializers to handle incoming empty buffers
that happen to have a nil base. They should simply create another
buffer with nil base rather than crashing!

It is valid for an Unsafe[Raw]BufferPointer can have a nil base
address. This allows round-tripping with C code that takes a
pointer/length pair and uses `0` as the pointer value.

The original design wrongly assumed that we would use a sentinel value
for empty buffers and was never updated for or tested with the current
design.

Fixes <rdar://problem/47946984> Regression in Foundation.Data's
UnsafeBufferPointer constructor.
2019-02-11 13:38:48 -08:00
Ben Cohen
0f339d3663 Merge branch 'master' into safe-conversion 2019-02-11 12:58:51 -08:00
Michael Ilseman
8dcfac6e87 Merge pull request #22168 from benrimmington/sr-6127
[stdlib] Fix memory leaks in readLine()
2019-02-07 14:25:22 -08:00
Michael Ilseman
9bc5bd26e4 Merge pull request #22417 from milseman/null_and_void
[String] Fix crash when given null UBP
2019-02-07 10:46:01 -08:00
swift-ci
998d9c4b1e Merge pull request #22430 from milseman/whoops 2019-02-06 18:06:26 -08:00
Andrew Trick
fa952d3986 Merge pull request #22338 from atrick/speedup-ubp-subscript
Remove useless optional unwrap from Unsafe[Raw]BufferPointer subscript.
2019-02-06 15:29:00 -08:00
Michael Ilseman
a742a62c18 [String] Use the new value in utf8 setter.
ð
2019-02-06 15:11:17 -08:00
Michael Ilseman
877a20ead0 [String] Fix crash when given null UBP 2019-02-06 14:44:01 -08:00
Scott Perry
45522918ec Header docs for internal methods validateChanges(_:) and init(validatedChanges:) 2019-02-05 14:34:27 -08:00
Michael Ilseman
d376a0f9c9 Merge pull request #21077 from linux-on-ibm-z/s390x-smallstring-v2
[string] Fix string implementation for big endian platforms
2019-02-05 13:36:05 -08:00
Ben Rimmington
7c65c14df7 [stdlib] Fix memory leaks in readLine()
<https://bugs.swift.org/browse/SR-6127>
2019-02-05 03:43:00 +00:00
Scott Perry
b7f36c3399 Include renamed CollectionDifference.swift 2019-02-04 15:37:22 -08:00
Scott Perry
b467e24a9e Apply public documentation and type modifications from proposal acceptance 2019-02-04 13:28:36 -08:00
Andrew Trick
a557976f95 Remove useless optional unwrap from Unsafe[Raw]BufferPointer subscript.
It is unfortunate that `Unsafe[Raw]BufferPointer._pointer` and
`baseAddress` are declared Optional. This leaves extra runtime checks
in the code in the most performance critical paths. Contrast this with
Array, which uses an sentinal pointer for the empty representation.

This forces us to use _unsafelyUnwrappedUnchecked whenever we just
want to dereference a non-empty buffer pointer.

Fixes SR-9809: swiftc appears to make some sub-optimal optimization choices
2019-02-03 21:25:41 -08:00
Ben Cohen
95a15d12bd Revert count(where:) (#22289) 2019-02-01 15:05:06 -08:00
Max Moiseev
91d8615cb9 Merge pull request #22275 from airspeedswift/unsafe-conversion
[stdlib] Restore concrete initializers on Unsafe{Raw}Pointer
2019-02-01 15:04:55 -08:00
Max Moiseev
556e089d19 Merge pull request #22138 from moiseev/spring-cleaning
[stdlib] Remove a bunch of declarations marked as obsoleted in 4
2019-02-01 11:03:37 -08:00
Ben Cohen
c3239b90b4 Neaten breadcrumb cast 2019-01-31 21:09:40 -08:00
Ben Cohen
779ea19a6a Revert count(where:) 2019-01-31 18:57:17 -08:00
Ben Cohen
2010f02e8a Remove overly-permissive UnsafePointer init 2019-01-31 18:05:11 -08:00
Ben Cohen
351c1291a9 Restore concrete initializers on Unsafe{Raw}Pointer 2019-01-31 17:11:16 -08:00
John McCall
8be4ec32e6 Protocol requirement overrides must match in mutating-ness.
Without this change, SILGen will crash when compiling a use of the
derived protocol's requirement: it will instead attempt to use
the base protocol's requirement, but the code will have been
type-checked incorrectly for that.

This has a potential for source-compatibility impact if anyone's
using explicit override checking for their protocol requirements:
reasonable idioms like overriding a mutating requirement with a
non-mutating one will no longer count as an override.  However,
this is arguably a bug-fix, because the current designed intent
of protocol override checking is to not allow any differences in
type, even "covariant" changes like making a mutating requirement
non-mutating.  Moreover, we believe explicit override checking in
protocols is quite uncommon, so the overall compatibility impact
will be low.

This also has a potential for ABI impact whenever something that
was once an override becomes a non-override and thus requires a
new entry.  It might require a contrived test case to demonstrate
that while using the derived entry, but it's quite possible to
imagine a situation where the derived entry is not used directly
but nonetheless has ABI impact.

Furthermore, as part of developing this patch (earlier versions of
which used stricter rules in places), I discovered a number of
places where the standard library was unintentionally introducing
a new requirement in a derived protocol when it intended only to
guide associated type deduction.  Fixing that (as I have in this
patch) *definitely* has ABI impact.
2019-01-30 01:33:09 -05:00
Maxim Moiseev
d00307202b Uncomment 'obsoleted: 5.0' on a flatMap variant 2019-01-29 16:26:46 -08:00
Maxim Moiseev
02cc2256e9 [stdlib] Remove a bunch of declarations marked as obsoleted in 4 2019-01-29 11:13:47 -08:00
Ravi Kandhadai
ee222c3fdf [Constant Evaluator] Add support for string appends and equals to
the constant evaluator.
2019-01-25 18:51:33 -08:00
Saleem Abdulrasool
72f0efe76e Merge pull request #22027 from linux-on-ibm-z/master_s390x_string_comparison
fixed small String comparison for big_endian
2019-01-25 18:32:03 -08:00
Ben Cohen
80f0a697fc Remove a couple of obsoleted-in-4.0 methods 2019-01-25 13:33:21 -08:00
Stephen Canon
3501568fc0 Make SIMD types Codable. (#22092)
* Make SIMD types codable. We're considering this a bugfix.

This is a very tiny ABI change, in that user-defined SIMD types compiled with an earlier version of 5.0 will be missing the necessary conformance to Codable. Discussed with Ben, and we're OK with this because we don't think there are such types yet, and it can be fixed with a recompile.

* Add basic tests
2019-01-24 23:08:29 -05:00
Ravi Kandhadai
a0277e2010 [stdlib] Fixing a buggy example in the comments in the file UnsafeRawPointer.swift 2019-01-23 13:08:47 -08:00
Xiaodi Wu
870dae5204 [docs] hasPrefix and hasSuffix don't match scalars (#22056) 2019-01-23 10:21:55 -06:00
Michael Ilseman
81e87ac838 Merge pull request #21959 from milseman/fast_foundation
[String] Add UTF-8 fast-paths for Foundation initializers
2019-01-22 16:26:36 -08:00
Michael Ilseman
3df92911f9 [String] Speed up ASCII checking.
Perform ASCII checking using pointer-width strides, making sure to
align properly.
2019-01-22 15:06:03 -08:00