Commit Graph

5543 Commits

Author SHA1 Message Date
Dmitri Hrybenko
581e853428 stdlib: make filter() a protocol requirement for range replaceable collections
This allows array types to get the best performance.  The default
implementation for range replaceable collections appends elements one by
one, and the optimizer can't hoist uniqueness checks from the loop in
that case yet.

Swift SVN r27314
2015-04-15 05:17:28 +00:00
Dmitri Hrybenko
0af19e7ff3 stdlib: use unsafeBitCast to implement map() and filter() on top of lazy()
Array(other_collection) is using an optimized code path for copying
collections.  An explicit for loop does not.

This commit should recover the performance regression in
rdar://20530390.

Swift SVN r27313
2015-04-15 05:17:27 +00:00
Dmitri Hrybenko
c4b82718d5 stdlib: correct comment
Swift SVN r27312
2015-04-15 05:17:20 +00:00
Dmitri Hrybenko
f1de46300a stdlib: move readLine() API to the core standard library
This API has passed API review.

rdar://15911365

Swift SVN r27287
2015-04-14 20:30:12 +00:00
Dmitri Hrybenko
6e09dad1e6 stdlib: move sequence and collection algorithms to topic-centered files
Swift SVN r27273
2015-04-14 07:03:49 +00:00
Dmitri Hrybenko
d267b86cb6 stdlib: move the bulk of SequenceType algorithms to protocol extensions
rdar://19895265

Swift SVN r27269
2015-04-14 01:53:19 +00:00
Dmitri Hrybenko
a03680e7fd stdlib: print struct members, in addition to the type name
Swift SVN r27250
2015-04-13 07:22:36 +00:00
Dmitri Hrybenko
5bb6490636 stdlib: when doing ad-hoc printing, use the debug representation
Swift SVN r27249
2015-04-13 06:04:13 +00:00
Dmitri Hrybenko
29b15adff1 stdlib: make println() output atomic within one call
rdar://17016326

Swift SVN r27248
2015-04-13 05:51:47 +00:00
Joe Groff
7612df1918 Runtime: Rename 'becomeNSError' to 'bridgeErrorTypeToNSError'.
We may want to use optimized ErrorType representations that don't naturally "become" NSErrors, such as tagged-pointer representations of small error enums, or a tagged function pointer to a deferred error type constructor. Rename the runtime function to something a bit more descriptive of its real purpose, not its implementation.

Swift SVN r27209
2015-04-10 17:37:40 +00:00
Dave Abrahams
3cebb1444c [stdlib] Make staging typealiases public
Really unbreak external projects this time!

Swift SVN r27187
2015-04-09 22:43:14 +00:00
Roman Levenstein
d1698ba1cb Use a _bridgeable suffix for newly introduced fast bridging functions. NFC.
Dave explained that stdlib usually uses the suffix notation in such cases. This change follows his advice.

Swift SVN r27177
2015-04-09 20:59:42 +00:00
Erik Eckstein
4c2ce1ee84 stdlib: some simplifications in Arrays.swift.gyb source code.
It's not just refactoring. It is a functional change. But it should not have a significant effect on performance.



Swift SVN r27168
2015-04-09 15:49:58 +00:00
Erik Eckstein
36fae15313 stdlib: rewrite Array.append to simplify the generated SIL code.
Swift SVN r27167
2015-04-09 15:37:14 +00:00
Dmitri Hrybenko
c8af957f08 stdlib: fix a typo in comments
Swift SVN r27161
2015-04-09 04:45:37 +00:00
Dmitri Hrybenko
9c03811987 stdlib: add initializers from String to integer and floating-point types
rdar://17232531

Swift SVN r27159
2015-04-09 03:20:41 +00:00
Roman Levenstein
8341a4f5b3 As suggested by DaveA, remove useless information, which just repeats the declaration. NFC.
Swift SVN r27158
2015-04-09 02:35:28 +00:00
Erik Eckstein
43d41147a6 stdlib: implement nativeOwner in all array buffers to avoid %else in Arrays.swift.gyb. NFC.
Swift SVN r27133
2015-04-08 19:48:48 +00:00
Erik Eckstein
d79078a391 stdlib: fix coding style in ArrayBuffer
Swift SVN r27131
2015-04-08 19:24:39 +00:00
Dave Abrahams
72585a7bdd [stdlib] Restore GeneratorOf/SequenceOf for staging
Let's keep internal projects building for a while

Swift SVN r27128
2015-04-08 18:10:19 +00:00
Dave Abrahams
5671f7399d [stdlib] fix comments
Swift SVN r27127
2015-04-08 17:40:49 +00:00
Dave Abrahams
4400bce00a Revert "[stdlib] Workaround for <rdar://20409234>"
This reverts commit r27091 because Doug fixed the underlying bug.

