Commit Graph

28 Commits

Author SHA1 Message Date
Doug Gregor
22eecacc35 Adopt unsafe annotations throughout the standard library 2025-02-26 14:28:01 -08:00
Kuba Mracek
bde23e2c2f [embedded] Avoid using reinterpretCast in set bridging 2023-12-20 14:39:38 +01:00
Karoy Lorentey
298ab208d8 [stdlib][nfc] Prefer to put the _pointerBitWidth(_64) case first, as that is far more common 2023-04-27 16:33:50 -07:00
Karoy Lorentey
b82ce9c3be [stdlib] Adopt _pointerBitWidth conditional 2023-04-27 13:33:24 -07:00
Karoy Lorentey
2e3e88cab8 [stdlib] Optimize Set.intersection(_:)
Use a temporary bitset to speed up the `Sequence` variant by roughly a factor of ~4-6, and the set/set variant by a factor of ~1-4, depending on the ratio of overlapping elements.
2021-11-01 21:38:10 -07:00
Karoy Lorentey
db80c78809 [stdlib] Optimize Set.filter(_:)
This works the same way as `Set.subtracting<S>(_:)`, and has similar performance benefits.
2021-11-01 21:38:10 -07:00
Karoy Lorentey
6b1f6c075c [stdlib] _SetVariant.convertedToNative: New convenience function 2021-11-01 21:38:09 -07:00
Robert Widmann
0149ccd0ca Add arm64_32 support for Swift
Commit the platform definition and build script work necessary to
cross-compile for arm64_32.

arm64_32 is a variant of AARCH64 that supports an ILP32 architecture.
2021-04-20 14:59:04 -07:00
Max Desiatov
67297904ac [WebAssembly] Add ifdefs for the WASI target 2020-02-08 07:37:10 +00:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Mike Ash
fa5888fb3f [Stdlib][Overlays] Rename various classes to avoid conflicting ObjC names.
Old Swift and new Swift runtimes and overlays need to coexist in the same process. This means there must not be any classes which have the same ObjC runtime name in old and new, because the ObjC runtime doesn't like name collisions.

When possible without breaking source compatibility, classes were renamed in Swift, which results in a different ObjC name.

Public classes were renamed only on the ObjC side using the @_objcRuntimeName attribute.

This is similar to the work done in pull request #19295. That only renamed @objc classes. This renames all of the others, since even pure Swift classes still get an ObjC name.

rdar://problem/46646438
2019-01-15 12:21:20 -05:00
Karoy Lorentey
ce96f1e528 [stdlib] _modify: Use defer to ensure invariants are restored when yield throws
_modify mustn’t leave Collection storage in an inconsistent state when the code to which we’re yielding happens to throw. In practice this means that any cleanup code must happen in defer blocks before the yield.

Fix Dictionary to do just that and add tests to cover this functionality (as well as some other aspects of _modify).
2018-12-05 17:35:24 +00:00
Karoy Lorentey
c4c4c17871 [stdlib] _BridgeStorage: Remove second type parameter (ObjCClass)
It used to be a shadow protocol existential, but now it’s invariably AnyObject.
I see no reason to keep supporting this unused abstraction.
2018-11-15 09:54:25 +00:00
Karoy Lorentey
4f8eeae64e [stdlib] Make _NSSetCore, _NSSet internal
These shadow protocols don’t add any real type safety, and exposing them in the ABI seems unnecessary.
2018-11-15 09:54:25 +00:00
Karoy Lorentey
0304c3a567 [stdlib] ABI audit for _BridgeStorage
- Make internal (but @inlinable)
- Limit API to what is actually supported: a single boolean value.
- Rename members:

    init(native:,bits:) ⟹ init(native:,isFlagged:)
    func isNativeWithClearedSpareBits() ⟹ isUnflaggedNative
    var nativeInstance_noSpareBits ⟹ unflaggedNativeInstance
    func isUniquelyReferenced_native_noSpareBits() ⟹ isUniquelyReferencedUnflaggedNative()
2018-10-31 11:59:41 +00:00
Karoy Lorentey
35502ef476 [stdlib] Acknowledge there are no spare bits in Set/Dictionary’s BridgeObject storage
We really need to do a pass on the _BridgeStorage API at some point soon.
2018-10-05 12:33:25 +01:00
Karoy Lorentey
21da7da9d0 [stdlib] Fix build on 32-bit platforms 2018-10-05 12:33:25 +01:00
Karoy Lorentey
5c0d27036a [stdlib] Set._Variant: Add a dummy initializer for use in _modify
Dictionary already does this.
2018-10-05 12:33:25 +01:00
Karoy Lorentey
3c60042b6c [stdlib] Fix building on platforms without an Objective-C runtime 2018-10-05 12:33:25 +01:00
Karoy Lorentey
363b74d1f2 [stdlib] Set, Dictionary: Implement modify accessor for _variant.asNative 2018-10-05 12:33:25 +01:00
Karoy Lorentey
64d19f44db [stdlib] Set, Dictionary: Switch to using a _BridgeObject instead of an enum 2018-10-05 12:33:25 +01:00
Karoy Lorentey
e24f2ba6e5 [stdlib] Set, Dictionary: Flatten switch statements
The optimizer dislikes nested switch statements; flatten them out to simplify optimization and to hopefully speed things up a little.
2018-10-05 12:33:25 +01:00
Karoy Lorentey
1529d37301 [stdlib] Implement formIndex(after:) in all hashed collections 2018-09-29 02:30:08 +01:00
Karoy Lorentey
7a8b34a499 [stdlib] Set, Dictionary: Make reserveCapacity non-inlinable
This allows us to record the reserved capacity in storage later, which will enable removals to resize the hash table.
2018-09-28 04:59:33 +01:00
Karoy Lorentey
e687464154 [stdlib] Set: Allow limited use of Cocoa indices in native sets
Affected operations:

subscript(index:)
remove(at:)

Note that index(after:) is intentionally not on this list.
2018-09-27 19:11:43 +01:00
Karoy Lorentey
e78635119a [stdlib] _NativeSet.Index: Rename to “Bucket”
Update code to reflect the new name, including in method and variable names.
2018-09-27 00:12:20 +01:00
Karoy Lorentey
c3bc84e680 [stdlib] Set, Dictionary: __consuming/__owned audit
Add __consuming and __owned to Set and Dictionary members where applicable.

Ignore compiler intrinsics for casting for now — their ARC behavior is covered by unit tests that need to be updated.
2018-09-24 13:46:40 +01:00
Karoy Lorentey
e9186000d0 [stdlib][NFC] Break Set/Dictionary implementation into smaller files
This has long been overdue; splitting the Dictionary.swift/Set.swift monoliths makes for a far less confusing editing experience.
2018-09-23 01:38:37 +01:00