Commit Graph

21492 Commits

Author SHA1 Message Date
Greg Parker
e473436383 [runtime] Remove workaround for Swift marker bit in ObjC class data.
arclite and libobjc now preserve this bit.


Swift SVN r20568
2014-07-25 22:49:12 +00:00
Dave Abrahams
71d8e16fbf [stdlib] bitwise assignments for NS_OPTIONS
Fixes <rdar://problem/17797711>

This is rather a kluge because of two other problems.  Having these
fixed would allow a cleaner solution:

<rdar://problem/17815538> synthesize an allZeros static var for
BitwiseOperationsType conformance of imported NS_OPTIONS

<rdar://problem/17815767> Adding three overloads to stdlib slows
Fibonacci by 18-19%

Swift SVN r20563
2014-07-25 22:05:08 +00:00
Dave Abrahams
b2ac0e32dd [stdlib] Concise operators for advance(i, +/-n)
Fixes <rdar://problem/17814560>.

Swift SVN r20561
2014-07-25 20:53:38 +00:00
Dave Abrahams
fedd70715d [stdlib] Add missing mode string to .gyb file
Swift SVN r20560
2014-07-25 20:53:36 +00:00
Dave Abrahams
7d30512409 [stdlib] Improved doc comments
Swift SVN r20557
2014-07-25 20:18:15 +00:00
Dmitri Hrybenko
9b1cf666c2 stdlib: add semantic requirements to the doc comments of Equatable and
Comparable


Swift SVN r20555
2014-07-25 18:43:46 +00:00
Dmitri Hrybenko
ed855afb68 stdlib/String: use the Unicode collation algorithm in String's and Character's conformance to Comparable
rdar://17498444


Swift SVN r20554
2014-07-25 18:32:36 +00:00
Dmitri Hrybenko
c52e9270b8 stdlib: fix grammar in doc comments
Swift SVN r20552
2014-07-25 18:28:01 +00:00
Dmitri Hrybenko
2470d2f439 stdlib: add doc comments for Equatable and Comparable
Swift SVN r20551
2014-07-25 18:21:51 +00:00
Chris Lattner
6d0934d33d Introduce a new 'renamed' modifier on unavailable attributes. This allows Xcode
to emit fixit's when we rename something, e.g.:

t.swift:6:9: error: 'float' has been renamed to Float
var y : float
        ^~~~~
        Float

Adopt this in the stdlib.



Swift SVN r20549
2014-07-25 18:00:37 +00:00
Doug Gregor
681059a089 Make CGFloat conform to Strideable but not RandomAccessIndex.
This brings CGFloat into line with changes recently made to the other
floating-point types. <rdar://problem/17758020>

Swift SVN r20548
2014-07-25 17:17:18 +00:00
Doug Gregor
505674484b Allow construction of CGFloat from the sized Int/UInt types and vice-versa.
Fixes <rdar://problem/17670817> (+ dupes).
Notably, we were also missing a UInt(CGFloat) initializer, which

Swift SVN r20547
2014-07-25 16:56:47 +00:00
Dmitri Hrybenko
089fd8d6ec stdlib/String: rename the function in one more place, follow-up for
r20543

Swift SVN r20544
2014-07-25 14:55:26 +00:00
Dmitri Hrybenko
c44b42c7aa stdlib/String: add a test that shows that equality comparison of strings
is performed according to the deterministic Unicode collation algorithm,
which allows us to use the hash of the NFD form.

rdar://17498444

Swift SVN r20543
2014-07-25 14:31:07 +00:00
Dmitri Hrybenko
eff383932c stdlib/Character: add Hashable conformance
Swift SVN r20539
2014-07-25 10:32:00 +00:00
Dmitri Hrybenko
fbcbd2e118 stdlib/Hashable: add a doc comment about hashValue/equality comparison
consistency requirement

Swift SVN r20538
2014-07-25 10:31:44 +00:00
John McCall
64aa0ea950 When instantiating a generic class, compensate for
unexpected forematter from the superclass.

This requires a pretty substantial shift in the
generic-metadata allocation/initialization dance
because (1) we can't allocate class metadata without
knowing what the superclass is and (2) the offset
from the metadata cache entry to the address point is
no longer determined solely by the metadata pattern.

While I'm making invasive changes to metadata, fix
two race conditions in metadata creation.  The first
is that we need to ensure that only one thread succeeds
at lazily creating a generic-metadata cache.  The second
is that we need to ensure that only one thread actually
attempts to create a particular metadata; any others
should block until the metadata is successfully built.

This commit finishes rdar://17776354.  LLDB will
need to adjust to the runtime-private metadata layout
changes.

Swift SVN r20537
2014-07-25 10:08:51 +00:00
Dmitri Hrybenko
a38b282a7b StdlibUnittest: move checkHashable to unit testing library, it is a
utility that is useful in general