Swift SVN r27126
2015-04-08 17:38:55 +00:00
Dave Abrahams
00bc80b5d0 [stdlib] Bring back toString & co. for staging
Renaming broke external projects and we want to handle this more
smoothly.

Swift SVN r27125
2015-04-08 15:26:25 +00:00
Erik Eckstein
ddb25915b6 stdlib: Avoid a isNative check in _getOwner in the Array's mutableAddressWithPinnedNativeOwner
When calling _getOwner at this point we know that it is a native array.
This simplifies the SIL code for assigning a class array element (a[i] = x).



Swift SVN r27124
2015-04-08 09:54:04 +00:00
Erik Eckstein
10166ba228 stdlib: return the correct buffer property in _getArrayPropertyIsNative
As _getArrayPropertyIsNative is not use yet, there is NFC.



Swift SVN r27123
2015-04-08 09:32:36 +00:00
Dmitri Hrybenko
e5ca5f5952 stdlib: remove unused typealias that was added by mistake
Swift SVN r27114
2015-04-08 00:41:21 +00:00
Roman Levenstein
3effd6fcf7 Introduce two new compiler-known library functions for performing bridging casts when conformances are known statically.
We define two new library functions _knownForceBridgeFromObjectiveC/_knownConditionallyBridgeFromObjectiveC, similar to _forceBridgeFromObjectiveC/_conditionallyBridgeFromObjectiveC. The main difference is that they require their arguments to conform to _BridgedToObjectiveC and _BridgedToObjectiveC. _ObjectiveCType accordingly. With this change, it is now possible to invoke the _BridgedToObjectiveC._forceBridgeFromObjectiveC witness directly, without going via the inefficient swift_bridgeNonVerbatimFromObjectiveC.

So now, for a cast O -> S, if it can be statically proven that an ObjC type O is bridgeable to a Swift type S implementing the _BridgedToObjectiveC protocol (i.e. O is the class (or its subclass) defined by the S._ObjectiveCType alias), we can generate a code to invoke the newly defined library function _knownForceBridgeFromObjectiveC/_knownConditionallyBridgeFromObjectiveC instead of _forceBridgeFromObjectiveC/_conditionallyBridgeFromObjectiveC.

After inlining, this will end-up invoking  S._forceBridgeFromObjectiveC directly instead of invoking a more general, but less effective swift_bridgeNonVerbatimFromObjectiveC, which always performs conformance checks at runtime, even if conformances are known statically. As a result, no conformance checks are performed at run-time if conformances are known statically.

The client code making use of these new APIs and the tests are coming in the subsequent commits.

The naming of the two new helper library functions was discussed with Dmitri.

This is part of the bridging casts optimization effort. And it is specifically useful for e.g. rdar://19081345.

Swift SVN r27100
2015-04-07 22:53:55 +00:00
Dave Abrahams
0464c3d957 [stdlib] [Generator|Sequence]Of => Any[Generator|Sequence]
Retire the old components now that the new ones have passed API review.

<rdar://20406937> covers the migration fallout of this change.

Swift SVN r27092
2015-04-07 20:32:31 +00:00
Dave Abrahams
858b1223a6 [stdlib] Workaround for <rdar://20409234>
Doug will revert this any second now when he checks in his fix

Swift SVN r27091
2015-04-07 20:32:30 +00:00
Dave Abrahams
ac3f047496 [stdlib] Renaming fallout from Mirror API review
toString(x)      => String(x)
toDebugString(x) => String(reflecting: x)
Printable        => CustomStringConvertible
DebugPrintable   => CustomDebugStringConvertible

Also updated comments to clarify these protocols

Swift SVN r27090
2015-04-07 20:32:26 +00:00
Michael Gottesman
2c143aee96 Revert "[stdlib] [Generator|Sequence]Of => Any[Generator|Sequence]"
This reverts commit r27081. It broke the build.

Swift SVN r27086
2015-04-07 17:21:03 +00:00
Doug Gregor
6fe861474c Revert "[stdlib] Workaround for <rdar://20409234>"
This reverts r27080; the workaround is no longer necessary.

Swift SVN r27085
2015-04-07 16:40:18 +00:00
Dave Abrahams
367b2e40f0 [stdlib] Mirror -> public/core
The new mirror design passed our API review and blocking bugs have been
fixed/worked-around, so integrating it into the core standard library.

Swift SVN r27082
2015-04-07 15:33:49 +00:00
Dave Abrahams
a80b1a4caa [stdlib] [Generator|Sequence]Of => Any[Generator|Sequence]
Retire the old components now that the new ones have passed API review.

<rdar://20406937> covers the migration fallout of this change.

