Commit Graph

7762 Commits

Author SHA1 Message Date
Doug Gregor
6fe861474c Revert "[stdlib] Workaround for <rdar://20409234>"
This reverts r27080; the workaround is no longer necessary.

Swift SVN r27085
2015-04-07 16:40:18 +00:00
Dave Abrahams
367b2e40f0 [stdlib] Mirror -> public/core
The new mirror design passed our API review and blocking bugs have been
fixed/worked-around, so integrating it into the core standard library.

Swift SVN r27082
2015-04-07 15:33:49 +00:00
Dave Abrahams
a80b1a4caa [stdlib] [Generator|Sequence]Of => Any[Generator|Sequence]
Retire the old components now that the new ones have passed API review.

<rdar://20406937> covers the migration fallout of this change.

Swift SVN r27081
2015-04-07 15:20:40 +00:00
Dave Abrahams
ed5156e3ee [stdlib] Workaround for <rdar://20409234>
Doug will revert this any second now when he checks in his fix

Swift SVN r27080
2015-04-07 15:12:12 +00:00
Dave Abrahams
4ba169ae16 [stdlib] ExistentialCollection -> public/core
It passed our API review so integrating it into the core standard
library.

Swift SVN r27079
2015-04-07 15:12:10 +00:00
Dmitri Hrybenko
1b9ca12c5b stdlib: remove old declarations that were marked unavailable
rdar://20169533

Swift SVN r27020
2015-04-05 09:15:49 +00:00
Dmitri Hrybenko
ff2dd6320a stdlib: fix coding style
When colon specifies is-a relationship between types, we put spaces on
both sides of the colon.

Swift SVN r27016
2015-04-05 05:54:55 +00:00
Joe Groff
66ae68bcc3 Sema: Allow ErrorType-conforming types to be explicitly coerced 'as NSError'.
Swift SVN r26993
2015-04-04 22:38:04 +00:00
Erik Eckstein
78a3572fa4 Rename NoDTC to NoTypeCheck. NFC.
Swift SVN r26973
2015-04-04 08:24:59 +00:00
Joe Groff
b2cb75ad30 Runtime: Add a 'swift_becomeNSError' entry point to coerce an ErrorType box to an NSError instance.
If the NSError part of the box hasn't been initialized yet, fill it in with the domain and code of the contained value. This will allow us to efficiently turn ErrorType values into NSErrors, either for bridging or for coercion purposes.

Swift SVN r26958
2015-04-03 22:16:52 +00:00
Nadav Rotem
7ebd9f1adc Mark methods in protocol extension as final.
Swift SVN r26948
2015-04-03 19:29:20 +00:00
Ben Langmuir
0c120e5914 Reapply r26926 after fixing SourceKit test
r26926 was reverted in r26930 because of a SourceKit failure, that was
fixed in r26945.

Swift SVN r26946
2015-04-03 19:04:50 +00:00
Erik Eckstein
4c4b9abd99 stdlib: avoid masking out the array buffer spare bits if we know that they are zero.
Swift SVN r26938
2015-04-03 14:14:56 +00:00
Erik Eckstein
2f971c22cb re-apply r26871: stdlib: Do the Array fast-path check with a single array property call.
Changes compared to the original version:
I fixed the 2 bugs and added a test for the so far undetected missing range check bug.
To keep the SIL simple (4 basic blocks for arr[x]) I extracted the slow path for getElement into a
non-inlinable function.
On the other hand I inlined _typeCheck into the slow-path function.
This speeds up NSArray accesses because now only a single objectAtIndex is required for both
type checking and element retrieving.

Update on performance: DeltaBlue is now only 12% better (and not 25%). I suspect this is because
now Arnold's tail duplication cannot detect the ObjC call in the slow path.



