Commit Graph

350 Commits

Author SHA1 Message Date
practicalswift
debeebaa3a [gardening] Fix recently introduced typo: "nsenumator" → "nsenumerator" 2016-11-05 20:32:25 +01:00
Alexis Beingessner
e4c5e159c9 remove useless constant redefinition 2016-11-04 03:17:13 -04:00
Alexis Beingessner
3cdc8ec444 remove buffer header to eliminate optional traps 2016-11-04 02:44:29 -04:00
Alexis Beingessner
931f7ba658 actually used the cached keys/values pointer 2016-11-04 01:19:50 -04:00
Alexis Beingessner
5e776e5e39 cleanup initializers in HashedCollections 2016-11-04 01:19:50 -04:00
Alexis Beingessner
428cdac57c leave FIXME for future dictionary bucaneers 2016-11-04 01:01:35 -04:00
Alexis Beingessner
a62f6c6a89 Fix incorrect bitcasts, refactor code to guard against this error. 2016-11-04 01:01:35 -04:00
Alexis Beingessner
b4d97776d8 more comment cleanups 2016-11-04 01:01:35 -04:00
Alexis Beingessner
731aa1494b Properly if-def out bridging code. 2016-11-03 19:55:36 -04:00
Alexis Beingessner
bb0b4be7ac Update comment to clarify why it's interesting, link a relevant impl. 2016-11-03 19:55:36 -04:00
Alexis Beingessner
8eea522e9c rename storage type to be more useful 2016-11-03 19:52:30 -04:00
Alexis Beingessner
b1425ce78b remove _'s from some variables that don't need it 2016-11-03 19:52:30 -04:00
Alexis Beingessner
41fb15f042 rename Buffer <---> Storage in HashedCollections to match conventions 2016-11-03 19:52:30 -04:00
Alexis Beingessner
3144870e86 add new toll-free bridge fast-paths to HashedCollections 2016-11-03 19:52:30 -04:00
Alexis Beingessner
a43c1dfba0 Some minor cleanups in HashedCollections:
* rename bridgingStorage to bridged
* add a missing fixLifetime
* remove useless temporary
2016-11-03 19:52:30 -04:00
Alexis Beingessner
f12d7914e8 update comments in HashedCollections to reflect new design 2016-11-03 19:52:30 -04:00
Alexis Beingessner
052e94a34a refactor HashedCollections to support verbatim bridging 2016-11-03 19:52:30 -04:00
Alexis Beingessner
d179655952 refactor Dictionary to support an empty singleton 2016-11-03 19:52:30 -04:00
Alexis Beingessner
953e51a97e [stdlib] Handle some outstanding Dictionary indexing-model FIXMEs/TODOs 2016-10-29 10:04:35 -04:00
Alexis Beingessner
b08732cbd4 [stdlib] Update Dictionary comments to reflect new design 2016-10-29 10:04:35 -04:00
Alexis Beingessner
76c6281fea [stdlib] Rewriting native hashed collection indices
Changes:
- Native dictionary and set indices no longer hold references to storage
- Cocoa-based dictionary and set indices no longer hold references to storage
- Removed double indirection trick from hashed collections
- Rewrote storage types to reflect simpler model
- Updated unit tests
2016-10-29 10:04:35 -04:00
practicalswift
cc852042c9 [gardening] Fix accidental trailing whitespace. 2016-10-29 10:22:58 +02:00
Dave Abrahams
22f5dfa50a Merge pull request #5264 from shajrawi/idasany_perf
improve set's conditional downcast performance by over 2X
2016-10-19 12:13:02 -07:00
Dave Abrahams
76b5afcc4a Speed up Set/Dictionary init from Sequence
Alternative to #5264
2016-10-19 10:23:22 -07:00
Joe Shajrawi
eeae7e1f8c improve set's conditional downcast performance by over 2X 2016-10-12 16:27:54 -07:00
Slava Pestov
fab574c3a7 stdlib: Add some @_versioned declarations to fix resilient build
A recent change made accessibility checking stricter. This had some
fallout on the half-baked @_versioned attribute, where we could no
longer define @_versioned members on a non-@_versioned type.

This was wrong anyway (and will be diagnosed when we add proper
diagnostics for @_versioned), because type metadata for the
internal type did not get the right linkage, but it used to work
as long as you didn't try to get the type metadata at runtime.

This patch adds @_versioned attributes to the right types now that
this broken behavior is gone.

As a result, _Variant{Set,Dictionary}Storage became resilient
(non-@_versioned internal types are not resilient), which broke
too many tests that assumed you can exhaustively switch over all
the cases. Since eager-bridging is going to eliminate this enum
anyway (or so I've heard), make it @_fixed_layout for now.
2016-09-30 18:28:11 -07:00
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