Commit Graph

1309 Commits

Author SHA1 Message Date
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
Nadav Rotem
59e033f710 Make toStringReadOnly non-public.
Swift SVN r21054
2014-08-05 23:49:11 +00:00
Nadav Rotem
e67c274cbe Convert the toString overloads to GYB.
Swift SVN r21053
2014-08-05 23:48:43 +00:00
Nadav Rotem
744d1fb7b9 Remove the non-generic toString versions and create a single @readonly toString function that can be used by convertFromStringInterpolationSegment.
Swift SVN r21050
2014-08-05 22:59:13 +00:00
Nadav Rotem
ae52323dab toString() optimizations:
1. Remove incorrect @readonly semantics on two functions.
2. Overload toString for some of the popular types and add readonly semantics so that we can optimize them away.



Swift SVN r21045
2014-08-05 22:09:53 +00:00
Dmitri Hrybenko
ab8b14f2d5 StdlibUnittest: allow xfail and skip annotations on tests
rdar://17906092


Swift SVN r21040
2014-08-05 15:03:54 +00:00
Dmitri Hrybenko
b09698a6e6 stdlib: privatize lazyConcatenate() and related APIs
Swift SVN r21039
2014-08-05 14:55:09 +00:00
Dmitri Hrybenko
1335a05e15 stdlib: remove FIXMEs from stdlib doc comments and add a test to catch these in
future

rdar://17906333


Swift SVN r21037
2014-08-05 09:31:10 +00:00
Enrico Granata
a472b40551 Add Mirror conformances for StrideTo and StrideThrough. These are mostly there to embellish the labels for child elements, as the default struct Mirror is doing a good enough job on its own. Fixes rdar://17876067
Swift SVN r21023
2014-08-04 19:07:33 +00:00
Dmitri Hrybenko
a75c7a427a stdlib/NSString APIs on String: add more tests and fix a crash in
_countFormatSpecifiers() that was triggered by non-BMP characters in the format
string


Swift SVN r21014
2014-08-04 15:37:58 +00:00
Doug Gregor
015bf179fe Use preferred formatting for && in an "if" across lines. NFC
Swift SVN r21008
2014-08-04 14:42:46 +00:00
Dmitri Hrybenko
ddefab2bee stdlib: adjust the suggested default implementation to reserve the correct
amount of storage


Swift SVN r21004
2014-08-04 10:58:59 +00:00
Dave Abrahams
7eacae411a [stdlib] Make String.extend/append overloads available
These will probably be faster than the generic versions, so why not
expose them?

Swift SVN r20998
2014-08-04 06:44:34 +00:00
Dave Abrahams
e70c19f021 [stdlib] Don't allow String() + Character("x")
Symmetry with what we did for Arrays says that Strings shoudl only
concatenate to Strings using "+".  We have append() for adding single
characters.

Swift SVN r20997
2014-08-04 06:44:34 +00:00
Dave Abrahams
70b388ba77 [stdlib] Add append() to ExtensibleCollectionType
If you can be grown by an arbitrary sequence of your element type, you
can be grown by a single element.

Swift SVN r20996
2014-08-04 06:44:33 +00:00
Doug Gregor
91fb509558 Outside function input types, ban single-element tuples with a label and variadic tuples.
Addresses <rdar://problem/15456156> and <rdar://problem/17466857>, and
sets us up for more simplification in the type system.


Swift SVN r20995
2014-08-04 04:43:32 +00:00
Dave Abrahams
1ec2b36fc1 [stdlib] Implement String.reserveCapacity
Fixes <rdar://problem/16970908>

Swift SVN r20989
2014-08-03 23:55:57 +00:00
Dave Abrahams
9fc959b862 [stdlib] UnicodeScalarView : RangeReplaceableCollectionType
Fixes <rdar://problem/17860946> Full Array mutation APIs for String and UnicodeScalarView

Swift SVN r20983
2014-08-03 22:44:03 +00:00
Dave Abrahams
0c5cbd88ca [stdlib] String : RangeReplaceableCollectionType
Addresses <rdar://problem/17860946> Full Array mutation APIs for String and UnicodeScalarView

Swift SVN r20980
2014-08-03 22:02:42 +00:00
Dmitri Hrybenko
aaaedefb63 stdlib/pointer types: give all pointers to objects (COpaquePointer,
Unsafe*Pointer) equivalent APIs, and change the initializer from a bare integer
to require a 'bitPattern:' label.

rdar://17895306


Swift SVN r20979
2014-08-03 21:47:31 +00:00
Dave Abrahams
9bec796c94 [stdlib] Lazy and eager concatenate
Swift SVN r20978
2014-08-03 21:34:28 +00:00
Dmitri Hrybenko
6e401c20ca stdlib: add a mirror for the Unicode scalar String view
Swift SVN r20977
2014-08-03 20:01:34 +00:00
Dmitri Hrybenko
4c0075f5bd stdlib: fix mirrors for UTF8 and UTF16 String views so that they actually work
instead of causing a stack overflow

