Commit Graph

170 Commits

Author SHA1 Message Date
Dmitri Hrybenko
397d2fb8c3 stdlib: coding style: when colon specifies is-a relationship, we put
spaces on both sides of it

Swift SVN r23935
2014-12-15 06:55:30 +00:00
Dave Abrahams
d9c750eefd [stdlib] Remove ArrayBuffer indirection
The case where Array stores class instances no longer requires an
intermediate indirect buffer object.

Also fixes <rdar://problem/17348939>

These are the speed changes < 0.95x and > 1.05x, as I measured them.
Although I don't have great confidence in these numbers, some are
consistent with Arnold's measurements, FWIW.

-O:
0.93 ArrayLiteral
1.56 Ary
1.39 Ary2
1.06 CaptureProp
1.93 ClassArrayGetter
1.08 DeltaBlue
1.08 DollarChain
1.13 InsertionSort
1.08 PrimeNum
1.11 RC4
0.93 Rectangles
1.08 SwiftStructuresBubbleSort

-Onone:
1.06 ArrayLiteral
1.10 ArraySubscript
1.12 Ary
1.12 Ary2
1.10 Ary3
1.20 ClassArrayGetter
1.19 DeltaBlue
1.08 DollarChain
1.09 Hash
1.07 Havlak
1.10 HeapSort
1.11 ImageProc
1.17 InsertionSort
1.18 Memset
1.11 NBody
1.07 PrimeNum
1.11 QuickSort
1.12 RC4
1.08 Rectangles
1.07 SelectionSort
1.06 StringBuilder
1.12 SwiftStructuresBubbleSort
1.10 Walsh
1.12 XorLoop

-Ounchecked:
0.91 ArrayLiteral
1.74 Ary
1.53 Ary2
2.08 ClassArrayGetter
1.19 DeltaBlue
1.06 DollarChain
1.07 Havlak
1.09 ImageProc
1.22 InsertionSort
0.89 PopFrontArrayGeneric
1.11 PrimeNum
0.85 QuickSort
1.10 RC4
1.12 Rectangles
1.06 StrToInt
1.11 SwiftStructuresBubbleSort

Swift SVN r23551
2014-11-22 08:19:57 +00:00
Dave Abrahams
66da8500c7 [stdlib] Kill a stray backslash
Swift SVN r23467
2014-11-20 03:41:10 +00:00
Arnold Schwaighofer
06a0a23562 Add a destructor memory effect analysis
This adds an analysis to the compiler that identifies types that are may store
to memory on destruction.

It adds a compiler known protocol _DestructorSafeContainer that allows the
standard library to identify containers whose destructor's memory effects
depends strictly on the type parameters of the container.

Array<T> : _DestructorSafeContainer {} may not store to memory during
destruction if the bound T is a type that does not store to memory on
destruction.

This is needed to deduce that for example Array<Array<Int>> is does not store to
memory on destruction (e.g during a call to release).

rdar://18940376

Swift SVN r23242
2014-11-11 19:27:41 +00:00
Graham Batty
dc6a776d10 stdlib: Use config directives to work without objective-c.
Swift SVN r23211
2014-11-10 20:06:25 +00:00
Graham Batty
373414864d Revert "Use config directives to carve out a 'portable' kernel stdlib."
This reverts commit r23202 pending further discussion.

Swift SVN r23205
2014-11-10 18:46:42 +00:00
Graham Batty
dfa260fab1 Use config directives to carve out a 'portable' kernel stdlib.
Swift SVN r23202
2014-11-10 18:03:09 +00:00
Arnold Schwaighofer
8644e9c93c stdlib: Don't inline copyBuffer
copyBuffer contains a copy loop which will prevent retain/release matching
across it.

This fixes a 50% regression in MatMul after applying Dave's array patches.

rdar://18777237

Swift SVN r23133
2014-11-06 21:17:39 +00:00
Erik Eckstein
e7ddfe4dde [stdlib] Make ArrayType public because it is accessed from tests.
Swift SVN r22966
2014-10-27 15:08:24 +00:00
Dave Abrahams
46846c4ec1 Revert "[stdlib] _ArrayBufferType: drop baseAddress"
This reverts r22950 because the optimizer can't yet eliminate the
abstraction penalty of closures.

Swift SVN r22963
2014-10-27 13:06:54 +00:00
Dave Abrahams
ac79309e01 [stdlib] _ArrayBufferType: drop baseAddress
Exposing the raw baseAddress without lifetime control is error-prone.
Began to strip actual uses of baseAddress from specific models of
_ArrayBufferType, too.

