Commit Graph

75 Commits

Author SHA1 Message Date
Karoy Lorentey
ff882f4a06 [stdlib] Set, Dictionary: Sanitize @objc-ness for NSEnumerator members 2018-09-22 13:36:05 +01:00
Karoy Lorentey
430a9f3064 [stdlib] _BridgingHashBuffer: Fix memory management
- Have the hash buffer include a reference to the original hash storage instance, along with a copy of its _HashTable, so that its lifetime can be independent from the deferred bridging object.
- Convert _BridgingHashBuffer to a ManagedBuffer so that we can easily put reference-counted properties in its header.
2018-09-22 13:36:05 +01:00
Karoy Lorentey
b2d4e801a4 [stdlib] Discourage CoW copying / rehashing from getting inlined 2018-09-22 02:04:11 +01:00
Karoy Lorentey
4e64931b77 [stdlib] Set.Iterator.next(): Work around compiler crash in non-ObjC builds 2018-09-22 02:04:10 +01:00
Karoy Lorentey
2094581c5c [stdlib] Add missing calls to cocoaPath()
This should reduce code size and perhaps trigger more optimizations.
2018-09-22 02:04:10 +01:00
Karoy Lorentey
778defac93 [stdlib] Set, Dictionary: Speed up insert/remove when there’s nothing to do
Moving the uniqueness check before the first lookup was a bad idea. Revert it.
2018-09-22 02:04:09 +01:00
Karoy Lorentey
8366edd93d [stdlib] Set, Dictionary: Simplify variant processing
Don’t duplicate native paths — make the cocoa case conditionally unreachable instead.
2018-09-22 02:04:09 +01:00
Karoy Lorentey
c19e20b464 [stdlib] Set, Dictionary: Make _HashTableDelegate implementations inlinable 2018-09-22 02:04:09 +01:00
Karoy Lorentey
098275f3c7 [stdlib] Clean up Set and Dictionary
- Use _HashTable to unify low-level hashing operations across Set and Dictionary.
- Store the capacity directly inside the storage header. This allows the maximum load factor to be controlled by non-inlinable code.
- Introduce a dedicated class for the empty singleton.
- Add _BridgingHashBuffer, a standalone flat hash buffer for use in deferred bridging. Use it to eliminate the need to support non-hashable storage/wrapper variants and to improve memory use in cases where Key or Value are verbatim bridged.
- Eliminate the “TypedNative*Storage” class and _NativeSet/_NativeDictionary’s support for non-hashable keys.
- Rename storage classes as follows:

_RawNativeSetStorage ⟹ _RawSetStorage
_RawNativeDictionaryStorage ⟹ _RawDictionaryStorage
_TypedNativeSetStorage ⟹ (removed)
_TypedNativeDictionaryStorage ⟹ (removed)
_HashableTypedNativeSetStorage ⟹ _SetStorage
_HashableTypedNativeDictionaryStorage ⟹ _DictionaryStorage

