Commit Graph

745 Commits

Author SHA1 Message Date
Dave Abrahams
1fb0f889d7 [stdlib] Make UnsafePointer conversions explicit
Previously, it was possible to write Unsafe[Mutable]Pointer(x) and have
Swift deduce the pointee type based on context.  Since reinterpreting
memory is a fundamentally type-unsafe operation, it's better to be
explicit about conversions from Unsafe[Mutable]Pointer<T> to
Unsafe[Mutable]Pointer<U>.  This change is consistent with the move from
reinterpretCast(x) to unsafeBitCast(x, T.self).

Also, we've encoded the operations of explicitly adding or removing
mutability as properties, so that adding mutability can be separated
from wild reinterpretCast'ing, a much more severe form of unsafety.

Swift SVN r21324
2014-08-20 23:15:56 +00:00
Adrian Prantl
7a58f76fe8 Revert "[test] Disable autorelease optimization test on arm64 pending rdar://17999904."
Akira fixed this in LLVM. rdar://18032228

Swift SVN r21237
2014-08-15 19:33:53 +00:00
Dmitri Hrybenko
8cca039e62 StdlibUnittest: rename TestCase to TestSuite since it contains multiple tests
Thanks, Ben!


Swift SVN r21222
2014-08-15 00:09:58 +00:00
Anna Zaks
c519ecfe4f API Notes File: The product of the 2d nullability audit of Foundation.
As well as the required test/stdlib modifications.

Swift SVN r21181
2014-08-13 19:39:59 +00:00
Greg Parker
a4e5452ae6 [test] Disable autorelease optimization test on arm64 pending rdar://17999904.
Swift SVN r21165
2014-08-13 01:35:41 +00:00
Doug Gregor
8df878c02a Give CGRect/CGSize/CGVector initializers that take Doubles.
Now that CGFloat is its own distinct type, it's useful to have Double
initializers to go along with the Int initializers we added a while
back <rdar://problem/17224725>.

Swift SVN r21156
2014-08-12 21:54:50 +00:00
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
Anna Zaks
ca03e527c3 API Notes File: Add the notes generated as the product of the first nullability audit of Foundation
As well as the required test modifications.

Swift SVN r21126
2014-08-09 01:40:48 +00:00
Jordan Rose
903cfacfa5 [DebugInfo] When looking up an imported module, don't include the scope.
i.e. for "import func Darwin.C.sqrt", use the module path "Darwin.C",
not the full path "Darwin.C.sqrt".

<rdar://problem/17895650>

Swift SVN r21097
2014-08-07 21:26:34 +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
Jordan Rose
ee22004b84 [IRGen] Walk inlineable Clang functions and emit their dependencies.
This handles things like NSSwapHostLongLongToBig and MKMapRectMake that
are static inline functions that themselves call other static inline
functions.

<rdar://problem/17227237>

Swift SVN r21080
2014-08-06 23:21:17 +00:00
Joe Groff
0fb61b3c33 Interpreter test for @objc unowned reference.
Swift SVN r21076
2014-08-06 21:32:53 +00:00
Jordan Rose
9b07f35cc0 Audit NSDictionary's subscript.
This requires a bit of special handling because we override the getter's type
in the importer, to make sure it's compatible with the setter, but other than
that we just use the information from the apinotes file.

<rdar://problem/17891179>

Swift SVN r21027
2014-08-04 23:16:53 +00:00
Doug Gregor
4ff01af85a Remove most of the 'NS' types from the dictionary pattern matching example.
This now makes use of bridging and IUO unwrapping in "switch".

Swift SVN r21020
2014-08-04 17:21:44 +00:00
Doug Gregor
bb02b85e74 Implicitly introduce .Some(x) to balance out optionals in is/as patterns.
This allows us to switch on an optional value and match it to concrete
values without explicitly writing the ".Some"'s. Better testing to follow...

Swift SVN r21018
2014-08-04 17:01:53 +00:00
Jordan Rose
5197f3c506 [test] Don't assume Dictionary contents are ordered.
Swift SVN r21000
2014-08-04 07:00:40 +00:00
Doug Gregor
1c484d91a0 Allow bridging "as" patterns in switch cases <rdar://problem/17408934>.
We now allow switches like this:

  switch anyObject {
  case let str as String: // bridged via NSString
    println(str) 

  case let intArr as [Int]: // bridged via NSArray
    println(intArr)

  default:
  }

Note that we do not allow collection downcasting in switch statements
(yet); that's covered by <rdar://problem/17897378>.



