Commit Graph

21665 Commits

Author SHA1 Message Date
Enrico Granata
b730ab0da7 Add a Mirror for Interval types
Swift SVN r19983
2014-07-15 20:31:30 +00:00
Chris Lattner
3ad9c58c18 Disallow (with a nice fixit) the infix modifier on func decls, it is just validated
and ignored anyway.  It is still required on operator decls though.


Swift SVN r19978
2014-07-15 16:52:04 +00:00
Dave Abrahams
b5f682b4d3 [stdlib] @availability for renamed protocols
Swift SVN r19964
2014-07-14 23:09:09 +00:00
Chris Lattner
e0b0205cd7 Remove the @assignment attribute entirely. It doesn't do anything except
enforce its own little constraints.  The type checker isn't using it for
anything, and it is just clutter.

This resolves <rdar://problem/16656024> Remove @assignment from operator implementations



Swift SVN r19960
2014-07-14 22:44:25 +00:00
Doug Gregor
71cd9245ba Rename swift_stdlib_core -> swiftCore and swift_runtime -> swiftRuntime.
We can't use underscores in plists, so just makes the names consistent
<rdar://problem/17652418>.

Swift SVN r19954
2014-07-14 22:19:03 +00:00
Dave Abrahams
166ebb2996 [stdlib] Add Range pattern matching
But it doesn't work yet, pending rdar://17668465

Swift SVN r19946
2014-07-14 21:02:30 +00:00
Dave Abrahams
fa991ca164 [stdlib] deep debugDescription for Interval/Range
debugDescription on a type that represents its subparts should use
toDebugString() for their representations.

Swift SVN r19937
2014-07-14 17:53:25 +00:00
Chris Lattner
f0911fd4ed Update the .gyb file.
Swift SVN r19934
2014-07-14 17:13:36 +00:00
Chris Lattner
57cd2506ff Change "operator infix" to "infix operator" for consistency with the rest of the declaration
modifiers and with the func implementations of the operators.  This resolves the rest of:
<rdar://problem/17527000> change operator declarations from "operator prefix" to "prefix operator" & make operator a keyword




Swift SVN r19931
2014-07-14 16:39:10 +00:00
Chris Lattner
8991456ff2 Switch infix/postfix/prefix to be declaration modifiers instead of attributes,
eliminating the @'s from them when used on func's.  This is progress towards
<rdar://problem/17527000> change operator declarations from "operator prefix" to "prefix operator" & make operator a keyword

This also consolidates rejection of custom operator definitions into one
place and makes it consistent, and adds postfix "?" to the list of rejected
operators.

This also changes the demangler to demangle weak/inout/postfix and related things
without the @.



Swift SVN r19929
2014-07-14 15:51:49 +00:00
Chris Lattner
d3ee7520fe remove the old .. operator.
Swift SVN r19926
2014-07-14 14:29:47 +00:00
Dave Abrahams
cced061ee9 [stdlib] Printable conformance for Range
Swift SVN r19906
2014-07-13 21:21:32 +00:00
Dave Abrahams
9ecbdc2135 [stdlib] punctuation fix in comment
Swift SVN r19905
2014-07-13 21:21:30 +00:00
Dave Abrahams
be37cd904b [stdlib] Trap invalid Ranges of Comparable Indexes
When the Index type of a Range is Comparable, we can reject invalid
ranges at their formation.

It might be worth injecting some checkability concept into ForwardIndex
so that even in generic contexts where Comparability is unknown, we can
do this same check in the Range constructor.

Also, remove pattern matching support for Ranges of RandomAccessIndex,
as that is covered by Interval.

Fixes <rdar://problem/16254937> (#Seed 4: Ranges with negative strides
are broken) to the extent possible (it's still possible to form an
invalid Range of indices that are not Comparable)

Fixes <rdar://problem/17164391> (Swift: Using ranges in for in for
counting down, causes the loop to go inifinely)

Fixes <rdar://problem/17580871> (Swift: Closed range with negative
endpoint excludes that endpoint)

Swift SVN r19903
2014-07-13 19:58:21 +00:00
Dave Abrahams
d85a7f5d0c [stdlib] Pointer types are not BooleanType's
Fixes <rdar://problem/17597917>.  Someone still needs to do this for the
Optional types.

Swift SVN r19901
2014-07-13 19:21:54 +00:00
Dave Abrahams
cb050eee52 [stdlib] Add Interval support
This allows 0.0..<10.3 and 0.1...4.4 to work properly in pattern
matching.

Fixes <rdar://problem/12016900> (#Seed 4: add a "contains" method to the
range types) by making "contains" available on Interval

Addresses <rdar://problem/16254937> (#Seed 4: Ranges with negative
strides are broken) by making the formation of an invalid Interval a
runtime error.

Fixes <rdar://problem/16304317> (Range<T> has limited awesomeness: it is
restricted to types that conform to ForwardIndex)

Fixes <rdar://problem/16736924> (#Seed 4: Enable range inclusion pattern
matching for all types that conform to Equatable and Comparable)

Addresses <rdar://problem/16846325> (#Seed 4: Introduce index range) by
distinguishing Range (which operates on indices) from Interval

Fixes <rdar://problem/17051263> (Pattern-matching a Double range with an
infinite endpoint triggers an assertion failure)

Fixes <rdar://problem/17051271> (#Seed 4: Pattern-matching Double ranges
excludes fractional values)

Addresses <rdar://problem/17171420> (Separate types for closed and
half-open ranges)

Swift SVN r19900
2014-07-13 18:49:36 +00:00
Dmitri Hrybenko
b53ed944b0 stdlib: replace masking arithmetic with less complex code
Swift SVN r19899
2014-07-13 15:42:51 +00:00
Dmitri Hrybenko
45f9706c22 stdlib/Dictionary: remove 'public' from more Dictionary implementation details
Swift SVN r19898
2014-07-13 12:21:20 +00:00
Dmitri Hrybenko
08d6650828 stdlib/Dictionary: move implementation of Dictionary.bridgeToObjectiveC() from
Foundation overlay to core stdlib, and remove 'public' from some Dictionary
implementation details


Swift SVN r19897
2014-07-13 11:51:23 +00:00
Doug Gregor
a5c079af59 Replace the class_protocol attribute with a "class" requirement.
This only tackles the protocol case (<rdar://problem/17510790>); it
does not yet generalize to an arbitrary "class" requirement on either
existentials or generics.

Swift SVN r19896
2014-07-13 06:57:48 +00:00
Dave Abrahams
0412b0cfc1 [stdlib] BooleanType is just for Bools
For now, it still applies to Optionals and Pointers, but this commit
removes it from everything else.

Swift SVN r19888
2014-07-13 01:19:39 +00:00
Dave Abrahams
bf55e6b4ed [stdlib] s/FloatingPointNumberType/FloatingPointType/
Swift SVN r19887
2014-07-13 01:00:51 +00:00
Dave Abrahams
cbcf9aba21 s/LogicValueType/BooleanType/
We're moving toward using that protocol for straight-up Bool types

Swift SVN r19884
2014-07-12 18:58:18 +00:00
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