Commit Graph

1397 Commits

Author SHA1 Message Date
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
Dmitri Hrybenko
3a04e0809f stdlib: add a function to squeeze a number in a given range from a hash value
This function mixes the bits in the hash value, which improves Dictionary
performance for keys with bad hashes.

PrecommitBenchmark changes with greater than 7% difference:

``````````Dictionary2`,```1456.00`,```1508.00`,```1502.00`,````624.00`,````607.00`,````592.00`,`864.00`,``145.9%
``````````Dictionary3`,```1379.00`,```1439.00`,```1408.00`,````585.00`,````567.00`,````552.00`,`827.00`,``149.8%
````````````Histogram`,````850.00`,````849.00`,````851.00`,```1053.00`,```1049.00`,```1048.00`,`199.00`,``-19.0%
````````````````Prims`,```1999.00`,```2005.00`,```2018.00`,```1734.00`,```1689.00`,```1701.00`,`310.00`,```18.4%
``````````StrSplitter`,```2365.00`,```2334.00`,```2316.00`,```1979.00`,```1997.00`,```2000.00`,`337.00`,```17.0%
```````````````TwoSum`,```1551.00`,```1568.00`,```1556.00`,```1771.00`,```1741.00`,```1716.00`,`165.00`,```-9.6%

Regressions are in benchmarks that use `Int` as dictionary key: we are just
doing more work than previously (hashing an `Int` was an identity function).

rdar://17962402


Swift SVN r21142
2014-08-12 12:02:26 +00:00
Jordan Rose
1ef2ee770d [stdlib] Make StaticString and AssertString DebugPrintable too.
Swift SVN r21136
2014-08-11 21:05:04 +00:00
Dmitri Hrybenko
4b9c318c05 stdlib: correct trap messages for float to integer conversion
rdar://17943841


Swift SVN r21128
2014-08-09 18:02:28 +00:00
Dmitri Hrybenko
a5c03a5e13 stdlib: trap when constructing integers from Float and Double NaNs. Not implementable for Float80 yet.
Partially fixes rdar://17958458


Swift SVN r21109
2014-08-08 15:43:39 +00:00
Jordan Rose
3d45b04657 [stdlib] Make StaticString and AssertString Printable.
Swift SVN r21094
2014-08-07 17:35:08 +00:00
Dmitri Hrybenko
f2436065db StdlibUnittest: run tests out of process
The test harness now can recover after test crashes, allowing:

- check for crashes themselves (without reporting them to the Python lit driver,
  which is about 10x slower -- even if CrashTracer is disabled);

- recover from unexpected test crashes and run the rest of the tests;

- this lays the groundwork for assertions that end the test execution, but
  allow the rest of the tests to run (rdar://17906801).

Note that we don't spawn a fresh process for every test.  We create a child
process and reuse it until it crashes.


Swift SVN r21090
2014-08-07 15:14:57 +00:00
Nadav Rotem
4cf6181785 Replace @semantics("readonly") with @effects(readonly).
Swift SVN r21088
2014-08-07 07:22:18 +00:00
Dmitri Hrybenko
3277397330 Correct the string interpolation optimization (r21066): UnicodeScalar is
Streamable

Swift SVN r21067
2014-08-06 16:41:26 +00:00
Dmitri Hrybenko
e921cc1c11 stdlib: dispatch directly to the property getter in _toStringReadOnly
+10% on Richards, +6% on StringInterpolation

Swift SVN r21066
2014-08-06 10:05:14 +00:00
Dmitri Hrybenko
20f74214ca stdlib: refactor StringInterpolation.swift.gyb to use SwiftIntTypes instead of
duplicating it


Swift SVN r21065
2014-08-06 09:17:00 +00:00
Dmitri Hrybenko
06ac06667a stdlib: underscore-prefix toStringReadOnly, fix 80-columns violations
Swift SVN r21064
2014-08-06 09:02:52 +00:00
Nadav Rotem
d96e940c36 Mark the concatination of two strings as @readonly.
Swift SVN r21061
2014-08-06 05:19:51 +00:00