Swift SVN r27081
2015-04-07 15:20:40 +00:00
Dave Abrahams
ed5156e3ee [stdlib] Workaround for <rdar://20409234>
Doug will revert this any second now when he checks in his fix

Swift SVN r27080
2015-04-07 15:12:12 +00:00
Dave Abrahams
4ba169ae16 [stdlib] ExistentialCollection -> public/core
It passed our API review so integrating it into the core standard
library.

Swift SVN r27079
2015-04-07 15:12:10 +00:00
Dmitri Hrybenko
1b9ca12c5b stdlib: remove old declarations that were marked unavailable
rdar://20169533

Swift SVN r27020
2015-04-05 09:15:49 +00:00
Dmitri Hrybenko
ff2dd6320a stdlib: fix coding style
When colon specifies is-a relationship between types, we put spaces on
both sides of the colon.

Swift SVN r27016
2015-04-05 05:54:55 +00:00
Joe Groff
66ae68bcc3 Sema: Allow ErrorType-conforming types to be explicitly coerced 'as NSError'.
Swift SVN r26993
2015-04-04 22:38:04 +00:00
Erik Eckstein
78a3572fa4 Rename NoDTC to NoTypeCheck. NFC.
Swift SVN r26973
2015-04-04 08:24:59 +00:00
Joe Groff
b2cb75ad30 Runtime: Add a 'swift_becomeNSError' entry point to coerce an ErrorType box to an NSError instance.
If the NSError part of the box hasn't been initialized yet, fill it in with the domain and code of the contained value. This will allow us to efficiently turn ErrorType values into NSErrors, either for bridging or for coercion purposes.

Swift SVN r26958
2015-04-03 22:16:52 +00:00
Nadav Rotem
7ebd9f1adc Mark methods in protocol extension as final.
Swift SVN r26948
2015-04-03 19:29:20 +00:00
Ben Langmuir
0c120e5914 Reapply r26926 after fixing SourceKit test
r26926 was reverted in r26930 because of a SourceKit failure, that was
fixed in r26945.

Swift SVN r26946
2015-04-03 19:04:50 +00:00
Erik Eckstein
4c4b9abd99 stdlib: avoid masking out the array buffer spare bits if we know that they are zero.
Swift SVN r26938
2015-04-03 14:14:56 +00:00
Erik Eckstein
2f971c22cb re-apply r26871: stdlib: Do the Array fast-path check with a single array property call.
Changes compared to the original version:
I fixed the 2 bugs and added a test for the so far undetected missing range check bug.
To keep the SIL simple (4 basic blocks for arr[x]) I extracted the slow path for getElement into a
non-inlinable function.
On the other hand I inlined _typeCheck into the slow-path function.
This speeds up NSArray accesses because now only a single objectAtIndex is required for both
type checking and element retrieving.

Update on performance: DeltaBlue is now only 12% better (and not 25%). I suspect this is because
now Arnold's tail duplication cannot detect the ObjC call in the slow path.



Swift SVN r26935
2015-04-03 06:48:25 +00:00
Greg Parker
f9ca55df0f Revert r26926 which broke a SourceKit test.
Swift SVN r26930
2015-04-03 03:54:12 +00:00
Dave Abrahams
17de46f1c9 [stdlib] ExistentialCollection: perf de-regression
The performance regression that occurred when ++ and -- were added as
requirements to the Index protocols was due to the fact that it caused a
dubious hack of mine to be bypassed: when treated as indices, integer
types are incremented and decremented without overflow checking.  While
technically justifiable (see the r20576 commit message), this makes the
standard library extremely fragile and makes successor() and
predecessor() mathematically unsafe. We really should see what the
optimizer team can do to make that hack unnecessary.

In the meantime, instead of dispatching through ++ and --, use a
special, defaulted _[successor|predecessor]InPlace() method to give
indices their own, customizable in-place inc/dec-rement path.

Swift SVN r26926
2015-04-03 02:39:40 +00:00
Michael Gottesman
0255a5b948 Revert "[stdlib] [Generator|Sequence]Of => Any[Generator|Sequence]"
This reverts commit r26904. Fixing the build.

Swift SVN r26912
2015-04-02 22:55:30 +00:00
Michael Gottesman
d53bff777b Revert "[stdlib] ExistentialCollection -> public/core"
This reverts commit r26888. Trying to fix the build.

Swift SVN r26911
2015-04-02 22:55:29 +00:00
Dave Abrahams
0b40374d10 [stdlib] [Generator|Sequence]Of => Any[Generator|Sequence]
Retire the old components now that the new ones have passed API review.

<rdar://20406937> covers the migration fallout of this change.

Swift SVN r26904
2015-04-02 21:55:22 +00:00