Commit Graph

5543 Commits

Author SHA1 Message Date
Dmitri Hrybenko
57d296772f stdlib: remove _Strideable
Swift SVN r32675
2015-10-14 03:37:19 +00:00
Dmitri Hrybenko
371e189608 stdlib: tighten constraints on MutableCollectionType.SubSequence
Swift SVN r32674
2015-10-14 01:38:12 +00:00
Dave Abrahams
fd4a9cd658 [stdlib] Fix typo in doc comment
Swift SVN r32667
2015-10-13 20:56:57 +00:00
Andrew Trick
f3e5b1d5af Convert unsafeDownCast to use Builtin.castReference.
Generally avoid casting to a raw pointer unless a raw pointer is needed.
Builtin.castReference is now the canonical way to cast reference types.
Canonical generally = better optimizer. In practice this will reduce to
the same SIL since the stdlib code will be optimized.

There are enough unit tests for unsafeDowncast and Builtin.castReference.

I measured no performance regressions.

Swift SVN r32646
2015-10-13 01:07:54 +00:00
Andrew Trick
8007dc8cfa Add Builtin.castReference and internal API _unsafeCastReference.
_unsafeCastReference allows casting of any references types, regardless
of whether they are references to objects or class existentials. The
implementation is responsible for converting between representations.

_unsafeCastReference provides a dynamic check to ensure that the source
and dest are both actually references. If not, the implementation will
trap at runtime. Generally, the optimizer can prove that the source
and dest are references, and promote this cast to an
unchecked_ref_cast bitcast. There is no dynamic check that the
references types are compatible.

This differs from unsafeDownCast in two ways:

(1) The source and dest types are not statically typed
AnyObjects. Therefore, unsafeCastReference can be used when the
surrounding code dynamically handles both reference and nonreference
types.

(2) The source and dest also need not dynamically conform to AnyObject.
Either side of the cast may be a class existential. The primary
requirement is that the source and dest refer to the same reference
counted object.

Swift SVN r32588
2015-10-10 03:39:34 +00:00
Dmitri Hrybenko
6536edd68c stdlib: fix coding style
Swift SVN r32425
2015-10-03 21:13:15 +00:00
Dmitri Hrybenko
f7005d520f stdlib: clean up code: arrays of functions work now
Swift SVN r32424
2015-10-03 21:13:07 +00:00
Dave Abrahams
06e32293a4 [stdlib] Attempt to fix linux build
An Array's buffer is a ContiguousArrayBuffer on Linux.

Swift SVN r32323
2015-09-29 23:52:24 +00:00
Dave Abrahams
243b528fac [stdlib] Array refactoring: simplify all array subscript checking
Swift SVN r32314
2015-09-29 22:38:59 +00:00
Dave Abrahams
ee60b5f0e2 [stdlib] Array refactoring: rewrite ArrayBuffer._isValidSubscript
Swift SVN r32313
2015-09-29 22:38:58 +00:00
Dave Abrahams
cfe877bc0a [stdlib] Array refactoring: s/hoistedIs/was/
Swift SVN r32312
2015-09-29 22:38:57 +00:00
Dave Abrahams
b1e98fe3e1 [stdlib] Array refactoring: s/NoTypeCheck/TypeChecked/
First in a long series of commits to clean up the array implementation
and make it maintainable by the stdlib team.

Swift SVN r32311
2015-09-29 22:38:56 +00:00
Dave Abrahams
5cf32911fb Array: Improve function, parameter names and add documentation
NFC.

Swift SVN r32310
2015-09-29 22:38:53 +00:00
Andrew Trick
08bc41849e Remove from unsafeBitCast argument--it doesn't need an address.
Swift SVN r32300
2015-09-29 15:42:38 +00:00
Arnold Schwaighofer
599a438015 Don't force to grow the buffer everytime we make it unique
rdar://22873620