Swift SVN r22950
2014-10-26 21:37:39 +00:00
Dave Abrahams
a71e88bb1d [stdlib] Use ''' instead of """ to deconfuse Emacs
The indenter does great until it sees the Python triple-quoted string
containing a swift string with a string intepolation inside; that brings
it out to quotation level zero and then the backslash escapes the open
paren causing the nesting level to go negative when it sees the close
paren.  Sheesh.

Swift SVN r22948
2014-10-26 18:29:43 +00:00
Dave Abrahams
1a9f96e1c7 [stdlib] Drop unneeded protocol requirement
Conversion to cocoa is not a common requirement for all models of
_ArrayBufferType

Swift SVN r22947
2014-10-26 18:29:42 +00:00
Dave Abrahams
6786969209 [stdlib] Introduce _SwiftDeferredNSArray
This is mostly just a renaming of _SwiftNativeNSArray, except that we
want to add another NSArray subclass for verbatim-bridged elements, so
we want a common base class.  _SwiftNativeNSArray is the name of that
new base class, to parallel the other _SwiftNativeNSXXX classes.

Swift SVN r22913
2014-10-24 15:48:48 +00:00
Dave Abrahams
418aa75eb2 [stdlib] Rename _NSSwiftXXX => _SwiftNativeNSXXX
...to better reflect the purpose of these classes

Swift SVN r22911
2014-10-24 15:48:46 +00:00
Dave Abrahams
981a156823 [stdlib] Add _UnitTestArray[Buffer] temporarily
We're going to replace StdlibUnittest's use of ContiguousArray with
_UnitTestArray so that we can work on (and potentially break)
_ContiguousArray and still get useful test results.  When refactoring is
complete, we can optionally replace StdlibUnittest's use of
_UnitTestArray with ContiguousArray, or move the decoupled component
into the StdlibUnittest module.

Swift SVN r22874
2014-10-22 05:28:22 +00:00
Dave Abrahams
69194280a7 [stdlib] Nix an unused protocol and rename another
Swift SVN r22791
2014-10-16 03:46:34 +00:00
Dave Abrahams
ab69e26656 [stdlib] Actually run the ArrayCore test
Fixes rdar://problem/18646425

Running the test uncovered avoidable inefficiencies in Array copying, so
dispatch of _copyToNativeArrayBuffer was revamped.  It's reasonable to
expect some speedups from this.

Also, the internal Array API requestNativeBuffer was highly error prone
when the source was a Slice, because it could return an array buffer
that represented more than the entire slice.  That capability was
probably used for optimization once, but is no longer, and the error
prone API probably caused bugs, so it was reformed.

Swift SVN r22746
2014-10-15 03:24:47 +00:00
Arnold Schwaighofer
c1eefb1dad Reapply "stdlib: Remove dead semantic Array._setElement function
Also remove helper functions."

With fixes.

Swift SVN r22479
2014-10-02 20:26:32 +00:00
Arnold Schwaighofer
2bd116c20b Revert "stdlib: Remove dead semantic Array._setElement function"
This reverts r22468. Because it breaks the build.

Swift SVN r22469
2014-10-02 18:46:24 +00:00
Arnold Schwaighofer
cfd4a0902d stdlib: Remove dead semantic Array._setElement function
Also remove helper functions.

Swift SVN r22468
2014-10-02 18:44:31 +00:00
Erik Eckstein
48e4c951e0 Remove dead arrays which are constrcuted with _allocateUninitialized
This fixes the performance regressions in Richards and some other benchmarks.



Swift SVN r22465
2014-10-02 14:08:49 +00:00
Arnold Schwaighofer
b6f28bede1 ArraySemantics: Teach array semantics about getting the address of an array element
rdar://18517410

Swift SVN r22439
2014-10-01 21:08:22 +00:00
Erik Eckstein
cd4b943897 Don't call reserveCapacity if constructing an empty uninitalized array.
This speeds up empty array literals and fixes the performance regression in the Havlak benchmark.
See <rdar://problem/18480488> PerfReg: Havlak - Megaclang - r353047-r353195 - 3x



Swift SVN r22427
2014-10-01 14:52:25 +00:00
Dmitri Hrybenko
50c99099ec Remove redundant semicolon
Swift SVN r22422
2014-10-01 06:31:25 +00:00
John McCall
1fa4f422ba Use mutable addressors for Array, now that doing so
doesn't prevent us from using a getter for immutable
accesses.

rdar://17270560

Swift SVN r22421
2014-10-01 05:20:43 +00:00
Dave Abrahams
c93f32a4b3 [stdlib] Eliminate needless intermediate class
Swift SVN r22415
2014-09-30 23:43:25 +00:00
Dave Abrahams
156020de19 [stdlib] Rename 'countElements' => 'count'
The name was not only long and unwieldy, but inconsistent with our
conscious decision to avoid the use of "elements" in APIs as mostly
redundant.

Swift SVN r22408
2014-09-30 22:00:26 +00:00
Joe Groff
c04992bf78 stdlib: Remove Array.convertFromHeapArray.
Swift SVN r22297
2014-09-26 04:27:19 +00:00
Joe Groff
9eb4f5b512 SILGen: Use Array._allocateUninitialized to form array literals.
This avoids a pointless copy every time an array literal is written, and will let us retire the horrible "alloc_array" instruction and globs of broken IRGen code. Implements rdar://problem/16386862, and probably fixes a bunch of bugs related to alloc_array brokenness.

Swift SVN r22289
2014-09-25 22:26:20 +00:00
Dmitri Hrybenko
42b9bf3e28 stdlib: use addressors in {ContiguousArray,Slice}.subscript(_: Int)
Swift SVN r22265
2014-09-24 14:38:23 +00:00
Dave Abrahams
a7f3e4222e [stdlib] finish public non-protocol docs
The 58 undocumented public non-operator APIs still present in core are
all on non-exposed (underscored) APIs.

Swift SVN r22263
2014-09-24 12:31:45 +00:00
Dave Abrahams
66d2ba43c6 [stdlib] underscore APIs made visible by r22212
That commit made a protocol public.  The protocol was underscored but
some of its APIs were not, and those became unintentionally publicly
visible.  This commit corrects that problem.  Since Builtin.RawPointer
properties were being renamed from "value" to "_rawValue" for clarity,
COpaquePointer got that treatment too, even though it wasn't strictly
necessary, for consistency.

Swift SVN r22252
2014-09-24 02:50:43 +00:00
Dave Abrahams
dbde275230 [stdlib] Propagate Reflectable docs
230 undocumented public non-operator APIs remain in core

Swift SVN r22236
2014-09-23 23:08:43 +00:00
Dave Abrahams
6bb89ae255 [stdlib] Propagate RangeReplaceableCollectionType docs
240 undocumented public non-operator APIs remain in core

Swift SVN r22235
2014-09-23 22:48:15 +00:00
Dave Abrahams
24fe53ed6c [stdlib] Propagate OutputStream docs
240 undocumented public non-operator APIs remain in core

Note: previous estimates were wrong because my regex was broken.  The
previous commit, for example, had 260 undocumented APIs.

Swift SVN r22234
2014-09-23 22:01:49 +00:00
Dave Abrahams
f5c80b115b [stdlib] Propagate ExtensibleCollectionType docs
184 undocumented public non-operator APIs remain in core

Swift SVN r22231
2014-09-23 21:13:45 +00:00
Dave Abrahams
7c9ebaa19f [stdlib] Propagate LiteralConvertible docs
219 undocumented public APIs remain in core

Swift SVN r22213
2014-09-23 11:12:39 +00:00
Dave Abrahams
f4a7812065 [stdlib] Propagate SequenceType docs to models
235 undocumented public APIs remain in core

Swift SVN r22210
2014-09-23 10:40:37 +00:00
Dave Abrahams
1dd7272fe9 [stdlib] Propagate CollectionType docs to models
266 undocumented public APIs remain in core

Swift SVN r22206
2014-09-23 08:19:23 +00:00
Dave Abrahams
40e9a0f859 [stdlib] Fix memory safety with evil collections
A collection whose count changes between traversals could cause a memory
safety problem, as we would measure the collection in one pass and
assume that it was the same length when actually initializing array
elements.  Fix that by always using the initial measurement, which
corresponds exactly to allocated memory.  If the collection wants to
trap because we've gone past its new bounds, that's fine.  If it
doesn't, at least we haven't done anything unsafe.

Swift SVN r22152
2014-09-20 03:35:23 +00:00
Dmitri Hrybenko
b64f6a48fa stdlib: attach documentation comments to array types
Swift SVN r22072
2014-09-18 14:04:15 +00:00
Dmitri Hrybenko
b095339da7 stdlib/Array: implement delayed bridging
rdar://18191358

Swift SVN r22071
2014-09-18 13:46:39 +00:00
Doug Gregor
3972316d25 Switch ArrayLiteralConvertible over to an initializer requirement.
Swift SVN r22024
2014-09-17 17:46:26 +00:00
Dmitri Hrybenko
e6e17ac7d4 stdlib: replace _CocoaArrayType with _SwiftNSArrayRequiredOverridesType
Swift SVN r21972
2014-09-16 12:53:00 +00:00
Dave Abrahams
213f59e546 [stdlib] doc-comment Arrays.swift.gyb
Swift SVN r21897
2014-09-12 00:35:09 +00:00
Erik Eckstein
962a50160a stdlib: Optimize convertion from array literal for Array
Replaced the general implementation (which works for all array types) to the obvious and trivial implementation for Array.
This speeds up array literal initialization by about 2x.



Swift SVN r21626
2014-09-01 08:21:13 +00:00
Nadav Rotem
9a495b56e5 Inline _arrayReplace into replaceRange.
The buffer argument of _arrayReplace was a protocol and it forced
all of the calls to that member to be virtually dispatched and generic.

This boosts DeltaBlue by 2X.

Swift SVN r21405
2014-08-22 06:56:22 +00:00
Dave Abrahams
1eba71e4e6 [stdlib] Doc comments and parameter naming, NFC
Fixes <rdar://problem/17998481>

Swift SVN r21204
2014-08-14 17:31:54 +00:00
Nadav Rotem
4cf6181785 Replace @semantics("readonly") with @effects(readonly).
Swift SVN r21088
2014-08-07 07:22:18 +00:00