Commit Graph

21492 Commits

Author SHA1 Message Date
Dave Abrahams
6d1095f44e Protocol names end in "Type," "ible," or "able"
Mechanically add "Type" to the end of any protocol names that don't end
in "Type," "ible," or "able."  Also, drop "Type" from the end of any
associated type names, except for those of the *LiteralConvertible
protocols.

There are obvious improvements to make in some of these names, which can
be handled with separate commits.

Fixes <rdar://problem/17165920> Protocols `Integer` etc should get
uglier names.

Swift SVN r19883
2014-07-12 17:29:57 +00:00
Dmitri Hrybenko
355316a49b stdlib/Dictionary: when bridging from Objective-C, recognize bridged
native Dictionary storage and adopt it if KeyType and ValueType match
exactly

This was the last missing piece to allow Dictionary to round-trip
thorough objc entrypoints of Swift methods in O(1).

Fixes rdar://17556319, partially fixes rdar://17010353

Swift SVN r19873
2014-07-12 01:17:13 +00:00
Joe Groff
34592229ff AppKit overlay: Make NSApplicationMain overlay public.
Enabling access control caused a regression in <rdar://problem/17577380>. Add a parse test so we don't regress again.

Swift SVN r19857
2014-07-11 18:48:55 +00:00
Nadav Rotem
bb3ad55201 Document the use of the non overflowing arithmetic when multiplying sizeof() by 8.
Swift SVN r19856
2014-07-11 18:35:23 +00:00
Dmitri Hrybenko
9cbf6df734 stdlib/Dictionary: add _DictionaryBuilder, which is faster than adding elements
one by one.

Use _DictionaryBuilder in Foundation overlay instead of poking Dictionary's
internals directly.


Swift SVN r19855
2014-07-11 17:35:32 +00:00
Dmitri Hrybenko
bc682c8e3e stdlib: coding style: don't hide 'public' at the end of the line where it is
hard to notice it


Swift SVN r19854
2014-07-11 17:26:25 +00:00
Dmitri Hrybenko
ee06efdd2c stdlib/Dictionary: when bridging Dictionary of non-verbatim-bridged
types to NSDictionary, perform bridging operation in O(1), and defer
bridging of the contents until the NSDictionary is accessed

There is no cache for bridged keys and values; the Swift NSDictionary
will return values with different pointer values when a given key is
repeatedly accessed.

Part of rdar://17556319

Does not fix the O(N) performance of objc thunks, because Dictionary is
not recognizing its own native storage when bridging from Objective-C.
This tracked by rdar://17010353

Swift SVN r19853
2014-07-11 17:24:06 +00:00
Andrew Trick
8882999b63 Add Array semantic model.
This unblocks work on bounds and mutable check hoisting. Pete is also
tuning -O3 Array performance, which should be done on top of this
patch.

Overall, this significantly improves performance, but there is one
issue that causes regressions on Hash and QuickSort at -O3 only. This
patch does not cause the performance issue. It is already a serious
problem that needs to be fixed. This patch just adds a level of benign
function calls that further exposes the existing performance problem.
We are independently working on fixing this: <rdar://problem/17634697>
Array access forces retain/release of storage object for each inlined
call.

