Commit Graph

24 Commits

Author SHA1 Message Date
Doug Gregor
22eecacc35 Adopt unsafe annotations throughout the standard library 2025-02-26 14:28:01 -08:00
Holly Borla
dc3893d9ca [Concurrency] Remove redundant Sendable conformances in the standard library.
These conformances are all redundant because the `Sendable` conformance is
inherited from a superclass.
2024-07-25 21:51:56 -07:00
Alejandro Alonso
f9f640b141 Sendablize the standard library
oops dont add this flag

no more nonisolated
2024-03-05 15:02:09 -08:00
Kuba Mracek
392f2c36eb [embedded] Add Dictionary to embedded stdlib 2024-01-16 13:40:13 -08:00
Kuba Mracek
25f971d344 [embedded] Add explaining comment about _swiftEmptyArrayStorage/_swiftEmptySetSingleton 2023-12-20 14:08:16 +01:00
Kuba Mracek
2f0883ab24 [embedded] Add Set to the embedded stdlib 2023-12-13 11:28:17 -08:00
Mike Ash
440d2799f7 [Stdlib] Eagerly realize EmptyDictionarySingleton and EmptySetSingleton.
These objects can escape into ObjC without their class being realized first, which can cause a crash if the unrealized class gets passed into the ObjC runtime.

rdar://problem/59295395
2020-02-14 11:57:52 -05: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
Ben Cohen
1673c12d78 [stdlib] Replace "sanityCheck" with "internalInvariant" (#20616)
* Replace "sanityCheck" with "internalInvariant"
2018-11-15 20:50:22 -08:00
Karoy Lorentey
ca09281b34 [stdlib] Let’s try leaving Set/Dictionary storage non-fixed as an experiment
The current ivars are all defined in the parent class, so (provided my mental model of how this works is correct) this may make some actual sense.
2018-11-12 21:01:23 +00:00
Karoy Lorentey
671de071c6 [stdlib] Audit @_fixed_layout usage in collection storage classes
- Remove __SwiftNativeNSEnumerator from the ABI. (It’s only used in internal classes and in the Objective-C runtime.)
- Remove inlinability of init() and deinit for all the __SwiftNativeNSFoo superclasses except Array’s and Data’s.
2018-11-12 20:53:10 +00:00
Karoy Lorentey
b92c301e99 [stdlib] Set, Dictionary: Clean up storage allocation 2018-09-28 04:04:29 +01:00
Karoy Lorentey
91c5a310fa [stdlib] Set, Dictionary: Prepare for per-instance hash seeds
Implement the per-instance seeding infrastructure without actually enabling per-instance seeding.
2018-09-28 04:04:28 +01:00
Karoy Lorentey
c0d153505b [stdlib] Add *another* missing check for ObjC runtime 2018-09-28 02:14:10 +01:00
Karoy Lorentey
d3178a0394 [stdlib] Tighten up Cocoa index validation for native sets/dictionaries
Like before, allow the use of Cocoa indices to access native sets/dictionaries, but approximate the same mutation count-based check as we do for native indices.

- Ensure that native collections that were converted from Cocoa have an age generated from the address of the original Cocoa object.
- To get the age of a Cocoa index, regenerate one from the object embedded in it.
- Compare self.age to index.age and trap if it doesn’t match.

# Conflicts:
#	stdlib/public/core/HashTable.swift
2018-09-27 19:11:19 +01:00
Karoy Lorentey
863e8b6373 [stdlib] Set, Dictionary: Add a message to fast enumeration state checks 2018-09-27 01:49:51 +01:00
Karoy Lorentey
f600426d87 [stdlib][NFC] Update comments 2018-09-27 01:49:50 +01:00
Karoy Lorentey
e608901eb0 [stdlib] Fill out the 24 bits currently left as padding in Set/Dictionary storage 2018-09-27 01:49:50 +01:00
Karoy Lorentey
6358294be8 [stdlib] Set, Dictionary: Add a mutation count to storage ivars
The mutation count will allow us to recognize and trap on invalid indices more reliably. (However, it won’t be foolproof — some invalid indices may pass through the checks.)

- Change _scale to Int8 to make space for an extra Int32 without enlarging the storage header.
- Add an _age field inside the new gap.
- Initialize the age to a scrambled version of the storage address.
- Generate a new counter for every newly allocated storage instance, except for identical copy-on-write copies.
- Increment the mutation counter after every removal.
2018-09-27 01:49:50 +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
6cef0beff9 Merge pull request #19495 from lorentey/simplify-rawHashValue
[stdlib] Finalize one-shot hashing interface
2018-09-24 21:44:36 +01:00
Mike Ash
1fb165a0ea Merge branch 'master' into rename-conflicting-classes-and-methods 2018-09-24 10:17:22 -04:00
Karoy Lorentey
6d81663716 [stdlib] Make Hashable._rawHashValue(seed:) safer and more convenient
- Don’t expose the raw execution seed to _rawHashValue.
- Change the type of _rawHashValue’s seed from (UInt64,UInt64) to a single Int. Working with a pair of UInt64s is unwieldy, and overkill in practice. Int as a seed also integrates nicely with Int as a hash value.
- Remove _HasherCore._generateSeed(). Instead, simply call finalize() on a copy of the hasher to get a seed suitable for _rawHashValue.
- Update Set and Dictionary to store a single Int as the seed value.

Note that this doesn’t affect the core hasher, which still mixes in the actual 128-bit execution seed during its initialization. To reduce the potential of confusion, use the name “rawSeed” to refer to an actual 128-bit seed value.
2018-09-24 13:30:05 +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