Commit Graph

3245 Commits

Author SHA1 Message Date
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
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
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
Dmitri Hrybenko
f793cf0996 Arithmetic traps test: add run lines for new tests
Swift SVN r20475
2014-07-24 06:14:17 +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
Jordan Rose
836c9d6eb4 Rename -Ofast to -Ounchecked.
<rdar://problem/17202004>

Swift SVN r20454
2014-07-24 01:12:56 +00:00
Jordan Rose
79224874eb [Driver] Switch debug info to use ld's new -add_ast_path option.
Rather than embed AST info directly in binaries, we now include a special
symbol table entry that points to the serialized AST as a separate file.
This requires a very recent version of ld.

We still want to support the __SWIFT,__ast section in a binary because
that's how it's modeled in dSYM, so manually test both modes in
ASTSection_linker.swift.

Part of <rdar://problem/15796201>.

Swift SVN r20421
2014-07-23 18:04:10 +00:00
Dmitri Hrybenko
766c9816de stdlib: underscore-prefix String.core
Swift SVN r20411
2014-07-23 16:28:57 +00:00
Dave Abrahams
fd2c67c89c [stdlib] Generic String init from integers
also, dump a bunch of other init() functions from other types.

Fixes <rdar://problem/16925296> #Seed 5: Remove unneeded String initializers

Swift SVN r20395
2014-07-23 14:09:01 +00:00
Dmitri Hrybenko
09561ae6fa stdlib/Printing: when printing objects without Printable conformances, print
demangled names

rdar://16929868


Swift SVN r20386
2014-07-23 11:01:51 +00:00
Dave Abrahams
478c41fa3c [stdlib] Drop withUnsafe[Mutable]PointerToElements
Now that arrays have withUnsafe[Mutable]BufferPointer, and the buffer
pointers have a baseAddress property, this API is obsolete.

Swift SVN r20347
2014-07-22 23:04:45 +00:00
Dave Abrahams
00f9ca5eda [stdlib] Rename [_]elementStorage=>[_]baseAddress
Swift SVN r20342
2014-07-22 22:29:03 +00:00
Dave Abrahams
e3f8d0e630 [stdlib] rename UnsafeArray => UnsafeBufferPointer
Also,

  UnsafeMutableArray => UnsafeMutableBufferPointer
  withUnsafeMutableStorage => withUnsafeMutableBufferPointer

Swift SVN r20340
2014-07-22 22:20:37 +00:00
Dave Abrahams
e570866bf6 [stdlib] On-demand unique contiguous Array storage
Lift the precondition that contiguous storage already exist on the use
of Array.withUnsafe[Mutable]PointerToElements.  Automatically guarantee
that storage is unique when using the mutable variants of these methods.

Also, fix some---essentially---inout aliasing violations in
test/stdlib/Unicode.swift that were revealed by the new careful
implementation of these methods.

Swift SVN r20339
2014-07-22 21:34:57 +00:00
Dmitri Hrybenko
bf8bcf0c9e stdlib tests: use more specialized expect*() functions
Swift SVN r20331
2014-07-22 20:49:37 +00:00
Dave Abrahams
dfe2ba4d8d [stdlib] const-correct withUnsafePointer APIs
Fixes <rdar://problem/17364737>

Swift SVN r20329
2014-07-22 20:39:59 +00:00
Dave Abrahams
1a6c80a93d [stdlib] .first and .last are var:T?, not func->T
The global first() and last() algorithms return T?, nil when empty

All .first() and .last() methods became T? vars that are nil when the
Collection is empty

Swift SVN r20326
2014-07-22 19:30:42 +00:00
Dmitri Hrybenko
1c2cd46094 stdlib/Printing: fix pointer printing on 32-bit platforms
Swift SVN r20325
2014-07-22 19:03:04 +00:00
Dave Abrahams
1438d617cd [stdlib] Rename ConstUnsafePointer=>UnsafePointer
Swift SVN r20318
2014-07-22 17:10:54 +00:00
Dave Abrahams
03dca56669 Add merges missed in r20316
Swift SVN r20317
2014-07-22 17:02:12 +00:00
Dave Abrahams
21669b3aee [stdlib] Add "Mutable" to [Autoreleasing]UnsafePointer
UnsafePointer becomes UnsafeMutablePointer
AutoreleasingUnsafePointer becomes AutoreleasingUnsafeMutablePointer

Swift SVN r20316
2014-07-22 16:56:23 +00:00
Dmitri Hrybenko
80748a5883 stdlib/Printing: add DebugPrintable conformances to unsafe pointer types
rdar://16896025 rdar://16896013

