Commit Graph

96 Commits

Author SHA1 Message Date
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
5798cf9014 [stdlib] Fix a dumb omission
This should fix the build

Swift SVN r23509
2014-11-21 04:27:15 +00:00
Dave Abrahams
b9342e5c1b [stdlib] Array: one-element _typeCheck, for ARC
the ARC optimizer does not handle loops well, and so can get blocked by
the presence of a loop over the range. Therefore, add a single-element
check for the common case where we're not slicing.

Swift SVN r23502
2014-11-21 01:39:53 +00:00
Dave Abrahams
d59e781b61 [stdlib] Kill some dead code
That this code is dead implies we are throwing away the knowledge that
we have a native buffer whenever we downcast an array.  That'll be fixed
when the array buffer simplification goes in.

Swift SVN r23350
2014-11-15 03:42:12 +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
Dave Abrahams
2942359d81 [stdlib] Kill unused enum
Swift SVN r23196
2014-11-09 06:23:23 +00:00
Dave Abrahams
c20389583c [stdlib] Drop needless unsafeBitCast
Swift SVN r23191
2014-11-09 04:53:34 +00:00
Dave Abrahams
057d680726 [stdlib] Kill off some needless downcasting
We're still casting down, but only to the common base of all native
array buffers.  Given that native buffers might turn out to be the empty
array buffer, this eliminates some evil type punning.

Swift SVN r23187
2014-11-09 03:46:27 +00:00
Dave Abrahams
2794fe3a13 [stdlib] Restore a combination of 11 commits
...but remove all new uses of closures, to make things easier on the
optimizer.

Swift SVN r23183
2014-11-08 20:04:29 +00:00
Arnold Schwaighofer
26b50b8115 stdlib: Don't inline _uninitializeCopy
Again there is a loop that blocks retain/release matching.

The ARC optimizer is conservative and currently stops at loops.

This will get exposed by Dave's array patches.

rdar://18777237

Swift SVN r23134
2014-11-06 21:17:40 +00:00
Arnold Schwaighofer
63623ed6bf stdlib: only build a sub-range if we need to type check
Creating a range creates overflow checks, since we don't do anything with the
range in the case of value types these checks were truly superflous, and not
always cleaned up by llvm.

rdar://18777237

Swift SVN r23132
2014-11-06 21:17:39 +00:00
Dave Abrahams
c77d7e353c Revert a combination of 11 commits
These commits are suspected of causing performance regressions:

r22995, "[stdlib] Array nil state elimination, part trois"
r22994, "[stdlib] Array nil-state elimination II"
r22993, "[stdlib] Array nil-state elimination I"
r22992, "[stdlib] Still more nil buffer elimination"
r22991, "[stdlib] Nix an unneeded typealias"
r22988, "[stdlib] Nix _ContiguousArrayBuffer._base, part deux"
r22986, "[stdlib] Kill _ContiguousArrayBuffer._base, part I"
r22985, "[stdlib] destroy redundant property"
r22975, "[stdlib] More array nil-state destruction"
r22974, "[stdlib] Construct HeapBuffer without AnyObject"
r22959, "[stdlib] non-nil ContiguousArray"

Swift SVN r23001
2014-10-29 02:57:45 +00:00
Dave Abrahams
5957b8bc3e [stdlib] Array nil state elimination, part trois
Array<T> now has no nil state.  It still has an indirection when T is a
class type.

Swift SVN r22995
2014-10-28 21:32:27 +00:00
Dave Abrahams
e7fb0ea3dd [stdlib] Array nil-state elimination II
Had to XFAIL one test: <rdar://problem/18800316>
SILPasses/array_mutable.swift test is fragile

Swift SVN r22994
2014-10-28 19:53:32 +00:00
Dave Abrahams
c9622352c6 [stdlib] Array nil-state elimination I
Swift SVN r22993
2014-10-28 19:53:31 +00:00
Dave Abrahams
f7bf9bf16d [stdlib] Still more nil buffer elimination
Swift SVN r22992
2014-10-28 18:00:55 +00:00
Dave Abrahams
7c8364fb52 [stdlib] More array nil-state destruction
Baby steps.

Swift SVN r22975
2014-10-27 22:36: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
383ebdc7dd Revert "[stdlib] ArrayBuffer: replace unsafeBitCasts"
This reverts r22824, again.  I need to try to reproduce the failure
Jordan is seeing on my own machine.

Swift SVN r22841
2014-10-20 16:39:01 +00:00
Dave Abrahams
fc862c1954 [stdlib] bisect replacement of bitcasts 0..<2 of 6
Swift SVN r22840
2014-10-20 16:02:45 +00:00
Dave Abrahams
5ef5df8b89 [stdlib] bisect replacement of bitcasts 0..<3 of 6
Applying half of an earlier change, trying to zero in on a bot-only
failure.

Swift SVN r22836
2014-10-20 11:14:23 +00:00
Dave Abrahams
b9d5a7a71b Revert "[stdlib] ArrayBuffer: replace unsafeBitCasts"
This reverts r22824 as it appeared to be causing

Swift SVN r22826
2014-10-18 13:21:05 +00:00
Dave Abrahams
14043e8ed8 [stdlib] ArrayBuffer: replace unsafeBitCasts
Swift SVN r22824
2014-10-18 04:49:01 +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
56c4cb2d42 [stdlib] Kill off _isUniquelyReferenced
It was doing an unsafeBitCast and possibly not managing lifetimes;
replace it with more-typesafe and memory-safe calls where possible.