-O3
| benchmark    | baserun0 | baserun1 | baserun2 |  optrun0 |  optrun1 |  optrun2 |   delta | speedup |
| Dictionary   |  1072.00 |  1087.00 |  1099.00 |  1060.00 |  1132.00 |  1172.00 |   12.00 |    1.1% |
| EditDistance |  1602.00 |  1612.00 |  1611.00 |  1646.00 |  1652.00 |  1678.00 |   44.00 |   -2.7% |
| ForLoops     |  1511.00 |  1506.00 |  1519.00 |  1519.00 |  1521.00 |  1614.00 |   13.00 |   -0.9% |
| Forest       |  1245.00 |  1233.00 |  1252.00 |  1233.00 |  1248.00 |  1245.00 |    0.00 |    0.0% |
| GlobalClass  |  3624.00 |  3571.00 |  3569.00 |  3533.00 |  3540.00 |  3548.00 |   36.00 |    1.0% |
| Hash         |  1855.00 |  1760.00 |  1796.00 |  2085.00 |  2160.00 |  2075.00 |  315.00 |  -15.2% |
| Histogram    |  1695.00 |  1714.00 |  1763.00 |  1802.00 |  1865.00 |  1987.00 |  107.00 |   -5.9% |
| LinkedList   |  1584.00 |  1594.00 |  1587.00 |  1576.00 |  1598.00 |  1652.00 |    8.00 |    0.5% |
| NBody        |   700.00 |   698.00 |   691.00 |   480.00 |   479.00 |   484.00 |  212.00 |   44.3% |
| Phonebook    |  1886.00 |  1814.00 |  1849.00 |  1823.00 |  1801.00 |  1836.00 |   13.00 |    0.7% |
| QuickSort    |   248.00 |   245.00 |   237.00 |   265.00 |   287.00 |   291.00 |   28.00 |  -10.6% |
| R17315246    |   541.00 |   545.00 |   549.00 |   551.00 |   561.00 |   578.00 |   10.00 |   -1.8% |
| RC4          |  1664.00 |  1781.00 |  1776.00 |   953.00 |   961.00 |   974.00 |  711.00 |   74.6% |
| Rectangles   |   739.00 |   725.00 |   734.00 |   724.00 |   719.00 |   729.00 |    6.00 |    0.8% |
| SmallPT      |  1421.00 |  1429.00 |  1406.00 |   574.00 |   589.00 |   599.00 |  832.00 |  144.9% |
| StringWalk   |   651.00 |   647.00 |   653.00 |   645.00 |   633.00 |   673.00 |   14.00 |    2.2% |
| Total        | 26525.00 | 26445.00 | 26593.00 | 24908.00 | 25227.00 | 25793.00 | 1537.00 |    6.2% |
-Ofast
| benchmark    | baserun0 | baserun1 | baserun2 |  optrun0 |  optrun1 |  optrun2 |  delta | speedup |
| Dictionary   |  1103.00 |  1051.00 |  1047.00 |  1051.00 |  1033.00 |  1036.00 |  14.00 |    1.4% |
| EditDistance |  1554.00 |  1493.00 |  1512.00 |  1524.00 |  1511.00 |  1524.00 |  18.00 |   -1.2% |
| ForLoops     |  1644.00 |  1610.00 |  1612.00 |  1638.00 |  1628.00 |  1630.00 |  18.00 |   -1.1% |
| Forest       |  1118.00 |  1066.00 |  1105.00 |  1062.00 |  1079.00 |  1076.00 |   4.00 |    0.4% |
| GlobalClass  |  2226.00 |  2204.00 |  2194.00 |  2248.00 |  2227.00 |  2234.00 |  33.00 |   -1.5% |
| Hash         |  1006.00 |   967.00 |   975.00 |   998.00 |   996.00 |  1011.00 |  29.00 |   -2.9% |
| Histogram    |  1324.00 |  1173.00 |  1225.00 |  1197.00 |  1183.00 |  1217.00 |  10.00 |   -0.8% |
| LinkedList   |  1558.00 |  1552.00 |  1558.00 |  1560.00 |  1571.00 |  1558.00 |   6.00 |   -0.4% |
| NBody        |   910.00 |   906.00 |   903.00 |   796.00 |   790.00 |   789.00 | 114.00 |   14.4% |
| Phonebook    |  1659.00 |  1649.00 |  1638.00 |  1846.00 |  1713.00 |  1613.00 |  25.00 |    1.5% |
| QuickSort    |   699.00 |   700.00 |   689.00 |   686.00 |   679.00 |   679.00 |  10.00 |    1.5% |
| R17315246    |     0.00 |     0.00 |     0.00 |     0.00 |     0.00 |     0.00 |   0.00 |       * |
| RC4          |  1281.00 |  1227.00 |  1234.00 |  1056.00 |  1051.00 |  1066.00 | 176.00 |   16.7% |
| Rectangles   |   726.00 |   772.00 |   738.00 |   737.00 |   727.00 |   721.00 |   5.00 |    0.7% |
| SmallPT      |   978.00 |   963.00 |   971.00 |   629.00 |   623.00 |   631.00 | 340.00 |   54.6% |
| StringWalk   |   456.00 |   462.00 |   450.00 |   467.00 |   461.00 |   445.00 |   5.00 |    1.1% |
| Total        | 22315.00 | 21688.00 | 21716.00 | 21589.00 | 21342.00 | 21294.00 | 394.00 |    1.9% |

