Commit Graph

1309 Commits

Author SHA1 Message Date
Dmitri Hrybenko
001c00fb44 stdlib/Dictionary: add a doc comment for _DictionaryBuilder
Swift SVN r21456
2014-08-26 11:33:06 +00:00
Dave Abrahams
ea73121217 [stdlib] Make a method final
Swift SVN r21441
2014-08-25 16:50:29 +00:00
Dmitri Hrybenko
203cbaa5df stdlib: remove unused GYB code
Swift SVN r21437
2014-08-25 14:46:14 +00:00
Dmitri Hrybenko
7c943d5377 stdlib: remove migration aids for IntXX.asSigned(), IntXX.asUnsigned()
Swift SVN r21436
2014-08-25 14:02:36 +00:00
Dmitri Hrybenko
44bf1a81a6 stdlib/Printing: print floating point numbers with appropriate precesion for
the type

Printing Float32 with %0.15g not only wastes screen space, but also causes
confusion for users, and pretends that a Float32 has more precision than it
actually does.

rdar://18043123


Swift SVN r21435
2014-08-25 13:56:38 +00:00
Dmitri Hrybenko
ea48185358 stdlib: don't silently truncate Float80 literals
We used to first truncate them to Float64, and then construct a Float80.

Swift SVN r21433
2014-08-25 13:21:54 +00:00
Dmitri Hrybenko
3e5154b23a stdlib: fix typo in private API name
Swift SVN r21431
2014-08-23 18:21:36 +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
Arnold Schwaighofer
9a7b869faf Revert "Add @effects(readnone) to _swift_isClassOrObjCExistential"
We have not defined whether readnone would potentially allow it to be
speculatively executed which is not desired semantics for
_swift_isClassOrObjCExistential because the metadata might not have been loaded
at the speculative point. Since we don't need the readnone property on this
function after the Builtin.canBeClass change for performance remove it for now.

This reverts commit r21330.

Swift SVN r21422
2014-08-22 21:34:33 +00:00
Dave Abrahams
f3ac09497d Store ASCII string literals as UTF8
Fixes <rdar://problem/16740011> ASCII string literals produce UTF16
Strings

Swift SVN r21419
2014-08-22 19:05:15 +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
Nadav Rotem
07f84793f3 Zap the string compare API.
We used this API for benchmarking and we don't need it anymore.

Swift SVN r21398
2014-08-22 00:53:27 +00:00
Dmitri Hrybenko
7db1d04f2c stdlib: add a comment for using modular arithmetic
Swift SVN r21397
2014-08-22 00:48:02 +00:00
Nadav Rotem
5319d8d220 Remove the overflow check because the variables are indices that must point to valid elements of the array of chars.
Swift SVN r21395
2014-08-22 00:19:58 +00:00
Dave Abrahams
4b2ccff3a4 [stdlib] Replace assert(false) with compile error
Unsupported architectures will cause a failure to compile rather than
some kind of runtime trap.  In particular, assert() should never be used
in the standard library; we have _sanityCheck for that purpose.

Swift SVN r21373
2014-08-21 21:06:20 +00:00
Dmitri Hrybenko
18bbf0dfef stdlib/Dictionary: implement fast enumartion for NSEnumerator of
bridged Swift.Dictionary; this allows us to autorelease less.

rdar://17944094


Swift SVN r21372
2014-08-21 20:28:28 +00:00
Dmitri Hrybenko
9404f1c055 Dictionary: in fast enumeration, don't autorelease objects that Dictionary has
a strong reference to.

rdar://17944094


Swift SVN r21368
2014-08-21 18:05:06 +00:00
Doug Gregor
d1c76de9e0 Unbreak iOS build after r21324.
Swift SVN r21342
2014-08-21 05:07: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
Arnold Schwaighofer
411ad98fba Add @effects(readnone) to _swift_isClassOrObjCExistential
rdar://17961249

Swift SVN r21330
2014-08-21 00:55:36 +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
Arnold Schwaighofer
f1ffbf0e0e Revert "stdlib: Add a _isClassOrObjCExistentialAndSizeofAnyObject function"
This reverts commit r21287.