rdar://17897212


Swift SVN r20974
2014-08-03 19:44:17 +00:00
Dmitri Hrybenko
56473c34cd stdlib: change out-of-bounds subscripting traps on mirrors to be
_preconditionFailure()s.  Some of these checks are clearly redundant (for
example, the check of array subscript), but since we have no tests for
these traps (and reflection is not fast in general), I prefer to keep this
transformation as straightforward as possible.


Swift SVN r20971
2014-08-03 18:42:53 +00:00
Dmitri Hrybenko
5746e4e9ca stdlib: rename _fatalError to _sanityCheckFailure. Name similarity between
fatalError and _fatalError has caused some damage already, as some
memory-safety checks in Mirrors are _fatalErrors.


Swift SVN r20969
2014-08-03 15:20:37 +00:00
Doug Gregor
54c4dbb666 Fix weird formatting; NFC
Swift SVN r20968
2014-08-03 05:57:48 +00:00
Doug Gregor
e32acec6e3 VarArgs: use "is" checking on metatypes to check for floating-point arguments on x86-64.
Previously, we were checking whether a particular argument could be
dynamic-casted to a Float or Double (via as?). However, now that
dynamic casting considers bridging, this would try to pass an NSNumber
in a floating-point register, and hilarity ensues. Fixes the
regression I introduced with object-to-value bridging in r20963.


Swift SVN r20967
2014-08-03 05:56:19 +00:00
Dmitri Hrybenko
6d4f8adbf5 stdlib/String: fix a race in _StringBuffer.grow()
rdar://17855614


Swift SVN r20960
2014-08-02 22:50:45 +00:00
Doug Gregor
a53f7f5dbf Formatting cleanup and comments; NFC
Swift SVN r20952
2014-08-02 16:36:18 +00:00
Dave Abrahams
a7e485d601 [stdlib] _StringCore.replaceRange precondition checks
Swift SVN r20949
2014-08-02 06:01:12 +00:00
Dave Abrahams
6edfddcc1f [stdlib] Remove obsolete _precondition check
Range now guarantees it won't be inverted.

Swift SVN r20948
2014-08-02 06:01:11 +00:00
Dave Abrahams
f270a5b6f3 [stdlib] _StringCore : RangeReplaceable
Swift SVN r20947
2014-08-02 05:44:40 +00:00
Dmitri Hrybenko
eff9c61a14 stdlib: attempt to fix Runtime.swift test on some systems; looks like a
compiler bug -- all I changed is inlined the _withUninitializedString
function into the caller

Swift SVN r20942
2014-08-02 02:16:24 +00:00
Dmitri Hrybenko
000df9699d stdlib: remove @semantics("readonly") from toString while this change is being
discussed and redesigned


Swift SVN r20939
2014-08-02 01:20:22 +00:00
Doug Gregor
c593d49b08 Rework the _ObjectiveCBridgeable to use inout parameters rather than returns.
The _forceBridgeFromObjectiveC and _conditionallyBridgeFromObjectiveC
requirements of the _ObjectiveCBridgeable protocol previously returned
Self and Self?, respectively, where 'Self' is the value type that is
bridged. This use of returns is fairly hostile to the idea of calling
the witnesses for these requirements from the C++ part of the runtime,
leading to "interesting" tricks with OpaqueExistentialContainer that
made it hard to use these witnesses within the dynamic casting
infrastructure.

Replace the returns with inout Self? parameters, which are far easier
to deal with in the C++ part of the runtime. Despite the churn because
we're changing the _ObjectiveCBridgeable protocol, this is NFC.

Swift SVN r20934
2014-08-02 01:03:41 +00:00
Dave Abrahams
921045c7f8 [stdlib] Enable commented test part
As I was reducing a test case for a typechecker bug, I ended up
commenting out important test code in the regression suite.  This
restores it (and makes it work).

Swift SVN r20925
2014-08-01 23:01:02 +00:00
Dave Abrahams
1f8ec23ebe [stdlib] Correct/test _StringCore.reserveCapacity
The old one could never have worked.

Swift SVN r20916
2014-08-01 21:35:15 +00:00
Dmitri Hrybenko
142a32a944 stdlib/Assert: allow string interpolation in assertion messages
rdar://17248446


Swift SVN r20892
2014-08-01 13:44:38 +00:00
Dmitri Hrybenko
a79339ee8f stdlib/Assert: adopt new names for trapping functions:
assert() / assertionFailure() -- debug mode
precondition() / preconditionFailure() -- debug and release modes
fatalError() -- always traps


Swift SVN r20890
2014-08-01 10:22:23 +00:00