Swift SVN r26935
2015-04-03 06:48:25 +00:00
Greg Parker
f9ca55df0f Revert r26926 which broke a SourceKit test.
Swift SVN r26930
2015-04-03 03:54:12 +00:00
Dave Abrahams
17de46f1c9 [stdlib] ExistentialCollection: perf de-regression
The performance regression that occurred when ++ and -- were added as
requirements to the Index protocols was due to the fact that it caused a
dubious hack of mine to be bypassed: when treated as indices, integer
types are incremented and decremented without overflow checking.  While
technically justifiable (see the r20576 commit message), this makes the
standard library extremely fragile and makes successor() and
predecessor() mathematically unsafe. We really should see what the
optimizer team can do to make that hack unnecessary.

In the meantime, instead of dispatching through ++ and --, use a
special, defaulted _[successor|predecessor]InPlace() method to give
indices their own, customizable in-place inc/dec-rement path.

Swift SVN r26926
2015-04-03 02:39:40 +00:00
Michael Gottesman
0255a5b948 Revert "[stdlib] [Generator|Sequence]Of => Any[Generator|Sequence]"
This reverts commit r26904. Fixing the build.

Swift SVN r26912
2015-04-02 22:55:30 +00:00
Michael Gottesman
d53bff777b Revert "[stdlib] ExistentialCollection -> public/core"
This reverts commit r26888. Trying to fix the build.

Swift SVN r26911
2015-04-02 22:55:29 +00:00
Dave Abrahams
0b40374d10 [stdlib] [Generator|Sequence]Of => Any[Generator|Sequence]
Retire the old components now that the new ones have passed API review.

<rdar://20406937> covers the migration fallout of this change.

Swift SVN r26904
2015-04-02 21:55:22 +00:00
Chris Willmore
690daa539a Back out changes for in-place methods/operators from Xcode 7.
This reverts commits r26508, r26545, and r26576.

Swift SVN r26900
2015-04-02 21:14:28 +00:00
Dave Abrahams
910c895346 [stdlib] ExistentialCollection -> public/core
It passed our API review so integrating it into the core standard
library.

Swift SVN r26888
2015-04-02 20:17:53 +00:00
Dave Abrahams
44bddea674 [stdlib] Protocol-dispatch ++ and -- for indices
...and take advantage of this capability to optimize AnyXXXIndex.

Swift SVN r26876
2015-04-02 17:21:45 +00:00
Ted Kremenek
69a12dfcb8 Revert "stdlib: Do the Array fast-path check with a single array property call."
This was causing test '1_stdlib/ArrayTraps.swift.gyb' to fail.

Swift SVN r26872
2015-04-02 14:47:19 +00:00
Erik Eckstein
834645a901 stdlib: Do the Array fast-path check with a single array property call.
Now that we can check isNative and NoDTC (no deffered type check needed) with a single bit-mask operation,
it makes sense to have a single array property call for it.
I replaced the the semantics call array.props.needsElementTypeCheck with array.props.isNativeNoDTC,
which is the combination of isNative && !needsElementTypeCheck. I kept array.props.isNative, which is not used for now,
but might be useful in the future, e.g. for array operations which don't care about type checks.

The optimized SIL for a class array access arr[i] now contains the minimum of 4 basic blocks.
PerfTests show +25% for DeltaBlue and some improvemements for -Onone.



Swift SVN r26871
2015-04-02 14:10:54 +00:00
Dmitri Hrybenko
4edc305438 stdlib: change CVarArgType._encode() method into a '_cVarArgEncoding'
property per API review proposal that passed review

For a given type, obtaining its C vararg encoding is O(1) for any
instance.

Swift SVN r26794
2015-04-01 02:55:24 +00:00
Dmitri Hrybenko
cf912bcaae stdlib: underscore the only requirement of CVarArgType
Defining conformances to CVarArgType outside of the standard library is
not supported.

Swift SVN r26793
2015-04-01 02:16:15 +00:00
Joe Groff
7514921a86 Runtime: Remove obsolete _stdlib_conformsToProtocol function.
'x is P' works now, and this function isn't used anywhere except by a test that exercises it. Removing this also lets us remove a swath of otherwise unused helper static functions in the runtime.