Swift SVN r19849
2014-07-11 16:44:16 +00:00
Nadav Rotem
f4a470979b Use unsafe arithmetic for basic sizeof and alignof calculations.
Swift SVN r19838
2014-07-11 00:03:57 +00:00
Nadav Rotem
98ab6d8286 Perform unsafe arithmetic on sizeof() calculations. This calculation is unlikely to overflow. I did not see a noticable performance change to the string benchmarks.
Swift SVN r19836
2014-07-10 23:43:15 +00:00
Enrico Granata
2cd27ad3d2 Tweaks to get PlaygroundLogger to build and work in a world of accessibility-enforced rules
1) Add an ObjCObject disposition that tells us this Mirror is reflecting upon an ObjC-imported type
2) Change the default summary of _ClassMirror and _StructMirror to be the mangled typename, with no children count



Swift SVN r19817
2014-07-10 18:54:25 +00:00
Ben Langmuir
a0f72c56f1 Change _swift_fmodf to return float
Hoping this fixes the armv7 test failures.

Swift SVN r19811
2014-07-10 16:39:08 +00:00
Dmitri Hrybenko
86f58123f9 stdlib/Array: hide some Array implementation details:
ArrayBuffer
ArrayBufferType
ContiguousArrayBuffer
ContiguousArrayStorage
IndirectArrayBuffer
SliceBuffer

Unfortunately, can not remove 'public' from them since they are used by
Foundation overlay in bridging code.


Swift SVN r19810
2014-07-10 14:30:54 +00:00
Dmitri Hrybenko
8ea2b6b887 stdlib/Array: remove some dead code that supported 'Array' being named
'NewArray'


Swift SVN r19809
2014-07-10 13:33:12 +00:00
Dmitri Hrybenko
54efce9aa5 stdlib/Dictionary bridging: optimize NSDictionary to Dictionary conversion
during eager bridging

rdar://17325454


Swift SVN r19808
2014-07-10 13:18:07 +00:00
Dmitri Hrybenko
0e59dcac1f stdlib/Dictionary bridging: don't wrap NSDictionary in Dictionary<K, V> when
either K or V is bridged non-verbatim

rdar://17325454


Swift SVN r19807
2014-07-10 12:02:22 +00:00
Dmitri Hrybenko
909d49495c stdlib/Dictionary: remove debug output that I accidentally committed
Swift SVN r19806
2014-07-10 11:33:35 +00:00
Dmitri Hrybenko
febc98d5a4 stdlib/Dictionary: change internal bridging interfaces so that wrong code (that
does not copy NSDictionary) looks wrong


Swift SVN r19804
2014-07-10 09:45:42 +00:00
Dave Abrahams
cf6842efdb [stdlib] Drop the "by" method on Range<T>
That functionality is now covered by the stride() functions for
Range<T:RandomAccessIndex>, and probably shouldn't be used for ranges of
lesser Index protocols anyway.

Swift SVN r19803
2014-07-10 09:29:03 +00:00
Dave Abrahams
0cbd541a16 [stdlib] Floating point types are Strideable...
...but not RandomAccessIndex'en