Swift SVN r20536
2014-07-25 10:06:22 +00:00
Dmitri Hrybenko
9302423c3d stdlib/Character: trap when trying to construct a Character from more
than one grapheme cluster

Swift SVN r20535
2014-07-25 10:06:18 +00:00
Dmitri Hrybenko
aa929798d0 stdlib: eliminate an inconsistent overload of == on NSString that would
make == and != inconsistent in non-generic code, and that would not be
used at all in generic code.

Part of rdar://17498444

Swift SVN r20524
2014-07-24 22:38:41 +00:00
Dmitri Hrybenko
27cbb5a9d5 stdlib/String: change == to perform string comparison after NFD
normalization

There is still some obscure bug with != on NSString, probably caused by
an ill-thought overload somewhere.

Part of rdar://17498444

Swift SVN r20518
2014-07-24 21:36:01 +00:00
Dave Abrahams
e00e41af39 [stdlib] Remove String.compare()
This was added for benchmarking purposes, without the realization that
it conflicts with the NSString API we adopt when importing Foundation.
http://oleb.net/blog/2014/07/swift-strings/#comparing-strings describes
the problem.

Fixes <rdar://problem/17800504>

Swift SVN r20517
2014-07-24 21:29:48 +00:00
Dmitri Hrybenko
2324d843ec StdlibUnittest: demangle names in error output
Swift SVN r20515
2014-07-24 21:19:21 +00:00
Pete Cooper
b68de9d4c0 Update strideof in stdlib to call new strideof_nonzero.
This hides the call to max in the compiler and removes the control flow
associated with max.  The resulting -O3 performance is

2Sum           ,  1303.00   ,  1286.00   ,  17.00     ,        1.3%
Ackermann      ,  4077.00   ,  4498.00   ,  421.00    ,        -9.4%
DeltaBlue      ,  19473.00  ,  17265.00  ,  2208.00   ,        12.8%
Dictionary     ,  882.00    ,  817.00    ,  65.00     ,        8.0%
EditDistance   ,  1467.00   ,  1416.00   ,  51.00     ,        3.6%
ForLoops       ,  1998.00   ,  2014.00   ,  16.00     ,        -0.8%
Forest         ,  1125.00   ,  1055.00   ,  70.00     ,        6.6%
GlobalClass    ,  1633.00   ,  1640.00   ,  7.00      ,        -0.4%
Hash           ,  1634.00   ,  945.00    ,  689.00    ,        72.9%
Histogram      ,  1196.00   ,  1054.00   ,  142.00    ,        13.5%
Life           ,  71.00     ,  64.00     ,  7.00      ,        10.9%
LinkedList     ,  1573.00   ,  1573.00   ,  0.00      ,        0.0%
Memset         ,  5987.00   ,  273.00    ,  5714.00   ,        2093.0%
NBody          ,  208.00    ,  44.00     ,  164.00    ,        372.7%
Phonebook      ,  2193.00   ,  1486.00   ,  707.00    ,        47.6%
PrimeNum       ,  1093.00   ,  393.00    ,  700.00    ,        178.1%
Prims          ,  1710.00   ,  1712.00   ,  2.00      ,        -0.1%
QuickSort      ,  121.00    ,  112.00    ,  9.00      ,        8.0%
R17315246      ,  1109.00   ,  1273.00   ,  164.00    ,        -12.9%
RC4            ,  745.00    ,  63.00     ,  682.00    ,        1082.5%
Rectangles     ,  947.00    ,  1015.00   ,  68.00     ,        -6.7%
SmallPT        ,  1071.00   ,  1088.00   ,  17.00     ,        -1.6%
StringBuilder  ,  928.00    ,  799.00    ,  129.00    ,        16.1%
StringWalk     ,  1221.00   ,  1264.00   ,  43.00     ,        -3.4%
Totals         ,  54980.00  ,  43284.00  ,  11696.00  ,        27.0%
Walsh          ,  1215.00   ,  135.00    ,  1080.00   ,        800.0%

Swift SVN r20509
2014-07-24 18:44:42 +00:00
Pete Cooper
3590f4a896 Alignof can never return 0, so don't max against 1
Swift SVN r20507
2014-07-24 18:44:41 +00:00
Dmitri Hrybenko
c2adafc897 Revert "stdlib/String: change == to perform string comparison after NFD"
This breaks consistency between == comparison and hash value.

Swift SVN r20500
2014-07-24 17:28:40 +00:00
Dave Abrahams
4866705260 [stdlib] Fix typo in availability message
Swift SVN r20497
2014-07-24 17:15:15 +00:00
Doug Gregor
d3012a0c26 Replace an 'override' with a 'required' for init(coder:).
Swift SVN r20496
2014-07-24 17:01:03 +00:00
Dmitri Hrybenko
a3d5a8a0de stdlib/String: change == to perform string comparison after NFD
normalization

There is still some obscure bug with != on NSString, probably caused by
an ill-thought overload somewhere.

