Commit Graph

27 Commits

Author SHA1 Message Date
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
Erik Eckstein
aae60ff271 stdlib: Code size improvements for Dictionary for -Osize
The first change is to remove some @inline(__always) attributes. Those were added before we had the guaranteed-by-default calling convention. They are not necessary anymore.

The second change is to not specialize some slow-path functions. This results that no specialization code for these functions is generated at the client side. Instead those functions are directly called in the libSwiftCore.
Note that Key-related hash and equality comparisons are still specialized, because otherwise the performance hit for Osize would be too big.

Some Dictionary benchmarks regress a bit with -Osize, but the code size wins are big.

rdar://problem/46534453
2018-12-13 16:59:19 -08: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
d32fd283b0 [stdlib] Refactor Dictionary.subscript._modify for better layering
This may also reduce ARC traffic by a little bit.
2018-11-30 17:47:08 +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
096903732c [stdlib] Make _NSDictionaryCore, _NSDictionary 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
73771b1ca9 [stdlib] Rework Dictionary.values._modify 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
ee4ad7a014 Merge pull request #19589 from lorentey/prepare-for-per-instance-seeds
[stdlib] Set, Dictionary: Prepare for per-instance hash seeds
2018-09-28 11:38:02 +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
b92c301e99 [stdlib] Set, Dictionary: Clean up storage allocation 2018-09-28 04:04:29 +01:00
Karoy Lorentey
9a0e303ac6 [stdlib] Dictionary: Allow limited use of Cocoa indices in native dictionaries
Affected operations:

subscript(index:)
keys.subscript(index:)
values.subscript(index:) (setter and _modify)
remove(at:)
swapAt(_:, _:)

Note that index(after:) is intentionally not on this list.
2018-09-27 19:11:50 +01:00
Karoy Lorentey
656685777f [stdlib] Dictionary: Update remove(at:) and Values to allow Cocoa indices 2018-09-27 19:09:43 +01:00
Karoy Lorentey
e5d976de14 [stdlib] Dictionary: Embed & check the mutation count in native indices 2018-09-27 01:49:51 +01:00
Karoy Lorentey
efe6f38d40 [stdlib] _NativeDictionary.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