Commit Graph

99 Commits

Author SHA1 Message Date
Andrew Trick
c2f3622ac3 Revert "Mark _copyCollectionToNativeArrayBuffer readonly."
This reverts commit 71eb477aa6d9354cbad7baebae4283936bb1831a.

Per Erik's review.
The correct fix is interprocedural analysis that has visibility
into specialized functions. Let's just wait for that.

Swift SVN r24007
2014-12-18 18:22:01 +00:00
Andrew Trick
361ceea369 Mark _copyCollectionToNativeArrayBuffer readonly.
This fixes one of the issues preventing optimization of RangeAssignment
when it isn't fully inlined. There is still another problem with this benchmark I haven't fixed:
<rdar://problem/19252374> We fail to fully optimize RangeAssignment. Forced inlining achieves 3-4x speedup.

This fix at least unblocks CopyForwarding, which perturbs inlining enough to expose the issue.

Swift SVN r23944
2014-12-15 21:20:03 +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
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
Joe Groff
af0121f8e6 IRGen: Don't nonlazily realize classes (unless they ask).
We lazily realize classes when we access their metadata now, so there's no need to force the ObjC runtime to do this greedily anymore, except for classes that the runtime statically references. For those cases, add an @objc_non_lazy_realization class attribute that will put that class reference in the nlclslist section.

Swift SVN r23105
2014-11-05 00:19:37 +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
f7bf9bf16d [stdlib] Still more nil buffer elimination
Swift SVN r22992
2014-10-28 18:00:55 +00:00
Dave Abrahams
8ced867315 [stdlib] Nix an unneeded typealias
Swift SVN r22991
2014-10-28 18:00:51 +00:00
Dave Abrahams
7a1463e4ec [stdlib] Nix _ContiguousArrayBuffer._base, part deux
This commit eliminates (finally) the nil state from
_ContiguousArrayBuffer.

Swift SVN r22988
2014-10-28 03:58:41 +00:00
Dave Abrahams
838fc13011 [stdlib] Drop unused operators
Swift SVN r22987
2014-10-28 03:58:40 +00:00
Dave Abrahams
cc0c66df75 [stdlib] destroy redundant property
Swift SVN r22985
2014-10-28 03:58:39 +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
84a955d987 [stdlib] Construct HeapBuffer without AnyObject
The existential was causing the optimizer problems.

Swift SVN r22974
2014-10-27 21:48:38 +00:00
Dave Abrahams
1adda3e81b [stdlib] non-nil ContiguousArray
This is the barest-minimum change required to ensure that the buffer is
never nil.  Codegen problems were crushing all more-ambitious
efforts (radar to follow)

Swift SVN r22959
2014-10-27 05:02:44 +00:00
Dave Abrahams
f07b42ee9a [stdlib] replace an assign with a swap
Theoretically, this should cut down retain/release traffic

Swift SVN r22957
2014-10-27 04:45:46 +00:00
Dave Abrahams
60e79b7560 [stdlib] Replace an unsafeBitCast
Swift SVN r22956
2014-10-27 04:45:45 +00:00
Dave Abrahams
f8f82a9061 [stdlib] ContiguousArrayBuffer: tiny logic cleanup
Swift SVN r22951
2014-10-26 21:37:40 +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
4a1d2e67ec [stdlib] ContiguousArrayBuffer: truthful types
The buffer stored in a _ContiguousArrayBuffer<T> is not always
_ContiguousArrayStorage<T>.  It might in fact be the special empty
buffer class.

Swift SVN r22835
2014-10-20 05:13:21 +00:00
Dave Abrahams
b9bdbb87b6 Revert "[stdlib] ContiguousArrayBuffer: truthful types"
This reverts commit r22824, which I suspect of causing the
closure_multivalue failure at

Swift SVN r22834
2014-10-20 03:20:46 +00:00
Dave Abrahams
f765ffdc45 [stdlib] ContiguousArrayBuffer: truthful types
The buffer stored in a _ContiguousArrayBuffer<T> is not always
_ContiguousArrayStorage<T>.  It might in fact be the special empty
buffer class.