Swift SVN r20976
2014-08-03 19:58:49 +00:00
Doug Gregor
df9fd70421 Dynamic casting: test class-existential-to-value casts via bridging.
These casts were already functional. <rdar://problem/17637959> appears
to be done.


Swift SVN r20965
2014-08-03 05:22:01 +00:00
Doug Gregor
c66a1ef98f Dynamic casting: handle value-to-class-existential casts via bridging.
This allows one to cast a value type (say, [String]) to AnyObject or
NSCoding, for example. It's another piece of <rdar://problem/17637959>.


Swift SVN r20964
2014-08-03 05:15:47 +00:00
Doug Gregor
4c06dff759 Dynamic casting: Handle object-to-value casts that use bridging.
For example, this allows dynamic casts from NSArray to [Int], using
bridging. Part of <rdar://problem/17637959>.


Swift SVN r20963
2014-08-03 04:11:45 +00:00
Jordan Rose
c75bdc81e1 [test] Drop import of UIKit in this test; we don't want to bring in OpenGL.
This was causing the iOS build to fail.

Swift SVN r20943
2014-08-02 02:20:17 +00:00
Doug Gregor
439e7ecafe Separate forced from conditional tests. NFC
Swift SVN r20907
2014-08-01 18:51:24 +00:00
Doug Gregor
fd3fa7228f Dynamic casting from Objective-C bridged value types to class types.
First part of <rdar://problem/17637959>.

Swift SVN r20906
2014-08-01 18:44:05 +00:00
Greg Parker
c5b71e9e42 Don't use punycode when mangling names for Objective-C metadata.
Swift SVN r20886
2014-08-01 05:19:28 +00:00
Jordan Rose
a627411b43 [ClangImporter] Imported NS_OPTIONS structs should not conform to BooleanType.
In general, RawOptionSetType no longer inherits from BooleanType.

Swift SVN r20846
2014-07-31 19:23:08 +00:00
Dmitri Hrybenko
cbdefd719b Unbreak iOS builds: there is no NSRectEdge on iOS
Swift SVN r20755
2014-07-30 13:08:11 +00:00
Greg Parker
af25d7c6b0 [test] Fix un-terminated cstring in test Interpreter/SDK/libc.swift.
Swift SVN r20753
2014-07-30 11:53:38 +00:00
Dmitri Hrybenko
fc05064131 Foundation overlay: introduce correctly-typed NS{Min,Max}{X,Y}Edge constants
that correspond to macros in the SDK

... and revert the previous attempt at fixing this, r20269.

rdar://16593744


Swift SVN r20752
2014-07-30 11:33:25 +00:00
Dmitri Hrybenko
ac0d9b8175 stdlib/CGFloat: GYB'ify initializers that convert between CGFloat and
integer types.  Never miss an integer type again.

rdar://17853313

Swift SVN r20751
2014-07-30 11:24:11 +00:00
Joe Pamer
db085b95e8 Fix rdar://problem/17584531 ("Crash in emitDynamicSubscript on access of multiple Foundation containers by subscript")
In buildSubscript, when forcing an implicitly unwrapped optional base expression of a subscript expression, we weren't updating the base type in for later use. In the case of a nested subscript expression, this could cause us to coerce to the wrong inner type.

Swift SVN r20736
2014-07-30 05:08:08 +00:00
Joe Pamer
1fec0afbd0 Disallow value-to-optional conversions between argument and parameter types when resolving overloads for operators applied to nil literal operands.
This is a targeted fix to address rdar://problem/16848110 ("Disallow non-optionals to be compared to nil") and its associated dupes.

Swift SVN r20716
2014-07-29 23:24:36 +00:00
Dave Abrahams
9a13a7148b [stdlib] Consolidate bridging protocols
Squash _[Conditionally]BridgedToObjectiveC into one protocol.  This
change results in simpler bridging code with fewer dynamic protocol
conformance checks, and solves the nasty naming/semantics problem that
resulted from having _ConditionallyBridgedToObjectiveC refining
_BridgedToObjectiveC.

Also, rename things so they're more symmetrical and less confusing.

Swift SVN r20664
2014-07-29 01:30:27 +00:00
Joe Pamer
f55c751958 Add a fixit for optional-typed expressions used in conditional expression positions.
Swift SVN r20639
2014-07-28 19:20:42 +00:00
Joe Pamer
94dac129d4 Remove the BooleanType conformance from optional types (rdar://problem/17110911)
To limit user confusion when using conditional expressions of type Bool?, we've decided to remove the BooleanType (aka "LogicValue") conformance from optional types. (If users would like to use an expression of type Bool? as a conditional, they'll need to check against nil.)