Swift SVN r19802
2014-07-10 09:19:28 +00:00
Dave Abrahams
4c31d819ec [stdlib] Striding over closed ranges
Swift SVN r19801
2014-07-10 09:10:02 +00:00
Dave Abrahams
34374354cd [stdlib] Striding over half-open ranges
Swift SVN r19800
2014-07-10 08:44:31 +00:00
Dave Abrahams
c36beddfb4 [stdlib] Every FloatingPointNumber is Strideable
Swift SVN r19795
2014-07-10 06:56:36 +00:00
Dave Abrahams
bec9a26380 [stdlib] Strideable refines Comparable
We can stop handling Comparable explicitly as part of RandomAccessIndex,
because RandomAccessIndex is Strideable

Swift SVN r19794
2014-07-10 06:56:36 +00:00
Chris Lattner
5b49d59c57 Remove the @ from @final and @lazy, the last major piece of
rdar://17168115.

Also, reinstate the ARM driver change and testcase that I removed
in my last patch.


Swift SVN r19790
2014-07-10 06:23:27 +00:00
Dave Abrahams
9e89dba36f [stdlib] make FloatingPoint.swift.gyb parse as swift
Swift SVN r19786
2014-07-10 05:43:28 +00:00
Dave Abrahams
eb1a5cfac4 [stdlib] Add Strideable protocol
And make RandomAccessIndex refine it.

