Commit Graph

8969 Commits

Author SHA1 Message Date
Xi Ge
d9fb110674 Revert "[stdlib] String index interchange, etc." (#10812)
rdar://33186295
2017-07-07 12:03:16 -07:00
Dave Abrahams
0a483187b1 Merge pull request #10740 from apple/fix-unsafebufferpointer-_copyContents
[stdlib] Correct UnsafeBufferPointer._copyContents
2017-07-07 10:39:22 -07:00
Itai Ferber
9f7506f002 Allow application of JSON strategies in all cases
One of the limitations of not having conditional conformance at the
moment is that the implementation of `init(from:)` and `encode(to:)` on
types which require it is that failure to cast dependent types to
`Encodable` or `Decodable` is a runtime failure. There is no way to
statically guarantee that the wrapped type is `Encodable` or
`Decodable`.

As such, in those implementations, at best we can directly call
`(element as! Encodable).encode(to: encoder)`, or similar. However, this
encodes the element directly into an encoder, without giving the encoder
a chance to intercept the type. This is problematic for `JSONEncoder`
because it cannot apply a strategy if it doesn't get to intercept the
type.

This gives a temporary workaround for JSON strategies because of
internal Foundation knowledge.
2017-07-07 09:38:07 -07:00
swift-ci
844cce79cb Merge pull request #10809 from uunlu/master 2017-07-07 09:27:19 -07:00
Ugur Unlu
f441f53e65 [stdlib] Correct UnsafeRawPointer.bindMemory example 2017-07-07 15:29:03 +02:00
Dave Abrahams
283775ed1f [stdlib] Rebuild String.Index for UTF8View 2017-07-07 06:15:26 -07:00
Dave Abrahams
576b8de64a [stdlib] Speed String.UTF8View.count even more 2017-07-07 06:15:26 -07:00
Dave Abrahams
cf09e6b383 [stdlib] UTF8View: count by iterating
The fancy code didn't turn out to be any faster.
2017-07-07 06:15:26 -07:00
Dave Abrahams
dd3fb9b71d [stdlib] Small correction to UTF8 Iterator
This works either way I suppose, but the code is clearer now.
2017-07-07 06:15:25 -07:00
Dave Abrahams
189f1660fd [stdlib] Foundation SPI fixup 2017-07-07 06:15:25 -07:00
Dave Abrahams
b21fa4575a [stdlib] UTF8View Iterator and count specialization 2017-07-07 06:15:25 -07:00
Dave Abrahams
d94297ced1 [stdlib] Bring back some SPI that Foundation-on-linux uses. 2017-07-07 06:15:24 -07:00
Nate Cook
b9f3a2ae47 [stdlib] Minimal docs for the new string index 2017-07-07 06:15:24 -07:00
Dave Abrahams
b1d2f4c68e [stdlib] String index interchange, part III (UTF8) 2017-07-07 06:15:24 -07:00
Dave Abrahams
2e0bb2f533 [stdlib] String index interchange, part II (UTF16) 2017-07-07 06:15:23 -07:00
Dave Abrahams
e523c80339 [stdlib] Index interchange, part I 2017-07-07 00:59:04 -07:00
Joe Groff
101788dbd4 IRGen: Support for computed properties with dependent generic context.
Use the KeyPath implementation's new support for instantiating and dealing with captures to lower the generic context required to dispatch computed accessors with dependent generics.
2017-07-06 20:07:41 -07:00
Joe Groff
c142e7d953 KeyPaths: Support captured arguments in computed components.
A necessary precursor to supporting subscripts and unspecialized generic accessors in general. Give get/set components the ability to have an "argument" area that gets instantiated by copying out of the key path pattern arguments at instantiation time, and which holds "witness" information for how to copy, destroy, equate, and hash arguments.
2017-07-06 20:07:41 -07:00
Philippe Hausler
56f509f059 [Foundation] Merge sequence initializer fast paths into one initializer 2017-07-06 19:24:17 -07:00
Xiaodi Wu
5d731c8a93 Make a fix-up to account for operator precedence 2017-07-06 20:01:09 -05:00
Maxim Moiseev
764d7d42fb Merge pull request #10791 from moiseev/no-rrc-string
[stdlib] StringProtocol no longer refines RangeReplaceableCollection
2017-07-06 13:48:19 -07:00
Philippe Hausler
a842c6d43d [Foundation] Update Data sequence initializer to use initialize(from:) and add _copyContents 2017-07-06 09:45:53 -07:00
Philippe Hausler
aeb61e361b [Foundation] Add fast paths for Data initialization for common sequences 2017-07-06 09:45:53 -07:00
Max Moiseev
1a1c1a0d21 [stdlib] StringProtocol no longer refines RangeReplaceableCollection
https://bugs.swift.org/browse/SR-5379
2017-07-06 09:40:10 -07:00
Xiaodi Wu
590ce5314d Restore indentation (partially) 2017-07-06 00:15:17 -05:00
Xiaodi Wu
3528479730 Silence compiler warnings 2017-07-05 23:56:44 -05:00
Xiaodi Wu
6ae074acfa [stdlib] Silence a compiler warning [NFC]
This PR updates `_FixedArray${N}` to conform to `ExpressibleByIntegerLiteral` rather than `IntegerLiteralConvertible`. This silences a compiler warning (actually, several).
2017-07-05 20:11:52 -05:00
Maxim Moiseev
f2dbd65fec Merge pull request #10713 from ktopley-apple/dispatch-sync-fixup
Fix warnings in DispatchQueue.sync() implementation when using a comp…
2017-07-05 09:42:42 -07:00
Itai Ferber
a8ba0772cd Merge pull request #10728 from itaiferber/non-optional-coding-paths
Make coding paths non-optional [DO NOT MERGE]
2017-07-01 14:34:40 -07:00
Dave Abrahams
dc904d1378 [stdlib] Drop a premature @inline(__always) 2017-06-30 19:33:05 -07:00
Dave Abrahams
4ff733202a [stdlib] Correct UnsafeBufferPointer._copyContents
The implementation imposed stricter requirements on its inputs than those allowed by Sequence
2017-06-30 19:28:05 -07:00
Michael Ilseman
091738cf97 Merge pull request #10693 from milseman/zalgorithmic_complexity
[stdlib] Update non-contiguous NSStrings to Unicode 9
2017-06-30 14:13:39 -07:00
Itai Ferber
e1007a2e3b Make coding paths non-optional
For the benefit of unkeyed containers, coding paths currently contain optional `CodingKey`s — unkeyed containers are allowed to report a `nil` key in a path. However, this is unhelpful for debugging purposes, or inspecting the coding path for context, since any unkeyed container simply reports `nil`, whether it’s at index 1 or 1000.

Now all containers are required to report a non-optional CodingKey for their segment of the coding path, and coding paths are now exposed as `[CodingKey]`.
2017-06-30 12:43:40 -07:00
Kim Topley
6194f37e1a Fix warnings in DispatchQueue.sync() implementation when using a compiler with SE-0176 support. 2017-06-30 08:45:15 -07:00
Andrew Trick
91405a7f91 Remove the hash function from the runtime's exclusive access checks.
I expect this to improve the following Onone benchmarks:
- 1.09x accessGlobal
- 1.08x accessInMatSet
- 1.06x accessIndependent

And the preexisting benchmarks:

| TEST                    | DELTA | SPEEDUP   |
|                         |       |           |
| Random                  | -7.9% | **1.09x** |
| MatMul                  | -7.6% | **1.08x** |
| XorShift                | -7.2% | **1.08x** |
| PolymorphicCalls        | -6.2% | **1.07x** |
| NopDeinit               | -6.1% | **1.06x** |
| Ary                     | -6.0% | **1.06x** |
| Integrate               | -5.8% | **1.06x** |
| StringWalk              | -5.5% | **1.06x** |
| ArrayInClass            | -5.2% | **1.06x** |
| MultiFileTogether       | -5.2% | **1.06x** |
| DictionaryHashableClass | -5.2% | **1.05x** |
| MultiFileSeparate       | -4.9% | **1.05x** |
2017-06-29 16:32:35 -07:00
Itai Ferber
aa91b7273d Merge pull request #10667 from itaiferber/codable-encode-decode-nil-changes
Optionality updates to Codable API
2017-06-29 13:15:25 -07:00
Itai Ferber
b40c0bd3db Merge pull request #10685 from itaiferber/codingerror-bridging-and-conveniences
EncodingError/DecodingError bridging fixes and conveniences
2017-06-29 10:05:35 -07:00
Kuba (Brecka) Mracek
4b88da2a2c Use the debugger hook, reportToDebugger, for all calls to _swift_stdlib_reportFatalError[InFile]. Only do this when a hidden frontend flag, -report-errors-to-debugger, is used. (#10617) 2017-06-29 09:12:26 -07:00
Itai Ferber
0696b963da Merge pull request #10680 from itaiferber/jsonencoder-deferred-to-data
JSONEncoder data encoding strategy tweaks
2017-06-28 16:01:20 -07:00
Michael Ilseman
a3e892fca5 [stdlib] Relax ephemeralString sanity check
Creating an ephemeral string from a non-contiguous substring does not
reuse the same storage. Relax a sanity check assuming that it did.
2017-06-28 15:48:17 -07:00
Michael Ilseman
5bc20cba08 [stdlib] Clean up non-contiguous string grapheme breaking code.
Removes the legacy grapheme breaking code paths. Simplifies and
clarifies the non-contiguous grapheme breaking code through consistent
naming and handling of absolute positions vs relative offsets.
2017-06-28 15:46:44 -07:00
Michael Ilseman
b3b28e0c50 [gardening] 80 columns; NFC 2017-06-28 15:46:39 -07:00
Michael Ilseman
a37a823e6e [stdlib] Update non-contiguous NSStrings to Unicode 9
This adds Unicode 9 grapheme breaking support for non-contiguous
NSStrings. Non-contiguous NSStrings that don't hit our fast paths are
very rare, but should still behave identically to contiguous
strings.

We first copy a fixed number of code units into a fixed size buffer
(currently 16 in size) and try to grapheme break inside of that
buffer. This is sufficient storage for all known non-pathological
graphemes. Any graphemes larger than the buffer are handled by copying
larger portions of the string into an Array.

Test cases added, including pathological "zalgo" text that stresses
extremely long graphemes.
2017-06-28 15:35:25 -07:00
Itai Ferber
cf0ebc195d Expose underlying serialization errors
If JSONSerialization or PropertyListSerialization throw errors during encoding or decoding, the error should be exposed as an EncodingError or DecodingError
2017-06-28 15:10:19 -07:00
Itai Ferber
f088cfbdfe Add DecodingError.dataCorrupted conveniences
DecodingError.dataCorrupted is an error most commonly thrown from user code. We can expose conveniences to more easily throw .dataCorrupted errors.
2017-06-28 14:34:35 -07:00
Itai Ferber
92fccf964b Fix coding error bridging to NSError
CustomNSError briding only works when the CustomNSError conformance is in the same module as the original error declaration. We need to sink these down into the standard library.
2017-06-28 14:33:15 -07:00
Itai Ferber
8f38678911 Expose underlyingError on coding errors
Some errors are caused by others — this allows us to expose the underlying problem.
2017-06-28 14:31:53 -07:00
Itai Ferber
850b21f50d JSONEncoder data encoding strategy tweaks
* Add deferredToData strategy on encode and decode
* Rename base64{Encode,Decode} to base64 (missed this in previous fixes)
* Add unit test to confirm behavior
2017-06-28 14:17:23 -07:00
swift-ci
4830841139 Merge pull request #10359 from CodaFi/cygni-imperator 2017-06-28 14:00:26 -07:00
Robert Widmann
0cf1b52452 Treat Cygwin as a separate OS
Cygwin is considered a distinct target with a distinct ABI, environment
conditions, and data types.  Though the goal of the project is
native Windows integration with UNIX-likes, that is not compatible with
the idea that the platform can be ignored as Win-like enough to have the
existing os(Windows) condition apply.
2017-06-28 13:31:05 -07:00