Swift SVN r26618
2015-03-27 02:08:58 +00:00
Erik Eckstein
663f08557a stdlib: Use a dedicated pointer spare bit to distinguish between native and ObjC object in BrigeStorage.
This simplifies the code for is-native checking. Now it can be done by a single and-mask operation.



Swift SVN r26591
2015-03-26 14:35:10 +00:00
Erik Eckstein
7eeffa04c7 stdlib: Do the needs-type-check check in the Array subscript immediately before it is needed.
This reduces the amount of basic blocks in the function.



Swift SVN r26590
2015-03-26 14:21:52 +00:00
Erik Eckstein
5c7f0e833f stdlib: Don't do subscript checking for objc arrays.
ObjC arrays do their own checking.
This reduces the generated code for array accesses.



Swift SVN r26589
2015-03-26 14:19:52 +00:00
Dave Abrahams
2a84ade467 [stdlib] Clarify an oft-repeated doc comment
Thanks, Dmitri!

Swift SVN r26512
2015-03-25 01:54:08 +00:00
Chris Willmore
1ee6f7e67c Implement syntax changes for in-place methods.
Rename 'assignment' attribute of infix operators to 'mutating'. Add
'has_assignment' attribute, which results in an implicit declaration of
the assignment version of the same operator. Parse "func =foo"
declaration and "foo.=bar" expression. Validate some basic properties of
in-place methods.

Not yet implemented: automatic generation of wrapper for =foo() if foo()
is implemented, or vice versa; likewise for operators.

Swift SVN r26508
2015-03-25 00:22:41 +00:00
Dmitri Hrybenko
ab408d4dc3 Update the compiler and SDK overlay for nullability and generics in Foundation
We have an SPI between the Swift compiler and Foundation based on the
SWIFT_SDK_OVERLAY_FOUNDATION_EPOCH preprocessor macro that allows us to
request the new API.  rdar://20270080 tracks removing it.

Swift SVN r26475
2015-03-24 02:18:06 +00:00
Mark Lacey
3ab2e208af Devirtualize during mandatory inlining.
With this change we will devirtualize in trivial cases where mandatory
inlining has exposed opportunities due to substituting types, for
example substituting a struct type into a witness_method where we can
now easily determine exactly what method will be called.

This makes it possible to use @transparent on struct methods that are
dispatched via generic functions, resulting in the opportunity to emit
diagnostics for these methods as well as eliminate the overhead of the
indirect call.

I saw a handful of 10+% perf improvements at -Onone on our benchmarks.