Swift SVN r22823
2014-10-18 04:49:00 +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
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
2d850421bc [stdlib] Internalize HeapBuffer[Storage], OnHeap
They were never really useful to users, because their APIs were
insufficiently public.  They have been replaced with a single class,
ManagedBuffer<Value,Element>, which is really designed for user
consumption.

Swift SVN r22636
2014-10-09 21:45:44 +00:00
Dave Abrahams
1f38b125f4 [stdlib] Fix typos in sanity check strings
Swift SVN r22627
2014-10-09 18:25:24 +00:00
Dave Abrahams
add753905b [stdlib] Use a lifetime-managed "with" construct
...instead of an internal API that releases an UnsafeBufferPointer into the wild.

Swift SVN r22561
2014-10-07 01:08:35 +00:00
Dave Abrahams
41fe3896d8 [stdlib] Synchronization-free empty array buffer
Now that <rdar://problem/18540783> is fixed, we can stop allocating the
empty array buffer dynamically and go back to using the one that is
statically laid out in GlobalObjects.cpp, thereby avoiding the
atomic instructions required to make it threadsafe.

Swift SVN r22545
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
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
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
b095339da7 stdlib/Array: implement delayed bridging
rdar://18191358

Swift SVN r22071
2014-09-18 13:46:39 +00:00
Dmitri Hrybenko
0e7e60b50b Remove stale comment
Swift SVN r22069
2014-09-18 11:42:41 +00:00
Dmitri Hrybenko
e6e17ac7d4 stdlib: replace _CocoaArrayType with _SwiftNSArrayRequiredOverridesType
Swift SVN r21972
2014-09-16 12:53:00 +00:00
Dmitri Hrybenko
9b62c620a7 stdlib: remove implied default 'internal' access modifier
Swift SVN r21970
2014-09-16 11:14:38 +00:00
Dmitri Hrybenko
4cf865de73 stdlib: factor all _NSXXXBase classes to a single place
Swift SVN r21969
2014-09-16 11:13:06 +00:00
Dmitri Hrybenko
50d497c05f stdlib/Array: fix an issue in fast enumeration
Array did not initialize fast enumeration state if it was empty.
Surprisingly, this did not break code that is generated by Clang
currently.  (But as far as I understand fast enumeration, it may abort
the program because mutation pointer is null.)

Swift SVN r21940
2014-09-15 13:49:56 +00:00
Dmitri Hrybenko
4a1dfdb6ad stdlib/Array: remove default parameters in bridging routines, and
reorder function declarations

Swift SVN r21938
2014-09-15 07:08:09 +00:00
Dmitri Hrybenko
001db58bb1 stdlib: remove trailing whitespace and fix coding style
Swift SVN r21906
2014-09-12 13:23:21 +00:00
Dave Abrahams
09793716cb [stdlib] try to measure sequences before array-izing
When creating an array from a SequenceType not statically known to be a
CollectionType, don't neglect to pre-allocate based on its
underestimated count.

Swift SVN r21829
2014-09-10 03:21:14 +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
Arnold Schwaighofer
16e41ada77 Make Builtin.canBeClass return a tri-state
Replace the true/maybe state that Builtin.canBeClass was returning by a
tri-state (yes, no, maybe) allowing the optimizer to use the definite no
answer.  This removes the need of the sizeof check that we had in
isClassOrObjCExistential. It also removes the need to CSE this function since
in most cases we will be able to instantiate canBeClass to yes or no (vs maybe)
at compile time.

benchmark``````````````,``baserun0``,``optrun2``,``delta,``speedup
ClassArrayGetter```````,``988.00````,``337.00```,``644.00``,````````191.7%
DeltaBlue``````````````,``2429.00```,``1927.00``,``460.00``,````````23.9%
Dictionary`````````````,``1374.00```,``1231.00``,``129.00``,````````10.9%
Havlak`````````````````,``1079.00```,``911.00```,``124.00``,````````13.7%
Rectangles`````````````,``924.00````,``541.00```,``379.00``,````````70.1%

radar://16823238

Swift SVN r21331
2014-08-21 00:55:40 +00:00