Swift SVN r20312
2014-07-22 16:06:47 +00:00
Dmitri Hrybenko
d14f17beef Change 'getLogicValue()' into a property 'boolValue'; change
'getArrayBoundValue()' into a property 'arrayBoundValue'.

rdar://17156123


Swift SVN r20304
2014-07-22 12:08:10 +00:00
Dave Abrahams
2c3ab47cf2 [stdlib] O(1) Array<non-verbatim> round-tripping
Arrays of non-verbatim-bridged types (such as Int, and today's String)
are converted to Objective-C lazily, with the objects created due to
element conversion being autoreleased when necessary.

Fixes <rdar://problem/17360154>

Note: test/SIL/Parser/array_roundtrip.swift was XFAIL'd;
see <rdar://problem/17758203>

Swift SVN r20293
2014-07-22 04:42:47 +00:00
Joe Groff
3ac89dc4eb Enable 'dynamic'.
And spot-update tests that appear to rely on ObjC dispatch (review please!)

Swift SVN r20285
2014-07-22 00:23:37 +00:00
Joe Groff
436acb00f3 Foundation: Remove the prepareWithInvocationTarget overlay.
Giving the invocation target proxy a type will be bogus when we turn on 'dynamic'. This breaks the NSUndoManager tests because we still can't work with lvalues through AnyObject. <rdar://problem/17755906>

Swift SVN r20283
2014-07-22 00:23:34 +00:00
Dave Abrahams
079b5e57ef [stdlib] += no longer appends array elements
+= only extends arrays with another sequence of the same element type.

Fixes <rdar://problem/17151420> The use of the overloaded += operator in
Swift is inconsistent and confusing with Arrays.

Note that this commits generated 3 new radars against the type checker:

  <rdar://problem/17751308>
  <rdar://problem/17750582>
  <rdar://problem/17751359>

Swift SVN r20274
2014-07-21 20:07:13 +00:00
Doug Gregor
eed37dc92e Remove bridging of NSPoint, NSSize, and NSRect because they are OSX-only.
This effectively reverts all but the NSRange part of r20241, because
it's better to have consistent behavior across the platforms than have
this feature on just one platform.

Swift SVN r20252
2014-07-21 15:13:37 +00:00
Dmitri Hrybenko
5c71e5075e stdlib/String: add tests for trapping on out-of-range String.UTF16View indexes
rdar://17539993


Swift SVN r20246
2014-07-21 08:44:40 +00:00
Dmitri Hrybenko
e6d2194b22 stdlib/String: trap when attempting to increment or index using
String.UTF8View.endIndex

rdar://17539993

Swift SVN r20244
2014-07-21 08:31:30 +00:00
Dave Abrahams
085b566a28 [stdlib] Fix the NSValueBridging test for iOS
Swift SVN r20243
2014-07-21 06:03:50 +00:00
Dave Abrahams
3731a0d1d2 [stdlib] Deal with various zero-division scenarios
Primarily, this means becoming resilient to Builtin.strideof(x) == 0.
Pretty much the only way to get pointers and arrays to make sense is to
treat zero-sized elements as having a stride of 1, so we do that in our
wrapper for Builtin.strideof.  Other points include precondition checks
for radixes in number formatting.

Fixes <rdar://problem/17097768>

Swift SVN r20242
2014-07-21 05:21:22 +00:00
Dave Abrahams
8091436114 [stdlib] Bridge the types NSValue wraps explicitly
NSRange, NSPoint, NSSize, and NSRect.  This time, using Jordan's
suggestion for iOS portability.

Fixes <rdar://problem/16973060>


Conflicts:
	stdlib/objc/Foundation/CMakeLists.txt
	stdlib/objc/Foundation/Foundation.swift

Swift SVN r20241
2014-07-21 04:18:40 +00:00
Dave Abrahams
8e853fd0d4 [stdlib] Add isEmpty first() and last() to lazy collections
<rdar://problem/16953693> part 3 of 3

Swift SVN r20239
2014-07-21 03:27:17 +00:00
Dave Abrahams
c9e55b48c4 [stdlib] Add first() and last() to Array types
Also, tests for the isEmpty property

<rdar://problem/16953693> part 2 of 3

Swift SVN r20238
2014-07-21 03:27:17 +00:00
Dave Abrahams
a1c1d09c6c [stdlib] Add first, last, and isEmpty algorithms
<rdar://problem/16953693> part 1 of 3

Swift SVN r20237
2014-07-21 03:27:15 +00:00
Dmitri Hrybenko
6aaac97c8d Fixed point arithmetic traps test: reenable Int8 multiplication test, the LLVM
bug is fixed now


Swift SVN r20234
2014-07-20 21:31:58 +00:00
Greg Parker
5209dab8c0 [test] Update tests now that NSStringFromClass() returns demangled names.
Swift SVN r20204
2014-07-19 01:53:26 +00:00
Dave Abrahams
de368b9070 [stdlib] Make algorithms safe with illegal predicates
Even if the user supplies an ordering predicate that isn't a strict-weak
ordering, algorithms should not index beyond their bounds.  Otherwise, a
use of withUnsafeMutableStorage for optimization purposes could easily
do an unsafe memory access.

This commit comments and tests our algorithms that require strict weak
orderings, and fixes safety problems in partition().  Most benchmarks
are unaffected, but the rewrite of partition produces a 27% speedup in
the Phonebook benchmark at -O3 and a 22% speedup at -Ofast.

Also, at -Ofast, QuickSort lost 6% and RC4 gained 6%.  These benchmarks
were not noticeably affected at -O3

====================`PrecommitBench_O3`====================
````benchmark`,`baserun0`,`baserun1`,`baserun2`,``optrun0`,``optrun1`,``optrun2`,``delta`,`speedup`
````Phonebook`,``1608.00`,``1676.00`,``1651.00`,``1265.00`,``1278.00`,``1281.00`,`343.00`,```27.1%`
````QuickSort`,```430.00`,```448.00`,```429.00`,```428.00`,```431.00`,```428.00`,```1.00`,````0.2%`
``````````RC4`,```925.00`,```924.00`,```922.00`,```916.00`,```919.00`,```917.00`,```6.00`,````0.7%`
====================`PrecommitBench_Ofast`====================
````benchmark`,`baserun0`,`baserun1`,`baserun2`,``optrun0`,``optrun1`,``optrun2`,``delta`,`speedup`
````Phonebook`,``1521.00`,``1546.00`,``1591.00`,``1252.00`,``1255.00`,``1256.00`,`269.00`,```21.5%`
````QuickSort`,```478.00`,```477.00`,```476.00`,```506.00`,```510.00`,```513.00`,``30.00`,```-5.9%`
``````````RC4`,``1033.00`,``1874.00`,``1030.00`,```974.00`,```982.00`,```975.00`,``56.00`,````5.7%`

Swift SVN r20202
2014-07-19 01:51:03 +00:00
Enrico Granata
e4cfd3ae0a Reflect ranges in the half-open format - it's not always consistent with what the user typed, but at least it resembles language syntax, and is more consistent with what LLDB already does too. Last chunk of work for rdar://16117421
Swift SVN r20168
2014-07-18 18:26:17 +00:00
Dmitri Hrybenko
7cad51564f stdlib: add tests for a fixed bug in advance()
rdar://17719966


Swift SVN r20156
2014-07-18 16:37:39 +00:00
Dave Abrahams
3a90aaf8a3 [stdlib] Ensure full bounds checking for Array
Swift SVN r20132
2014-07-18 02:40:24 +00:00
Dave Abrahams
4d704c3574 Revert "[stdlib] Array resilient slicing"
We've decided resilience is wrong for Swift given current constraints;
see rdar://problem/11940897 for more detail.

This reverts commit r20052

Swift SVN r20127
2014-07-18 00:21:22 +00:00
Dave Abrahams
a84f46ca26 [stdlib] Add prefix/suffix functions on Sliceable
Also, improve comments in Collection.swift

Swift SVN r20125
2014-07-18 00:11:44 +00:00
Dave Abrahams
4e54fafb35 [stdlib] Fix symmetry of bounded advance()
It wasn't properly handling the cases where the bound was in the
opposite direction from the amount, when advancing random access
indices.

Swift SVN r20123
2014-07-18 00:11:43 +00:00
Dmitri Hrybenko
4c4f83fb52 stdlib: underscore-prefix requirements of _BridgedToObjectiveCType and
_ConditionallyBridgedToObjectiveCType protocols

rdar://17283639


Swift SVN r20079
2014-07-17 09:42:19 +00:00
Dave Abrahams
304f27218b [stdlib] Array resilient slicing
Partially addresses <rdar://problem/11940897> #Seed 4: Slicing should
limit to valid slices

Swift SVN r20052
2014-07-16 22:27:09 +00:00
Dave Abrahams
3d61398376 [stdlib] Add clamp method to Interval
Swift SVN r20051
2014-07-16 22:16:26 +00:00