Note: This change effectively regresses the "case is" pattern over types, since it currently demands a BooleanType conformance. I've filed rdar://problem/17791533 to track reinstating it if necessary.

Swift SVN r20637
2014-07-28 19:20:39 +00:00
Jordan Rose
ee176e7269 [ClangImporter] Give NS_OPTIONS structs a static 'allZeros' property.
This will allow RawOptionSet to conform to BitwiseOperations.

<rdar://problem/17815538>

Swift SVN r20600
2014-07-27 00:47:41 +00:00
Doug Gregor
bc0648ffca Test UInt construction from a CGFloat
Swift SVN r20550
2014-07-25 18:20:16 +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
Doug Gregor
64e73744bd Mark NSString's designated initializers.
Different SDKs have different beliefs on what NSString's designated
initializers are. Use API notes to smooth over the differences.


Swift SVN r20498
2014-07-24 17:16:36 +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
Doug Gregor
eee00ca58b Require 'required' keyword when overriding a required initializer.
Swift SVN r20489
2014-07-24 15:30:15 +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
Jordan Rose
b6818046a8 Eliminate optimization levels 0-3 in favor of -Onone/-O/-Ofast.
We were already effectively doing this everywhere /except/ when building
the standard library (which used -O2), so just use the model we want going
forward.

Swift SVN r20455
2014-07-24 01:12:59 +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
070ee7713a Treat imported initializers from Objective-C protocols as 'required'.
Initializers for non-final classes will soon need to be 'required' to
conform to an initializer requirement in a protocol, so start
marking imported initializers from Objective-C protocols as
'required'. This is part of <rdar://problem/17408284> and
<rdar://problem/17415607>.

Swift SVN r20428
2014-07-23 22:16:35 +00:00
Dmitri Hrybenko
766c9816de stdlib: underscore-prefix String.core
Swift SVN r20411
2014-07-23 16:28:57 +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
Mark Lacey
a7556c89f9 Enable transparent inlining of some generic functions.
Fixes part of <rdar://problem/16196801>.

Inline generic functions, but only when:

- There are no unbound archetypes being substituted (due to various
  assumptions in TypeSubstCloner about having all concrete types).

- When no substitution is an existential (due to
  <rdar://problem/17431105>, <rdar://problem/17544901>, and
  <rdar://problem/17714025>).

This gets things limping along, but we really need to fix the above
limitations so that mandatory inlining never fails.

This doesn't enable inlining generics in the performance inliner. There
is no reason it shouldn't work as well, but there is no compelling
reason to do so now and it could have unintended effects on performance.

Some highlights from PreCommitBench -
O0:
            old (ms)   new (ms)  delta (ms)   speedup
ForLoops    1127.00     294.00      833.00     283.3%
LinkedList   828.00     165.00      663.00     401.8%
R17315246    982.00     288.00      694.00     241.0%
SmallPT     3018.00    1388.00     1630.00     117.4%
StringWalk  1276.00      89.00     1187.00    1333.7%
-- most others improve ~10% --

O3:
            old (ms)   new (ms)  delta (ms)   speedup
Ackermann   4138.00    3724.00      414.00      11.1%
Life          59.00      64.00        5.00      -7.8%
Phonebook   2103.00    1815.00      288.00      15.9%
R17315246    430.00     582.00      152.00     -26.1%
StringWalk  1173.00    1097.00       76.00       6.9%

Ofast:
            old (ms)   new (ms)  delta (ms)   speedup
Ackermann   3505.00    3715.00      210.00      -5.7%
Life          49.00      41.00        8.00      19.5%
Memset       684.00     554.00      130.00      23.5%
Phonebook   2166.00    1769.00      397.00      22.4%
StringWalk   829.00     790.00       39.00       4.9%

I've opened the following to track remaining issues that need to be
fixed before we can inline all transparent function applications:
<rdar://problem/17431105>
<rdar://problem/17544901>
<rdar://problem/17714025>
<rdar://problem/17768777>
<rdar://problem/17768931>
<rdar://problem/17769717>

Swift SVN r20378
2014-07-23 06:29:23 +00:00
Jordan Rose
709327b4d7 [test] Fix submodules_smoke_test.swift again.
Per Ben's suggestion, use OpenAL as an example of a module with only
explicit submodules. Continue testing OpenGL on OS X since we've gotten
several bugs about it.

Swift SVN r20320
2014-07-22 17:15:56 +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