Discussions ongoing.

Swift SVN r21288
2014-08-19 18:15:24 +00:00
Arnold Schwaighofer
87fe2bf736 stdlib: Add a _isClassOrObjCExistentialAndSizeofAnyObject function
The function _isClassOrObjCExistentialAndSizeofAnyObject encapsulates the
"sizeof(x) == sizeof(AnyObject)" check and the call to
swift_isClassOrObjCExistential. The sizeof(x) check cannot be eliminated at the
SIL level and creates extra control flow such that the call to
swift_isClassOrObjCExistential does not dominate. Encapsulating both checks
results in one function call that does dominate allowing us to CSE calls when we
add the attributes inline(late) and effects(readnone).

benchmark``````````````,``baserun0``,``optrun2``,``delta,``speedup
ClassArrayGetter```````,``977.00````,``571.00```,``409.00``,````````72.0%
DeltaBlue``````````````,``2594.00```,``2086.00``,``311.00``,````````14.9%
Rectangles`````````````,``921.00````,``605.00```,``314.00``,````````52.0%

rdar://17961249

Swift SVN r21287
2014-08-19 18:05:44 +00:00
Mikhail Zolotukhin
4027d140d1 stdlib: Replace quicksort with introsort.
Also, unite predicated and unpredicated versions of all functions via
GYB.

Swift SVN r21280
2014-08-19 13:41:04 +00:00
Dmitri Hrybenko
670c5989e1 stdlib: remove ImplicitlyUnwrappedOptional.hasBool, IUO is not a
BooleanType

rdar://18054470

Swift SVN r21275
2014-08-19 08:31:30 +00:00
Dmitri Hrybenko
9fb350761a stdlib: use unchecked arithmetic in _floorLog2 because it can never
overflow

Also improves comments and _sanityCheck messages.

Swift SVN r21259
2014-08-18 19:44:29 +00:00
Dmitri Hrybenko
cdc876f04d stdlib: remove 'public' from some internal bit twiddling functions
Swift SVN r21254
2014-08-18 15:10:49 +00:00
Mikhail Zolotukhin
fd50a501b1 stdlib: Add floorLog2 function.
Swift SVN r21252
2014-08-18 14:26:02 +00:00
Dmitri Hrybenko
58083094d8 stdlib: port Assert.swift test to StdlibUnittest
Swift SVN r21251
2014-08-18 14:07:56 +00:00
Dmitri Hrybenko
cae11e1e41 stdlib/Assert: add overloads for assertionFailure(), preconditionFailure(),
fatalError() that accept string interpolation

rdar://18043533


Swift SVN r21250
2014-08-18 10:48:52 +00:00
Dmitri Hrybenko
16604871b3 stdlib: disallow concatenating Characters with "+"
rdar://18026160


Swift SVN r21249
2014-08-18 10:13:36 +00:00
Dmitri Hrybenko
532ca776ca stdlib/String: fix a memory safety issue with using foreign indexes
(indexes obtained from a different object)

rdar://18037790

Swift SVN r21244
2014-08-15 23:56:30 +00:00
Dave Abrahams
980ccb7788 [stdlib] Fix reserve when extending String
I wish I knew how to code a regression test for this, but sadly I don't.

The only performance differences with magnitude > 7% show up in
-Ounchecked, and most of these look suspiciously like noise due to the
irrelevance of generic string append.  The only one I'd be remotely
concerned about is StrToInt, but it doesn't make any sense that it
should have gotten slower, so I think that's noise too.

Ackermann: -14.3%
Fibonacci: 33.3%
ImageProc: 9.0%
Phonebook: -7.1%
QuickSort: 15.6%
StrToInt: -14.3%

Swift SVN r21236
2014-08-15 16:44:10 +00:00
Arnold Schwaighofer
dc001d3ece stdlib: Don't check overflow on UnsafePointers they are unsafe
This also reverts the commit "stdlib: Don't check for overflow in subscript accesses to
ContigousArrayBuffer" as removing the overflow check on all unsafe pointers has
the same effect.

Swift SVN r21220
2014-08-14 23:16:20 +00:00
Arnold Schwaighofer
70caa2e83e stdlib: Don't check for overflow in subscript accesses to ContigousArrayBuffer
We overflow checked the mulitplication in "a + sizeof(T) * i". This is not
necessary for ContingousArrayBuffer because this overflow check has happened
when we compute the size of the array during allocation of a native swift array
or a NSArray.

benchmark``````````````,``baserun0``,``optrun2``,``delta,``speedup
Memset`````````````````,``1184.00```,``487.00```,``698.00``,````````143.9%
QuickSort``````````````,``1299.00```,``1458.00``,``178.00``,````````-12.2%
SelectionSort``````````,``1027.00```,``814.00```,``213.00``,````````26.2%
StdlibSort`````````````,``1718.00```,``1587.00``,``127.00``,````````8.0%
Walsh``````````````````,``1160.00```,``1076.00``,``86.00```,````````8.1%
XorLoop````````````````,``1248.00```,``884.00```,``369.00``,````````42.0%

The  regression in quicksort is noise - i looked at the LLVM IR and the only
thing different in the graph is that we have removed the mulitplication with
overflow check (that is - we should be running faster). Same thing looking at
the assembly.

XorLoop and Memset speed up because we are now able to vectorize those loops.

Swift SVN r21218
2014-08-14 21:49:34 +00:00
Dmitri Hrybenko
9977f78393 stdlib: unbreak build with INTERNAL_CHECKS_ENABLED=NO
Swift SVN r21207
2014-08-14 17:44:56 +00:00
Dave Abrahams
35d9fc22fa [stdlib] Doc comment reduce algorithm
Swift SVN r21206
2014-08-14 17:36:49 +00:00
Dmitri Hrybenko
84abad0be4 stdlib: clarify a trap error message
Swift SVN r21205
2014-08-14 17:36:27 +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
Doug Gregor
7a80e1249e Minor standard library cleanups. NFC
Swift SVN r21203
2014-08-14 17:27:43 +00:00
Doug Gregor
15b1790245 Fix generic definitions of &= and ^= for bitwise types <rdar://problem/18018525>.
Swift SVN r21202
2014-08-14 17:27:42 +00:00
Dmitri Hrybenko
938e7c2676 stdlib: introduce UnicodeScalarLiteralConvertible protocol
This allows UnicodeScalars to be constructed from an integer, rather
then from a string.  Not only this avoids an unnecessary memory
allocation (!) when creating a UnicodeScalar, this also allows the
compiler to statically check that the string contains a single scalar
value (in the same way the compiler checks that Character contains only
a single extended grapheme cluster).

rdar://17966622

Swift SVN r21198
2014-08-14 16:04:39 +00:00
Dmitri Hrybenko
2f80b28c5f stdlib: remove a bogus implementation of an unavailable function
Swift SVN r21193
2014-08-14 11:33:31 +00:00
Doug Gregor
0fc92aabe1 Remove empty Nil.swift from the standard library
Swift SVN r21190
2014-08-14 00:38:46 +00:00
Dmitri Hrybenko
cfa2bdaf83 stdlib/Hashing: use unchecked arithmetic when mixing in the per-execution seed
The per-process seed is actually fixed right now, so this bug was dormant.


Swift SVN r21189
2014-08-14 00:25:44 +00:00
Dave Abrahams
f075c1070a [stdlib] Add a ?? overload with T? on the RHS
Swift SVN r21175
2014-08-13 16:33:35 +00:00
Dmitri Hrybenko
d812966d32 stdlib: remove Optional.hasValue property
rdar://17931456


Swift SVN r21172
2014-08-13 10:51:26 +00:00
Dmitri Hrybenko
6770802036 stdlib: mark Optional initializers as transparent
Swift SVN r21171
2014-08-13 09:47:52 +00:00
Dmitri Hrybenko
502b4bf67b stdlib: coding style, trailing whitespace
Swift SVN r21170
2014-08-13 09:47:49 +00:00