Swift SVN r32280
2015-09-28 20:47:23 +00:00
Andrew Trick
21e7b06e77 Migrate the unsafeBitCast API to use Builtin.reinterpretCast.
This avoids unnecessary address-taking. Instead use the builtin that directly
supports unsafe casts. The optimizer now follows clear rules for
Builtin.reinterpretCast (so it's safe to use) and knows how to optimize it.

Swift SVN r32268
2015-09-28 01:58:30 +00:00
Andrew Trick
9055b274ee Use bridgeToRawPointer instead of unsafeBitCast.
Swift SVN r32264
2015-09-27 00:55:37 +00:00
Arnold Schwaighofer
66275a3ad8 Replace handrolled max by max.
Swift SVN r32250
2015-09-25 23:37:29 +00:00
Arnold Schwaighofer
9ec0c2391d Nuke the CollectionType implementation from _BitMap.
It is dead code.

Swift SVN r32249
2015-09-25 23:37:23 +00:00
Arnold Schwaighofer
fd00a80029 HashedCollections: Fix code only executed if compiled with internal checks enabled
Swift SVN r32247
2015-09-25 22:47:33 +00:00
Arnold Schwaighofer
6c88b414cd Fix _BitMap's endIndex function
Swift SVN r32246
2015-09-25 22:19:14 +00:00
Arnold Schwaighofer
a5e75311af stdlib: Implement Dictionary using a structs of arrays strategy
Instead of Optional entries use a third bitmap array to mark whether an entry is
valid. This representation saves space (because individual entries don't have a
alignment padding slack) and simplifies ARC's job leading to better performance.

Speedup measured (before/after) at -O:

DictionaryHashableClass`````````3.1
DollarFilter````````````````````1.3
DollarMap```````````````````````1.3
DollarReduce````````````````````1.4
JSONHelperDeserialize```````````1.4
NSDictionaryImplicitConversion``1.4
NSXMLParser`````````````````````1.3

Speedup measured (before/after) at -Onone:

DictOfArraysToArrayOfDicts``````1.3
Dictionary``````````````````````3.5
Dictionary2`````````````````````3.2
Dictionary3`````````````````````3.2
DictionaryHashableClass`````````1.9
DictionaryHashableStruct````````2.4
DictionaryRemove````````````````3.3
DictionarySwap``````````````````2.5
DollarFilter````````````````````1.2
DollarMap```````````````````````1.2
DollarReduce````````````````````1.3
Forest``````````````````````````1.8
Histogram```````````````````````1.6
JSONHelperDeserialize```````````1.6
NSDictionaryImplicitConversion``1.3
Prims```````````````````````````2.9
RGBHistogram````````````````````1.4

rdar://22173734

Swift SVN r32244
2015-09-25 22:05:15 +00:00
Arnold Schwaighofer
6e51e15a59 Add _sizeInBytes to fixed point types.
Swift SVN r32243
2015-09-25 22:05:15 +00:00
Arnold Schwaighofer
cc4e41cb3e Add a ispod builtin and _isPOD function to the stdlib
The builtin returns true if the argument type is a POD type: needs no special
handling for copy and destruct operations.

Swift SVN r32242
2015-09-25 22:05:14 +00:00
Dmitri Hrybenko
f57947a7e0 stdlib: fix capitalization issues in documentation comments
Patch by Nate Cook.

rdar://22054901

Swift SVN r32226
2015-09-25 17:13:54 +00:00
Dmitri Hrybenko
153d95efc6 SwiftShims: don't redeclare libc functions
Clang importer thinks that SwiftShims is the primary module where they
live, and this confuses code completion.

rdar://22488333

Swift SVN r32218
2015-09-25 03:33:50 +00:00
Dmitri Hrybenko
9da0b57178 stdlib: Add an initializer to RangeReplaceableCollectionType from SequenceType
rdar://19815116

Swift SVN r32213
2015-09-24 23:20:13 +00:00
Dmitri Hrybenko
1c0bb69a32 stdlib: add removeFirst() and removeLast() functions to slices
It is an oversight that we didn't add these when we were converting to
protocol extensions.

Swift SVN r32144
2015-09-22 02:50:33 +00:00
Dmitri Hrybenko
f7612273cf stdlib: simplify AnyGenerator API
Change the non-final class into a struct, and migrate global functions
into initializers.

rdar://21878289

Swift SVN r32137
2015-09-22 00:23:10 +00:00
Dmitri Hrybenko
384ec05ae4 stdlib: stop using Builtin types in UnicodeScalar
There is no reason for that now, and using Swift types simplifies code.

Swift SVN r32109
2015-09-21 01:33:10 +00:00
Dmitri Hrybenko
4375a463a7 stdlib: rename Int**.value and Float**.value to _value per naming convention
rdar://21357661

Swift SVN r32096
2015-09-20 00:01:13 +00:00
Dmitri Hrybenko
a2e1dc5fb7 stdlib: remove some workarounds for compiler bugs from ExistentialCollection
Swift SVN r32066
2015-09-18 03:37:03 +00:00
Dmitri Hrybenko
4f114006ab stdlib: fix the comment on removeFirst() to not refer to the 'n' parameter
Swift SVN r31954
2015-09-15 00:51:06 +00:00
Dmitri Hrybenko
cf19c6c532 stdlib: format a code snippet as a code block
rdar://22422749

Swift SVN r31922
2015-09-14 06:29:25 +00:00
Dmitri Hrybenko
2ff89aa40e stdlib: fix comment on ArraySlice.startIndex
ArraySlice.startIndex is not necessarily zero anymore.

rdar://22633052

Swift SVN r31921
2015-09-14 05:40:14 +00:00
Dmitri Hrybenko
67944589d6 stdlib: improve index invalidation guarantees for removeFirst()
Slice types that are RangeReplaceable (like ArraySlice) now slice
themselves in removeFirst().  Previously, these types were picking up
the wrong default implementation, and they were going through
replaceRange(), which caused all indices to be invalidated.  The new
implementation preserves all indices.

rdar://22536664

Swift SVN r31918
2015-09-12 04:35:51 +00:00
Dave Abrahams
07c47326cb [stdlib] Integer Prototype: get most signifcant bit
Swift SVN r31898
2015-09-11 18:40:47 +00:00
Argyrios Kyrtzidis
742f65c66b [stdlib] Fix comment of _ColorLiteralConvertible, NFC.
Swift SVN r31847
2015-09-10 02:03:16 +00:00
Enrico Granata
db4c6e4ab1 It is not necessary to return a quick look object for range - the summary takes good enough care of it
Swift SVN r31776
2015-09-08 21:03:31 +00:00
Nadav Rotem
da49bf2733 Revert "[stdlib] Move Low-Level Integers into stdlib"
This reverts commit r31707.

Swift SVN r31736
2015-09-07 04:57:07 +00:00
Dave Abrahams
e06ed15ece [stdlib] Move Low-Level Integers into stdlib
This should fix the build; the builtins for Int128 needed to be
generated in the stdlib.

Swift SVN r31707
2015-09-05 03:09:54 +00:00
Arnold Schwaighofer
1b8cd94410 stdlib: Half the size of dictionary get/set operations inlined into user code
Reapply of 31644 with fix for building on linux.

Mark one method on the cocoa path noinline and outline the cocoa path for
maybeGet.

Swift SVN r31648
2015-09-03 01:07:06 +00:00
Xi Ge
df3dd4564b Revert "stdlib: Half the size of dictionary get/set operations inlined into user code"
To unblock Swift master Incremental RA.

Swift SVN r31645
2015-09-03 00:19:29 +00:00
Arnold Schwaighofer
932bb37a4f stdlib: Half the size of dictionary get/set operations inlined into user code
Mark one method on the cocoa path noinline and outline the cocoa path for
maybeGet.

Swift SVN r31644
2015-09-02 23:35:37 +00:00
Arnold Schwaighofer
aeece6bc1f stdlib: DRY and disable inlining of code to curb code growth
This halves the code size of array append inlined into user code.

Swift SVN r31603
2015-09-01 16:45:05 +00:00
Arnold Schwaighofer
314e5d9378 stdlib: Remove dead code
Swift SVN r31602
2015-09-01 16:45:04 +00:00
Arnold Schwaighofer
55e4795972 stdlib: Fix formatting.
Swift SVN r31601
2015-09-01 16:45:04 +00:00
Arnold Schwaighofer
de90e57428 stdlib: Reformulate to make ARC's job easier
The extra control-flow seems to inhibit ARC and we end up with an extra
retain-release regressing LevenshteinDistance by 40%.

rdar://22479186

Swift SVN r31588
2015-08-31 18:02:12 +00:00
Arnold Schwaighofer
eb3d5e4d4a Revert "stdlib: Move the darwin String implementation over to use the ICU library."
Revert "Add test cases to exercise the native String vs cocoa buffer String path."
Revert "stdlib: Add back a test I removed"
Revert "stdlib: Fix hasPrefix,hasSuffix tests"
Revert "stdlib: Add documentation for the cached ascii collation tables"

This reverts commit 31493, 31492, 31491, 31490, 31489.

There are linking errors in SwiftExternalProjects (we probably have to link
against libicucore somewhere).

Swift SVN r31543
2015-08-27 21:02:32 +00:00
Arnold Schwaighofer
9fd52b9123 stdlib: Instead of calling reserveCapacity in Array.init(_uninitializedCount)
directly construct a buffer of the right size

This safes a uniqueness check and unecessary code bloat when inlining
reserveCapacity.

rdar://22446738

Swift SVN r31540
2015-08-27 20:07:07 +00:00