In theory this should allow us to remove the overloads for ++/-- in
FixedPoint.swift.gyb without a performance penalty (and with the proper
overflow diagnostics), but unfortunately if we were to do so, we would
currently dispatch to functions that lack runtime overflow
checks (rdar://problem/20226526).

Swift SVN r26397
2015-03-21 23:05:24 +00:00
Nadav Rotem
fe09d76acc Remove a stale comment that is incorrent and does not match the implementation.:w
Swift SVN r26313
2015-03-19 20:14:01 +00:00
Arnold Schwaighofer
63f4170a0e ArraySemantics: To facilitate make_unique hoisting add a array.owner call
After this change we can also hoist uniqueness checks for array of classes.

rdar://19955624

Swift SVN r26311
2015-03-19 19:32:16 +00:00
Dave Abrahams
d7156b0620 [stdlib] Kill obsolete comment
Swift SVN r26308
2015-03-19 18:32:13 +00:00
Joe Groff
970958c43c SILGen: Support method and property lookup on boxed existentials.
Swift SVN r26290
2015-03-19 02:10:14 +00:00
Dave Abrahams
a1d3895bd2 [stdlib] Plug a leak in String bridging
The way we bridge CFStringCreateCopy remains a nasty hack. The patch
attached to <rdar://20185167> is better, but that radar blocks the
better solution.

Fixes <rdar://20031203>.

Swift SVN r26223
2015-03-17 12:11:15 +00:00
Dmitri Hrybenko
4387f95a29 flatMap: fix the comment and simplify the implementation
rdar://20178405

Swift SVN r26205
2015-03-17 00:39:41 +00:00
Chris Lattner
7b13a367a7 clean up some uses of typed patterns in nested contexts. The only reason anyone was using
them was because of the obsolete AnyObject warning.


Swift SVN r26159
2015-03-15 18:26:24 +00:00
Dave Abrahams
d292f64d77 [stdlib] Eliminate unneeded _SignedNumberType protocol
As Dmitri as pointed out, our ~> dispatching doesn't require
underscored-protocol hacks any longer

Swift SVN r26157
2015-03-15 17:26:14 +00:00
Chris Lattner
20f8f09ea8 Land: <rdar://problem/19382905> improve 'if let' to support refutable patterns and untie it from optionals
This changes 'if let' conditions to take general refutable patterns, instead of
taking a irrefutable pattern and implicitly matching against an optional.

Where before you might have written:
  if let x = foo() {

you now need to write:
  if let x? = foo() {
    
The upshot of this is that you can write anything in an 'if let' that you can
write in a 'case let' in a switch statement, which is pretty general.

To aid with migration, this special cases certain really common patterns like
the above (and any other irrefutable cases, like "if let (a,b) = foo()", and
tells you where to insert the ?.  It also special cases type annotations like
"if let x : AnyObject = " since they are no longer allowed.

For transitional purposes, I have intentionally downgraded the most common
diagnostic into a warning instead of an error.  This means that you'll get:

t.swift:26:10: warning: condition requires a refutable pattern match; did you mean to match an optional?
if let a = f() {
       ^
        ?

I think this is important to stage in, because this is a pretty significant
source breaking change and not everyone internally may want to deal with it
at the same time.  I filed 20166013 to remember to upgrade this to an error.

In addition to being a nice user feature, this is a nice cleanup of the guts
of the compiler, since it eliminates the "isConditional()" bit from
PatternBindingDecl, along with the special case logic in the compiler to handle
it (which variously added and removed Optional around these things).




Swift SVN r26150
2015-03-15 07:06:22 +00:00
Joe Groff
fdde2a8e99 SIL: Add instructions for boxed existential operations.
Parsing and serialization for {Alloc,Open,Dealloc}ExistentialBox instructions to represent operations on ErrorType boxes.

Swift SVN r26145
2015-03-15 03:32:37 +00:00
Graham Batty
388f0dd5de Check if existing capacity is enough even on non-objc.
Fixes rdar://problem/20089729

Swift SVN r26109
2015-03-13 20:14:20 +00:00
Doug Gregor
c69294562e Clean up explicit protocol conformances in the standard library.
Eliminates redundant conformances and resolves ambiguous implied
conformances. NFC.

Swift SVN r26066
2015-03-12 21:11:12 +00:00
Enrico Granata
ac4e7329b8 Commit again with the proper indentation
Swift SVN r26057
2015-03-12 20:09:41 +00:00
Enrico Granata
566c462c10 Give StaticString a custom Reflectable conformance that reflects upon the string data
Fixes rdar://problem/19813456



Swift SVN r26051
2015-03-12 18:34:07 +00:00
Dmitri Hrybenko
013508df26 stdlib: fix the comment that was not updated during a refactoring
Swift SVN r26045
2015-03-12 08:47:26 +00:00
Chris Lattner
5549775677 enhance silgen to treat OptionalSomePattern and EnumElementPattern as
"similar", avoiding false positive "not exhaustive" diagnostics on switches
like:

switch ... {
case let x?: break
case .None: break
}

Also, start using x? patterns in the stdlib more (review appreciated!), which 
is what shook this issue out.



Swift SVN r26004
2015-03-12 00:39:43 +00:00