The new names make it obvious which ivar layout is in use.
2018-09-22 02:04:07 +01:00
Karoy Lorentey
18ad79378f [stdlib] _stdlib_NSObject_isEqual: Make internal 2018-09-22 02:04:06 +01:00
Karoy Lorentey
546c829491 [stdlib] _makeCollectionDescription: Make internal 2018-09-22 02:04:06 +01:00
Karoy Lorentey
19a6ca9ad2 [stdlib] Remove _UnsafeBitMap
Use _UnsafeBitset instead.
2018-09-22 02:04:05 +01:00
Karoy Lorentey
edb8a73203 [stdlib] Set, Dictionary: New storage classes for the empty singletons
This allows us to move the empty NSSet/NSDictionary overrides out of the root storage class; they don’t really belong there. More importantly, it makes empty sets/dictionaries super obvious to lldb and other runtime tools.
2018-09-22 02:04:05 +01:00
Ben Cohen
ae6f5dd604 [stdlib] Add consuming/owned annotations to Collection implementations (#19360)
* Add consuming/owned annotations to Collection implementations

* Update SILOptimizer tests

* Fix access_marker_verify test

* XFAIL reconstruct_type_from_mangled_name
2018-09-21 12:06:56 -07:00
Ben Cohen
75018155ff Kill old set/dictionary-specific bridging entrypoints (#18930) 2018-08-25 07:27:26 -07:00
Karoy Lorentey
d1ec3b9b9b [stdlib] Make Set.isSubset(of:) self-contained; remove standalone function for same 2018-08-16 21:35:24 +01:00
Karoy Lorentey
d2d3c0cb21 [stdlib] Implement Set.contains without retrieving the stored value 2018-08-16 21:35:24 +01:00
Karoy Lorentey
2213b4ee2d [stdlib] Set, Dictionary: Review _SwiftDeferredNS* 2018-08-16 20:05:32 +01:00
Karoy Lorentey
548f59a0e3 [stdlib] Set, Dictionary: Make internal representations conform to Sequence 2018-08-16 20:05:32 +01:00
Karoy Lorentey
5e969ce24c [stdlib] Set, Dictionary: Simplify _find(_:,startBucket:)
The startBucket argument is _bucket(key) in the vast majority of cases. Add an overload with this default value.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
b1c81e5ffe [test] Update api-digester source compatibility tests
DictionaryIterator & SetIterator have been renamed Dictionary.Iterator and Set.Iterator, with compatibility typealiases.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
3bb720c6b0 [stdlib] Set, Dictionary: Prefer collection-agnostic names for stored property names
This makes it easier to define lldb data formatters for these types.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
063d92627b [stdlib] Dictionary: Add implementation for first
This is primarily for documentation purposes, although the default implementation (based on an iterator) may not return the correct value for bridged dictionaries with exotic implementations.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
6ee9fce52c [stdlib] Set, Dictionary: Remove remaining internal typealiases 2018-08-16 20:05:32 +01:00
Karoy Lorentey
2201d0e3c8 [stdlib] Set, Dictionary: Move compatibility typealiases to end of file 2018-08-16 20:05:32 +01:00
Karoy Lorentey
791d29f422 [stdlib] Set, Dictionary: Audit one more round of inlinability attributes 2018-08-16 20:05:32 +01:00
Karoy Lorentey
ad3c970054 [stdlib] Set, Dictionary: Review builders
- Inlinability audit
- Create a _NativeSet/_NativeDictionary directly, without extracting it from a Set/Dictionary
- Swap the final result with an empty collection.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
3f9cd3fb4b [stdlib] Set, Dictionary: Review iterators
- DictionaryIterator => Dictionary.Iterator
- SetIterator => Set.Iterator

- Introduce an explicit struct for native iterators
- _CocoaDictionaryIterator => _CocoaDictionary.Iterator
- _CocoaSetIterator => _CocoaSet.Iterator
- Move representation enums under {Set,Dictionary}.Iterator as _Variant.
- Inlinability audit
2018-08-16 20:05:32 +01:00
Karoy Lorentey
e588f1a8ba [stdlib] Set, Dictionary: Audit inlinability of storage classes
- Remove @inlinable from @objc methods.
- _UnmanagedAnyObjectArray: make internal.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
fcadebc02b [stdlib] Set, Dictionary: Review indices
- Nest native/cocoa index types under their corresponding struct
- Move *IndexRepresentation enums under the corresponding Index type, renamed to _Variant.
- Rename Index._value to Index._variant.
- Remove internal typealiases.
- Remove underscore prefix from enum case names.
- _nativeIndex => _asNative, _cocoaIndex => _asCocoa
- Audit inlinability.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
ac9f29451f [stdlib] Set, Dictionary: Review enumerators
_NativeSetNSEnumerator => _SwiftSetNSEnumerator
_NativeDictionaryNSEnumerator => _SwiftDictionaryNSEnumerator
2018-08-16 20:05:32 +01:00
Karoy Lorentey
e2fb468b97 [stdlib] Set, Dictionary: Review native & cocoa representations
- Remove buffer suffix from type, property & variable names
  struct _NativeSetBuffer => _NativeSet
  struct _NativeDictionaryBuffer => _NativeDictionary
  struct _CocoaSetBuffer => _CocoaSet
  struct _CocoaDictionaryBuffer => _CocoaDictionary

- Remove internal typealiases related to these types
- Move nativeDelete, nativeMapValues from variant enum to corresponding struct
2018-08-16 20:05:32 +01:00
Karoy Lorentey
cc8e378319 [stdlib] Set, Dictionary: Remove obsolete operator definitions. 2018-08-16 20:05:32 +01:00
Karoy Lorentey
2053f74828 [stdlib] Set, Dictionary: Review variant enums
- Rename variant enum types and move them into the corresponding struct:
  _VariantSetBuffer => Set._Variant
  _VariantDictionaryBuffer => Dictionary._Variant

  I found the buffer suffix did not positively contribute to understanding these types. And the extra indirection of the typealiases wasn't exactly helpful, either.

- Remove internal typealiases that resolved to these.
2018-08-16 20:05:32 +01:00
Karoy Lorentey
c74e4daa2b [stdlib][NFC] Shorten notes about SR-6437 2018-08-16 20:05:32 +01:00
Ben Cohen
df22c3647c [stdlib] Build the standard library as Swift 5 (#18121)
* Update std lib to Swift 5.0

* Disable Unicode.* warnings for now

* Slow path to resiliently handle the case where an unknown rounding rule is passed

* Remove resilience from Encoding/DecodingError (which should only happen on slow paths anyway)

* internal typealiases now need @usableFromInline

* Force inlining on Array._owner.get
2018-07-24 20:47:58 -07:00
Karoy Lorentey
c19547a2e0 [stdlib] Set: Update methods defined in terms of key-value
insert(value, forKey: key), removeValue(forKey: key) doesn’t make sense for Set. Simplify.
2018-07-17 15:59:51 +01:00
Karoy Lorentey
543e050702 [stdlib] Set, Dictionary: Remove _Mutable*Buffer protocols
They had but a single type conforming them, so they did not pull their weight as internal interface-enforment protocols.
2018-07-17 15:59:51 +01:00
Karoy Lorentey
5a22b9016a [stdlib] Split _HashBuffer into four different protocols
This allows Set’s internal types not to define Key, Value, SequenceElement & SequenceElementWithoutLabels typealiases.

Splitting the protocol on the mutable/immutable axis allows us to remove some obsolete method definitions.
2018-07-17 15:59:51 +01:00
Karoy Lorentey
9756677d72 [stdlib] Set, Dictionary: Remove RawStorage typealiases
These were an artifact of gybbing.
2018-07-17 15:59:51 +01:00
Karoy Lorentey
a339f88a29 [stdlib] NFC: cosmetic changes 2018-07-17 15:59:51 +01:00
Karoy Lorentey
99f348800d [stdlib] Set, Dictionary: Make Cocoa->native conversion non-inlinable 2018-07-17 15:59:50 +01:00
Karoy Lorentey
47cae81c75 [stdlib] Set, Dictionary: Make Cocoa iteration state non-inlinable. 2018-07-17 15:59:50 +01:00
Karoy Lorentey
4ac2fc7517 [stdlib] _SwiftDeferredNS*: Clean up gyb artifacts
Remove typealiases and member functions made obsolete by de-gybbing.
2018-07-17 15:59:50 +01:00
Karoy Lorentey
619db38b5d [stdlib] Make non-verbatim bridged Set and Dictionary implementations internal
There is no reason to expose these in the Swift ABI.
2018-07-17 15:59:50 +01:00
Karoy Lorentey
c72bf4cdfa [stdlib] Make Set & Dictionary enumerators internal
There is no reason to expose these in the Swift ABI.
2018-07-17 15:59:50 +01:00
Ben Cohen
b77b544cdc Remove remaining @ininable from @_transparent (#17968) 2018-07-16 08:12:52 -07:00
Ben Cohen
a6952decab [stdlib] Remove inlineable annotation from transparent functions (#17800)
* Remove inlineable annotation from transparent functions
2018-07-07 08:47:02 -07:00
Karoy Lorentey
a4e9109618 Merge pull request #17396 from lorentey/anyhashable-is-not-hashable
[stdlib] Fix AnyHashable's Equatable/Hashable conformance
2018-06-29 17:38:08 +01:00
Ben Cohen
a4230ab2ad [stdlib] Update stdlib to 4.0 and reorganize compatibility shims (#17580)
* Update stdlib to 4.0 and move all compatibility shims into a dedicated source file
2018-06-29 06:26:52 -07:00