Swift SVN r22779
2014-10-15 22:25:12 +00:00
Dave Abrahams
506a1b07a6 [stdlib] Modernize ArrayBuffer uniqueness check
Swift SVN r22773
2014-10-15 21:17:31 +00:00
Dave Abrahams
4bdb9462c7 [stdlib] ArrayBufferType: identity is base address
Buffer identity is only used by tests.  The switch to an identity
representation that accounts for the buffer length was actually
incorrect for the way many tests used it.

Swift SVN r22771
2014-10-15 20:27:57 +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
Dave Abrahams
ab045d95af [stdlib] Tiny formatting fix
Swift SVN r22544
2014-10-06 18:40:06 +00:00
Dave Abrahams
eac8ca27f9 [stdlib] Use a universal empty array buffer
NFC, and no significant performance change expected.  This is part one
of a move to eliminate nil checks from the array implementation.

Swift SVN r22526
2014-10-05 17:55:11 +00:00
Dave Abrahams
b740ad0df9 Revert "[stdlib] Use a universal empty array buffer"
This reverts commit r22495, because it wroke havoc with SIL and the perf
test suite somehow.

Swift SVN r22499
2014-10-03 18:52:11 +00:00
Dave Abrahams
f2f068c3dc [stdlib] Use a universal empty array buffer
NFC, and no significant performance change expected.  This is part one
of a move to eliminate nil checks from the array implementation.

Swift SVN r22495
2014-10-03 16:01:50 +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
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
f3d1e5f448 [stdlib] Miscellaneous comments and cleanups
Swift SVN r21979
2014-09-16 20:00:31 +00:00
Dmitri Hrybenko
e6e17ac7d4 stdlib: replace _CocoaArrayType with _SwiftNSArrayRequiredOverridesType
Swift SVN r21972
2014-09-16 12:53:00 +00:00
Andrew Trick
125846a213 Consider capacity >= mincapacity the _fastPath in requestUniqueMutableBackingBuffer.
This should allow us to better optimize repeated push/pop benchmarks.

I didn't notice a performance change at the time I did this. I'm just
putting it in as a hopefully obvious drive-by fix.

Swift SVN r21429
2014-08-23 01:31:07 +00:00
Dave Abrahams
6c07fb4ad1 [stdlib] Revert UnsafePointer casting change
The syntax being reverted added busywork and noise to the common case
where you want to say "I have the right address, but the wrong type,"
without adding any real safety.

Also it eliminated the ability to write UnsafePointer<T>(otherPointer),
without adding ".self" to T.  Overall, it was not a win.

This reverts commits r21324 and r21342

Swift SVN r21424
2014-08-22 21:53:12 +00:00
Dave Abrahams
1fb0f889d7 [stdlib] Make UnsafePointer conversions explicit
Previously, it was possible to write Unsafe[Mutable]Pointer(x) and have
Swift deduce the pointee type based on context.  Since reinterpreting
memory is a fundamentally type-unsafe operation, it's better to be
explicit about conversions from Unsafe[Mutable]Pointer<T> to
Unsafe[Mutable]Pointer<U>.  This change is consistent with the move from
reinterpretCast(x) to unsafeBitCast(x, T.self).

Also, we've encoded the operations of explicitly adding or removing
mutability as properties, so that adding mutability can be separated
from wild reinterpretCast'ing, a much more severe form of unsafety.

Swift SVN r21324
2014-08-20 23:15:56 +00:00
Dave Abrahams
5847a0f7c3 [stdlib] defer Array element down-cast checks
Part 1 of <rdar://problem/17340393>

Swift SVN r20699
2014-07-29 21:41:10 +00:00
Joe Pamer
94dac129d4 Remove the BooleanType conformance from optional types (rdar://problem/17110911)
To limit user confusion when using conditional expressions of type Bool?, we've decided to remove the BooleanType (aka "LogicValue") conformance from optional types. (If users would like to use an expression of type Bool? as a conditional, they'll need to check against nil.)

Note: This change effectively regresses the "case is" pattern over types, since it currently demands a BooleanType conformance. I've filed rdar://problem/17791533 to track reinstating it if necessary.

Swift SVN r20637
2014-07-28 19:20:39 +00:00
Dave Abrahams
31d6f95452 [stdlib] UnsafeBufferPointer: add ".count"
In answering a forum post I noiced that I wanted this and it was
missing.

Also, extensive comments

Also, rename the length: init parameter to count:.  When writing the
comments for the init function it became painfully clear why we use
"count" is better than "length" especially around pointers and memory:
the former is much less easy to mistake for "length in bytes".  Plus
it's consistent with the new ".count" property

Swift SVN r20609
2014-07-28 01:03:09 +00:00
Doug Gregor
a6a3e48d1e Work around inability to deserialize local typealiases <rdar://problem/17795074>.
Swift SVN r20491
2014-07-24 15:53:38 +00:00
Dave Abrahams
d00e888d95 [stdlib] Rename reinterpretCast => unsafeBitCast
Also give unsafeBitCast an explicit type parameter.  So

  let x: T = reinterpretCast(y)

becomes

  let x = unsafeBitCast(y, T.self)

Swift SVN r20487
2014-07-24 13:17:36 +00:00
Pete Cooper
e0add45e63 Add isInBounds to stdlib and use this for bounds checking on array subscript.
Ultimately this gets to HeapBuffer which checks the index is in range by separately checking whether the storage is nil, then the index is less than the count

Swift SVN r20363
2014-07-23 02:53:45 +00:00
Dave Abrahams
478c41fa3c [stdlib] Drop withUnsafe[Mutable]PointerToElements
Now that arrays have withUnsafe[Mutable]BufferPointer, and the buffer
pointers have a baseAddress property, this API is obsolete.

Swift SVN r20347
2014-07-22 23:04:45 +00:00