Commit Graph

324 Commits

Author SHA1 Message Date
Erik Eckstein
5922aa8b14 stdlib: always inline the Set/Dictionary's _bucket function
If the Key is a class, then FunctionSignatureOpts cannot convert it to a @guaranteed parameter.
Using the new EpilogueARCAnalysis in FunctionSignatureOpts should fix that.
2016-09-20 16:34:51 -07:00
Erik Eckstein
8b1184708e stdlib: replace _squeezeHashValue with a specialized version for power-of-2 ranges.
This function is only used for Set and Dictionary and there the range (which is the capacity) is always a power of 2.
2016-09-20 16:34:51 -07:00
Erik Eckstein
36ef0e6cd7 stdlib: specify to the optimizer that the capacity value of Dictionary/Set is never negative.
This removes some runtime checks.
2016-09-20 16:34:51 -07:00
Erik Eckstein
504361ff66 stdlib: Replace some _preconditions with _sanityChecks.
Those conditions should not fail with any user code. They just check the internal implementation of the stdlib.
This removes some runtime checks in the generated code with the optimized library.
2016-09-20 16:34:51 -07:00
airspeedswift
ed5231b47c Numbered all FIXME(ABI) entries for tracking purposes. (#4868) 2016-09-19 16:41:41 -07:00
practicalswift
fa7fbdb8b0 [gardening] Remove redundant nil-initialization of optional variable
From the Swift documentation:

"If you define an optional variable without providing a default value,
 the variable is automatically set to nil for you."
2016-09-18 07:40:07 +02:00
Erik Eckstein
312b0d8521 fix coding style 2016-09-16 11:14:36 -07:00
Erik Eckstein
b67959a6c1 stdlib: Use builtin tail-allocated arrays instead of ManagedBuffer to allocate Set and Dictionary buffers
This reduces the amount of SIL generated for Set/Dictionary operations significantly.
The generated code should be mostly the same (modulo different inlining decisions).
2016-09-16 11:02:19 -07:00
Dmitri Gribenko
30856bf094 stdlib: add complexity docs to Set.removeFirst() 2016-09-15 22:04:46 -07:00
Dmitri Gribenko
fbb3cf35a5 Revert "New SIL instructions to support tail-allocated arrays in SIL." 2016-09-15 00:25:25 -07:00
Erik Eckstein
15cca80404 stdlib: Use builtin tail-allocated arrays instead of ManagedBuffer to allocate Set and Dictionary buffers
This reduces the amount of SIL generated for Set/Dictionary operations significantly.
The generated code should be mostly the same (modulo different inlining decisions).
2016-09-14 14:54:18 -07:00
Dave Abrahams
5c13e35f29 [stdlib] Suppress noisy warnings
We don't have a way yet to say "this is deprecated for users, but let
the stdlib use it without complaining" so we need to do refactoring
shenanigans.
2016-08-28 15:06:42 -07:00
Doug Gregor
57f1090a11 Revert "[Set/Dictionary] Eliminate "bridging" collection entrypoints."
This reverts commit dc0ae675bc. The
change here (presumably the change to Foundation) caused a regression
in several of the bridging-related benchmarks, e.g.,
ObjectiveCBridgeFromNSSetAnyObjectToString, DictionaryBridge,
ObjectiveCBridgeFromNSDictionaryAnyObjectToString.
2016-08-24 13:20:03 -07:00
Doug Gregor
dc0ae675bc [Set/Dictionary] Eliminate "bridging" collection entrypoints.
Remove the functions
_(set|dictionary)Bridge(From|To)ObjectiveC(Conditional) from the
standard library. These entrypoints are no longer used by the compiler
(thanks to generalized collection up/downcasting), so stop using them
in Foundation and in tests.
2016-08-22 15:14:09 -07:00
John McCall
a7a954ae8c Perform collection force-casts by force-casting the elements
instead of forcing conditional casts of the elements.

This should produce better and more compact code, allow more
efficient runtime behavior, and generate much better runtime
diagnostics if the cast fails.
2016-08-18 15:54:14 -07:00
Nate Cook
8b39706c3f [stdlib] Documentation revisions
- Various edits
- Standardized complexity formatting
2016-08-12 12:24:36 -05:00
Nate Cook
559092bbf2 [stdlib] Revise stdlib documentation comments
- Expand pre-example explanations
- Update documentation for SE-0118
- Removing remaining 'iff' usage
- Revise Array discussion
- Fix formIndex(_:offsetBy) parameter formatting
- Improve index/formIndex(_:offsetBy:(limitedBy:)?) discussion
- Update Quick Look discussions
- Fixes grammar inconsistencies
- Adds parameter / return documentation
- Adds and expands on examples
- Revises AnyObject discussion for new `id` bridging rules
- Revise readLine, print, and assertion functions
- Add missing docs to String index-moving methods
2016-08-05 16:07:46 -05:00
Dave Abrahams
b841f1eaa5 Revert "[stdlib] Speculative workaround for ASAN failure"
This reverts commit dc86186de7.

It didn't change anything.
2016-08-04 13:59:15 -07:00
Dave Abrahams
dc86186de7 [stdlib] Speculative workaround for ASAN failure
I suspect the fancy _unsafeUpcast implementation, that was supposed to
be more optimizable, was confusing the optimizer, and that is the cause
of ASAN failures we're seeing.  Let's see if this makes ASAN happy
again.
2016-08-04 11:55:03 -07:00
Jordan Rose
f42158b12e Revert "[Sema] ban multi-arguments to tuple coercion" (#3922)
It breaks cases where there really is a single unlabeled argument of tuple type, like this:

  let pairs = [(1, "A"), (2, "B")]
  print(pairs.map { $0.0 })
2016-08-01 19:22:19 -07:00
Daniel Duan
c9b73dacc2 [Sema] ban multi-arguments to tuple coercion
Implements part of SE-0110. Single argument in closures will not be accepted if
there exists explicit type with a number of arguments that's not 1.

```swift
let f: (Int, Int) -> Void = { x in } // this is now an error
```

Note there's a second part of SE-0110 which could be considered additive,
which says one must add an extra pair of parens to specify a single arugment
type that is a tuple:

```swift
let g ((Int, Int)) -> Void = { y in } // y should have type (Int, Int)
```

This patch does not implement that part.
2016-07-31 16:22:57 -07:00
Rintaro Ishizaki
091506315b [SE-0101] Implement: Reconfiguring sizeof and related functions into MemoryLayout struct
As of now:

* old APIs are just marked as `deprecated` not `unavaiable`. To make it
  easier to co-operate with other toolchain repos.
* Value variant of API is implemented as public @private
  `_ofInstance(_:)`.
2016-07-30 03:09:28 +09:00
Andrew Trick
0b75ee975e Remove "illegal" UnsafePointer casts from the stdlib.
Update for SE-0107: UnsafeRawPointer

This adds a "mutating" initialize to UnsafePointer to make
Immutable -> Mutable conversions explicit.

These are quick fixes to stdlib, overlays, and test cases that are necessary
in order to remove arbitrary UnsafePointer conversions.

Many cases can be expressed better up by reworking the surrounding
code, but we first need a working starting point.
2016-07-28 20:42:23 -07:00
Nate Cook
58fb4ef9c5 [stdlib] Clean up various documentation issues (#3804)
* [stdlib] Clean up some documentation formatting

* [stdlib] Update example code for SE-0103

* [stdlib] Fix UnsafeBufferPointer documentation typo

* [stdlib] Collection documentation cleanup

* [stdlib] Fix String.init?(_:UTF16View) description

* [stdlib] Documentation fixes for SE-0091

* [stdlib] Add param info for String(repeating:count:)
2016-07-28 11:25:38 -07:00
Andrew Trick
37c084bbeb Use UnsafeMutableRawPointer in HashedCollection _UnmanagedAnyObjectArray.
In order to conform to the memory model.
2016-07-27 08:05:55 -07:00
Bob Wilson
112451c44a [SE-0127] Remove withUnsafePointers and withUnsafeMutablePointers APIs.
These provide the same functionality as the one-argument versions for both
2 and 3 argument closures. Since these are less common, the same thing can be
achieved by composing the one-argument version. rdar://problem/26529498
2016-07-26 17:43:33 -07:00
Andrew Trick
a18d490d6a Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3773)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
2016-07-26 14:21:15 -07:00
Andrew Trick
0ed9ee8dee Revert "Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)"
This reverts commit ece0951924.

This results in lldb failues on linux that I can't readily debug.
Backing out until they can be resolved.
2016-07-26 02:50:57 -07:00
Andrew Trick
ece0951924 Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
2016-07-26 02:18:21 -07:00
Joe Groff
32b50c624d stdlib: Remove _isBridgedToObjectiveC from _ObjectiveCBridgeable.
All generic bridgeable types can bridge for all their instantiations now. Removing this ferrets out some now-unnecessary traps that check for unbridgeable parameter types.
2016-07-25 06:01:21 -07:00
John McCall
232a314a9f Teach the dynamic-cast machinery how to cast collection element types. 2016-07-23 10:30:10 -07:00
Patrick Pijnappel
79250704fa Merge pull request #3698 from PatrickPijnappel/spacing
[stdlib] Standardize function signature spacing
2016-07-23 15:07:19 +10:00
Patrick Pijnappel
2728bd0145 [stdlib] Standardize function signature spacing 2016-07-23 11:51:32 +10:00
Dave Abrahams
7c7fc160ac Work on Mac again 2016-07-22 16:52:29 -07:00
Dave Abrahams
591a0bd625 Fix a typo 2016-07-22 16:50:07 -07:00
Dave Abrahams
d96e129e71 [stdlib] id-as-Any: hashed collection casts on Linux 2016-07-22 16:17:22 -07:00
Dave Abrahams
bbaabbf16c [stdlib] id-as-Any: hashed collection casting
Relax some preconditions in the cast machinery and write a comprehensive
test suite.

FIXMEs in test/1_stdlib/HashedCollectionCasts.swift.gyb show where the
typechecker doesn't seem to quite work, or the frontend might be
generating the wrong runtime calls.

TODO: Add tests for failing downcasts
2016-07-22 16:12:53 -07:00
Dave Abrahams
e32775b7e2 Revert "[stdlib] id-as-Any: hashed collection casting"
This reverts commit c2642e65e7.
2016-07-21 16:42:25 -07:00
Dave Abrahams
231c80b794 Revert mistaken commit
This reverts commit 70a30c0449.
2016-07-21 16:40:44 -07:00
Dave Abrahams
70a30c0449 **REVERT ME** id-as-Any: add entry-point logging
Add some logging to the stdlib that may help with debugging hashed
collection casting.
2016-07-21 15:38:47 -07:00
Dave Abrahams
c2642e65e7 [stdlib] id-as-Any: hashed collection casting
Relax some preconditions in the cast machinery and write a comprehensive
test suite.

FIXMEs in test/1_stdlib/HashedCollectionCasts.swift.gyb show where the
typechecker doesn't seem to quite work, or the frontend might be
generating the wrong runtime calls.

TODO: Add tests for failing downcasts
2016-07-21 15:38:23 -07:00
Doug Gregor
778e76e158 [SE-0091 Follow-up] Move more operators into types, now for generic operators. 2016-07-21 12:54:27 -07:00
John McCall
0c642a8098 Stub out Set/Dictionary casting intrinsics on non-ObjC platforms. 2016-07-19 14:35:03 -07:00
Dave Abrahams
b2bbd4c599 reduce(_ initial:combine:) => reduce(_ initialResult:_ nextPartialResult) 2016-07-19 07:12:59 -06:00
Dave Abrahams
014b6972cf isOrderedBefore: => by areInIncreasingOrder: 2016-07-19 07:05:54 -06:00
Andrew Trick
73106dd7c3 Rename initialize(with:count:) to initialize(to:count:). (#3601)
As proposed in SE-0107: UnsafeRawPointer.

"with" is considered a vacuous preposition. "to" implies direction.
2016-07-18 23:37:45 -07:00
Michael Gottesman
fc37603c5f Revert "Implement SE-0118" 2016-07-18 16:44:58 -07:00
Dave Abrahams
b0044948df reduce(_ initial:combine:) => reduce(_ initialResult:_ nextPartialResult) 2016-07-18 14:30:46 -06:00
Dave Abrahams
f3ccc956c6 isOrderedBefore: => by areInIncreasingOrder: 2016-07-18 14:29:09 -06:00
Michael Gottesman
40e1991e12 Revert "Name and label changes for closure parameters (for review only) (#2981)"
This reverts commit 18406900ba.
2016-07-15 19:45:26 -07:00