* had to XFAIL
  test/Prototypes/TextFormatting.swift (<rdar://problem/17619178>)

* Had to compromise on the name of Strideable's associated
  type (<rdar://problem/17619038>)

Swift SVN r19785
2014-07-10 05:39:13 +00:00
Dave Abrahams
3e3f4a6e52 Revert "infix + and - for RandomAccessIndex"
This commit was premature; we're having trouble with protocols that needs to be
resolved first.

This reverts r19778

Swift SVN r19780
2014-07-10 04:47:12 +00:00
Dave Abrahams
64c6d32a99 [stdlib] infix + and - for RandomAccessIndex
A step towards implementing generalized striding

Swift SVN r19778
2014-07-10 04:16:53 +00:00
Greg Parker
bde0d301fc Fix fmod() covers. Add CGFloat to the math.h tests.
<rdar://problem/17275152> Can't call C fmodf() from stdlib


Swift SVN r19777
2014-07-10 03:54:27 +00:00
Dave Abrahams
b56c3a84d3 [stdlib] Drop Sliceable conformance for Range<T>
Sliceable is a totally non-critical protocol and Range slicing wasn't
even being tested.  Along with r19771, fixes <rdar://problem/16363898>

Swift SVN r19775
2014-07-10 02:08:46 +00:00
Dave Abrahams
b84a3377f0 [stdlib] Drop ReverseRange
Swift SVN r19773
2014-07-10 01:20:58 +00:00
Dave Abrahams
e261dda22b [stdlib] Give reverse() the eager/lazy treatments
Swift SVN r19772
2014-07-10 01:20:57 +00:00
Dave Abrahams
58f94698c3 [stdlib] Disallow indexing integer ranges with Int
This horrible hack prevents the user from indexing Range<I>, for all
integer types I, outside of a generic context.  This seems to be the
best we can do to prevent confusion given the current language.

Addresses <rdar://problem/16363898>

Unfortunately, I can't make this work for slicing ranges yet.

Swift SVN r19771
2014-07-10 01:20:57 +00:00
Dave Abrahams
9918145209 [stdlib] Drop RandomAccessRange
It won't be needed in the new Range plan after all

Swift SVN r19770
2014-07-10 01:20:56 +00:00
Doug Gregor
c7adb497ba Blocks "are" classes, from the runtime perspective.
This allows arrays of blocks to be bridged at runtime
<rdar://problem/17035548>.

Swift SVN r19765
2014-07-10 00:12:14 +00:00
Jordan Rose
254930a134 Update stdlib for r19751.
Swift SVN r19755
2014-07-09 22:56:25 +00:00
Jordan Rose
44b93b5ebc [XCTest] Fix enumerator names after r19732.
Swift SVN r19736
2014-07-09 19:48:34 +00:00
Enrico Granata
8cfde77fbb Part of logging an NSView is redrawing it if it's dirty
However, a view can ask to be redrawn by setting its needsDisplay flag to true
When this happens in a playground, the
self.needsDisplay = true line
forces the view to be logged - logging the view forces it to be redrawn, and unless there's a way out that does not force-redraw, this ends up being an endless loop & of course at some point we run out of stack, and "random" crashes ensue

Add a set of views currently being logged and add/remove views as needed to ensure we don't try to actively log the same view twice

Since UI drawing can only happen on the main thread, if you try to concurrently log views from different threads, you already have a problem, so this can be treated as a single-threaded problem

Fixes <rdar://problem/17027976>


Swift SVN r19730
2014-07-09 18:23:52 +00:00
Doug Gregor
2f3f6acf21 Make "true" and "false" Boolean literal constants for the BooleanLiteralConvertible protocol.
Introduce the new BooleanLiteralConvertible protocol for Boolean
literals. Take "true" and "false" as real keywords (which is most of the
reason for the testsuite churn). Make Bool BooleanLiteralConvertible
and the default Boolean literal type, and ObjCBool
BooleanLiteralConvertible. Fixes <rdar://problem/17405310> and the
recent regression that made ObjCBool not work with true/false.


Swift SVN r19728
2014-07-09 16:57:35 +00:00
Dmitri Hrybenko
f0621d1563 stdlib/Dictionary: eliminate invalid reinterpret casts
rdar://17509909


Swift SVN r19727
2014-07-09 16:03:46 +00:00
Dmitri Hrybenko
435a8ddf0c stdlib/Dictionary: copy the NSDictionary before wrapping it, so that
NSMutableDictionary and other mutable NSDictionary subclasses don't break
Dictionary's value semantics

rdar://17442261


Swift SVN r19726
2014-07-09 15:13:17 +00:00
Dmitri Hrybenko
19f3875079 stdlib/Array: remove === and !== for array types
Swift SVN r19725
2014-07-09 15:06:32 +00:00
Dmitri Hrybenko
0523fea01b stdlib/Dictionary: rewrite iteration over wrapped NSDictionary not to
rely on NSDictionary.allKeys, it leaves the array of keys on the
autorelease pool.  Not very bad, but it is better if we can avoid it.

rdar://17604820

Swift SVN r19724
2014-07-09 14:49:49 +00:00
Chris Hanson
73d268f0a9 XCTest: Use the new convention for format strings
When asking XCTest to generate format strings for assertions, pass the
requested index + 100 to ask XCTest to generate a string without space
for the expressions themselves, and don't bother passing them either
(since the overlay isn't actually generating stringified expressons).

Addresses <rdar://problem/17597526>.

Swift SVN r19712
2014-07-08 23:27:34 +00:00
Chris Lattner
02999cac51 Reinstate the @ on the @objc attribute. This is largely a revert of r19555 with a few tweaks.
Swift SVN r19706
2014-07-08 21:50:34 +00:00
Andrew Trick
7ed7be9c14 Put cocoa on the slow path of String.subscript.
Swift SVN r19700
2014-07-08 21:43:16 +00:00
Doug Gregor
8fb9a19542 Replace the "string" property of String.UnicodeScalarView with a String initializer.
Swift SVN r19695
2014-07-08 20:25:30 +00:00
Doug Gregor
0d6df5f78d Remove Bool <-> ObjCBool conversions.
There's a regression here because we can no longer use "true" or
"false" with ObjCBool. We'll get that back when true and false become
literals.


Swift SVN r19694
2014-07-08 20:17:35 +00:00
Doug Gregor
e6a71b8363 Remove the implicit CFString -> String conversion
Swift SVN r19693
2014-07-08 20:07:49 +00:00