Part of rdar://17498444

Swift SVN r20495
2014-07-24 16:51:48 +00:00
Ben Langmuir
6742613a19 Swap an em dash for -- in a comment to satisfy the sourcekit tests
We're checking for ascii-only comments in the stdlib.  It kind of sucks
that we can't have nice things.

Swift SVN r20493
2014-07-24 16:00:04 +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
Doug Gregor
5fc8ac7fd1 Require the 'override' keyword for initializers that override designated initializers.
Swift SVN r20490
2014-07-24 15:38:33 +00:00
Dave Abrahams
a792eb68a4 [stdlib] release notes, @availability attributes
Swift SVN r20488
2014-07-24 13:17:39 +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
Dmitri Hrybenko
89420772a2 stdlib/String: move enough bridging machinery into the core standard
library so that core library can bridge a String to Objective-C

Part of rdar://17498444

Swift SVN r20485
2014-07-24 13:07:12 +00:00
Dmitri Hrybenko
297c0a78f4 stdlib: coding style
Swift SVN r20484
2014-07-24 13:07:07 +00:00
Dave Abrahams
304b4f33ae [stdlib] Sequence and Generator documentation detail
Front-loaded reference to trap() will become valid when
rdar://problem/17792445 is handled, shortly.

Fixes <rdar://problem/17392226>

Swift SVN r20483
2014-07-24 09:06:49 +00:00
Dmitri Hrybenko
d0369e650b stdlib: mark init(bitPattern:) @transparent, this should be a free abstraction
Swift SVN r20482
2014-07-24 08:26:26 +00:00
Dmitri Hrybenko
2d27594d4e stdlib: clarify the comment: "same value" -> "same numeric value"
Can not say "may not compare equal" because there is no mixed-type overload of ==.


Swift SVN r20481
2014-07-24 08:24:27 +00:00
Dave Abrahams
1a7648b04b [stdlib] String.stringWithBytes: drop length param
The length could already be given by the input sequence.  Also, make it
accept any generic Sequence of bytes, rather than requiring an array.

Fixes <rdar://problem/17034413>

Swift SVN r20480
2014-07-24 08:23:10 +00:00
Dave Abrahams
993c7e0bae [stdlib] Replace .toSigned()/.toUnsigned() methods
...because their semantics were unclear.  The new idiom is explicit
construction of the target type using the "bitPattern:" argument label:

    myInt.toUnsigned() => UInt(bitPattern: myInt)

Fixes <rdar://problem/17000821>

Swift SVN r20479
2014-07-24 08:07:07 +00:00
Mark Lacey
c69ea64c0d Add specializations of prefix/postfix increment/decrement for integer types.
A few benchmarks in PreCommitBench improve at Onone (typically by a few
percent but for StringWalk it is 10%).

Swift SVN r20468
2014-07-24 05:10:12 +00:00
Doug Gregor
b1b6886fda Add missing required initializers to _NSContiguousString and _NSOpaqueString.
Swift SVN r20449
2014-07-23 23:47:02 +00:00
Dave Abrahams
8f5180cf71 [stdlib] Add entry point for array literals
Array literal construction currently goes through an expensive dance;
Adding _allocateUninitialized will allow SILGen to do something much
smarter.

Swift SVN r20448
2014-07-23 23:46:02 +00:00
Andrew Trick
f36ff584cf Add array.init semantics.
This way, array optimization can see initialization as a copy of the
whole array value into a local variable, regardless of whether it's
from a factory method or Array initializer.

I'm making an assumption that when we return an Array by value, we
can't have an alias of the array buffer without retaining it.

Swift SVN r20444
2014-07-23 23:25:17 +00:00
Dave Abrahams
a3211d0d68 [stdlib] dynamic NSString.localizedStringWithFormat
It used to always construct an NSString; now it constructs the class it
was called through

Swift SVN r20439
2014-07-23 22:59:27 +00:00
Doug Gregor
1cc28d4f80 An initializer requirement can only be satisfied by a required class initializer in a non-final class.
This is part of eliminating the notion of non-inheritable
conformances. Fixes <rdar://problem/17408284>.

Swift SVN r20430
2014-07-23 22:16:38 +00:00
Dmitri Hrybenko
766c9816de stdlib: underscore-prefix String.core
Swift SVN r20411
2014-07-23 16:28:57 +00:00
Dmitri Hrybenko
52f3ba25b4 stdlib: underscore a private String initializer
Swift SVN r20408
2014-07-23 16:15:17 +00:00
Doug Gregor
c2b5703865 API notes: rework CMake support so that we can separate the API notes sources.
Move all of the information about API notes into the "apinotes"
subdirectory, which specifies the API notes that it provides. The
organization is such that "apinotes" can become its own separate
repository, and the compiler build will pick up those API notes that
are available and build them along with the overlays.

Swift SVN r20406
2014-07-23 16:09:49 +00:00